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]

Avoid explicit use of machine modes (10/n) REAL_MODE_FORMAT


Currently, to get at the format structure for a floating point mode,
you have to do

  real_format_for_mode [M - QFmode] 

which is an unnecessary exposure of an implementation detail.  I've
macroized it so now you write

  REAL_MODE_FORMAT (M)

At present this just expands back to the above.  A future patch is
going to use something other than QFmode for the subtrahend - but
it'll only have to change one place.

Search-and-replace change, tested by building cc1 for the following
list of targets:

alpha-dec-vms c4x-elf i370-ibm-mvs i386-elf i960-coff ia64-elf
m68k-elf mips-elf powerpc-elf vax-elf

zw

        * real.h (REAL_MODE_FORMAT): New macro.
        * c-cppbuiltin.c, optabs.c, real.c, config/alpha/alpha.c
        * config/c4x/c4x.c, config/i370/i370.c, config/i386/freebsd.h
        * config/i386/i386.c, config/i960/i960.c, config/ia64/ia64.c
        * config/m68k/m68k.c, config/mips/mips.c, config/rs6000/rs6000.c
        * config/vax/vax.c: Use REAL_MODE_FORMAT instead of referring
        directly to real_format_for_mode array, wherever possible.

===================================================================
Index: c-cppbuiltin.c
--- c-cppbuiltin.c	30 Jun 2003 19:36:20 -0000	1.13
+++ c-cppbuiltin.c	6 Oct 2003 22:34:22 -0000
@@ -85,7 +85,7 @@ builtin_define_float_constants (const ch
   int dig, min_10_exp, max_10_exp;
   int decimal_dig;
 
-  fmt = real_format_for_mode[TYPE_MODE (type) - QFmode];
+  fmt = REAL_MODE_FORMAT (TYPE_MODE (type));
 
   /* The radix of the exponent representation.  */
   if (type == float_type_node)
===================================================================
Index: optabs.c
--- optabs.c	6 Oct 2003 12:48:49 -0000	1.191
+++ optabs.c	6 Oct 2003 22:34:23 -0000
@@ -2582,7 +2582,7 @@ expand_unop (enum machine_mode mode, opt
   if (unoptab->code == NEG && class == MODE_FLOAT
       && GET_MODE_BITSIZE (mode) <= 2 * HOST_BITS_PER_WIDE_INT)
     {
-      const struct real_format *fmt = real_format_for_mode[mode - QFmode];
+      const struct real_format *fmt = REAL_MODE_FORMAT (mode);
       enum machine_mode imode = int_mode_for_mode (mode);
       int bitpos = (fmt != 0) ? fmt->signbit : -1;
 
@@ -2756,7 +2756,7 @@ expand_abs_nojump (enum machine_mode mod
   if (GET_MODE_CLASS (mode) == MODE_FLOAT
       && GET_MODE_BITSIZE (mode) <= 2 * HOST_BITS_PER_WIDE_INT)
     {
-      const struct real_format *fmt = real_format_for_mode[mode - QFmode];
+      const struct real_format *fmt = REAL_MODE_FORMAT (mode);
       enum machine_mode imode = int_mode_for_mode (mode);
       int bitpos = (fmt != 0) ? fmt->signbit : -1;
 
===================================================================
Index: real.c
--- real.c	29 Sep 2003 21:59:58 -0000	1.127
+++ real.c	6 Oct 2003 22:34:23 -0000
@@ -2105,7 +2105,7 @@ real_nan (REAL_VALUE_TYPE *r, const char
 {
   const struct real_format *fmt;
 
-  fmt = real_format_for_mode[mode - QFmode];
+  fmt = REAL_MODE_FORMAT (mode);
   if (fmt == NULL)
     abort ();
 
@@ -2195,7 +2195,7 @@ real_maxval (REAL_VALUE_TYPE *r, int sig
   const struct real_format *fmt;
   int np2;
 
-  fmt = real_format_for_mode[mode - QFmode];
+  fmt = REAL_MODE_FORMAT (mode);
   if (fmt == NULL)
     abort ();
 
@@ -2368,7 +2368,7 @@ real_convert (REAL_VALUE_TYPE *r, enum m
 {
   const struct real_format *fmt;
 
-  fmt = real_format_for_mode[mode - QFmode];
+  fmt = REAL_MODE_FORMAT (mode);
   if (fmt == NULL)
     abort ();
 
@@ -2430,7 +2430,7 @@ real_to_target (long *buf, const REAL_VA
 {
   const struct real_format *fmt;
 
-  fmt = real_format_for_mode[mode - QFmode];
+  fmt = REAL_MODE_FORMAT (mode);
   if (fmt == NULL)
     abort ();
 
@@ -2455,7 +2455,7 @@ real_from_target (REAL_VALUE_TYPE *r, co
 {
   const struct real_format *fmt;
 
-  fmt = real_format_for_mode[mode - QFmode];
+  fmt = REAL_MODE_FORMAT (mode);
   if (fmt == NULL)
     abort ();
 
@@ -2470,7 +2470,7 @@ significand_size (enum machine_mode mode
 {
   const struct real_format *fmt;
 
-  fmt = real_format_for_mode[mode - QFmode];
+  fmt = REAL_MODE_FORMAT (mode);
   if (fmt == NULL)
     return 0;
 
===================================================================
Index: real.h
--- real.h	11 Sep 2003 21:40:41 -0000	1.73
+++ real.h	6 Oct 2003 22:34:23 -0000
@@ -145,6 +145,7 @@ struct real_format
    Indexed by MODE - QFmode.  */
 extern const struct real_format *real_format_for_mode[TFmode - QFmode + 1];
 
+#define REAL_MODE_FORMAT(MODE) (real_format_for_mode[(MODE) - QFmode])
 
 /* Declare functions in real.c.  */
 
===================================================================
Index: config/alpha/alpha.c
--- config/alpha/alpha.c	2 Oct 2003 00:44:14 -0000	1.329
+++ config/alpha/alpha.c	6 Oct 2003 22:34:25 -0000
@@ -472,9 +472,9 @@ override_options (void)
   /* Tell the compiler when we're using VAX floating point.  */
   if (TARGET_FLOAT_VAX)
     {
-      real_format_for_mode[SFmode - QFmode] = &vax_f_format;
-      real_format_for_mode[DFmode - QFmode] = &vax_g_format;
-      real_format_for_mode[TFmode - QFmode] = NULL;
+      REAL_MODE_FORMAT (SFmode) = &vax_f_format;
+      REAL_MODE_FORMAT (DFmode) = &vax_g_format;
+      REAL_MODE_FORMAT (TFmode) = NULL;
     }
 }
 
===================================================================
Index: config/c4x/c4x.c
--- config/c4x/c4x.c	2 Oct 2003 00:44:19 -0000	1.132
+++ config/c4x/c4x.c	6 Oct 2003 22:34:25 -0000
@@ -317,8 +317,8 @@ c4x_override_options (void)
 
   /* We're C4X floating point, not IEEE floating point.  */
   memset (real_format_for_mode, 0, sizeof real_format_for_mode);
-  real_format_for_mode[QFmode - QFmode] = &c4x_single_format;
-  real_format_for_mode[HFmode - QFmode] = &c4x_extended_format;
+  REAL_MODE_FORMAT (QFmode) = &c4x_single_format;
+  REAL_MODE_FORMAT (HFmode) = &c4x_extended_format;
 }
 
 
===================================================================
Index: config/i370/i370.c
--- config/i370/i370.c	27 Sep 2003 04:48:18 -0000	1.41
+++ config/i370/i370.c	6 Oct 2003 22:34:25 -0000
@@ -213,8 +213,8 @@ override_options ()
 {
   /* We're 370 floating point, not IEEE floating point.  */
   memset (real_format_for_mode, 0, sizeof real_format_for_mode);
-  real_format_for_mode[SFmode - QFmode] = &i370_single_format;
-  real_format_for_mode[DFmode - QFmode] = &i370_double_format;
+  REAL_MODE_FORMAT (SFmode) = &i370_single_format;
+  REAL_MODE_FORMAT (DFmode) = &i370_double_format;
 }
 
 /* ===================================================== */
===================================================================
Index: config/i386/freebsd.h
--- config/i386/freebsd.h	26 Sep 2003 03:28:27 -0000	1.40
+++ config/i386/freebsd.h	6 Oct 2003 22:34:25 -0000
@@ -137,9 +137,9 @@ Boston, MA 02111-1307, USA.  */
 #define SUBTARGET_OVERRIDE_OPTIONS			\
   do {							\
     if (!TARGET_64BIT) {				\
-      real_format_for_mode[XFmode - QFmode]		\
+      REAL_MODE_FORMAT (XFmode)				\
 	= &ieee_extended_intel_96_round_53_format;	\
-      real_format_for_mode[TFmode - QFmode]		\
+      REAL_MODE_FORMAT (TFmode)				\
 	= &ieee_extended_intel_96_round_53_format;	\
     }							\
   } while (0)
===================================================================
Index: config/i386/i386.c
--- config/i386/i386.c	26 Sep 2003 03:46:05 -0000	1.603
+++ config/i386/i386.c	6 Oct 2003 22:34:27 -0000
@@ -1113,8 +1113,8 @@ override_options (void)
 
   /* By default our XFmode is the 80-bit extended format.  If we have
      use TFmode instead, it's also the 80-bit format, but with padding.  */
-  real_format_for_mode[XFmode - QFmode] = &ieee_extended_intel_96_format;
-  real_format_for_mode[TFmode - QFmode] = &ieee_extended_intel_128_format;
+  REAL_MODE_FORMAT (XFmode) = &ieee_extended_intel_96_format;
+  REAL_MODE_FORMAT (TFmode) = &ieee_extended_intel_128_format;
 
   /* Set the default values for switches whose default depends on TARGET_64BIT
      in case they weren't overwritten by command line options.  */
===================================================================
Index: config/i960/i960.c
--- config/i960/i960.c	27 Sep 2003 04:48:19 -0000	1.56
+++ config/i960/i960.c	6 Oct 2003 22:34:27 -0000
@@ -169,7 +169,7 @@ i960_initialize ()
     }
 
   /* Tell the compiler which flavor of TFmode we're using.  */
-  real_format_for_mode[TFmode - QFmode] = &ieee_extended_intel_128_format;
+  REAL_MODE_FORMAT (TFmode) = &ieee_extended_intel_128_format;
 }
 
 /* Return true if OP can be used as the source of an fp move insn.  */
===================================================================
Index: config/ia64/ia64.c
--- config/ia64/ia64.c	4 Oct 2003 21:36:05 -0000	1.249
+++ config/ia64/ia64.c	6 Oct 2003 22:34:28 -0000
@@ -4509,7 +4509,7 @@ ia64_override_options (void)
 
   /* Tell the compiler which flavor of TFmode we're using.  */
   if (INTEL_EXTENDED_IEEE_FORMAT)
-    real_format_for_mode[TFmode - QFmode] = &ieee_extended_intel_128_format;
+    REAL_MODE_FORMAT (TFmode) = &ieee_extended_intel_128_format;
 }
 
 static enum attr_itanium_class ia64_safe_itanium_class (rtx);
===================================================================
Index: config/m68k/m68k.c
--- config/m68k/m68k.c	27 Sep 2003 04:48:24 -0000	1.104
+++ config/m68k/m68k.c	6 Oct 2003 22:34:28 -0000
@@ -212,7 +212,7 @@ override_options (void)
   SUBTARGET_OVERRIDE_OPTIONS;
 
   /* Tell the compiler which flavor of XFmode we're using.  */
-  real_format_for_mode[XFmode - QFmode] = &ieee_extended_motorola_format;
+  REAL_MODE_FORMAT (XFmode) = &ieee_extended_motorola_format;
 }
 
 /* Structure describing stack frame layout. */
===================================================================
Index: config/mips/mips.c
--- config/mips/mips.c	6 Oct 2003 17:52:35 -0000	1.327
+++ config/mips/mips.c	6 Oct 2003 22:34:29 -0000
@@ -4859,12 +4859,12 @@ override_options (void)
       flag_delayed_branch = 0;
     }
 
-  real_format_for_mode[SFmode - QFmode] = &mips_single_format;
-  real_format_for_mode[DFmode - QFmode] = &mips_double_format;
+  REAL_MODE_FORMAT (SFmode) = &mips_single_format;
+  REAL_MODE_FORMAT (DFmode) = &mips_double_format;
 #ifdef MIPS_TFMODE_FORMAT
-  real_format_for_mode[TFmode - QFmode] = &MIPS_TFMODE_FORMAT;
+  REAL_MODE_FORMAT (TFmode) = &MIPS_TFMODE_FORMAT;
 #else
-  real_format_for_mode[TFmode - QFmode] = &mips_quad_format;
+  REAL_MODE_FORMAT (TFmode) = &mips_quad_format;
 #endif
 
   mips_print_operand_punct['?'] = 1;
===================================================================
Index: config/rs6000/rs6000.c
--- config/rs6000/rs6000.c	4 Oct 2003 21:36:06 -0000	1.523
+++ config/rs6000/rs6000.c	6 Oct 2003 22:34:31 -0000
@@ -845,7 +845,7 @@ rs6000_override_options (const char *def
 
   if (TARGET_LONG_DOUBLE_128
       && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN))
-    real_format_for_mode[TFmode - QFmode] = &ibm_extended_format;
+    REAL_MODE_FORMAT (TFmode) = &ibm_extended_format;
 
   /* Allocate an alias set for register saves & restores from stack.  */
   rs6000_sr_alias_set = new_alias_set ();
===================================================================
Index: config/vax/vax.c
--- config/vax/vax.c	2 Oct 2003 00:44:29 -0000	1.49
+++ config/vax/vax.c	6 Oct 2003 22:34:31 -0000
@@ -86,9 +86,8 @@ override_options (void)
 {
   /* We're VAX floating point, not IEEE floating point.  */
   memset (real_format_for_mode, 0, sizeof real_format_for_mode);
-  real_format_for_mode[SFmode - QFmode] = &vax_f_format;
-  real_format_for_mode[DFmode - QFmode]
-    = (TARGET_G_FLOAT ? &vax_g_format : &vax_d_format);
+  REAL_MODE_FORMAT (SFmode) = &vax_f_format;
+  REAL_MODE_FORMAT (DFmode) = (TARGET_G_FLOAT ? &vax_g_format : &vax_d_format);
 }
 
 /* Generate the assembly code for function entry.  FILE is a stdio


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