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] PR other/66250: Can't adjust complex nor decimal floating point modes


machmode.def has

/* Allow the target to specify additional modes of various kinds.  */

/* Complex modes.  */
COMPLEX_MODES (INT);
COMPLEX_MODES (FLOAT);

/* Decimal floating point modes.  */
DECIMAL_FLOAT_MODE (SD, 4, decimal_single_format);
DECIMAL_FLOAT_MODE (DD, 8, decimal_double_format);
DECIMAL_FLOAT_MODE (TD, 16, decimal_quad_format);

We can't adjust any complex nor DFP modes in i386-modes.def since they
aren't available yet.  But we need to include i386-modes.def before

COMPLEX_MODES (INT);
COMPLEX_MODES (FLOAT);

to get extra modes.  This patch adds EXTRA_ADJUSTMENTS_FILE containing
 adjustments to machine modes and includes it after all modes have been
created.

Tested on Linux/x86-64.  The generated mode files are equivalent before
and after the change. I enclosed the diffs here.  OK for master?

Thanks.

H.J.
---
	PR other/66250
	* Makefile.in (extra_adjustments_file): New.
	(build/genmodes.o): Depend on $(extra_adjustments_file).
	* config.gcc (extra_adjustments): New.  Set to
	${cpu_type}/${cpu_type}-adjustments.def if available.
	* configure.ac (extra_adjustments): AC_SUBST and
	AC_DEFINE_UNQUOTED if set.
	* genmodes.c (HAVE_EXTRA_ADJUSTMENTS): New.
	(EXTRA_ADJUSTMENTS_FILE): Likewise.
	(emit_autogen_header): Likewise.
	(emit_insn_modes_h): Call emit_autogen_header.
	(emit_insn_modes_c_header): Likewise.
	(emit_min_insn_modes_c_header): Likewise.
	* machmode.def: Include EXTRA_ADJUSTMENTS_FILE if
	HAVE_EXTRA_ADJUSTMENTS is 1.
	* config.in: Regenerated.
	* configure: Likewise.
	* config/i386/i386-modes.def (ADJUST_FLOAT_FORMAT,
	ADJUST_BYTESIZE, ADJUST_ALIGNMENT): Moved to ...
	* config/i386/i386-adjustments.def: Here.  New file.
---
 gcc/Makefile.in                      |  3 ++-
 gcc/config.gcc                       |  9 +++++++++
 gcc/config.in                        |  7 +++++++
 gcc/config/i386/i386-adjustments.def | 28 ++++++++++++++++++++++++++++
 gcc/config/i386/i386-modes.def       | 12 +-----------
 gcc/configure                        | 16 ++++++++++++++--
 gcc/configure.ac                     |  9 +++++++++
 gcc/genmodes.c                       | 34 ++++++++++++++++++++++------------
 gcc/machmode.def                     |  5 +++++
 9 files changed, 97 insertions(+), 26 deletions(-)
 create mode 100644 gcc/config/i386/i386-adjustments.def

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 512e7c8..87e1cb1 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -544,6 +544,7 @@ lang_tree_files=@lang_tree_files@
 target_cpu_default=@target_cpu_default@
 OBJC_BOEHM_GC=@objc_boehm_gc@
 extra_modes_file=@extra_modes_file@
+extra_adjustments_file=@extra_adjustments_file@
 extra_opt_files=@extra_opt_files@
 host_hook_obj=@out_host_hook_obj@
 
@@ -2540,7 +2541,7 @@ CFLAGS-errors.o += -DHOST_GENERATOR_FILE
 build/genmddeps.o: genmddeps.c $(BCONFIG_H) $(SYSTEM_H) coretypes.h	\
   errors.h $(READ_MD_H)
 build/genmodes.o : genmodes.c $(BCONFIG_H) $(SYSTEM_H) errors.h		\
-  $(HASHTAB_H) machmode.def $(extra_modes_file)
+  $(HASHTAB_H) machmode.def $(extra_modes_file) $(extra_adjustments_file)
 build/genopinit.o : genopinit.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
   coretypes.h $(GTM_H) errors.h gensupport.h optabs.def
 build/genoutput.o : genoutput.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 1fcc290..85572d6 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -103,6 +103,10 @@
 #                       machine modes, if necessary and different from
 #                       "$cpu_type/$cpu_type-modes.def".
 #
+#  extra_adjustments    The name of the file containing adjustments to
+#                       machine modes, if necessary and different from
+#                       "$cpu_type/$cpu_type-adjustments.def".
+#
 #  extra_objs		List of extra objects that should be linked into
 #			the compiler proper (cc1, cc1obj, cc1plus)
 #			depending on target.
@@ -494,6 +498,11 @@ if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-modes.def
 then
 	extra_modes=${cpu_type}/${cpu_type}-modes.def
 fi
+extra_adjustments=
+if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-adjustments.def
+then
+	extra_adjustments=${cpu_type}/${cpu_type}-adjustments.def
+fi
 if test -f ${srcdir}/config/${cpu_type}/${cpu_type}.opt
 then
 	extra_options="${extra_options} ${cpu_type}/${cpu_type}.opt"
diff --git a/gcc/config/i386/i386-adjustments.def b/gcc/config/i386/i386-adjustments.def
new file mode 100644
index 0000000..690201e
--- /dev/null
+++ b/gcc/config/i386/i386-adjustments.def
@@ -0,0 +1,28 @@
+/* Definitions of target adjustments for GCC for x86.
+   Copyright (C) 2015 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+/* If TARGET_128BIT_LONG_DOUBLE is true, XFmode has size and alignment 16.
+   Otherwise, XFmode has size 12 and alignment 4.  */
+ADJUST_FLOAT_FORMAT (XF, (TARGET_128BIT_LONG_DOUBLE
+			  ? &ieee_extended_intel_128_format
+			  : TARGET_96_ROUND_53_LONG_DOUBLE
+			  ? &ieee_extended_intel_96_round_53_format
+			  : &ieee_extended_intel_96_format));
+ADJUST_BYTESIZE  (XF, TARGET_128BIT_LONG_DOUBLE ? 16 : 12);
+ADJUST_ALIGNMENT (XF, TARGET_128BIT_LONG_DOUBLE ? 16 : 4);
diff --git a/gcc/config/i386/i386-modes.def b/gcc/config/i386/i386-modes.def
index 714c138..9be0941 100644
--- a/gcc/config/i386/i386-modes.def
+++ b/gcc/config/i386/i386-modes.def
@@ -1,4 +1,4 @@
-/* Definitions of target machine for GCC for IA-32.
+/* Definitions of target machine for GCC for x86.
    Copyright (C) 2002-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -24,16 +24,6 @@ along with GCC; see the file COPYING3.  If not see
 FRACTIONAL_FLOAT_MODE (XF, 80, 12, ieee_extended_intel_96_format);
 FLOAT_MODE (TF, 16, ieee_quad_format);
 
-/* In ILP32 mode, XFmode has size 12 and alignment 4.
-   In LP64 mode, XFmode has size and alignment 16.  */
-ADJUST_FLOAT_FORMAT (XF, (TARGET_128BIT_LONG_DOUBLE
-			  ? &ieee_extended_intel_128_format
-			  : TARGET_96_ROUND_53_LONG_DOUBLE
-			  ? &ieee_extended_intel_96_round_53_format
-			  : &ieee_extended_intel_96_format));
-ADJUST_BYTESIZE  (XF, TARGET_128BIT_LONG_DOUBLE ? 16 : 12);
-ADJUST_ALIGNMENT (XF, TARGET_128BIT_LONG_DOUBLE ? 16 : 4);
-
 /* Add any extra modes needed to represent the condition code.
 
    For the i386, we need separate modes when floating-point
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 73de1ad..24abb5a 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1595,6 +1595,15 @@ if test -n "$extra_modes" && test -f $srcdir/config/$extra_modes; then
    for this architecture.])
 fi
 
+# Look for a file containing extra machine mode adjustments.
+if test -n "$extra_adjustments" && test -f $srcdir/config/$extra_adjustments; then
+  extra_adjustments_file='$(srcdir)'/config/${extra_adjustments}
+  AC_SUBST(extra_adjustments_file)
+  AC_DEFINE_UNQUOTED(EXTRA_ADJUSTMENTS_FILE, "config/$extra_adjustments",
+  [Define to the name of a file containing adjustments to machine modes
+   for this architecture.])
+fi
+
 # Convert extra_options into a form suitable for Makefile use.
 extra_opt_files=
 all_opt_files=
diff --git a/gcc/genmodes.c b/gcc/genmodes.c
index af1fe4f..d04602d 100644
--- a/gcc/genmodes.c
+++ b/gcc/genmodes.c
@@ -46,6 +46,13 @@ static const char *const mode_class_names[MAX_MODE_CLASS] =
 # define EXTRA_MODES_FILE ""
 #endif
 
+#ifdef EXTRA_ADJUSTMENTS_FILE
+# define HAVE_EXTRA_ADJUSTMENTS 1
+#else
+# define HAVE_EXTRA_ADJUSTMENTS 0
+# define EXTRA_ADJUSTMENTS_FILE ""
+#endif
+
 /* Data structure for building up what we know about a mode.
    They're clustered by mode class.  */
 struct mode_data
@@ -1049,18 +1056,27 @@ mode_inner_inline (machine_mode mode)\n\
 }
 
 static void
+emit_autogen_header (void)
+{
+  puts ("/* Generated automatically from");
+  puts ("\tmachmode.def");
+  if (HAVE_EXTRA_MODES)
+    printf ("\t%s\n", EXTRA_MODES_FILE);
+  if (HAVE_EXTRA_ADJUSTMENTS)
+    printf ("\t%s\n", EXTRA_ADJUSTMENTS_FILE);
+  puts ("   by genmodes.  */");
+}
+
+static void
 emit_insn_modes_h (void)
 {
   int c;
   struct mode_data *m, *first, *last;
   int n_int_n_ents = 0;
 
-  printf ("/* Generated automatically from machmode.def%s%s\n",
-	   HAVE_EXTRA_MODES ? " and " : "",
-	   EXTRA_MODES_FILE);
+  emit_autogen_header ();
 
   puts ("\
-   by genmodes.  */\n\
 \n\
 #ifndef GCC_INSN_MODES_H\n\
 #define GCC_INSN_MODES_H\n\
@@ -1136,12 +1152,9 @@ enum machine_mode\n{");
 static void
 emit_insn_modes_c_header (void)
 {
-  printf ("/* Generated automatically from machmode.def%s%s\n",
-	   HAVE_EXTRA_MODES ? " and " : "",
-	   EXTRA_MODES_FILE);
+  emit_autogen_header ();
 
   puts ("\
-   by genmodes.  */\n\
 \n\
 #include \"config.h\"\n\
 #include \"system.h\"\n\
@@ -1154,12 +1167,9 @@ emit_insn_modes_c_header (void)
 static void
 emit_min_insn_modes_c_header (void)
 {
-  printf ("/* Generated automatically from machmode.def%s%s\n",
-	   HAVE_EXTRA_MODES ? " and " : "",
-	   EXTRA_MODES_FILE);
+  emit_autogen_header ();
 
   puts ("\
-   by genmodes.  */\n\
 \n\
 #include \"bconfig.h\"\n\
 #include \"system.h\"\n\
diff --git a/gcc/machmode.def b/gcc/machmode.def
index c07a135..0fa0c29 100644
--- a/gcc/machmode.def
+++ b/gcc/machmode.def
@@ -250,6 +250,11 @@ DECIMAL_FLOAT_MODE (SD, 4, decimal_single_format);
 DECIMAL_FLOAT_MODE (DD, 8, decimal_double_format);
 DECIMAL_FLOAT_MODE (TD, 16, decimal_quad_format);
 
+/* Allow the target to make various adjustments to modes.  */
+#if HAVE_EXTRA_ADJUSTMENTS
+# include EXTRA_ADJUSTMENTS_FILE
+#endif
+
 /* The symbol Pmode stands for one of the above machine modes (usually SImode).
    The tm.h file specifies which one.  It is not a distinct mode.  */
 
-- 
2.1.0

Attachment: diffs
Description: Text document


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