]> git.proxmox.com Git - mirror_qemu.git/commitdiff
tcg: Push tcg-runtime routines into exec/helper-*
authorRichard Henderson <rth@twiddle.net>
Tue, 8 Apr 2014 06:08:47 +0000 (23:08 -0700)
committerRichard Henderson <rth@twiddle.net>
Wed, 28 May 2014 16:33:54 +0000 (09:33 -0700)
Rather than special casing them, use the standard mechanisms
for tcg helper generation.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <rth@twiddle.net>
include/exec/helper-gen.h
include/exec/helper-head.h
include/exec/helper-proto.h
include/exec/helper-tcg.h
tcg-runtime.c
tcg/tcg-op.h
tcg/tcg-runtime.h
tcg/tcg.c
tcg/tcg.h

index f6d9ec3167993210514040cffaba2917bdf66181..abde615e922ee3c2cafd25a82a0cd85ae615b3ad 100644 (file)
@@ -80,6 +80,7 @@ static inline void glue(gen_helper_, name)(dh_retvar_decl(ret) \
 }
 
 #include "helper.h"
+#include "tcg-runtime.h"
 
 #undef DEF_HELPER_FLAGS_0
 #undef DEF_HELPER_FLAGS_1
index 2cbae22b5fb34d5fede36ff00397f87eb90ddab2..0b5bd8398ec80ad40525cdf5f46bed9fe3a5f2a1 100644 (file)
@@ -18,6 +18,8 @@
 #ifndef DEF_HELPER_H
 #define DEF_HELPER_H 1
 
+#include "qemu/osdep.h"
+
 #define HELPER(name) glue(helper_, name)
 
 #define GET_TCGV_i32 GET_TCGV_I32
 #define dh_alias_s64 i64
 #define dh_alias_f32 i32
 #define dh_alias_f64 i64
-#if TARGET_LONG_BITS == 32
-#define dh_alias_tl i32
-#else
-#define dh_alias_tl i64
+#ifdef TARGET_LONG_BITS
+# if TARGET_LONG_BITS == 32
+#  define dh_alias_tl i32
+# else
+#  define dh_alias_tl i64
+# endif
 #endif
 #define dh_alias_ptr ptr
 #define dh_alias_void void
index 88d3543119a6fbcd122443b4c90c51e4ba3aded1..828951c6093494143cdb641cbf9bdf286b353fef 100644 (file)
@@ -27,6 +27,7 @@ dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2), dh_ctype(t3), \
                             dh_ctype(t4), dh_ctype(t5));
 
 #include "helper.h"
+#include "tcg-runtime.h"
 
 #undef DEF_HELPER_FLAGS_0
 #undef DEF_HELPER_FLAGS_1
index 9be5429fa13ede34bbede7b26abaf05deef9a79b..0da6b9788a51b9746706ecf81f0e29289c8adb27 100644 (file)
@@ -24,6 +24,7 @@ DEF_HELPER_FLAGS_0(name, flags, ret)
 DEF_HELPER_FLAGS_0(name, flags, ret)
 
 #include "helper.h"
+#include "tcg-runtime.h"
 
 #undef DEF_HELPER_FLAGS_0
 #undef DEF_HELPER_FLAGS_1
index 4b66e51ce776028d2a8839380e7b7414f758d46e..9daba6945ef01109a43d4e0055211f86a420d42a 100644 (file)
  */
 #include <stdint.h>
 #include "qemu/host-utils.h"
-#include "tcg/tcg-runtime.h"
+
+/* This file is compiled once, and thus we can't include the standard
+   "exec/helper-proto.h", which has includes that are target specific.  */
+
+#include "exec/helper-head.h"
+
+#define DEF_HELPER_FLAGS_2(name, flags, ret, t1, t2) \
+  dh_ctype(ret) HELPER(name) (dh_ctype(t1), dh_ctype(t2));
+
+#include "tcg-runtime.h"
+
 
 /* 32-bit helpers */
 
-int32_t tcg_helper_div_i32(int32_t arg1, int32_t arg2)
+int32_t HELPER(div_i32)(int32_t arg1, int32_t arg2)
 {
     return arg1 / arg2;
 }
 
-int32_t tcg_helper_rem_i32(int32_t arg1, int32_t arg2)
+int32_t HELPER(rem_i32)(int32_t arg1, int32_t arg2)
 {
     return arg1 % arg2;
 }
 
-uint32_t tcg_helper_divu_i32(uint32_t arg1, uint32_t arg2)
+uint32_t HELPER(divu_i32)(uint32_t arg1, uint32_t arg2)
 {
     return arg1 / arg2;
 }
 
-uint32_t tcg_helper_remu_i32(uint32_t arg1, uint32_t arg2)
+uint32_t HELPER(remu_i32)(uint32_t arg1, uint32_t arg2)
 {
     return arg1 % arg2;
 }
 
 /* 64-bit helpers */
 
-int64_t tcg_helper_shl_i64(int64_t arg1, int64_t arg2)
+uint64_t HELPER(shl_i64)(uint64_t arg1, uint64_t arg2)
 {
     return arg1 << arg2;
 }
 
-int64_t tcg_helper_shr_i64(int64_t arg1, int64_t arg2)
+uint64_t HELPER(shr_i64)(uint64_t arg1, uint64_t arg2)
 {
-    return (uint64_t)arg1 >> arg2;
+    return arg1 >> arg2;
 }
 
-int64_t tcg_helper_sar_i64(int64_t arg1, int64_t arg2)
+int64_t HELPER(sar_i64)(int64_t arg1, int64_t arg2)
 {
     return arg1 >> arg2;
 }
 
-int64_t tcg_helper_div_i64(int64_t arg1, int64_t arg2)
+int64_t HELPER(div_i64)(int64_t arg1, int64_t arg2)
 {
     return arg1 / arg2;
 }
 
-int64_t tcg_helper_rem_i64(int64_t arg1, int64_t arg2)
+int64_t HELPER(rem_i64)(int64_t arg1, int64_t arg2)
 {
     return arg1 % arg2;
 }
 
-uint64_t tcg_helper_divu_i64(uint64_t arg1, uint64_t arg2)
+uint64_t HELPER(divu_i64)(uint64_t arg1, uint64_t arg2)
 {
     return arg1 / arg2;
 }
 
-uint64_t tcg_helper_remu_i64(uint64_t arg1, uint64_t arg2)
+uint64_t HELPER(remu_i64)(uint64_t arg1, uint64_t arg2)
 {
     return arg1 % arg2;
 }
 
-uint64_t tcg_helper_muluh_i64(uint64_t arg1, uint64_t arg2)
+uint64_t HELPER(muluh_i64)(uint64_t arg1, uint64_t arg2)
 {
     uint64_t l, h;
     mulu64(&l, &h, arg1, arg2);
     return h;
 }
 
-int64_t tcg_helper_mulsh_i64(int64_t arg1, int64_t arg2)
+int64_t HELPER(mulsh_i64)(int64_t arg1, int64_t arg2)
 {
     uint64_t l, h;
     muls64(&l, &h, arg1, arg2);
index bdd01394826510c46994a21a3c0266b75243da7b..856069593049be16dfdbe606a572221364675623 100644 (file)
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 #include "tcg.h"
+#include "exec/helper-proto.h"
 
 int gen_new_label(void);
 
@@ -712,7 +713,7 @@ static inline void tcg_gen_div_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
         sizemask |= tcg_gen_sizemask(0, 0, 1);
         sizemask |= tcg_gen_sizemask(1, 0, 1);
         sizemask |= tcg_gen_sizemask(2, 0, 1);
-        tcg_gen_helper32(tcg_helper_div_i32, sizemask, ret, arg1, arg2);
+        tcg_gen_helper32(helper_div_i32, sizemask, ret, arg1, arg2);
     }
 }
 
@@ -737,7 +738,7 @@ static inline void tcg_gen_rem_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
         sizemask |= tcg_gen_sizemask(0, 0, 1);
         sizemask |= tcg_gen_sizemask(1, 0, 1);
         sizemask |= tcg_gen_sizemask(2, 0, 1);
-        tcg_gen_helper32(tcg_helper_rem_i32, sizemask, ret, arg1, arg2);
+        tcg_gen_helper32(helper_rem_i32, sizemask, ret, arg1, arg2);
     }
 }
 
@@ -756,7 +757,7 @@ static inline void tcg_gen_divu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
         sizemask |= tcg_gen_sizemask(0, 0, 0);
         sizemask |= tcg_gen_sizemask(1, 0, 0);
         sizemask |= tcg_gen_sizemask(2, 0, 0);
-        tcg_gen_helper32(tcg_helper_divu_i32, sizemask, ret, arg1, arg2);
+        tcg_gen_helper32(helper_divu_i32, sizemask, ret, arg1, arg2);
     }
 }
 
@@ -781,7 +782,7 @@ static inline void tcg_gen_remu_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2)
         sizemask |= tcg_gen_sizemask(0, 0, 0);
         sizemask |= tcg_gen_sizemask(1, 0, 0);
         sizemask |= tcg_gen_sizemask(2, 0, 0);
-        tcg_gen_helper32(tcg_helper_remu_i32, sizemask, ret, arg1, arg2);
+        tcg_gen_helper32(helper_remu_i32, sizemask, ret, arg1, arg2);
     }
 }
 
@@ -951,7 +952,7 @@ static inline void tcg_gen_shl_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
     sizemask |= tcg_gen_sizemask(1, 1, 1);
     sizemask |= tcg_gen_sizemask(2, 1, 1);
 
-    tcg_gen_helper64(tcg_helper_shl_i64, sizemask, ret, arg1, arg2);
+    tcg_gen_helper64(helper_shl_i64, sizemask, ret, arg1, arg2);
 }
 
 static inline void tcg_gen_shli_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
@@ -967,7 +968,7 @@ static inline void tcg_gen_shr_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
     sizemask |= tcg_gen_sizemask(1, 1, 1);
     sizemask |= tcg_gen_sizemask(2, 1, 1);
 
-    tcg_gen_helper64(tcg_helper_shr_i64, sizemask, ret, arg1, arg2);
+    tcg_gen_helper64(helper_shr_i64, sizemask, ret, arg1, arg2);
 }
 
 static inline void tcg_gen_shri_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
@@ -983,7 +984,7 @@ static inline void tcg_gen_sar_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
     sizemask |= tcg_gen_sizemask(1, 1, 1);
     sizemask |= tcg_gen_sizemask(2, 1, 1);
 
-    tcg_gen_helper64(tcg_helper_sar_i64, sizemask, ret, arg1, arg2);
+    tcg_gen_helper64(helper_sar_i64, sizemask, ret, arg1, arg2);
 }
 
 static inline void tcg_gen_sari_i64(TCGv_i64 ret, TCGv_i64 arg1, int64_t arg2)
@@ -1057,7 +1058,7 @@ static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
     sizemask |= tcg_gen_sizemask(1, 1, 1);
     sizemask |= tcg_gen_sizemask(2, 1, 1);
 
-    tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2);
+    tcg_gen_helper64(helper_div_i64, sizemask, ret, arg1, arg2);
 }
 
 static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
@@ -1068,7 +1069,7 @@ static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
     sizemask |= tcg_gen_sizemask(1, 1, 1);
     sizemask |= tcg_gen_sizemask(2, 1, 1);
 
-    tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2);
+    tcg_gen_helper64(helper_rem_i64, sizemask, ret, arg1, arg2);
 }
 
 static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
@@ -1079,7 +1080,7 @@ static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
     sizemask |= tcg_gen_sizemask(1, 1, 0);
     sizemask |= tcg_gen_sizemask(2, 1, 0);
 
-    tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2);
+    tcg_gen_helper64(helper_divu_i64, sizemask, ret, arg1, arg2);
 }
 
 static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
@@ -1090,7 +1091,7 @@ static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
     sizemask |= tcg_gen_sizemask(1, 1, 0);
     sizemask |= tcg_gen_sizemask(2, 1, 0);
 
-    tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2);
+    tcg_gen_helper64(helper_remu_i64, sizemask, ret, arg1, arg2);
 }
 
 #else
@@ -1362,7 +1363,7 @@ static inline void tcg_gen_div_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
         sizemask |= tcg_gen_sizemask(0, 1, 1);
         sizemask |= tcg_gen_sizemask(1, 1, 1);
         sizemask |= tcg_gen_sizemask(2, 1, 1);
-        tcg_gen_helper64(tcg_helper_div_i64, sizemask, ret, arg1, arg2);
+        tcg_gen_helper64(helper_div_i64, sizemask, ret, arg1, arg2);
     }
 }
 
@@ -1387,7 +1388,7 @@ static inline void tcg_gen_rem_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
         sizemask |= tcg_gen_sizemask(0, 1, 1);
         sizemask |= tcg_gen_sizemask(1, 1, 1);
         sizemask |= tcg_gen_sizemask(2, 1, 1);
-        tcg_gen_helper64(tcg_helper_rem_i64, sizemask, ret, arg1, arg2);
+        tcg_gen_helper64(helper_rem_i64, sizemask, ret, arg1, arg2);
     }
 }
 
@@ -1406,7 +1407,7 @@ static inline void tcg_gen_divu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
         sizemask |= tcg_gen_sizemask(0, 1, 0);
         sizemask |= tcg_gen_sizemask(1, 1, 0);
         sizemask |= tcg_gen_sizemask(2, 1, 0);
-        tcg_gen_helper64(tcg_helper_divu_i64, sizemask, ret, arg1, arg2);
+        tcg_gen_helper64(helper_divu_i64, sizemask, ret, arg1, arg2);
     }
 }
 
@@ -1431,7 +1432,7 @@ static inline void tcg_gen_remu_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2)
         sizemask |= tcg_gen_sizemask(0, 1, 0);
         sizemask |= tcg_gen_sizemask(1, 1, 0);
         sizemask |= tcg_gen_sizemask(2, 1, 0);
-        tcg_gen_helper64(tcg_helper_remu_i64, sizemask, ret, arg1, arg2);
+        tcg_gen_helper64(helper_remu_i64, sizemask, ret, arg1, arg2);
     }
 }
 #endif /* TCG_TARGET_REG_BITS == 32 */
@@ -2536,7 +2537,7 @@ static inline void tcg_gen_mulu2_i64(TCGv_i64 rl, TCGv_i64 rh,
         sizemask |= tcg_gen_sizemask(1, 1, 0);
         sizemask |= tcg_gen_sizemask(2, 1, 0);
         tcg_gen_mul_i64(t0, arg1, arg2);
-        tcg_gen_helper64(tcg_helper_muluh_i64, sizemask, rh, arg1, arg2);
+        tcg_gen_helper64(helper_muluh_i64, sizemask, rh, arg1, arg2);
         tcg_gen_mov_i64(rl, t0);
         tcg_temp_free_i64(t0);
     }
@@ -2581,7 +2582,7 @@ static inline void tcg_gen_muls2_i64(TCGv_i64 rl, TCGv_i64 rh,
         sizemask |= tcg_gen_sizemask(1, 1, 1);
         sizemask |= tcg_gen_sizemask(2, 1, 1);
         tcg_gen_mul_i64(t0, arg1, arg2);
-        tcg_gen_helper64(tcg_helper_mulsh_i64, sizemask, rh, arg1, arg2);
+        tcg_gen_helper64(helper_mulsh_i64, sizemask, rh, arg1, arg2);
         tcg_gen_mov_i64(rl, t0);
         tcg_temp_free_i64(t0);
     }
index a1ebef9f9c97eb9592f8400d231219072de82c05..23a0c37711c29d50f129557f84cb966b1109d324 100644 (file)
@@ -1,20 +1,16 @@
-#ifndef TCG_RUNTIME_H
-#define TCG_RUNTIME_H
+DEF_HELPER_FLAGS_2(div_i32, TCG_CALL_NO_RWG_SE, s32, s32, s32)
+DEF_HELPER_FLAGS_2(rem_i32, TCG_CALL_NO_RWG_SE, s32, s32, s32)
+DEF_HELPER_FLAGS_2(divu_i32, TCG_CALL_NO_RWG_SE, i32, i32, i32)
+DEF_HELPER_FLAGS_2(remu_i32, TCG_CALL_NO_RWG_SE, i32, i32, i32)
 
-/* tcg-runtime.c */
-int32_t tcg_helper_div_i32(int32_t arg1, int32_t arg2);
-int32_t tcg_helper_rem_i32(int32_t arg1, int32_t arg2);
-uint32_t tcg_helper_divu_i32(uint32_t arg1, uint32_t arg2);
-uint32_t tcg_helper_remu_i32(uint32_t arg1, uint32_t arg2);
+DEF_HELPER_FLAGS_2(div_i64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
+DEF_HELPER_FLAGS_2(rem_i64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
+DEF_HELPER_FLAGS_2(divu_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
+DEF_HELPER_FLAGS_2(remu_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
 
-int64_t tcg_helper_shl_i64(int64_t arg1, int64_t arg2);
-int64_t tcg_helper_shr_i64(int64_t arg1, int64_t arg2);
-int64_t tcg_helper_sar_i64(int64_t arg1, int64_t arg2);
-int64_t tcg_helper_div_i64(int64_t arg1, int64_t arg2);
-int64_t tcg_helper_rem_i64(int64_t arg1, int64_t arg2);
-int64_t tcg_helper_mulsh_i64(int64_t arg1, int64_t arg2);
-uint64_t tcg_helper_divu_i64(uint64_t arg1, uint64_t arg2);
-uint64_t tcg_helper_remu_i64(uint64_t arg1, uint64_t arg2);
-uint64_t tcg_helper_muluh_i64(uint64_t arg1, uint64_t arg2);
+DEF_HELPER_FLAGS_2(shl_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
+DEF_HELPER_FLAGS_2(shr_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
+DEF_HELPER_FLAGS_2(sar_i64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
 
-#endif
+DEF_HELPER_FLAGS_2(mulsh_i64, TCG_CALL_NO_RWG_SE, s64, s64, s64)
+DEF_HELPER_FLAGS_2(muluh_i64, TCG_CALL_NO_RWG_SE, i64, i64, i64)
index 3100d578963696432cbc4666ad81616e5bc13c68..4679c19846f4413c978901dab8f9d3cff2792021 100644 (file)
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -316,22 +316,6 @@ typedef struct TCGHelperInfo {
 
 static const TCGHelperInfo all_helpers[] = {
 #include "exec/helper-tcg.h"
-
-    /* Include tcg-runtime.c functions.  */
-    { tcg_helper_div_i32, "div_i32" },
-    { tcg_helper_rem_i32, "rem_i32" },
-    { tcg_helper_divu_i32, "divu_i32" },
-    { tcg_helper_remu_i32, "remu_i32" },
-
-    { tcg_helper_shl_i64, "shl_i64" },
-    { tcg_helper_shr_i64, "shr_i64" },
-    { tcg_helper_sar_i64, "sar_i64" },
-    { tcg_helper_div_i64, "div_i64" },
-    { tcg_helper_rem_i64, "rem_i64" },
-    { tcg_helper_divu_i64, "divu_i64" },
-    { tcg_helper_remu_i64, "remu_i64" },
-    { tcg_helper_mulsh_i64, "mulsh_i64" },
-    { tcg_helper_muluh_i64, "muluh_i64" },
 };
 
 void tcg_context_init(TCGContext *s)
index fbc93101cf96fdc9a506a2f4ec84bd317f500f61..7e7d5910e89338177765e0b6449368e8df513033 100644 (file)
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -54,8 +54,6 @@ typedef uint64_t tcg_target_ulong;
 #error unsupported
 #endif
 
-#include "tcg-runtime.h"
-
 #if TCG_TARGET_NB_REGS <= 32
 typedef uint32_t TCGRegSet;
 #elif TCG_TARGET_NB_REGS <= 64