mirror of
https://github.com/GaloisInc/macaw.git
synced 2024-11-29 11:02:13 +03:00
Merge pull request #405 from GaloisInc/vr/bits-memint
add a `Bits` instance to `MemInt`
This commit is contained in:
commit
32244627f2
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user