From: Bernhard Urban Date: Thu, 26 Apr 2012 09:37:45 +0000 (+0200) Subject: codegen: implement IF_ACMP X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mate.git;a=commitdiff_plain;h=938e054590e5e6b1a158f496678b7dfc3d61d943 codegen: implement IF_ACMP it's just IF_ICMP actually --- diff --git a/Makefile b/Makefile index 57f77e2..3bd63d4 100644 --- a/Makefile +++ b/Makefile @@ -60,8 +60,10 @@ test: mate $(CLASS_FILES) @printf "should be: 0x%08x 0x%08x\n" 0x1337 0x1337 ./$< tests/Native2 | grep "printstream" @printf "should be: 0x%08x\n" 0x1337 - ./$< tests/Native2 | grep "Hello World" - @printf "should be: %s" "Hello World" + ./$< tests/Native3 | egrep -e "^Hello World" + @printf "should be: %s\n" "Hello World" + ./$< tests/Strings1 | egrep -c -e "^okay :-\)" + @printf "should be: %d\n" 3 %.class: %.java $(JAVAC) $< diff --git a/Mate/BasicBlocks.hs b/Mate/BasicBlocks.hs index c5d9743..bde2697 100644 --- a/Mate/BasicBlocks.hs +++ b/Mate/BasicBlocks.hs @@ -169,6 +169,7 @@ 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 diff --git a/Mate/X86CodeGen.hs b/Mate/X86CodeGen.hs index 15616f5..9fc5756 100644 --- a/Mate/X86CodeGen.hs +++ b/Mate/X86CodeGen.hs @@ -294,6 +294,7 @@ emitFromBB method cls hmap = do emit (IINC x imm) = do add (Disp (cArgs x), ebp) (s8_w32 imm) + emit (IF_ACMP cond x) = emit (IF_ICMP cond x) emit (IF_ICMP cond _) = do pop eax -- value2 pop ebx -- value1 diff --git a/tests/Strings1.java b/tests/Strings1.java new file mode 100644 index 0000000..9a6a9ba --- /dev/null +++ b/tests/Strings1.java @@ -0,0 +1,27 @@ +package tests; + +public class Strings1 { + public static void main(String []args) { + String a = "abc"; + String b = "abc"; + String c = "wtf"; + + if (a == b) { + System.out.println("okay :-)"); + } else { + System.out.println("bad :-("); + } + + if (a != c) { + System.out.println("okay :-)"); + } else { + System.out.println("bad :-("); + } + + if (a == c) { + System.out.println("bad :-("); + } else { + System.out.println("okay :-)"); + } + } +}