tcg: Push tcg-runtime routines into exec/helper-*

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>
stable-2.1
Richard Henderson 2014-04-07 23:08:47 -07:00
parent 2ef6175aa7
commit 944eea962b
9 changed files with 70 additions and 74 deletions

View 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

View 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
@ -32,10 +34,12 @@
#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

View 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

View 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

View File

@ -23,75 +23,85 @@
*/
#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)
{
return (uint64_t)arg1 >> arg2;
}
int64_t tcg_helper_sar_i64(int64_t arg1, int64_t arg2)
uint64_t HELPER(shr_i64)(uint64_t arg1, uint64_t arg2)
{
return arg1 >> arg2;
}
int64_t tcg_helper_div_i64(int64_t arg1, int64_t arg2)
int64_t HELPER(sar_i64)(int64_t arg1, int64_t arg2)
{
return arg1 >> 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);

View 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);
}

View 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)

View File

@ -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)

View File

@ -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