macaw-base
Safe HaskellNone
LanguageHaskell2010

Data.Macaw.CFG.AssignRhs

Synopsis

Documentation

data AssignRhs arch (f :: Type -> Type) (tp :: Type) where Source #

The right hand side of an assignment is an expression that returns a value.

Constructors

EvalApp :: forall (f :: Type -> Type) (tp :: Type) arch. !(App f tp) -> AssignRhs arch f tp

An expression that is computed from evaluating subexpressions.

SetUndefined :: forall (tp :: Type) arch (f :: Type -> Type). !(TypeRepr tp) -> AssignRhs arch f tp

An expression with an undefined value.

ReadMem :: forall (f :: Type -> Type) arch (tp :: Type). !(f (BVType (ArchAddrWidth arch))) -> !(MemRepr tp) -> AssignRhs arch f tp

Read memory at given location.

CondReadMem :: forall (tp :: Type) (f :: Type -> Type) arch. !(MemRepr tp) -> !(f BoolType) -> !(f (BVType (ArchAddrWidth arch))) -> !(f tp) -> AssignRhs arch f tp

CondReadMem tp cond addr v reads from memory at the given address if the condition is true and returns the value if it false.

EvalArchFn :: forall arch (f :: Type -> Type) (tp :: Type). !(ArchFn arch f tp) -> !(TypeRepr tp) -> AssignRhs arch f tp 

Instances

Instances details
FoldableFC (ArchFn arch) => FoldableFC (AssignRhs arch :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

foldMapFC :: forall f m. Monoid m => (forall (x :: Type). f x -> m) -> forall (x :: Type). AssignRhs arch f x -> m #

foldrFC :: (forall (x :: Type). f x -> b -> b) -> forall (x :: Type). b -> AssignRhs arch f x -> b #

foldlFC :: forall f b. (forall (x :: Type). b -> f x -> b) -> forall (x :: Type). b -> AssignRhs arch f x -> b #

foldrFC' :: (forall (x :: Type). f x -> b -> b) -> forall (x :: Type). b -> AssignRhs arch f x -> b #

foldlFC' :: forall f b. (forall (x :: Type). b -> f x -> b) -> forall (x :: Type). b -> AssignRhs arch f x -> b #

toListFC :: (forall (x :: Type). f x -> a) -> forall (x :: Type). AssignRhs arch f x -> [a] #

HasRepr (AssignRhs arch f :: Type -> Type) TypeRepr Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

typeRepr :: forall (tp :: Type). AssignRhs arch f tp -> TypeRepr tp Source #

ArchConstraints arch => Pretty (AssignRhs arch (Value arch ids) tp) 
Instance details

Defined in Data.Macaw.CFG.Core

Methods

pretty :: AssignRhs arch (Value arch ids) tp -> Doc ann

prettyList :: [AssignRhs arch (Value arch ids) tp] -> Doc ann

MemRepr

data MemRepr (tp :: Type) where Source #

The provides information sufficient to read supported types of values from memory such as the number of bytes and endianness.

Constructors

BVMemRepr :: forall (w :: Natural). 1 <= w => !(NatRepr w) -> !Endianness -> MemRepr ('BVType (8 * w))

Denotes a bitvector with the given number of bytes and endianness.

FloatMemRepr :: forall (f :: FloatInfo). !(FloatInfoRepr f) -> !Endianness -> MemRepr ('FloatType f)

A floating point value (stored in given endianness.

PackedVecMemRepr :: forall (n :: Nat) (tp1 :: Type). !(NatRepr n) -> !(MemRepr tp1) -> MemRepr ('VecType n tp1)

A vector of values with zero entry first.

The first value is stored at the address, the second is stored at address + sizeof eltType, etc.

Instances

Instances details
TestEquality MemRepr Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

testEquality :: forall (a :: Type) (b :: Type). MemRepr a -> MemRepr b -> Maybe (a :~: b) #

HashableF MemRepr Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

hashWithSaltF :: forall (tp :: Type). Int -> MemRepr tp -> Int

hashF :: forall (tp :: Type). MemRepr tp -> Int

OrdF MemRepr Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

compareF :: forall (x :: Type) (y :: Type). MemRepr x -> MemRepr y -> OrderingF x y

leqF :: forall (x :: Type) (y :: Type). MemRepr x -> MemRepr y -> Bool

ltF :: forall (x :: Type) (y :: Type). MemRepr x -> MemRepr y -> Bool

geqF :: forall (x :: Type) (y :: Type). MemRepr x -> MemRepr y -> Bool

gtF :: forall (x :: Type) (y :: Type). MemRepr x -> MemRepr y -> Bool

HasRepr MemRepr TypeRepr Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

typeRepr :: forall (tp :: Type). MemRepr tp -> TypeRepr tp Source #

Show (MemRepr tp) Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

showsPrec :: Int -> MemRepr tp -> ShowS #

show :: MemRepr tp -> String #

showList :: [MemRepr tp] -> ShowS #

Eq (MemRepr tp) Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

(==) :: MemRepr tp -> MemRepr tp -> Bool #

(/=) :: MemRepr tp -> MemRepr tp -> Bool #

Hashable (MemRepr tp) Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

hashWithSalt :: Int -> MemRepr tp -> Int

hash :: MemRepr tp -> Int

Pretty (MemRepr tp) Source # 
Instance details

Defined in Data.Macaw.CFG.AssignRhs

Methods

pretty :: MemRepr tp -> Doc ann

prettyList :: [MemRepr tp] -> Doc ann

memReprBytes :: forall (tp :: Type). MemRepr tp -> Natural Source #

Return the number of bytes this uses in memory.

Architecture type families

type family RegAddrWidth (r :: Type -> Type) :: Nat Source #

Width of register used to store addresses.

type family ArchReg arch = (reg :: Type -> Type) | reg -> arch Source #

Type family for defining what a "register" is for this architecture.

Registers include things like the general purpose registers, any flag registers that can be read and written without side effects,

type family ArchFn arch = (fn :: (Type -> Type) -> Type -> Type) | fn -> arch Source #

A type family for architecture specific functions.

The functions associated with architecture-function depend on the contents of memory and implicit components of the processor state, but they should not affect any of the architecture registers in ArchReg arch.

Architecture specific functions are required to implement FoldableFC, and the evaluation of an architecture specific function may only depend on the value stored in a general purpose register if it is given through the fn parameter and provided when folding over values. This is required for accurate def-use analysis of general purpose registers.

type family ArchStmt arch = (stmt :: (Type -> Type) -> Type) | stmt -> arch Source #

A type family for defining architecture-specific statements.

The second parameter is used to denote the underlying values in the statements so that we can use ArchStmts with multiple CFGs.

type family ArchTermStmt arch :: (Type -> Type) -> Type Source #

A type family for defining architecture-specific statements that may have instruction-specific effects on control-flow and register state.

An architecture-specific terminal statement may have side effects and change register values, it may or may not return to the current function.

Note that the meaning of the type parameter is identical to that of ArchStmt

Synonyms

type RegAddrWord (r :: Type -> Type) = MemWord (RegAddrWidth r) Source #

A word for the given architecture register type.

type ArchAddrWidth arch = RegAddrWidth (ArchReg arch) Source #

Number of bits in addreses for architecture.

type ArchAddrWord arch = RegAddrWord (ArchReg arch) Source #

A word for the given architecture bitwidth.

type ArchMemAddr arch = MemAddr (ArchAddrWidth arch) Source #

An address for a given architecture.