Skip to contentSkip to conversation

target-arm: Fix intptr_t vs tcg_target_long

PATCH In review Richard Henderson 2 participants 5 messages Mar 5, 2014 – Mar 10, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-arm: Fix intptr_t vs tcg_target_long

Fixes a build error when these are different, e.g. x32.

---
 target-arm/translate-a64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/translate-a64.c +1 -1
index 08ac659..37e05e8 100644
@@ -210,7 +210,7 @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest)
     if (use_goto_tb(s, n, dest)) {
         tcg_gen_goto_tb(n);
         gen_a64_set_pc_im(dest);
-        tcg_gen_exit_tb((tcg_target_long)tb + n);
+        tcg_gen_exit_tb((intptr_t)tb + n);
         s->is_jmp = DISAS_TB_JUMP;
     } else {
         gen_a64_set_pc_im(dest);
Signature · 1 line
1.8.5.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Richard Henderson

Fixes a build error when these are different, e.g. x32.

A quick grep of the uses of tcg_gen_exit_tb() suggests we would be better to change this function to take (TranslationBlock *tb, int tb_exit_code), possibly also with a special case for 0 if "tcg_gen_exit_tb(NULL, 0)" seems too verbose.

I'll apply this to target-arm as the fix for 2.0, though.

Quoted 18 lines
---
 target-arm/translate-a64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/translate-a64.c +1 -2
index 08ac659..37e05e8 100644
@@ -210,7 +210,7 @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest)
     if (use_goto_tb(s, n, dest)) {
         tcg_gen_goto_tb(n);
         gen_a64_set_pc_im(dest);
-        tcg_gen_exit_tb((tcg_target_long)tb + n);
+        tcg_gen_exit_tb((intptr_t)tb + n);
         s->is_jmp = DISAS_TB_JUMP;
     } else {
         gen_a64_set_pc_im(dest);
--
Quoted 2 lines

1.8.5.3

thanks
-- PMM

#2 lore raw
Quoted 5 lines · Peter Maydell

A quick grep of the uses of tcg_gen_exit_tb() suggests we would be better to change this function to take (TranslationBlock *tb, int tb_exit_code), possibly also with a special case for 0 if "tcg_gen_exit_tb(NULL, 0)" seems too verbose.

No, since the goto_tb cases use (tb | n), so you wind up casting to an integer type anyway.

r~

#3 lore raw
Quoted 9 lines · Richard Henderson
Quoted 5 lines · Peter Maydell

A quick grep of the uses of tcg_gen_exit_tb() suggests we would be better to change this function to take (TranslationBlock *tb, int tb_exit_code), possibly also with a special case for 0 if "tcg_gen_exit_tb(NULL, 0)" seems too verbose.

No, since the goto_tb cases use (tb | n), so you wind up casting to an integer type anyway.

I'm confused. I can't see any callers in git grep
output which use 'tb | n':

$ git grep gen_exit_tb | grep -c '|'
0

The only cases I see are:
(1) tcg_gen_exit_tb(0)
(2) tcg_gen_exit_tb((uintptr_t)tb)
(3) tcg_gen_exit_tb((uintptr_t)tb + n)

which I am proposing would be better written as
tcg_gen_exit_tb(NULL, 0)
tcg_gen_exit_tb(tb, 0)
tcg_gen_exit_tb(tb, n)

and letting tcg_gen_exit_tb() do the cast to uintptr_t and add.

thanks
-- PMM

#4 lore raw
Quoted 7 lines · Peter Maydell

which I am proposing would be better written as
tcg_gen_exit_tb(NULL, 0)
tcg_gen_exit_tb(tb, 0)
tcg_gen_exit_tb(tb, n)

and letting tcg_gen_exit_tb() do the cast to uintptr_t and add.

Oh, I see. Yes, that would be fine.

r~