codegen: implement IF_ACMP
[mate.git] / Mate / BasicBlocks.hs
index 59e30521b5b33937262059169ea653d5b12dfd43..bde2697d67634e4a896813633097dde1a276eb7d 100644 (file)
@@ -21,22 +21,10 @@ import JVM.Converter
 import JVM.Assembler
 
 import Mate.Utilities
+import Mate.Types
 
 
-type BlockID = Int
--- Represents a CFG node
-data BasicBlock = BasicBlock {
-                     -- inputs  :: [Variable],
-                     -- outputs :: [Variable],
-                     code    :: [Instruction],
-                     successor :: BBEnd }
-
--- describes (leaving) edges of a CFG node
-data BBEnd = Return | FallThrough BlockID | OneTarget BlockID | TwoTarget BlockID BlockID deriving Show
-
-type MapBB = M.Map BlockID BasicBlock
-
--- for immediate representation for determine BBs
+-- for immediate representation to determine BBs
 type Offset = (Int, Maybe BBEnd) -- (offset in bytecode, offset to jump target)
 type OffIns = (Offset, Instruction)
 
@@ -181,8 +169,10 @@ calculateInstructionOffset = cio' (0, Nothing)
   cio' (off,_) (x:xs) = case x of
       IF _ w16 -> twotargets w16
       IF_ICMP _ w16 -> twotargets w16
+      IF_ACMP _ w16 -> twotargets w16
       GOTO w16 -> onetarget w16
       IRETURN -> notarget
+      ARETURN -> notarget
       RETURN -> notarget
       _ -> ((off, Nothing), x):next
     where