(movhi): Simplify code involving jump-table reference.
authorRichard Kenner <kenner@gcc.gnu.org>
Thu, 5 May 1994 17:39:17 +0000 (13:39 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Thu, 5 May 1994 17:39:17 +0000 (13:39 -0400)
(load_address): Handle case of jump-table reference; output required label.

From-SVN: r7215

gcc/config/m68k/m68k.md

index 436582709a84179750ba2054865f172540571b6c..7e4d89e9d506a09eb2d9df09d27f6c852fca75ad 100644 (file)
   /* Recognize the insn before a tablejump, one that refers
      to a table of offsets.  Such an insn will need to refer
      to a label on the insn.  So output one.  Use the label-number
-     of the table of offsets to generate this label.  */
+     of the table of offsets to generate this label.  This code,
+     and similar code below, assumes that there will be at most one
+     reference to each table.  */
   if (GET_CODE (operands[1]) == MEM
       && GET_CODE (XEXP (operands[1], 0)) == PLUS
-      && (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF
-         || GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == LABEL_REF)
-      && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) != PLUS
-      && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) != PLUS)
+      && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == LABEL_REF
+      && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) != PLUS)
     {
-      rtx labelref;
-      if (GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == LABEL_REF)
-       labelref = XEXP (XEXP (operands[1], 0), 0);
-      else
-       labelref = XEXP (XEXP (operands[1], 0), 1);
+      rtx labelref = XEXP (XEXP (operands[1], 0), 1);
 #if defined (MOTOROLA) && !defined (SGS_SWITCH_TABLES)
 #ifdef SGS
       asm_fprintf (asm_out_file, \"\\tset %LLI%d,.+2\\n\",
   [(set (match_operand:SI 0 "general_operand" "=a")
        (match_operand:QI 1 "address_operand" "p"))]
   ""
-  "lea %a1,%0")
+  "*
+{
+#ifndef SGS_NO_LI
+  /* Recognize an insn that refers to a table of offsets.  Such an insn will
+     need to refer to a label on the insn.  So output one.  Use the
+     label-number of the table of offsets to generate this label.  This code,
+     and similar code above, assumes that there will be at most one reference
+     to each table.  */
+  if (GET_CODE (operands[1]) == PLUS
+      && GET_CODE (XEXP (operands[1], 1)) == LABEL_REF
+      && GET_CODE (XEXP (operands[1], 0)) != PLUS)
+    {
+      rtx labelref = XEXP (operands[1], 1);
+#if defined (MOTOROLA) && !defined (SGS_SWITCH_TABLES)
+#ifdef SGS
+      asm_fprintf (asm_out_file, \"\\tset %LLI%d,.+2\\n\",
+                  CODE_LABEL_NUMBER (XEXP (labelref, 0)));
+#else /* not SGS */
+      asm_fprintf (asm_out_file, \"\\t.set %LLI%d,.+2\\n\",
+                  CODE_LABEL_NUMBER (XEXP (labelref, 0)));
+#endif /* not SGS */
+#else /* SGS_SWITCH_TABLES or not MOTOROLA */
+      ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, \"LI\",
+                                CODE_LABEL_NUMBER (XEXP (labelref, 0)));
+#ifdef SGS_SWITCH_TABLES
+      /* Set flag saying we need to define the symbol
+        LD%n (with value L%n-LI%n) at the end of the switch table.  */
+      switch_table_difference_label_flag = 1;
+#endif /* SGS_SWITCH_TABLES */
+#endif /* SGS_SWITCH_TABLES or not MOTOROLA */
+    }
+#endif /* SGS_NO_LI */
+
+  return \"lea %a1,%0\";
+}")
 \f
 ;; This is the first machine-dependent peephole optimization.
 ;; It is useful when a floating value is returned from a function call