Skip to content

Commit

Permalink
favor ArchAddrWidth over RegAddrWidth (ArchReg ...)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ptival committed Dec 9, 2023
1 parent 35b5fcd commit b34111d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion base/src/Data/Macaw/AbsDomain/AbsState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ setAbsIP a b
-- | The absolute value associated with a given architecture.
--
-- This is only a function of the address width.
type ArchAbsValue arch = AbsValue (RegAddrWidth (ArchReg arch))
type ArchAbsValue arch = AbsValue (ArchAddrWidth arch)

-- | This stores the abstract state of the system which may be within
-- a block.
Expand Down
6 changes: 3 additions & 3 deletions base/src/Data/Macaw/Architecture/Info.hs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ data ArchitectureInfo arch
{ withArchConstraints :: forall a . (ArchConstraints arch => a) -> a
-- ^ Provides the architecture constraints to any computation
-- that needs it.
, archAddrWidth :: !(AddrWidthRepr (RegAddrWidth (ArchReg arch)))
, archAddrWidth :: !(AddrWidthRepr (ArchAddrWidth arch))
-- ^ Architecture address width.
, archEndianness :: !Endianness
-- ^ The byte order values are stored in.
Expand All @@ -247,7 +247,7 @@ data ArchitectureInfo arch
-- ^ Create initial registers from address and precondition.
, disassembleFn :: !(DisassembleFn arch)
-- ^ Function for disassembling a block.
, mkInitialAbsState :: !(Memory (RegAddrWidth (ArchReg arch))
, mkInitialAbsState :: !(Memory (ArchAddrWidth arch)
-> ArchSegmentOff arch
-> AbsBlockState (ArchReg arch))
-- ^ Creates an abstract block state for representing the beginning of a
Expand All @@ -257,7 +257,7 @@ data ArchitectureInfo arch
, absEvalArchFn :: !(forall ids tp
. AbsProcessorState (ArchReg arch) ids
-> ArchFn arch (Value arch ids) tp
-> AbsValue (RegAddrWidth (ArchReg arch)) tp)
-> AbsValue (ArchAddrWidth arch) tp)
-- ^ Evaluates an architecture-specific function
, absEvalArchStmt :: !(forall ids
. AbsProcessorState (ArchReg arch) ids
Expand Down
2 changes: 1 addition & 1 deletion base/src/Data/Macaw/Discovery.hs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ recordWriteStmts ainfo mem absState writtenAddrs (stmt:stmts) =

-- | Get the memory representation associated with pointers in the
-- given architecture.
addrMemRepr :: ArchitectureInfo arch -> MemRepr (BVType (RegAddrWidth (ArchReg arch)))
addrMemRepr :: ArchitectureInfo arch -> MemRepr (BVType (ArchAddrWidth arch))
addrMemRepr arch_info =
case archAddrWidth arch_info of
Addr32 -> BVMemRepr n4 (archEndianness arch_info)
Expand Down
15 changes: 7 additions & 8 deletions macaw-semmc/src/Data/Macaw/SemMC/Generator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ data GenState arch ids s =

emptyPreBlock :: RegState (ArchReg arch) (Value arch ids)
-> Word64
-> MM.MemSegmentOff (RegAddrWidth (ArchReg arch))
-> MM.MemSegmentOff (ArchAddrWidth arch)
-> PreBlock arch ids
emptyPreBlock s0 idx addr =
PreBlock { pBlockIndex = idx
Expand All @@ -126,11 +126,11 @@ initGenState nonceGen addr st =
where
s0 = emptyPreBlock st 0 addr

initRegState :: (KnownNat (RegAddrWidth (ArchReg arch)),
1 <= RegAddrWidth (ArchReg arch),
initRegState :: (KnownNat (ArchAddrWidth arch),
1 <= ArchAddrWidth arch,
RegisterInfo (ArchReg arch),
MM.MemWidth (RegAddrWidth (ArchReg arch)))
=> MM.MemSegmentOff (RegAddrWidth (ArchReg arch))
MM.MemWidth (ArchAddrWidth arch))
=> MM.MemSegmentOff (ArchAddrWidth arch)
-> RegState (ArchReg arch) (Value arch ids)
initRegState startIP =
mkRegState Initial & curIP .~ RelocatableValue (addrWidthRepr startIP) (MM.segoffAddr startIP)
Expand Down Expand Up @@ -196,7 +196,7 @@ getRegSnapshotVal reg = do
-- the value first, if possible.
setRegVal :: ( MSS.SimplifierExtension arch
, OrdF (ArchReg arch)
, MM.MemWidth (RegAddrWidth (ArchReg arch))
, MM.MemWidth (ArchAddrWidth arch)
)
=> ArchReg arch tp
-> Value arch ids tp
Expand All @@ -219,7 +219,7 @@ cacheAppValue a v =

addExpr :: ( MSS.SimplifierExtension arch
, OrdF (ArchReg arch)
, MM.MemWidth (RegAddrWidth (ArchReg arch))
, MM.MemWidth (ArchAddrWidth arch)
, ShowF (ArchReg arch)
)
=> Expr arch ids tp
Expand Down Expand Up @@ -403,4 +403,3 @@ finishBlock' preBlock term =
Block { blockStmts = F.toList (preBlock ^. pBlockStmts)
, blockTerm = term (preBlock ^. pBlockState)
}

4 changes: 2 additions & 2 deletions macaw-semmc/src/Data/Macaw/SemMC/Translations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import qualified Data.Macaw.SemMC.Simplify as MSS
--
-- We pull this out to reduce the amount of code generated by TH
bvconcat :: ( OrdF (ArchReg arch)
, MM.MemWidth (RegAddrWidth (ArchReg arch))
, MM.MemWidth (ArchAddrWidth arch)
, MSS.SimplifierExtension arch
, ShowF (ArchReg arch)
)
Expand All @@ -51,7 +51,7 @@ bvconcat bv1Val bv2Val repV repU repW = do
-- This code is factored out of the TH module to improve compilation times.
bvselect :: ( MSS.SimplifierExtension arch
, OrdF (ArchReg arch)
, MM.MemWidth (RegAddrWidth (ArchReg arch))
, MM.MemWidth (ArchAddrWidth arch)
, ShowF (ArchReg arch)
)
=> (1 <= w, 1 <= n, i + n <= w)
Expand Down

0 comments on commit b34111d

Please sign in to comment.