Skip to content

Commit

Permalink
Merge pull request #405 from GaloisInc/vr/bits-memint
Browse files Browse the repository at this point in the history
add a `Bits` instance to `MemInt`
  • Loading branch information
Ptival authored Jul 24, 2024
2 parents 4b38285 + d2561b1 commit 3224462
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions base/src/Data/Macaw/Memory.hs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,20 @@ instance MemWidth w => Integral (MemInt w) where
where (q,r) = memIntValue x `quotRem` memIntValue y
toInteger = toInteger . memIntValue

instance MemWidth w => Bits (MemInt w) where
MemInt x .&. MemInt y = memInt (x .&. y)
MemInt x .|. MemInt y = memInt (x .|. y)
MemInt x `xor` MemInt y = memInt (x `xor` y)
complement (MemInt x) = memInt (complement x)
MemInt x `shift` i = memInt (x `shift` i)
MemInt x `rotate` i = memInt (x `rotate` i)
bitSize = addrBitSize
bitSizeMaybe x = Just (addrBitSize x)
isSigned _ = True
MemInt x `testBit` i = x `testBit` i
bit i = memInt (bit i)
popCount (MemInt x) = popCount x

------------------------------------------------------------------------
-- Relocation

Expand Down

0 comments on commit 3224462

Please sign in to comment.