This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] m68k: Use ASSEMBLER_DIALECT (Take 2)


Hi,

Attached is a revised patch to use ASSEMBLER_DIALECT to simplify
constructs that use MOTOROLA.

In this iteration, I have removed parts of the patch that touch jump
instructions, fmovem, and movem as they have alraedy been cleaned up.

Tested on m68k-elf.  OK to apply?

Kazu Hirata

2007-10-04  Kazu Hirata  <kazu@codesourcery.com>

	* config/m68k/m68k.c, config/m68k/m68k.md: Use the assembly
	syntax for ASSEMBLER_DIALECT.
	* config/m68k/m68k.h (ASSEMBLER_DIALECT): New.

Index: gcc/config/m68k/m68k.c
===================================================================
--- gcc/config/m68k/m68k.c	(revision 128994)
+++ gcc/config/m68k/m68k.c	(working copy)
@@ -3375,8 +3375,8 @@ output_addsi3 (rtx *operands)
 	  && (INTVAL (operands[2]) < -32768 || INTVAL (operands[2]) > 32767))
         return "move%.l %2,%0\n\tadd%.l %1,%0";
       if (GET_CODE (operands[2]) == REG)
-	return MOTOROLA ? "lea (%1,%2.l),%0" : "lea %1@(0,%2:l),%0";
-      return MOTOROLA ? "lea (%c2,%1),%0" : "lea %1@(%c2),%0";
+	return "lea {(%1,%2.l)|%1@(0,%2:l)},%0";
+      return "lea {(%c2,%1)|%1@(%c2)},%0";
     }
   if (GET_CODE (operands[2]) == CONST_INT)
     {
@@ -3414,7 +3414,7 @@ output_addsi3 (rtx *operands)
 	  if (TUNE_68040)
 	    return "add%.w %2,%0";
 	  else
-	    return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
+	    return "lea {(%c2,%0)|%0@(%c2)},%0";
 	}
     }
   return "add%.l %2,%0";
@@ -3730,11 +3730,11 @@ print_operand (FILE *file, rtx op, int l
   else if (letter == '#')
     asm_fprintf (file, "%I");
   else if (letter == '-')
-    asm_fprintf (file, MOTOROLA ? "-(%Rsp)" : "%Rsp@-");
+    asm_fprintf (file, "{-(%Rsp)|%Rsp@-}");
   else if (letter == '+')
-    asm_fprintf (file, MOTOROLA ? "(%Rsp)+" : "%Rsp@+");
+    asm_fprintf (file, "{(%Rsp)+|%Rsp@+}");
   else if (letter == '@')
-    asm_fprintf (file, MOTOROLA ? "(%Rsp)" : "%Rsp@");
+    asm_fprintf (file, "{(%Rsp)|%Rsp@}");
   else if (letter == '!')
     asm_fprintf (file, "%Rfpcr");
   else if (letter == '$')
@@ -3774,7 +3774,7 @@ print_operand (FILE *file, rtx op, int l
 	  && !(GET_CODE (XEXP (op, 0)) == CONST_INT
 	       && INTVAL (XEXP (op, 0)) < 0x8000
 	       && INTVAL (XEXP (op, 0)) >= -0x8000))
-	fprintf (file, MOTOROLA ? ".l" : ":l");
+	asm_fprintf (file, "{.|:}l");
     }
   else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == SFmode)
     {
@@ -3834,11 +3834,11 @@ print_operand_address (FILE *file, rtx a
     gcc_unreachable ();
 
   if (address.code == PRE_DEC)
-    fprintf (file, MOTOROLA ? "-(%s)" : "%s@-",
-	     M68K_REGNAME (REGNO (address.base)));
+    asm_fprintf (file, "{-(%s)|%s@-}",
+		 M68K_REGNAME (REGNO (address.base)));
   else if (address.code == POST_INC)
-    fprintf (file, MOTOROLA ? "(%s)+" : "%s@+",
-	     M68K_REGNAME (REGNO (address.base)));
+    asm_fprintf (file, "{(%s)+|%s@+}",
+		 M68K_REGNAME (REGNO (address.base)));
   else if (!address.base && !address.index)
     {
       /* A constant address.  */
@@ -3847,7 +3847,7 @@ print_operand_address (FILE *file, rtx a
 	{
 	  /* (xxx).w or (xxx).l.  */
 	  if (IN_RANGE (INTVAL (addr), -0x8000, 0x7fff))
-	    fprintf (file, MOTOROLA ? "%d.w" : "%d:w", (int) INTVAL (addr));
+	    asm_fprintf (file, "%d{.|:}w", (int) INTVAL (addr));
 	  else
 	    fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (addr));
 	}
Index: gcc/config/m68k/m68k.h
===================================================================
--- gcc/config/m68k/m68k.h	(revision 128994)
+++ gcc/config/m68k/m68k.h	(working copy)
@@ -29,6 +29,10 @@ along with GCC; see the file COPYING3.  
 # define TARGET_VERSION fprintf (stderr, " (68k, MIT syntax)")
 #endif
 
+/* Options 0 and 1 are the Motorola and MIT syntaxes,
+   respectively.  */
+#define ASSEMBLER_DIALECT	!MOTOROLA
+
 /* Handle --with-cpu default option from configure script.  */
 #define OPTION_DEFAULT_SPECS						\
   { "cpu",   "%{!mc68000:%{!m68000:%{!m68302:%{!m68010:%{!mc68020:%{!m68020:\
@@ -971,17 +975,11 @@ do { if (cc_prev_status.flags & CC_IN_68
 #define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM)	\
   sprintf (LABEL, "*%s%s%ld", LOCAL_LABEL_PREFIX, PREFIX, (long)(NUM))
 
-#define ASM_OUTPUT_REG_PUSH(FILE,REGNO)			\
-  asm_fprintf (FILE, (MOTOROLA				\
-		      ? "\tmove.l %s,-(%Rsp)\n"		\
-		      : "\tmovel %s,%Rsp@-\n"),		\
-	       reg_names[REGNO])
+#define ASM_OUTPUT_REG_PUSH(FILE,REGNO)					  \
+  asm_fprintf (FILE, "\tmove%.l %s,{-(%Rsp)|%Rsp@-}\n", reg_names[REGNO])
 
-#define ASM_OUTPUT_REG_POP(FILE,REGNO)			\
-  asm_fprintf (FILE, (MOTOROLA				\
-		      ? "\tmove.l (%Rsp)+,%s\n"		\
-		      : "\tmovel %Rsp@+,%s\n"),		\
-	       reg_names[REGNO])
+#define ASM_OUTPUT_REG_POP(FILE,REGNO)					     \
+  asm_fprintf (FILE, "\tmove%.l {(%Rsp)+|%Rsp@+},%s\n", reg_names[REGNO])
 
 /* The m68k does not use absolute case-vectors, but we must define this macro
    anyway.  */
Index: gcc/config/m68k/m68k.md
===================================================================
--- gcc/config/m68k/m68k.md	(revision 128994)
+++ gcc/config/m68k/m68k.md	(working copy)
@@ -825,7 +825,7 @@ (define_insn "*movsi_const0_68040_60"
   "TUNE_68040_60"
 {
   if (which_alternative == 0)
-    return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
+    return "lea 0{.|:}w,%0";
   else if (which_alternative == 1)
     return "clr%.l %0";
   else
@@ -1140,7 +1140,7 @@ (define_insn ""
 	{
 	  /* On the '040, 'subl an,an' takes 2 clocks while lea takes only 1 */
 	  if (TUNE_68040_60)
-	    return MOTOROLA ? "lea 0.w,%0" : "lea 0:w,%0";
+	    return "lea 0{.|:}w,%0";
 	  else
 	    return "sub%.l %0,%0";
 	}
@@ -2444,13 +2444,13 @@ (define_insn_and_split "*addsi3_5200"
       return "#";
 
     case 5:
-      return MOTOROLA ? "lea (%1,%2.l),%0" : "lea %1@(0,%2:l),%0";
+      return "lea {(%1,%2.l)|%1@(0,%2:l)},%0";
 
     case 6:
-      return MOTOROLA ? "lea (%2,%1.l),%0" : "lea %2@(0,%1:l),%0";
+      return "lea {(%2,%1.l)|%2@(0,%1:l)},%0";
 
     case 7:
-      return MOTOROLA ? "lea (%c2,%1),%0" : "lea %1@(%c2),%0";
+      return "lea {(%c2,%1)|%1@(%c2)},%0";
 
     default:
       gcc_unreachable ();
@@ -2521,7 +2521,7 @@ (define_insn "addhi3"
 	    }
 	}
       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
-	return MOTOROLA ? "lea (%c2,%0),%0" : "lea %0@(%c2),%0";
+	return "lea {(%c2,%0)|%0@(%c2)},%0";
     }
   return "add%.w %2,%0";
 })
@@ -2576,7 +2576,7 @@ (define_insn ""
 	    }
 	}
       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
-	return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
+	return "lea {(%c1,%0)|%0@(%c1)},%0";
     }
   return "add%.w %1,%0";
 })
@@ -2625,7 +2625,7 @@ (define_insn ""
 	    }
 	}
       if (ADDRESS_REG_P (operands[0]) && !TUNE_68040)
-	return MOTOROLA ? "lea (%c1,%0),%0" : "lea %0@(%c1),%0";
+	return "lea {(%c1,%0)|%0@(%c1)},%0";
     }
   return "add%.w %1,%0";
 })
@@ -2971,9 +2971,7 @@ (define_insn "mulhi3"
 	(mult:HI (match_operand:HI 1 "general_operand" "%0")
 		 (match_operand:HI 2 "general_src_operand" "dmSn")))]
   ""
-{
-  return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
-}
+  "muls{.w} %2,%0"
   [(set_attr "type" "muls_w")
    (set_attr "opy" "2")])
 
@@ -2984,9 +2982,7 @@ (define_insn "mulhisi3"
 		 (sign_extend:SI
 		  (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
   ""
-{
-  return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
-}
+  "muls{.w} %2,%0"
   [(set_attr "type" "muls_w")
    (set_attr "opy" "2")])
 
@@ -2996,9 +2992,7 @@ (define_insn "*mulhisisi3_s"
 		  (match_operand:HI 1 "nonimmediate_operand" "%0"))
 		 (match_operand:SI 2 "const_int_operand" "n")))]
   "INTVAL (operands[2]) >= -0x8000 && INTVAL (operands[2]) <= 0x7fff"
-{
-  return MOTOROLA ? "muls%.w %2,%0" : "muls %2,%0";
-}
+  "muls{.w} %2,%0"
   [(set_attr "type" "muls_w")
    (set_attr "opy" "2")])
 
@@ -3035,9 +3029,7 @@ (define_insn "umulhisi3"
 		 (zero_extend:SI
 		  (match_operand:HI 2 "nonimmediate_src_operand" "dmS"))))]
   ""
-{
-  return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
-}
+  "mulu{.w} %2,%0"
   [(set_attr "type" "mulu_w")
    (set_attr "opy" "2")])
 
@@ -3047,9 +3039,7 @@ (define_insn "*mulhisisi3_z"
 		  (match_operand:HI 1 "nonimmediate_operand" "%0"))
 		 (match_operand:SI 2 "const_int_operand" "n")))]
   "INTVAL (operands[2]) >= 0 && INTVAL (operands[2]) <= 0xffff"
-{
-  return MOTOROLA ? "mulu%.w %2,%0" : "mulu %2,%0";
-}
+  "mulu{.w} %2,%0"
   [(set_attr "type" "mulu_w")
    (set_attr "opy" "2")])
 
@@ -3472,10 +3462,7 @@ (define_insn "divmodhi4"
 	(mod:HI (match_dup 1) (match_dup 2)))]
   "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
 {
-  output_asm_insn (MOTOROLA ?
-    "ext%.l %0\;divs%.w %2,%0" :
-    "extl %0\;divs %2,%0",
-    operands);
+  output_asm_insn ("ext%.l %0\;divs{.w} %2,%0", operands);
   if (!find_reg_note(insn, REG_UNUSED, operands[3]))
     {
       CC_STATUS_INIT;
@@ -3494,15 +3481,9 @@ (define_insn "udivmodhi4"
   "!TARGET_COLDFIRE || TARGET_CF_HWDIV"
 {
   if (ISA_HAS_MVS_MVZ)
-    output_asm_insn (MOTOROLA ?
-      "mvz%.w %0,%0\;divu%.w %2,%0" :
-      "mvz%.w %0,%0\;divu %2,%0",
-      operands);
+    output_asm_insn ("mvz%.w %0,%0\;divu{.w} %2,%0", operands);
   else
-    output_asm_insn (MOTOROLA ?
-      "and%.l #0xFFFF,%0\;divu%.w %2,%0" :
-      "and%.l #0xFFFF,%0\;divu %2,%0",
-      operands);
+    output_asm_insn ("and%.l #0xFFFF,%0\;divu{.w} %2,%0", operands);
 
   if (!find_reg_note(insn, REG_UNUSED, operands[3]))
     {
@@ -6832,9 +6813,7 @@ (define_insn "*tablejump_internal"
   [(set (pc) (match_operand:SI 0 "register_operand" "a"))
    (use (label_ref (match_operand 1 "" "")))]
   ""
-{
-  return MOTOROLA ? "jmp (%0)" : "jmp %0@";
-}
+  "jmp {(%0)|%0@}"
   [(set_attr "type" "bra")])
 
 ;; Jump to variable address from dispatch table of relative addresses.
@@ -6851,14 +6830,12 @@ (define_insn ""
   if (TARGET_COLDFIRE)
     {
       if (ADDRESS_REG_P (operands[0]))
-	return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
-      else if (MOTOROLA)
-	return "ext%.l %0\;jmp (2,pc,%0.l)";
+	return "jmp {(2,pc,%0.l)|pc@(2,%0:l)}";
       else
-	return "extl %0\;jmp pc@(2,%0:l)";
+	return "ext%.l %0\;jmp {(2,pc,%0.l)|pc@(2,%0:l)}";
     }
   else
-    return MOTOROLA ? "jmp (2,pc,%0.w)" : "jmp pc@(2,%0:w)";
+    return "jmp {(2,pc,%0.w)|pc@(2,%0:w)}";
 #endif
 })
 
@@ -7225,12 +7202,10 @@ (define_insn "*link"
   "TARGET_68020 || INTVAL (operands[1]) >= -0x8004"
 {
   operands[1] = GEN_INT (INTVAL (operands[1]) + 4);
-  if (!MOTOROLA)
-    return "link %0,%1";
-  else if (INTVAL (operands[1]) >= -0x8000)
-    return "link.w %0,%1";
+  if (INTVAL (operands[1]) >= -0x8000)
+    return "link{.w} %0,%1";
   else
-    return "link.l %0,%1";
+    return "link{.l} %0,%1";
 })
 
 (define_expand "unlink"
@@ -7263,7 +7238,7 @@ (define_insn "load_got"
   if (TARGET_ID_SHARED_LIBRARY)
     {
       operands[1] = gen_rtx_REG (Pmode, PIC_REG);
-      return MOTOROLA ? "move.l %?(%1),%0" : "movel %1@(%?), %0";
+      return "move%.l {%?(%1)|%1@(%?)},%0";
     }
   else if (MOTOROLA)
     {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]