From 2ac2a68eb5b709caa636d1a9a56a40268d378550 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Tue, 4 Sep 2012 20:59:34 +0200 Subject: [PATCH] basicblock: annotate BBs with exceptions --- Mate/BasicBlocks.hs | 11 ++++++++++- Mate/Types.hs | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Mate/BasicBlocks.hs b/Mate/BasicBlocks.hs index 7fefb60..7fd2e48 100644 --- a/Mate/BasicBlocks.hs +++ b/Mate/BasicBlocks.hs @@ -35,6 +35,15 @@ type BBState = Targets type AnalyseState = State BBState [OffIns] +noException :: B.ByteString +noException = B.empty + +emptyBasicBlock :: BasicBlock +emptyBasicBlock = BasicBlock + { code = [] + , exception = noException + , successor = Return } + printMapBB :: MapBB -> IO () printMapBB hmap = do printfBb "BlockIDs: " @@ -144,7 +153,7 @@ buildCFG' hmap ((off, entry, _):xs) insns = buildCFG' (insertlist entryi hmap) x parseBasicBlock :: Int -> [OffIns] -> BasicBlock -parseBasicBlock i insns = BasicBlock insonly endblock +parseBasicBlock i insns = emptyBasicBlock { code = insonly, successor = endblock } where (lastblock, is) = takeWhilePlusOne validins omitins insns (_, _, insonly) = unzip3 is diff --git a/Mate/Types.hs b/Mate/Types.hs index 67ac2a5..de17e37 100644 --- a/Mate/Types.hs +++ b/Mate/Types.hs @@ -42,6 +42,7 @@ type BlockID = Int -- Represents a CFG node data BasicBlock = BasicBlock { code :: [Instruction], + exception :: B.ByteString, successor :: BBEnd } -- describes (leaving) edges of a CFG node -- 2.25.1