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] MIPS code cleanup: Use TARGET_NEWABI and TARGET_OLDABI consistently


Hello All,

this patch defines TARGET_OLDABI, and uses together with TARGET_NEWABI
to make the mips_abi checks a bit less obfuscated.

Tested for mips64-linux with gcc bootstrap and regression test.

I don't have a copyright assignment for gcc yet, but it's probably
not needed anyway for such search-and-replace style things.


Thiemo


2004-02-06  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>

	/gcc/ChangeLog
	* config/mips/mips.h (TARGET_OLDABI): Define. Use TARGET_NEWABI and
	TARGET_LODABI consistently.
	* config/mips/mips.c (function_arg,mips_setup_incoming_varargs,
	mips_va_arg,override_options,compute_frame_size,
	mips_initial_elimination_offset,mips16_fp_args,build_mips16_call_stub
	,mips_return_in_memory,mips_strict_argument_naming): Use TARGET_NEWABI
	and TARGET_LODABI consistently.
	* config/mips/mips.md (exception_receiver): Likewise.
	* config/mips/linux64.h: Likewise.


Index: gcc/config/mips/linux64.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/mips/linux64.h,v
retrieving revision 1.5
diff -u -p -r1.5 linux64.h
--- gcc/config/mips/linux64.h	23 Aug 2003 17:14:11 -0000	1.5
+++ gcc/config/mips/linux64.h	6 Feb 2004 00:58:00 -0000
@@ -74,8 +74,7 @@ Boston, MA 02111-1307, USA.  */
 %{mabi=32:-melf32%{EB:b}%{EL:l}tsmip}"
 
 #undef LOCAL_LABEL_PREFIX
-#define LOCAL_LABEL_PREFIX ((mips_abi == ABI_32 || mips_abi == ABI_O64) \
-			    ? "$" : ".")
+#define LOCAL_LABEL_PREFIX (TARGET_OLDABI ? "$" : ".")
 
 /* The size in bytes of a DWARF field indicating an offset or length
    relative to a debug info section, specified to be 4 bytes in the DWARF-2
Index: gcc/config/mips/mips.c
===================================================================
RCS file: /cvs/uberbaum/gcc/config/mips/mips.c,v
retrieving revision 1.377
diff -u -p -r1.377 mips.c
--- gcc/config/mips/mips.c	4 Feb 2004 20:01:00 -0000	1.377
+++ gcc/config/mips/mips.c	6 Feb 2004 00:58:01 -0000
@@ -3797,7 +3797,7 @@ function_arg (const CUMULATIVE_ARGS *cum
 
   if (type != 0
       && TREE_CODE (type) == RECORD_TYPE
-      && (mips_abi == ABI_N32 || mips_abi == ABI_64)
+      && TARGET_NEWABI
       && TYPE_SIZE_UNIT (type)
       && host_integerp (TYPE_SIZE_UNIT (type), 1)
       && named)
@@ -4004,7 +4004,7 @@ mips_setup_incoming_varargs (CUMULATIVE_
 	    }
 	}
     }
-  if (mips_abi == ABI_32 || mips_abi == ABI_O64)
+  if (TARGET_OLDABI)
     {
       /* No need for pretend arguments: the register parameter area was
 	 allocated by the caller.  */
@@ -4394,8 +4394,7 @@ mips_va_arg (tree valist, tree type)
 	 that alignments <= UNITS_PER_WORD are preserved by the va_arg
 	 increment mechanism.  */
 
-      if ((mips_abi == ABI_N32 || mips_abi == ABI_64)
-	  && TYPE_ALIGN (type) > 64)
+      if (TARGET_NEWABI && TYPE_ALIGN (type) > 64)
 	align = 16;
       else if (TARGET_64BIT)
 	align = 8;
@@ -4744,7 +4743,7 @@ override_options (void)
 	}
     }
 
-  if (mips_abi != ABI_32 && mips_abi != ABI_O64)
+  if (!TARGET_OLDABI)
     flag_pcc_struct_return = 0;
 
 #if defined(USE_COLLECT2)
@@ -6427,7 +6426,7 @@ compute_frame_size (HOST_WIDE_INT size)
 
   /* Add in space reserved on the stack by the callee for storing arguments
      passed in registers.  */
-  if (mips_abi != ABI_32 && mips_abi != ABI_O64)
+  if (!TARGET_OLDABI)
     total_size += MIPS_STACK_ALIGN (current_function_pretend_args_size);
 
   /* Save other computed information.  */
@@ -6498,7 +6497,7 @@ mips_initial_elimination_offset (int fro
 
     case ARG_POINTER_REGNUM:
       offset = cfun->machine->frame.total_size;
-      if (mips_abi == ABI_N32 || mips_abi == ABI_64)
+      if (TARGET_NEWABI)
 	offset -= current_function_pretend_args_size;
       break;
 
@@ -7856,7 +7855,7 @@ mips16_fp_args (FILE *file, int fp_code,
   unsigned int f;
 
   /* This code only works for the original 32 bit ABI and the O64 ABI.  */
-  if (mips_abi != ABI_32 && mips_abi != ABI_O64)
+  if (!TARGET_OLDABI)
     abort ();
 
   if (from_fp_p)
@@ -8053,7 +8052,7 @@ build_mips16_call_stub (rtx retval, rtx 
 
   /* This code will only work for o32 and o64 abis.  The other ABI's
      require more sophisticated support.  */
-  if (mips_abi != ABI_32 && mips_abi != ABI_O64)
+  if (!TARGET_OLDABI)
     abort ();
 
   /* We can only handle SFmode and DFmode floating point return
@@ -9359,7 +9358,7 @@ mips_hard_regno_nregs (int regno, enum m
 static bool
 mips_return_in_memory (tree type, tree fndecl ATTRIBUTE_UNUSED)
 {
-  if (mips_abi == ABI_32 || mips_abi == ABI_O64)
+  if (TARGET_OLDABI)
     return (TYPE_MODE (type) == BLKmode);
   else
     return ((int_size_in_bytes (type) > (2 * UNITS_PER_WORD))
@@ -9369,7 +9368,7 @@ mips_return_in_memory (tree type, tree f
 static bool
 mips_strict_argument_naming (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
 {
-  return (mips_abi != ABI_32 && mips_abi != ABI_O64);
+  return !TARGET_OLDABI;
 }
 
 static int
Index: gcc/config/mips/mips.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/mips/mips.h,v
retrieving revision 1.315
diff -u -p -r1.315 mips.h
--- gcc/config/mips/mips.h	3 Feb 2004 22:38:34 -0000	1.315
+++ gcc/config/mips/mips.h	6 Feb 2004 00:58:01 -0000
@@ -334,6 +334,7 @@ extern const struct mips_cpu_info *mips_
 #define TUNE_SB1                    (mips_tune == PROCESSOR_SB1)
 #define TUNE_SR71K                  (mips_tune == PROCESSOR_SR71000)
 
+#define TARGET_OLDABI		    (mips_abi == ABI_32 || mips_abi == ABI_O64)
 #define TARGET_NEWABI		    (mips_abi == ABI_N32 || mips_abi == ABI_64)
 
 /* IRIX specific stuff.  */
@@ -785,9 +786,8 @@ extern const struct mips_cpu_info *mips_
 /* True if the ABI can only work with 64-bit integer registers.  We
    generally allow ad-hoc variations for TARGET_SINGLE_FLOAT, but
    otherwise floating-point registers must also be 64-bit.  */
-#define ABI_NEEDS_64BIT_REGS	(mips_abi == ABI_64			\
-				 || mips_abi == ABI_O64			\
-				 || mips_abi == ABI_N32)
+#define ABI_NEEDS_64BIT_REGS	(TARGET_NEWABI				\
+				 || mips_abi == ABI_O64)
 
 /* Likewise for 32-bit regs.  */
 #define ABI_NEEDS_32BIT_REGS	(mips_abi == ABI_32)
@@ -1330,8 +1330,7 @@ extern const struct mips_cpu_info *mips_
 
 #define FLOAT_TYPE_SIZE 32
 #define DOUBLE_TYPE_SIZE 64
-#define LONG_DOUBLE_TYPE_SIZE \
-  (mips_abi == ABI_N32 || mips_abi == ABI_64 ? 128 : 64)
+#define LONG_DOUBLE_TYPE_SIZE (TARGET_NEWABI ? 128 : 64)
 
 /* long double is not a fixed mode, but the idea is that, if we
    support long double, we also want a 128-bit integer type.  */
@@ -1354,8 +1353,8 @@ extern const struct mips_cpu_info *mips_
 #define POINTERS_EXTEND_UNSIGNED 0
 
 /* Allocation boundary (in *bits*) for storing arguments in argument list.  */
-#define PARM_BOUNDARY ((mips_abi == ABI_O64 || mips_abi == ABI_N32 \
-			|| mips_abi == ABI_64 \
+#define PARM_BOUNDARY ((mips_abi == ABI_O64 \
+			|| TARGET_NEWABI \
 			|| (mips_abi == ABI_EABI && TARGET_64BIT)) ? 64 : 32)
 
 
@@ -2160,7 +2159,7 @@ extern enum reg_class mips_char_to_class
 
 /* o32 and o64 reserve stack space for all argument registers.  */
 #define REG_PARM_STACK_SPACE(FNDECL) 			\
-  ((mips_abi == ABI_32 || mips_abi == ABI_O64)		\
+  (TARGET_OLDABI					\
    ? (MAX_ARGS_IN_REGISTERS * UNITS_PER_WORD)		\
    : 0)
 
@@ -2172,7 +2171,7 @@ extern enum reg_class mips_char_to_class
 #define OUTGOING_REG_PARM_STACK_SPACE
 
 #define STACK_BOUNDARY \
-  ((mips_abi == ABI_32 || mips_abi == ABI_O64 || mips_abi == ABI_EABI) \
+  ((TARGET_OLDABI || mips_abi == ABI_EABI) \
    ? 64 : 128)
 
 
@@ -2185,7 +2184,7 @@ extern enum reg_class mips_char_to_class
 #define FP_RETURN ((TARGET_SOFT_FLOAT) ? GP_RETURN : (FP_REG_FIRST + 0))
 
 #define MAX_ARGS_IN_REGISTERS \
-  ((mips_abi == ABI_32 || mips_abi == ABI_O64) ? 4 : 8)
+  (TARGET_OLDABI ? 4 : 8)
 
 /* Largest possible value of MAX_ARGS_IN_REGISTERS.  */
 
@@ -2369,7 +2368,7 @@ typedef struct mips_args {
 /* Treat LOC as a byte offset from the stack pointer and round it up
    to the next fully-aligned offset.  */
 #define MIPS_STACK_ALIGN(LOC)						\
-  ((mips_abi == ABI_32 || mips_abi == ABI_O64 || mips_abi == ABI_EABI)	\
+  ((TARGET_OLDABI || mips_abi == ABI_EABI)				\
    ? ((LOC) + 7) & ~7							\
    : ((LOC) + 15) & ~15)
 
@@ -2392,7 +2391,7 @@ typedef struct mips_args {
   fprintf (FILE, "\t.set\tnoat\n");					\
   fprintf (FILE, "\tmove\t%s,%s\t\t# save current return address\n",	\
 	   reg_names[GP_REG_FIRST + 1], reg_names[GP_REG_FIRST + 31]);	\
-  if (mips_abi != ABI_N32 && mips_abi != ABI_64)			\
+  if (!TARGET_NEWABI)							\
     {									\
       fprintf (FILE,							\
 	       "\t%s\t%s,%s,%d\t\t# _mcount pops 2 words from  stack\n", \
@@ -3382,9 +3381,7 @@ while (0)
 /* See mips_expand_prologue's use of loadgp for when this should be
    true.  */
 
-#define DONT_ACCESS_GBLS_AFTER_EPILOGUE (TARGET_ABICALLS 		\
-					 && mips_abi != ABI_32		\
-					 && mips_abi != ABI_O64)
+#define DONT_ACCESS_GBLS_AFTER_EPILOGUE (TARGET_ABICALLS && !TARGET_OLDABI)
 
 
 #define DFMODE_NAN \
Index: gcc/config/mips/mips.md
===================================================================
RCS file: /cvs/uberbaum/gcc/config/mips/mips.md,v
retrieving revision 1.214
diff -u -p -r1.214 mips.md
--- gcc/config/mips/mips.md	3 Feb 2004 06:43:49 -0000	1.214
+++ gcc/config/mips/mips.md	6 Feb 2004 00:58:04 -0000
@@ -8318,7 +8318,7 @@ ld\t%2,%1-%S1(%2)\;daddu\t%2,%2,$31\;%*j
 (define_insn "exception_receiver"
   [(set (reg:SI 28)
 	(unspec_volatile:SI [(const_int 0)] UNSPEC_EH_RECEIVER))]
-  "TARGET_ABICALLS && (mips_abi == ABI_32 || mips_abi == ABI_O64)"
+  "TARGET_ABICALLS && TARGET_OLDABI"
 {
   operands[0] = pic_offset_table_rtx;
   operands[1] = mips_gp_save_slot ();


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