mirror of
https://github.com/GaloisInc/macaw.git
synced 2024-11-29 11:02:13 +03:00
add a Bits
instance to MemInt
This helps supporting bitwise operations over `MemInt`s without having to unwrap/rewrap them into `Int64`s.
This commit is contained in:
parent
83d3907054
commit
d2561b1078
@ -465,6 +465,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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user