diff mbox

[1/6] TCG/i386: use iargs or oargs instead of register names

Message ID CAAu8pHsRAOCh0kkjDT+bXo-k1FOGee3YC37ddbvswEhacTNKgA@mail.gmail.com
State New
Headers show

Commit Message

Blue Swirl Jan. 7, 2012, 10:24 p.m. UTC
Don't use register names directly but iargs or oargs tables. Later it will be
easier to shift the registers used.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 tcg/i386/tcg-target.c |   75 +++++++++++++++++++++++++++++-------------------
 1 files changed, 45 insertions(+), 30 deletions(-)


@@ -1196,35 +1196,38 @@ static void tcg_out_qemu_ld(TCGContext *s,
const TCGArg *args,

     switch(opc) {
     case 0 | 4:
-        tcg_out_ext8s(s, data_reg, TCG_REG_EAX, P_REXW);
+        tcg_out_ext8s(s, data_reg, tcg_target_call_oarg_regs[0], P_REXW);
         break;
     case 1 | 4:
-        tcg_out_ext16s(s, data_reg, TCG_REG_EAX, P_REXW);
+        tcg_out_ext16s(s, data_reg, tcg_target_call_oarg_regs[0], P_REXW);
         break;
     case 0:
-        tcg_out_ext8u(s, data_reg, TCG_REG_EAX);
+        tcg_out_ext8u(s, data_reg, tcg_target_call_oarg_regs[0]);
         break;
     case 1:
-        tcg_out_ext16u(s, data_reg, TCG_REG_EAX);
+        tcg_out_ext16u(s, data_reg, tcg_target_call_oarg_regs[0]);
         break;
     case 2:
-        tcg_out_mov(s, TCG_TYPE_I32, data_reg, TCG_REG_EAX);
+        tcg_out_mov(s, TCG_TYPE_I32, data_reg, tcg_target_call_oarg_regs[0]);
         break;
 #if TCG_TARGET_REG_BITS == 64
     case 2 | 4:
-        tcg_out_ext32s(s, data_reg, TCG_REG_EAX);
+        tcg_out_ext32s(s, data_reg, tcg_target_call_oarg_regs[0]);
         break;
 #endif
     case 3:
         if (TCG_TARGET_REG_BITS == 64) {
-            tcg_out_mov(s, TCG_TYPE_I64, data_reg, TCG_REG_RAX);
+            tcg_out_mov(s, TCG_TYPE_I64, data_reg,
+                        tcg_target_call_oarg_regs[0]);
         } else if (data_reg == TCG_REG_EDX) {
             /* xchg %edx, %eax */
             tcg_out_opc(s, OPC_XCHG_ax_r32 + TCG_REG_EDX, 0, 0, 0);
             tcg_out_mov(s, TCG_TYPE_I32, data_reg2, TCG_REG_EAX);
         } else {
-            tcg_out_mov(s, TCG_TYPE_I32, data_reg, TCG_REG_EAX);
-            tcg_out_mov(s, TCG_TYPE_I32, data_reg2, TCG_REG_EDX);
+            tcg_out_mov(s, TCG_TYPE_I32, data_reg,
+                        tcg_target_call_oarg_regs[0]);
+            tcg_out_mov(s, TCG_TYPE_I32, data_reg2,
+                        tcg_target_call_oarg_regs[1]);
         }
         break;
     default:
@@ -1246,9 +1249,12 @@ static void tcg_out_qemu_ld(TCGContext *s,
const TCGArg *args,
                use the ADDR32 prefix.  For now, do nothing.  */

             if (offset != GUEST_BASE) {
-                tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_RDI, GUEST_BASE);
-                tgen_arithr(s, ARITH_ADD + P_REXW, TCG_REG_RDI, base);
-                base = TCG_REG_RDI, offset = 0;
+                tcg_out_movi(s, TCG_TYPE_I64, tcg_target_call_iarg_regs[0],
+                             GUEST_BASE);
+                tgen_arithr(s, ARITH_ADD + P_REXW,
+                            tcg_target_call_iarg_regs[0], base);
+                base = tcg_target_call_iarg_regs[0];
+                offset = 0;
             }
         }

@@ -1361,37 +1367,43 @@ static void tcg_out_qemu_st(TCGContext *s,
const TCGArg *args,
     /* XXX: move that code at the end of the TB */
     if (TCG_TARGET_REG_BITS == 64) {
         tcg_out_mov(s, (opc == 3 ? TCG_TYPE_I64 : TCG_TYPE_I32),
-                    TCG_REG_RSI, data_reg);
-        tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_RDX, mem_index);
+                    tcg_target_call_iarg_regs[1], data_reg);
+        tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
+                     mem_index);
         stack_adjust = 0;
     } else if (TARGET_LONG_BITS == 32) {
-        tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_EDX, data_reg);
+        tcg_out_mov(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[1], data_reg);
         if (opc == 3) {
-            tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_ECX, data_reg2);
+            tcg_out_mov(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
+                        data_reg2);
             tcg_out_pushi(s, mem_index);
             stack_adjust = 4;
         } else {
-            tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_ECX, mem_index);
+            tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
+                         mem_index);
             stack_adjust = 0;
         }
     } else {
         if (opc == 3) {
-            tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_EDX, args[addrlo_idx + 1]);
+            tcg_out_mov(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[1],
+                        args[addrlo_idx + 1]);
             tcg_out_pushi(s, mem_index);
             tcg_out_push(s, data_reg2);
             tcg_out_push(s, data_reg);
             stack_adjust = 12;
         } else {
-            tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_EDX, args[addrlo_idx + 1]);
+            tcg_out_mov(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[1],
+                        args[addrlo_idx + 1]);
             switch(opc) {
             case 0:
-                tcg_out_ext8u(s, TCG_REG_ECX, data_reg);
+                tcg_out_ext8u(s, tcg_target_call_iarg_regs[2], data_reg);
                 break;
             case 1:
-                tcg_out_ext16u(s, TCG_REG_ECX, data_reg);
+                tcg_out_ext16u(s, tcg_target_call_iarg_regs[2], data_reg);
                 break;
             case 2:
-                tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_ECX, data_reg);
+                tcg_out_mov(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
+                            data_reg);
                 break;
             }
             tcg_out_pushi(s, mem_index);
@@ -1423,9 +1435,12 @@ static void tcg_out_qemu_st(TCGContext *s,
const TCGArg *args,
                use the ADDR32 prefix.  For now, do nothing.  */

             if (offset != GUEST_BASE) {
-                tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_RDI, GUEST_BASE);
-                tgen_arithr(s, ARITH_ADD + P_REXW, TCG_REG_RDI, base);
-                base = TCG_REG_RDI, offset = 0;
+                tcg_out_movi(s, TCG_TYPE_I64, tcg_target_call_iarg_regs[0],
+                             GUEST_BASE);
+                tgen_arithr(s, ARITH_ADD + P_REXW,
+                            tcg_target_call_iarg_regs[0], base);
+                base = tcg_target_call_iarg_regs[0];
+                offset = 0;
             }
         }

@@ -1451,7 +1466,7 @@ static inline void tcg_out_op(TCGContext *s,
TCGOpcode opc,

     switch(opc) {
     case INDEX_op_exit_tb:
-        tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_EAX, args[0]);
+        tcg_out_movi(s, TCG_TYPE_PTR, tcg_target_call_oarg_regs[0], args[0]);
         tcg_out_jmp(s, (tcg_target_long) tb_ret_addr);
         break;
     case INDEX_op_goto_tb:
diff mbox

Patch

From 9773a03cec6b6c0dc3832087ca7ccb46bab7a784 Mon Sep 17 00:00:00 2001
Message-Id: <9773a03cec6b6c0dc3832087ca7ccb46bab7a784.1325974684.git.blauwirbel@gmail.com>
From: Blue Swirl <blauwirbel@gmail.com>
Date: Sun, 25 Sep 2011 11:05:56 +0000
Subject: [PATCH 1/6] TCG/i386: use iargs or oargs instead of register names

Don't use register names directly but iargs or oargs tables. Later it will be
easier to shift the registers used.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
---
 tcg/i386/tcg-target.c |   75 +++++++++++++++++++++++++++++-------------------
 1 files changed, 45 insertions(+), 30 deletions(-)

diff --git a/tcg/i386/tcg-target.c b/tcg/i386/tcg-target.c
index dc81572..c74bd1a 100644
--- a/tcg/i386/tcg-target.c
+++ b/tcg/i386/tcg-target.c
@@ -186,12 +186,12 @@  static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
         ct->ct |= TCG_CT_REG;
         if (TCG_TARGET_REG_BITS == 64) {
             tcg_regset_set32(ct->u.regs, 0, 0xffff);
-            tcg_regset_reset_reg(ct->u.regs, TCG_REG_RSI);
-            tcg_regset_reset_reg(ct->u.regs, TCG_REG_RDI);
+            tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[0]);
+            tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[1]);
         } else {
             tcg_regset_set32(ct->u.regs, 0, 0xff);
-            tcg_regset_reset_reg(ct->u.regs, TCG_REG_EAX);
-            tcg_regset_reset_reg(ct->u.regs, TCG_REG_EDX);
+            tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[0]);
+            tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[1]);
         }
         break;
 
@@ -1196,35 +1196,38 @@  static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
 
     switch(opc) {
     case 0 | 4:
-        tcg_out_ext8s(s, data_reg, TCG_REG_EAX, P_REXW);
+        tcg_out_ext8s(s, data_reg, tcg_target_call_oarg_regs[0], P_REXW);
         break;
     case 1 | 4:
-        tcg_out_ext16s(s, data_reg, TCG_REG_EAX, P_REXW);
+        tcg_out_ext16s(s, data_reg, tcg_target_call_oarg_regs[0], P_REXW);
         break;
     case 0:
-        tcg_out_ext8u(s, data_reg, TCG_REG_EAX);
+        tcg_out_ext8u(s, data_reg, tcg_target_call_oarg_regs[0]);
         break;
     case 1:
-        tcg_out_ext16u(s, data_reg, TCG_REG_EAX);
+        tcg_out_ext16u(s, data_reg, tcg_target_call_oarg_regs[0]);
         break;
     case 2:
-        tcg_out_mov(s, TCG_TYPE_I32, data_reg, TCG_REG_EAX);
+        tcg_out_mov(s, TCG_TYPE_I32, data_reg, tcg_target_call_oarg_regs[0]);
         break;
 #if TCG_TARGET_REG_BITS == 64
     case 2 | 4:
-        tcg_out_ext32s(s, data_reg, TCG_REG_EAX);
+        tcg_out_ext32s(s, data_reg, tcg_target_call_oarg_regs[0]);
         break;
 #endif
     case 3:
         if (TCG_TARGET_REG_BITS == 64) {
-            tcg_out_mov(s, TCG_TYPE_I64, data_reg, TCG_REG_RAX);
+            tcg_out_mov(s, TCG_TYPE_I64, data_reg,
+                        tcg_target_call_oarg_regs[0]);
         } else if (data_reg == TCG_REG_EDX) {
             /* xchg %edx, %eax */
             tcg_out_opc(s, OPC_XCHG_ax_r32 + TCG_REG_EDX, 0, 0, 0);
             tcg_out_mov(s, TCG_TYPE_I32, data_reg2, TCG_REG_EAX);
         } else {
-            tcg_out_mov(s, TCG_TYPE_I32, data_reg, TCG_REG_EAX);
-            tcg_out_mov(s, TCG_TYPE_I32, data_reg2, TCG_REG_EDX);
+            tcg_out_mov(s, TCG_TYPE_I32, data_reg,
+                        tcg_target_call_oarg_regs[0]);
+            tcg_out_mov(s, TCG_TYPE_I32, data_reg2,
+                        tcg_target_call_oarg_regs[1]);
         }
         break;
     default:
@@ -1246,9 +1249,12 @@  static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
                use the ADDR32 prefix.  For now, do nothing.  */
 
             if (offset != GUEST_BASE) {
-                tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_RDI, GUEST_BASE);
-                tgen_arithr(s, ARITH_ADD + P_REXW, TCG_REG_RDI, base);
-                base = TCG_REG_RDI, offset = 0;
+                tcg_out_movi(s, TCG_TYPE_I64, tcg_target_call_iarg_regs[0],
+                             GUEST_BASE);
+                tgen_arithr(s, ARITH_ADD + P_REXW,
+                            tcg_target_call_iarg_regs[0], base);
+                base = tcg_target_call_iarg_regs[0];
+                offset = 0;
             }
         }
 
@@ -1361,37 +1367,43 @@  static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
     /* XXX: move that code at the end of the TB */
     if (TCG_TARGET_REG_BITS == 64) {
         tcg_out_mov(s, (opc == 3 ? TCG_TYPE_I64 : TCG_TYPE_I32),
-                    TCG_REG_RSI, data_reg);
-        tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_RDX, mem_index);
+                    tcg_target_call_iarg_regs[1], data_reg);
+        tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
+                     mem_index);
         stack_adjust = 0;
     } else if (TARGET_LONG_BITS == 32) {
-        tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_EDX, data_reg);
+        tcg_out_mov(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[1], data_reg);
         if (opc == 3) {
-            tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_ECX, data_reg2);
+            tcg_out_mov(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
+                        data_reg2);
             tcg_out_pushi(s, mem_index);
             stack_adjust = 4;
         } else {
-            tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_ECX, mem_index);
+            tcg_out_movi(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
+                         mem_index);
             stack_adjust = 0;
         }
     } else {
         if (opc == 3) {
-            tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_EDX, args[addrlo_idx + 1]);
+            tcg_out_mov(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[1],
+                        args[addrlo_idx + 1]);
             tcg_out_pushi(s, mem_index);
             tcg_out_push(s, data_reg2);
             tcg_out_push(s, data_reg);
             stack_adjust = 12;
         } else {
-            tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_EDX, args[addrlo_idx + 1]);
+            tcg_out_mov(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[1],
+                        args[addrlo_idx + 1]);
             switch(opc) {
             case 0:
-                tcg_out_ext8u(s, TCG_REG_ECX, data_reg);
+                tcg_out_ext8u(s, tcg_target_call_iarg_regs[2], data_reg);
                 break;
             case 1:
-                tcg_out_ext16u(s, TCG_REG_ECX, data_reg);
+                tcg_out_ext16u(s, tcg_target_call_iarg_regs[2], data_reg);
                 break;
             case 2:
-                tcg_out_mov(s, TCG_TYPE_I32, TCG_REG_ECX, data_reg);
+                tcg_out_mov(s, TCG_TYPE_I32, tcg_target_call_iarg_regs[2],
+                            data_reg);
                 break;
             }
             tcg_out_pushi(s, mem_index);
@@ -1423,9 +1435,12 @@  static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
                use the ADDR32 prefix.  For now, do nothing.  */
 
             if (offset != GUEST_BASE) {
-                tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_RDI, GUEST_BASE);
-                tgen_arithr(s, ARITH_ADD + P_REXW, TCG_REG_RDI, base);
-                base = TCG_REG_RDI, offset = 0;
+                tcg_out_movi(s, TCG_TYPE_I64, tcg_target_call_iarg_regs[0],
+                             GUEST_BASE);
+                tgen_arithr(s, ARITH_ADD + P_REXW,
+                            tcg_target_call_iarg_regs[0], base);
+                base = tcg_target_call_iarg_regs[0];
+                offset = 0;
             }
         }
 
@@ -1451,7 +1466,7 @@  static inline void tcg_out_op(TCGContext *s, TCGOpcode opc,
 
     switch(opc) {
     case INDEX_op_exit_tb:
-        tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_EAX, args[0]);
+        tcg_out_movi(s, TCG_TYPE_PTR, tcg_target_call_oarg_regs[0], args[0]);
         tcg_out_jmp(s, (tcg_target_long) tb_ret_addr);
         break;
     case INDEX_op_goto_tb:
-- 
1.7.2.5