Merged trunk and subtype.
[cacao.git] / src / vm / jit / i386 / emit.c
index e2e762bd0f1ca464b64df1486e1dfe179fc0c8be..66fba15ffcc36d30922e8c46422529126a58388c 100644 (file)
 
 #include "threads/lock-common.h"
 
-#include "vm/exceptions.h"
+#include "vm/options.h"
+#include "vm/statistics.h"
 
 #include "vm/jit/abi.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/dseg.h"
-#include "vm/jit/emit-common.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/replace.h"
-#include "vm/jit/trace.h"
+#include "vm/jit/emit-common.hpp"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/patcher-common.hpp"
+#include "vm/jit/replace.hpp"
+#include "vm/jit/trace.hpp"
 #include "vm/jit/trap.h"
 
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
 
 /* emit_load ******************************************************************
 
@@ -460,9 +458,15 @@ void emit_classcast_check(codegendata *cd, instruction *iptr, s4 condition, s4 r
                case BRANCH_LE:
                        M_BGT(6);
                        break;
+               case BRANCH_GE:
+                       M_BLT(6);
+                       break;
                case BRANCH_EQ:
                        M_BNE(6);
                        break;
+               case BRANCH_NE:
+                       M_BEQ(6);
+                       break;
                case BRANCH_ULE:
                        M_BBE(6);
                        break;
@@ -927,6 +931,15 @@ void emit_movb_imm_membase(codegendata *cd, s4 imm, s4 basereg, s4 disp)
 }
 
 
+void emit_movsbl_reg_reg(codegendata *cd, s4 a, s4 b)
+{
+       assert(a < 4);                     /* Can only operate on al, bl, cl, dl. */
+       *(cd->mcodeptr++) = 0x0f;
+       *(cd->mcodeptr++) = 0xbe;
+       emit_reg((b),(a));
+}
+
+
 void emit_movsbl_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
 {
        COUNT(count_mov_mem_reg);
@@ -953,6 +966,15 @@ void emit_movswl_memindex_reg(codegendata *cd, s4 disp, s4 basereg, s4 indexreg,
 }
 
 
+void emit_movzbl_reg_reg(codegendata *cd, s4 a, s4 b)
+{
+       assert(a < 4);                     /* Can only operate on al, bl, cl, dl. */
+       *(cd->mcodeptr++) = 0x0f;
+       *(cd->mcodeptr++) = 0xb6;
+       emit_reg((b),(a));
+}
+
+
 void emit_movzwl_reg_reg(codegendata *cd, s4 a, s4 b)
 {
        *(cd->mcodeptr++) = 0x0f;
@@ -1068,6 +1090,11 @@ void emit_alu_imm_memabs(codegendata *cd, s4 opc, s4 imm, s4 disp)
        }
 }
 
+void emit_alu_memindex_reg(codegendata *cd, s4 opc, s4 disp, s4 basereg, s4 indexreg, s4 scale, s4 reg)
+{
+       *(cd->mcodeptr++) = (((u1) (opc)) << 3) + 3;
+       emit_memindex(cd, (reg),(disp),(basereg),(indexreg),(scale));
+}
 
 void emit_test_reg_reg(codegendata *cd, s4 reg, s4 dreg)
 {
@@ -1088,6 +1115,12 @@ void emit_test_imm_reg(codegendata *cd, s4 imm, s4 reg)
 /*
  * inc, dec operations
  */
+void emit_inc_reg(codegendata *cd, s4 reg)
+{
+       *(cd->mcodeptr++) = 0xff;
+       emit_reg(0,(reg));
+}
+
 void emit_dec_mem(codegendata *cd, s4 mem)
 {
        *(cd->mcodeptr++) = 0xff;