Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Macaw.Analysis.FunctionArgs
Description
This performs a whole-program analysis to compute which registers are needed to evaluate different blocks. It can be used to compute which registers are needed for function arguments.
Synopsis
- functionDemands :: ArchConstraints arch => ArchDemandInfo arch -> Memory (ArchAddrWidth arch) -> ResolveCallArgsFn arch -> [Some (DiscoveryFunInfo arch)] -> (AddrDemandMap (ArchReg arch), FunctionSummaryFailureMap (ArchReg arch))
- data ArchDemandInfo arch = ArchDemandInfo {
- functionArgRegs :: ![Some (ArchReg arch)]
- functionRetRegs :: ![Some (ArchReg arch)]
- calleeSavedRegs :: !(Set (Some (ArchReg arch)))
- computeArchTermStmtEffects :: !(forall ids. ComputeArchTermStmtEffects arch ids)
- demandInfoCtx :: !(DemandContext arch)
- data ArchTermStmtRegEffects arch = ArchTermStmtRegEffects {
- termRegDemands :: ![Some (ArchReg arch)]
- termRegTransfers :: ![Some (ArchReg arch)]
- type ComputeArchTermStmtEffects arch ids = ArchTermStmt arch (Value arch ids) -> RegState (ArchReg arch) (Value arch ids) -> ArchTermStmtRegEffects arch
- type ResolveCallArgsFn arch = forall ids. ArchSegmentOff arch -> RegState (ArchReg arch) (Value arch ids) -> Either String [Some (Value arch ids)]
- type AddrDemandMap (r :: Type -> Type) = Map (RegSegmentOff r) (DemandSet r)
- data DemandSet (r :: Type -> Type) = DemandSet {
- registerDemands :: !(RegisterSet r)
- functionResultDemands :: !(Map (MemSegmentOff (RegAddrWidth r)) (RegisterSet r))
- type FunctionSummaryFailureMap (r :: Type -> Type) = Map (RegSegmentOff r) (FunctionArgAnalysisFailure (RegAddrWidth r))
- data FunctionArgAnalysisFailure (w :: Nat)
- type RegSegmentOff (r :: Type -> Type) = MemSegmentOff (RegAddrWidth r)
- type RegisterSet (r :: Type -> Type) = Set (Some r)
Documentation
Arguments
:: ArchConstraints arch | |
=> ArchDemandInfo arch | Architecture-specific demand information. |
-> Memory (ArchAddrWidth arch) | State of memory for resolving segment offsets. |
-> ResolveCallArgsFn arch | |
-> [Some (DiscoveryFunInfo arch)] | List of function to compute demands for. |
-> (AddrDemandMap (ArchReg arch), FunctionSummaryFailureMap (ArchReg arch)) |
This analyzes the discovered functions and returns a mapping from each block to the registers demanded by that blog.
Callbacks for architecture-specific information
data ArchDemandInfo arch Source #
Information about the architecture/environment what arguments a function needs.
Constructors
ArchDemandInfo | |
Fields
|
data ArchTermStmtRegEffects arch Source #
Describes the effects of an architecture-specific statement
Constructors
ArchTermStmtRegEffects | |
Fields
|
type ComputeArchTermStmtEffects arch ids = ArchTermStmt arch (Value arch ids) -> RegState (ArchReg arch) (Value arch ids) -> ArchTermStmtRegEffects arch Source #
Returns information about the registers needed and modified by a terminal statement
The first argument is the terminal statement.
The second is the state of registers when it is executed.
type ResolveCallArgsFn arch = forall ids. ArchSegmentOff arch -> RegState (ArchReg arch) (Value arch ids) -> Either String [Some (Value arch ids)] Source #
Function for resolving arguments to call.
Takes address of callsite and registers.
Demands
type AddrDemandMap (r :: Type -> Type) = Map (RegSegmentOff r) (DemandSet r) Source #
Maps each function to the demand set for that function.
data DemandSet (r :: Type -> Type) Source #
This stores the information that is needed to compute a value of some sort.
Constructors
DemandSet | |
Fields
|
Instances
OrdF r => Monoid (DemandSet r) Source # | |
OrdF r => Semigroup (DemandSet r) Source # | |
(ShowF r, MemWidth (RegAddrWidth r)) => Show (DemandSet r) Source # | |
TestEquality r => Eq (DemandSet r) Source # | |
OrdF r => Ord (DemandSet r) Source # | |
Defined in Data.Macaw.Analysis.FunctionArgs |
Errors
type FunctionSummaryFailureMap (r :: Type -> Type) = Map (RegSegmentOff r) (FunctionArgAnalysisFailure (RegAddrWidth r)) Source #
Map function entry points that fail to reasons why we could not infer arguments.
data FunctionArgAnalysisFailure (w :: Nat) Source #
Describes a reason a function call failed.
Constructors
CallAnalysisError !(MemSegmentOff w) !String | Could not determine call arguments. |
PLTStubNotSupported | PLT stub analysis not supported. |
Instances
MemWidth w => Show (FunctionArgAnalysisFailure w) Source # | |
Defined in Data.Macaw.Analysis.FunctionArgs Methods showsPrec :: Int -> FunctionArgAnalysisFailure w -> ShowS # show :: FunctionArgAnalysisFailure w -> String # showList :: [FunctionArgAnalysisFailure w] -> ShowS # |
Utilities
type RegSegmentOff (r :: Type -> Type) = MemSegmentOff (RegAddrWidth r) Source #
A memory segment offset compatible with the architecture registers.