tcg: make tcg_const_ptr actually accept a pointer argument
PATCH 1/1 tcg: make tcg_const_ptr actually accept a pointer argument
Make tcg_const_ptr() include a cast so that you can pass it a pointer. This allows us to drop the casts we had in all the places that use this macro.
---
Minor cleanup; I have a patchset cooking that wants to use tcg_const_ptr(), which is why I noticed this infelicity.
tcg/tcg-op.h | 6 +++--- tcg/tcg.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
tcg/tcg-op.h +3 -3
@@ -389,7 +389,7 @@ static inline void tcg_gen_helperN(void *func, int flags, int sizemask, TCGArg ret, int nargs, TCGArg *args) { TCGv_ptr fn; - fn =tcg_const_ptr ((tcg_target_long )func); + fn =tcg_const_ptr (func);tcg_gen_callN (&tcg_ctx, fn, flags, sizemask, ret, nargs, args);tcg_temp_free_ptr (fn);
@@ -405,7 +405,7 @@ static inline void tcg_gen_helper32(void *func, int sizemask, TCGv_i32 ret, {TCGv_ptr fn;TCGArg args[2 ]; - fn =tcg_const_ptr ((tcg_target_long )func); + fn =tcg_const_ptr (func); args[0 ] =GET_TCGV_I32 (a); args[1 ] =GET_TCGV_I32 (b); tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask,
@@ -418,7 +418,7 @@ static inline void tcg_gen_helper64(void *func, int sizemask, TCGv_i64 ret, {TCGv_ptr fn;TCGArg args[2 ]; - fn =tcg_const_ptr ((tcg_target_long )func); + fn =tcg_const_ptr (func); args[0 ] =GET_TCGV_I64 (a); args[1 ] =GET_TCGV_I64 (b); tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask,
tcg/tcg.h +2 -2
@@ -544,7 +544,7 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs);#define TCGV_NAT_TO_PTR (n) MAKE_TCGV_PTR(GET_TCGV_I32(n))#define TCGV_PTR_TO_NAT (n) MAKE_TCGV_I32(GET_TCGV_PTR(n)) -#define tcg_const_ptr (V ) TCGV_NAT_TO_PTR(tcg_const_i32(V)) +#define tcg_const_ptr (V ) TCGV_NAT_TO_PTR(tcg_const_i32((tcg_target_long)(V)))#define tcg_global_reg_new_ptr (R ,N ) \ TCGV_NAT_TO_PTR(tcg_global_reg_new_i32((R), (N)))#define tcg_global_mem_new_ptr (R ,O ,N ) \
@@ -555,7 +555,7 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs);#define TCGV_NAT_TO_PTR (n) MAKE_TCGV_PTR(GET_TCGV_I64(n))#define TCGV_PTR_TO_NAT (n) MAKE_TCGV_I64(GET_TCGV_PTR(n)) -#define tcg_const_ptr (V ) TCGV_NAT_TO_PTR(tcg_const_i64(V)) +#define tcg_const_ptr (V ) TCGV_NAT_TO_PTR(tcg_const_i64((tcg_target_long)(V)))#define tcg_global_reg_new_ptr (R ,N ) \ TCGV_NAT_TO_PTR(tcg_global_reg_new_i64((R), (N)))#define tcg_global_mem_new_ptr (R ,O ,N ) \
Signature · 1 line
1.7.1
Am 10.12.2011 17:35, schrieb Peter Maydell:
Quoted 5 lines
Make
tcg_const_ptr()include a cast so that you can pass it a pointer. This allows us to drop the casts we had in all the places that use this macro.Signed-off-by Peter Maydell <[email protected]>
At first the use of tcg_target_long seemed wrong to me, in case anyone else is wondering, but it is in fact the type depending on TCG_TARGET_REG_BITS not TARGET_LONG_BITS. (I'll have to fix my series.)
Andreas
Quoted 61 lines
---
Minor cleanup; I have a patchset cooking that wants to usetcg_const_ptr(), which is why I noticed this infelicity.tcg/tcg-op.h | 6 +++--- tcg/tcg.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)tcg/tcg-op.h +3
-3@@ -389,7 +389,7 @@ static inline void tcg_gen_helperN(void *func, int flags, int sizemask, TCGArg ret, int nargs, TCGArg *args) { TCGv_ptr fn; - fn =tcg_const_ptr ((tcg_target_long )func); + fn =tcg_const_ptr (func);tcg_gen_callN (&tcg_ctx, fn, flags, sizemask, ret, nargs, args);tcg_temp_free_ptr (fn);@@ -405,7 +405,7 @@ static inline void tcg_gen_helper32(void *func, int sizemask, TCGv_i32 ret, {TCGv_ptr fn;TCGArg args[2 ]; - fn =tcg_const_ptr ((tcg_target_long )func); + fn =tcg_const_ptr (func); args[0 ] =GET_TCGV_I32 (a); args[1 ] =GET_TCGV_I32 (b); tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask,@@ -418,7 +418,7 @@ static inline void tcg_gen_helper64(void *func, int sizemask, TCGv_i64 ret, {TCGv_ptr fn;TCGArg args[2 ]; - fn =tcg_const_ptr ((tcg_target_long )func); + fn =tcg_const_ptr (func); args[0 ] =GET_TCGV_I64 (a); args[1 ] =GET_TCGV_I64 (b); tcg_gen_callN(&tcg_ctx, fn, TCG_CALL_CONST | TCG_CALL_PURE, sizemask,tcg/tcg.h +2
-2@@ -544,7 +544,7 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs);#define TCGV_NAT_TO_PTR (n) MAKE_TCGV_PTR(GET_TCGV_I32(n))#define TCGV_PTR_TO_NAT (n) MAKE_TCGV_I32(GET_TCGV_PTR(n)) -#define tcg_const_ptr (V ) TCGV_NAT_TO_PTR(tcg_const_i32(V)) +#define tcg_const_ptr (V ) TCGV_NAT_TO_PTR(tcg_const_i32((tcg_target_long)(V)))#define tcg_global_reg_new_ptr (R ,N ) \ TCGV_NAT_TO_PTR(tcg_global_reg_new_i32((R), (N)))#define tcg_global_mem_new_ptr (R ,O ,N ) \@@ -555,7 +555,7 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs);#define TCGV_NAT_TO_PTR (n) MAKE_TCGV_PTR(GET_TCGV_I64(n))#define TCGV_PTR_TO_NAT (n) MAKE_TCGV_I64(GET_TCGV_PTR(n)) -#define tcg_const_ptr (V ) TCGV_NAT_TO_PTR(tcg_const_i64(V)) +#define tcg_const_ptr (V ) TCGV_NAT_TO_PTR(tcg_const_i64((tcg_target_long)(V)))#define tcg_global_reg_new_ptr (R ,N ) \ TCGV_NAT_TO_PTR(tcg_global_reg_new_i64((R), (N)))#define tcg_global_mem_new_ptr (R ,O ,N ) \
Stefan Hajnoczi
AppliedQuoted 4 lines · Peter Maydell
Make
tcg_const_ptr()include a cast so that you can pass it a pointer. This allows us to drop the casts we had in all the places that use this macro.
Quoted 8 lines
Signed-off-by Peter Maydell <[email protected]>---
Minor cleanup; I have a patchset cooking that wants to usetcg_const_ptr(), which is why I noticed this infelicity.tcg/tcg-op.h | 6 +++--- tcg/tcg.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
Thanks, applied to the trivial patches -next tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches-next
Stefan