Split up the functions that will comprise ppc_linux_info

This commit is contained in:
Tristan Ravitch 2017-10-02 11:19:34 -07:00
parent 1f1a6d8561
commit 4d9c7cd028
6 changed files with 121 additions and 59 deletions

View File

@ -16,9 +16,13 @@ extra-source-files: ChangeLog.md
cabal-version: >=1.10
library
exposed-modules: Data.Macaw.PPC,
Data.Macaw.PPC.ArchTypes,
exposed-modules: Data.Macaw.PPC
Data.Macaw.PPC.ArchTypes
Data.Macaw.PPC.Disassemble
Data.Macaw.PPC.Eval
Data.Macaw.PPC.Identify
Data.Macaw.PPC.PPCReg
Data.Macaw.PPC.Rewrite
-- other-modules:
-- other-extensions:
build-depends: base >=4.9 && <5,

View File

@ -33,8 +33,21 @@ import qualified SemMC.Architecture.PPC32 as PPC32
import qualified SemMC.Architecture.PPC64 as PPC64
import Data.Macaw.PPC.ArchTypes
import Data.Macaw.PPC.Disassemble ( disassembleFn )
import Data.Macaw.PPC.Eval ( mkInitialAbsState,
absEvalArchFn,
absEvalArchStmt,
postCallAbsState,
preserveRegAcrossSyscall
)
import Data.Macaw.PPC.Identify ( identifyCall,
identifyReturn
)
import Data.Macaw.PPC.PPCReg
-- import Data.Macaw.PPC.Rewrite
import Data.Macaw.PPC.Rewrite ( rewriteArchFn,
rewriteArchStmt,
rewriteArchTermStmt
)
data Hole = Hole
@ -137,62 +150,6 @@ getReg r = PPCGenerator $ St.StateT $ \genState -> do
let expr = ValueExpr (genState ^. blockState ^. pBlockState ^. boundValue r)
return (expr, genState)
disassembleFn :: proxy ppc -> MM.Memory (ArchAddrWidth ppc)
-> NC.NonceGenerator (ST ids) ids
-> ArchSegmentOff ppc
-> ArchAddrWord ppc
-> MA.AbsBlockState (ArchReg ppc)
-- ^ NOTE: We are leaving the type function ArchReg here because
-- we need to generalize over PPC64 vs PPC32
-> ST ids ([Block ppc ids], MM.MemWord (ArchAddrWidth ppc), Maybe String)
disassembleFn = undefined
preserveRegAcrossSyscall :: proxy ppc -> ArchReg ppc tp -> Bool
preserveRegAcrossSyscall = undefined
mkInitialAbsState :: proxy ppc -> MM.Memory (RegAddrWidth (ArchReg ppc))
-> ArchSegmentOff ppc
-> MA.AbsBlockState (ArchReg ppc)
mkInitialAbsState = undefined
absEvalArchFn :: proxy ppc -> AbsProcessorState (ArchReg ppc) ids
-> ArchFn ppc (Value ppc ids) tp
-> AbsValue (RegAddrWidth (ArchReg ppc)) tp
absEvalArchFn = undefined
absEvalArchStmt :: proxy ppc -> AbsProcessorState (ArchReg ppc) ids
-> ArchStmt ppc ids
-> AbsProcessorState (ArchReg ppc) ids
absEvalArchStmt = undefined
postCallAbsState :: proxy ppc -> AbsBlockState (ArchReg ppc)
-> ArchSegmentOff ppc
-> AbsBlockState (ArchReg ppc)
postCallAbsState = undefined
identifyCall :: proxy ppc -> MM.Memory (ArchAddrWidth ppc)
-> [Stmt ppc ids]
-> RegState (ArchReg ppc) (Value ppc ids)
-> Maybe (Seq.Seq (Stmt ppc ids), ArchSegmentOff ppc)
identifyCall = undefined
identifyReturn :: proxy ppc -> [Stmt ppc ids]
-> RegState (ArchReg ppc) (Value ppc ids)
-> Maybe [Stmt ppc ids]
identifyReturn = undefined
rewriteArchFn :: proxy ppc -> ArchFn ppc (Value ppc src) tp
-> Rewriter ppc src tgt (Value ppc tgt tp)
rewriteArchFn = undefined
rewriteArchStmt :: proxy ppc -> ArchStmt ppc src
-> Rewriter ppc src tgt ()
rewriteArchStmt = undefined
rewriteArchTermStmt :: proxy ppc -> ArchTermStmt ppc src
-> Rewriter ppc src tgt (ArchTermStmt ppc tgt)
rewriteArchTermStmt = undefined
archDemandContext :: proxy ppc -> MDS.DemandContext ppc ids
archDemandContext = undefined

View File

@ -0,0 +1,18 @@
module Data.Macaw.PPC.Disassemble ( disassembleFn ) where
import Control.Monad.ST ( ST )
import Data.Macaw.AbsDomain.AbsState as MA
import Data.Macaw.CFG
import Data.Macaw.CFG.Block
import qualified Data.Macaw.Memory as MM
import qualified Data.Parameterized.Nonce as NC
disassembleFn :: proxy ppc
-> MM.Memory (ArchAddrWidth ppc)
-> NC.NonceGenerator (ST ids) ids
-> ArchSegmentOff ppc
-> ArchAddrWord ppc
-> MA.AbsBlockState (ArchReg ppc)
-> ST ids ([Block ppc ids], MM.MemWord (ArchAddrWidth ppc), Maybe String)
disassembleFn = undefined

View File

@ -0,0 +1,38 @@
module Data.Macaw.PPC.Eval (
mkInitialAbsState,
absEvalArchFn,
absEvalArchStmt,
postCallAbsState,
preserveRegAcrossSyscall
) where
import Data.Macaw.AbsDomain.AbsState as MA
import Data.Macaw.CFG
import qualified Data.Macaw.Memory as MM
preserveRegAcrossSyscall :: proxy ppc -> ArchReg ppc tp -> Bool
preserveRegAcrossSyscall = undefined
mkInitialAbsState :: proxy ppc
-> MM.Memory (RegAddrWidth (ArchReg ppc))
-> ArchSegmentOff ppc
-> MA.AbsBlockState (ArchReg ppc)
mkInitialAbsState = undefined
absEvalArchFn :: proxy ppc
-> AbsProcessorState (ArchReg ppc) ids
-> ArchFn ppc (Value ppc ids) tp
-> AbsValue (RegAddrWidth (ArchReg ppc)) tp
absEvalArchFn = undefined
absEvalArchStmt :: proxy ppc
-> AbsProcessorState (ArchReg ppc) ids
-> ArchStmt ppc ids
-> AbsProcessorState (ArchReg ppc) ids
absEvalArchStmt = undefined
postCallAbsState :: proxy ppc
-> AbsBlockState (ArchReg ppc)
-> ArchSegmentOff ppc
-> AbsBlockState (ArchReg ppc)
postCallAbsState = undefined

View File

@ -0,0 +1,22 @@
module Data.Macaw.PPC.Identify (
identifyCall,
identifyReturn
) where
import qualified Data.Sequence as Seq
import Data.Macaw.CFG
import qualified Data.Macaw.Memory as MM
identifyCall :: proxy ppc
-> MM.Memory (ArchAddrWidth ppc)
-> [Stmt ppc ids]
-> RegState (ArchReg ppc) (Value ppc ids)
-> Maybe (Seq.Seq (Stmt ppc ids), ArchSegmentOff ppc)
identifyCall = undefined
identifyReturn :: proxy ppc
-> [Stmt ppc ids]
-> RegState (ArchReg ppc) (Value ppc ids)
-> Maybe [Stmt ppc ids]
identifyReturn = undefined

View File

@ -0,0 +1,23 @@
module Data.Macaw.PPC.Rewrite (
rewriteArchFn,
rewriteArchStmt,
rewriteArchTermStmt
) where
import Data.Macaw.CFG
import Data.Macaw.CFG.Rewriter
rewriteArchFn :: proxy ppc
-> ArchFn ppc (Value ppc src) tp
-> Rewriter ppc src tgt (Value ppc tgt tp)
rewriteArchFn = undefined
rewriteArchStmt :: proxy ppc
-> ArchStmt ppc src
-> Rewriter ppc src tgt ()
rewriteArchStmt = undefined
rewriteArchTermStmt :: proxy ppc
-> ArchTermStmt ppc src
-> Rewriter ppc src tgt (ArchTermStmt ppc tgt)
rewriteArchTermStmt = undefined