HPPA (PA-RISC) host support
[qemu] / tcg / x86_64 / tcg-target.c
index a2f0e4c..480ffcb 100644 (file)
@@ -40,7 +40,7 @@ const char *tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
     "%r15",
 };
 
-int tcg_target_reg_alloc_order[TCG_TARGET_NB_REGS] = {
+int tcg_target_reg_alloc_order[] = {
     TCG_REG_RDI,
     TCG_REG_RSI,
     TCG_REG_RDX,
@@ -74,8 +74,9 @@ const int tcg_target_call_oarg_regs[2] = {
 };
 
 static void patch_reloc(uint8_t *code_ptr, int type, 
-                        tcg_target_long value)
+                        tcg_target_long value, tcg_target_long addend)
 {
+    value += addend;
     switch(type) {
     case R_X86_64_32:
         if (value != (uint32_t)value)
@@ -294,6 +295,7 @@ static inline void tcg_out_modrm_offset(TCGContext *s, int opc, int r, int rm,
     }
 }
 
+#if defined(CONFIG_SOFTMMU)
 /* XXX: incomplete. index must be different from ESP */
 static void tcg_out_modrm_offset2(TCGContext *s, int opc, int r, int rm, 
                                   int index, int shift,
@@ -330,6 +332,7 @@ static void tcg_out_modrm_offset2(TCGContext *s, int opc, int r, int rm,
         tcg_out32(s, offset);
     }
 }
+#endif
 
 static inline void tcg_out_mov(TCGContext *s, int ret, int arg)
 {
@@ -354,16 +357,22 @@ static inline void tcg_out_movi(TCGContext *s, TCGType type,
     }
 }
 
-static inline void tcg_out_ld(TCGContext *s, int ret, 
+static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret,
                               int arg1, tcg_target_long arg2)
 {
-    tcg_out_modrm_offset(s, 0x8b | P_REXW, ret, arg1, arg2); /* movq */
+    if (type == TCG_TYPE_I32)
+        tcg_out_modrm_offset(s, 0x8b, ret, arg1, arg2); /* movl */
+    else
+        tcg_out_modrm_offset(s, 0x8b | P_REXW, ret, arg1, arg2); /* movq */
 }
 
-static inline void tcg_out_st(TCGContext *s, int arg, 
+static inline void tcg_out_st(TCGContext *s, TCGType type, int arg,
                               int arg1, tcg_target_long arg2)
 {
-    tcg_out_modrm_offset(s, 0x89 | P_REXW, arg, arg1, arg2); /* movq */
+    if (type == TCG_TYPE_I32)
+        tcg_out_modrm_offset(s, 0x89, arg, arg1, arg2); /* movl */
+    else
+        tcg_out_modrm_offset(s, 0x89 | P_REXW, arg, arg1, arg2); /* movq */
 }
 
 static inline void tgen_arithi32(TCGContext *s, int c, int r0, int32_t val)
@@ -431,7 +440,7 @@ static void tcg_out_jxx(TCGContext *s, int opc, int label_index)
             tcg_out8(s, 0x80 + opc);
         }
         tcg_out_reloc(s, s->code_ptr, R_386_PC32, label_index, -4);
-        tcg_out32(s, -4);
+        s->code_ptr += 4;
     }
 }
 
@@ -445,7 +454,7 @@ static void tcg_out_brcond(TCGContext *s, int cond,
             /* use test */
             switch(cond) {
             case TCG_COND_EQ:
-                c = JCC_JNE;
+                c = JCC_JE;
                 break;
             case TCG_COND_NE:
                 c = JCC_JNE;
@@ -471,7 +480,7 @@ static void tcg_out_brcond(TCGContext *s, int cond,
             tcg_out_jxx(s, tcg_cond_to_jcc[cond], label_index);
         }
     } else {
-        tcg_out_modrm(s, 0x01 | (ARITH_CMP << 3) | rexw, arg1, arg2);
+        tcg_out_modrm(s, 0x01 | (ARITH_CMP << 3) | rexw, arg2, arg1);
         tcg_out_jxx(s, tcg_cond_to_jcc[cond], label_index);
     }
 }