macaw-base
Safe HaskellNone
LanguageHaskell2010

Data.Macaw.AbsDomain.JumpBounds.Internal

Description

NOT A PUBLIC API. This module contains the full implementation of Data.Macaw.AbsDomain.JumpBounds. It is exposed only so that the test suite can access symbols that are intentionally omitted from the public interface. Do not import this module in production code; use Data.Macaw.AbsDomain.JumpBounds instead.

Synopsis

Range predicates

data RangePred (u :: Nat) Source #

A lower and or upper bound on a value when the value is interpreted as an unsigned integer.

Constructors

RangePred

RangePred w l h indicates a constraint on w bits of the value are between l and h when the bitvector is treated as an unsigned integer.

Instances

Instances details
Show (RangePred u) Source # 
Instance details

Defined in Data.Macaw.AbsDomain.JumpBounds.Internal

Pretty (RangePred u) Source # 
Instance details

Defined in Data.Macaw.AbsDomain.JumpBounds.Internal

Methods

pretty :: RangePred u -> Doc ann

prettyList :: [RangePred u] -> Doc ann

mkLowerBound :: forall (u :: Nat). NatRepr u -> Natural -> RangePred u Source #

mkUpperBound :: forall (u :: Nat). NatRepr u -> Natural -> RangePred u Source #

mkRangeBound :: forall (u :: Nat). NatRepr u -> Natural -> Natural -> RangePred u Source #

rangeNotTotal :: forall (u :: Nat). RangePred u -> Bool Source #

Return true if range does not include whole domain.

disjoinRangePred :: forall (u :: Nat). RangePred u -> RangePred u -> Maybe (RangePred u) Source #

Take the union of two subranges, and return Nothing if this is a maximum range bound.

data SubRange (tp :: Type) where Source #

This indicates a range predicate on a selected number of bits.

Constructors

SubRange :: forall (u :: Nat) (w :: Nat). u <= w => !(RangePred u) -> SubRange ('BVType w) 

Instances

Instances details
Pretty (SubRange tp) Source # 
Instance details

Defined in Data.Macaw.AbsDomain.JumpBounds.Internal

Methods

pretty :: SubRange tp -> Doc ann

prettyList :: [SubRange tp] -> Doc ann

disjoinSubRange :: forall (tp :: Type). SubRange tp -> SubRange tp -> Maybe (SubRange tp) Source #

Take the union of two subranges.

Return Nothing if range is not value.

type BlockStartRangePred arch = LocMap (ArchReg arch) SubRange Source #

Constraints on start of block

Initial jump bounds

data InitJumpBounds arch Source #

Bounds for a function as the start of a block.

Instances

Instances details
ShowF (ArchReg arch) => Show (InitJumpBounds arch) Source # 
Instance details

Defined in Data.Macaw.AbsDomain.JumpBounds.Internal

ShowF (ArchReg arch) => Pretty (InitJumpBounds arch) Source # 
Instance details

Defined in Data.Macaw.AbsDomain.JumpBounds.Internal

Methods

pretty :: InitJumpBounds arch -> Doc ann

prettyList :: [InitJumpBounds arch] -> Doc ann

functionStartBounds :: RegisterInfo (ArchReg arch) => InitJumpBounds arch Source #

Bounds at start of function.

ppInitJumpBounds :: ShowF (ArchReg arch) => InitJumpBounds arch -> [Doc ann] Source #

Pretty print jump bounds.

joinInitialBounds :: (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch), HasRepr (ArchReg arch) TypeRepr) => InitJumpBounds arch -> InitJumpBounds arch -> Maybe (InitJumpBounds arch) Source #

Return a jump bounds that implies both input bounds, or Nothing if every fact in the old bounds is implied by the new bounds.

joinRangePredMap Source #

Arguments

:: forall (r :: Type -> Type). (OrdF r, MemWidth (RegAddrWidth r)) 
=> LocMap r SubRange

old

-> LocMap r SubRange

new

-> (LocMap r SubRange, Bool) 

Pointwise union of two range-predicate maps, returning the joined map alongside a flag indicating whether old lost any precision in the join. A location is present in the result iff it is present in BOTH inputs and the union of the two ranges is not saturated. This is the lattice-theoretic join: a fact survives iff it holds on every incoming edge. The flag is True when some location in old is either absent from the result or present with bounds that are strictly looser than old's.

joinAddrPredMap Source #

Arguments

:: Ord k 
=> Map k (MemVal SubRange)

old

-> Map k (MemVal SubRange)

new

-> (Map k (MemVal SubRange), Bool) 

Pointwise union of two address-predicate maps, mirroring joinRangePredMap: returns the joined map along with a flag indicating whether old lost any precision.

IntraJumpBounds

data IntraJumpBounds arch ids Source #

This tracks bounds on a block during execution.

Instances

Instances details
ShowF (ArchReg arch) => Pretty (IntraJumpBounds arch ids) Source # 
Instance details

Defined in Data.Macaw.AbsDomain.JumpBounds.Internal

Methods

pretty :: IntraJumpBounds arch ids -> Doc ann

prettyList :: [IntraJumpBounds arch ids] -> Doc ann

blockEndBounds :: (MemWidth (ArchAddrWidth arch), OrdF (ArchReg arch), ShowF (ArchReg arch), FoldableFC (ArchFn arch)) => InitJumpBounds arch -> [Stmt arch ids] -> IntraJumpBounds arch ids Source #

Create bounds for end of block.

postCallBounds :: RegisterInfo (ArchReg arch) => CallParams (ArchReg arch) -> IntraJumpBounds arch ids -> RegState (ArchReg arch) (Value arch ids) -> InitJumpBounds arch Source #

Return the index bounds after a function call.

postJumpBounds Source #

Arguments

:: RegisterInfo (ArchReg arch) 
=> IntraJumpBounds arch ids

Bounds at end of this state.

-> RegState (ArchReg arch) (Value arch ids)

Register values at start of next state.

-> InitJumpBounds arch 

Bounds for block after jump

postBranchBounds Source #

Arguments

:: RegisterInfo (ArchReg arch) 
=> IntraJumpBounds arch ids

Bounds just before jump

-> RegState (ArchReg arch) (Value arch ids)

Register values at start of next state.

-> Value arch ids BoolType

Branch condition

-> BranchBounds arch 

unsignedUpperBound :: forall arch ids (tp :: Type). (OrdF (ArchReg arch), ShowF (ArchReg arch), RegisterInfo (ArchReg arch)) => IntraJumpBounds arch ids -> Value arch ids tp -> Maybe Natural Source #

This returns a natural number with a computed upper bound for the value or Nothing if no explicit bound was inferred.

Jump Targets

type IntraJumpTarget arch = (ArchSegmentOff arch, AbsBlockState (ArchReg arch), InitJumpBounds arch) Source #

This type is used to represent the location to return to *within a function* after executing an architecture-specific terminator instruction.

  • The MemSegmentOff is the address to jump to next (within the function)
  • The AbsBlockState is the abstract state to use at the start of the block returned to (reflecting any changes made by the architecture-specific terminator)
  • The InitJumpBounds is a collection of relations between values in registers and on the stack that should hold (see postCallBounds for to construct this in the common case)

Note: This is defined here (despite not being used here) to avoid import cycles elsewhere