buildCFG' :: MapBB -> [OffIns] -> [OffIns] -> MapBB
buildCFG' hmap [] _ = hmap
-buildCFG' hmap (((off, Just entry), _):xs) insns = buildCFG' (insertlist entryi hmap) xs insns
+buildCFG' hmap (((off, entry), _):xs) insns = buildCFG' (insertlist entryi hmap) xs insns
where
insertlist :: [BlockID] -> MapBB -> MapBB
insertlist [] hmap = hmap
entryi :: [BlockID]
entryi = (if off == 0 then [0] else []) ++ -- also consider the entrypoint
case entry of
- TwoTarget t1 t2 -> [t1, t2]
- OneTarget t -> [t]
- Return -> []
-
-buildCFG' hmap (((_, Nothing), _):xs) insns = buildCFG' hmap xs insns
+ Just (TwoTarget t1 t2) -> [t1, t2]
+ Just (OneTarget t) -> [t]
+ Just (Return) -> []
+ Nothing -> []
parseBasicBlock :: Int -> [OffIns] -> BasicBlock
where
notarget = ((off, Just Return), x):next
onetarget w16 = ((off, Just $ OneTarget $ (off `addW16Signed` w16)), x):next
- twotargets w16 = ((off, Just $ TwoTarget (off `addW16Signed` w16) (off + 3)), x):next
+ twotargets w16 = ((off, Just $ TwoTarget (off + 3) (off `addW16Signed` w16)), x):next
next = cio' (newoffset x off) xs