Patchwork [v3,13/20] tcg-arm: Cleanup tcg_out_goto_label

login
register
mail settings
Submitter Richard Henderson
Date March 28, 2013, 3:32 p.m.
Message ID <1364484781-15561-14-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/232099/
State New
Headers show

Comments

Richard Henderson - March 28, 2013, 3:32 p.m.
Since we folded the epilogue into exit_tb directly, we no longer
have a long direct branch.  Fold tcg_out_goto into its only user,
eliminate the long branch case.  Drop the long forward branch
case for tcg_out_goto_label.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/arm/tcg-target.c | 42 ++++--------------------------------------
 1 file changed, 4 insertions(+), 38 deletions(-)

Patch

diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c
index e5ec999..7bcba19 100644
--- a/tcg/arm/tcg-target.c
+++ b/tcg/arm/tcg-target.c
@@ -1011,37 +1011,6 @@  static inline void tcg_out_st8(TCGContext *s, int cond,
         tcg_out_st8_12(s, cond, rd, rn, offset);
 }
 
-/* The _goto case is normally between TBs within the same code buffer,
- * and with the code buffer limited to 16MB we shouldn't need the long
- * case.
- *
- * .... except to the prologue that is in its own buffer.
- */
-static inline void tcg_out_goto(TCGContext *s, int cond, uint32_t addr)
-{
-    int32_t val;
-
-    if (addr & 1) {
-        /* goto to a Thumb destination isn't supported */
-        tcg_abort();
-    }
-
-    val = addr - (tcg_target_long) s->code_ptr;
-    if (val - 8 < 0x01fffffd && val - 8 > -0x01fffffd)
-        tcg_out_b(s, cond, val);
-    else {
-        if (cond == COND_AL) {
-            tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_PC, -4);
-            tcg_out32(s, addr);
-        } else {
-            tcg_out_movi32(s, cond, TCG_REG_TMP, val - 8);
-            tcg_out_dat_reg(s, cond, ARITH_ADD,
-                            TCG_REG_PC, TCG_REG_PC,
-                            TCG_REG_TMP, SHIFT_IMM_LSL(0));
-        }
-    }
-}
-
 /* The call case is mostly used for helpers - so it's not unreasonable
  * for them to be beyond branch range */
 static inline void tcg_out_call(TCGContext *s, uint32_t addr)
@@ -1081,14 +1050,11 @@  static inline void tcg_out_goto_label(TCGContext *s, int cond, int label_index)
 {
     TCGLabel *l = &s->labels[label_index];
 
-    if (l->has_value)
-        tcg_out_goto(s, cond, l->u.value);
-    else if (cond == COND_AL) {
-        tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_PC, -4);
-        tcg_out_reloc(s, s->code_ptr, R_ARM_ABS32, label_index, 31337);
-        s->code_ptr += 4;
+    if (l->has_value) {
+        int32_t val = l->u.value - (tcg_target_long) s->code_ptr;
+        assert(val - 8 < 0x01fffffd && val - 8 > -0x01fffffd);
+        tcg_out_b(s, cond, val);
     } else {
-        /* Probably this should be preferred even for COND_AL... */
         tcg_out_reloc(s, s->code_ptr, R_ARM_PC24, label_index, 31337);
         tcg_out_b_noaddr(s, cond);
     }