rs6000: Use parameterized names for tablejump
authorSegher Boessenkool <segher@kernel.crashing.org>
Mon, 28 Sep 2020 23:57:52 +0000 (23:57 +0000)
committerSegher Boessenkool <segher@kernel.crashing.org>
Wed, 30 Sep 2020 00:13:47 +0000 (00:13 +0000)
We have too many tablejump patterns.  Using parameterized names
simplifies the code a bit.

2020-09-29  Segher Boessenkool  <segher@kernel.crashing.org>

* config/rs6000/rs6000.md (tablejump): Simplify.
(tablejumpsi): Merge this ...
(tablejumpdi): ... and this ...
(@tablejump<mode>_normal): ... into this.
(tablejumpsi_nospec): Merge this ...
(tablejumpdi_nospec): ... and this ...
(@tablejump<mode>_nospec): ... into this.
(*tablejump<mode>_internal1): Delete, rename to ...
(@tablejump<mode>_insn_normal): ... this.
(*tablejump<mode>_internal1_nospec): Delete, rename to ...
(@tablejump<mode>_insn_nospec): ... this.

gcc/config/rs6000/rs6000.md

index 694ff70635ed33e444056a860d84684f78614e8f..24ad80993adfbb765baec9209d32b7166d592974 100644 (file)
   ""
 {
   if (rs6000_speculate_indirect_jumps)
-    {
-      if (TARGET_32BIT)
-       emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
-      else
-       emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
-    }
+    emit_jump_insn (gen_tablejump_normal (Pmode, operands[0], operands[1]));
   else
     {
       rtx ccreg = gen_reg_rtx (CCmode);
   DONE;
 })
 
-(define_expand "tablejumpsi"
-  [(set (match_dup 3)
-       (plus:SI (match_operand:SI 0)
-                (match_dup 2)))
-   (parallel [(set (pc)
-                  (match_dup 3))
-             (use (label_ref (match_operand 1)))])]
-  "TARGET_32BIT && rs6000_speculate_indirect_jumps"
+(define_expand "@tablejump<mode>_normal"
+  [(use (match_operand:SI 0))
+   (use (match_operand:P 1))]
+  "rs6000_speculate_indirect_jumps"
 {
   operands[0] = force_reg (SImode, operands[0]);
-  operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
-  operands[3] = gen_reg_rtx (SImode);
+  if (<MODE>mode == SImode)
+    operands[4] = operands[0];
+  else
+    {
+      operands[4] = gen_reg_rtx (Pmode);
+      rtx src = gen_rtx_fmt_e (SIGN_EXTEND, Pmode, operands[0]);
+      emit_move_insn (operands[4], src);
+    }
+
+  operands[2] = force_reg (Pmode, gen_rtx_LABEL_REF (Pmode, operands[1]));
+  operands[3] = gen_reg_rtx (Pmode);
+
+  emit_insn (gen_add<mode>3 (operands[3], operands[4], operands[2]));
+  emit_jump_insn (gen_tablejump_insn_normal (Pmode, operands[3], operands[1]));
+  DONE;
 })
 
-(define_expand "tablejumpsi_nospec"
-  [(set (match_dup 4)
-       (plus:SI (match_operand:SI 0)
-                (match_dup 3)))
-   (parallel [(set (pc)
-                  (match_dup 4))
-             (use (label_ref (match_operand 1)))
-             (clobber (match_operand 2))])]
-  "TARGET_32BIT && !rs6000_speculate_indirect_jumps"
+(define_expand "@tablejump<mode>_nospec"
+  [(use (match_operand:SI 0))
+   (use (match_operand:P 1))
+   (use (match_operand:CC 2))]
+  "!rs6000_speculate_indirect_jumps"
 {
   operands[0] = force_reg (SImode, operands[0]);
-  operands[3] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
-  operands[4] = gen_reg_rtx (SImode);
-})
+  if (<MODE>mode == SImode)
+    operands[4] = operands[0];
+  else
+    {
+      operands[4] = gen_reg_rtx (Pmode);
+      rtx src = gen_rtx_fmt_e (SIGN_EXTEND, Pmode, operands[0]);
+      emit_move_insn (operands[4], src);
+    }
 
-(define_expand "tablejumpdi"
-  [(set (match_dup 4)
-        (sign_extend:DI (match_operand:SI 0 "lwa_operand")))
-   (set (match_dup 3)
-       (plus:DI (match_dup 4)
-                (match_dup 2)))
-   (parallel [(set (pc)
-                  (match_dup 3))
-             (use (label_ref (match_operand 1)))])]
-  "TARGET_64BIT && rs6000_speculate_indirect_jumps"
-{
-  operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
-  operands[3] = gen_reg_rtx (DImode);
-  operands[4] = gen_reg_rtx (DImode);
-})
+  operands[5] = force_reg (Pmode, gen_rtx_LABEL_REF (Pmode, operands[1]));
+  operands[3] = gen_reg_rtx (Pmode);
 
-(define_expand "tablejumpdi_nospec"
-  [(set (match_dup 5)
-        (sign_extend:DI (match_operand:SI 0 "lwa_operand")))
-   (set (match_dup 4)
-       (plus:DI (match_dup 5)
-                (match_dup 3)))
-   (parallel [(set (pc)
-                  (match_dup 4))
-             (use (label_ref (match_operand 1)))
-             (clobber (match_operand 2))])]
-  "TARGET_64BIT && !rs6000_speculate_indirect_jumps"
-{
-  operands[3] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
-  operands[4] = gen_reg_rtx (DImode);
-  operands[5] = gen_reg_rtx (DImode);
+  emit_insn (gen_add<mode>3 (operands[3], operands[4], operands[5]));
+  emit_jump_insn (gen_tablejump_insn_nospec (Pmode, operands[3], operands[1],
+                                            operands[2]));
+  DONE;
 })
 
-(define_insn "*tablejump<mode>_internal1"
+(define_insn "@tablejump<mode>_insn_normal"
   [(set (pc)
        (match_operand:P 0 "register_operand" "c,*l"))
    (use (label_ref (match_operand 1)))]
   "b%T0"
   [(set_attr "type" "jmpreg")])
 
-(define_insn "*tablejump<mode>_internal1_nospec"
+(define_insn "@tablejump<mode>_insn_nospec"
   [(set (pc)
        (match_operand:P 0 "register_operand" "c,*l"))
    (use (label_ref (match_operand 1)))