RFA: Use .opt files for the xtensa port

Richard Sandiford rsandifo@redhat.com
Thu Apr 7 21:30:00 GMT 2005


This patch makes the xtensa port define its options using a .opt file.
Very straightforward really.  The only thing is that I changed
TARGET/MASK_NO_FUSED_MADD to TARGET/MASK_FUSED_MADD, changed xtensa.md
accordingly, and added MASK_FUSED_MADD to the default flags.

Tested by building a xtensa-elf for a combined binutils/gcc tree.
Also tested by changing XCHAL_HAVE_BOOLEANS and XCHAL_HAVE_FP to 1
and rebuilding cc1 so that -mfused-madd would have an effect.
I checked that -m(no-)const16 and -m(no-)fused-madd still work.
The rest are ignored by gcc.  OK to install?

Richard


	* config/xtensa/xtensa.h (target_flags, MASK_NO_FUSED_MADD)
	(MASK_CONST16, TARGET_NO_FUSED_MADD, TARGET_CONST16)
	(TARGET_SWITCHES): Delete.
	* config/xtensa/xtensa.c (TARGET_DEFAULT_TARGET_FLAGS): Define.
	* config/xtensa/xtensa.md (muladdsf3, mulsubsf3): Check
	TARGET_FUSED_MADD instead of !TARGET_NO_FUSED_MADD.
	* config/xtensa/xtensa.opt: New file.

Index: config/xtensa/xtensa.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/xtensa.h,v
retrieving revision 1.64
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.64 xtensa.h
--- config/xtensa/xtensa.h	21 Mar 2005 18:08:31 -0000	1.64
+++ config/xtensa/xtensa.h	7 Apr 2005 21:18:21 -0000
@@ -24,7 +24,6 @@ 02111-1307, USA.  */
 
 /* Standard GCC variables that we reference.  */
 extern int current_function_calls_alloca;
-extern int target_flags;
 extern int optimize;
 
 /* External variables defined in xtensa.c.  */
@@ -42,10 +41,6 @@ extern struct rtx_def * branch_cmp[2];	/
 extern enum cmp_type branch_type;	/* what type of branch to use */
 extern unsigned xtensa_current_frame_size;
 
-/* Masks for the -m switches */
-#define MASK_NO_FUSED_MADD	0x00000001	/* avoid f-p mul/add */
-#define MASK_CONST16		0x00000002	/* use CONST16 instruction */
-
 /* Macros used in the machine description to select various Xtensa
    configuration options.  */
 #define TARGET_BIG_ENDIAN	XCHAL_HAVE_BE
@@ -66,39 +61,9 @@ #define TARGET_HARD_FLOAT_RSQRT	XCHAL_HA
 #define TARGET_ABS		XCHAL_HAVE_ABS
 #define TARGET_ADDX		XCHAL_HAVE_ADDX
 
-/* Macros controlled by command-line options.  */
-#define TARGET_NO_FUSED_MADD	(target_flags & MASK_NO_FUSED_MADD)
-#define TARGET_CONST16		(target_flags & MASK_CONST16)
-
 #define TARGET_DEFAULT (						\
   (XCHAL_HAVE_L32R	? 0 : MASK_CONST16))
 
-#define TARGET_SWITCHES							\
-{									\
-  {"const16",			MASK_CONST16,				\
-    N_("Use CONST16 instruction to load constants")},			\
-  {"no-const16",		-MASK_CONST16,				\
-    N_("Use PC-relative L32R instruction to load constants")},		\
-  {"no-fused-madd",		MASK_NO_FUSED_MADD,			\
-    N_("Disable fused multiply/add and multiply/subtract FP instructions")}, \
-  {"fused-madd",		-MASK_NO_FUSED_MADD,			\
-    N_("Enable fused multiply/add and multiply/subtract FP instructions")}, \
-  {"text-section-literals",	0,					\
-    N_("Intersperse literal pools with code in the text section")},	\
-  {"no-text-section-literals",	0,					\
-    N_("Put literal pools in a separate literal section")},		\
-  {"target-align",		0,					\
-    N_("Automatically align branch targets to reduce branch penalties")}, \
-  {"no-target-align",		0,					\
-    N_("Do not automatically align branch targets")},			\
-  {"longcalls",			0,					\
-    N_("Use indirect CALLXn instructions for large programs")},		\
-  {"no-longcalls",		0,					\
-    N_("Use direct CALLn instructions for fast calls")},		\
-  {"",				TARGET_DEFAULT, 0}			\
-}
-
-
 #define OVERRIDE_OPTIONS override_options ()
 
 /* Target CPU builtins.  */
Index: config/xtensa/xtensa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/xtensa.c,v
retrieving revision 1.72
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.72 xtensa.c
--- config/xtensa/xtensa.c	31 Mar 2005 14:59:59 -0000	1.72
+++ config/xtensa/xtensa.c	7 Apr 2005 21:18:22 -0000
@@ -232,6 +232,9 @@ #define TARGET_ASM_ALIGNED_SI_OP "\t.wor
 #undef TARGET_ASM_SELECT_RTX_SECTION
 #define TARGET_ASM_SELECT_RTX_SECTION  xtensa_select_rtx_section
 
+#undef TARGET_DEFAULT_TARGET_FLAGS
+#define TARGET_DEFAULT_TARGET_FLAGS (TARGET_DEFAULT | MASK_FUSED_MADD)
+
 #undef TARGET_RTX_COSTS
 #define TARGET_RTX_COSTS xtensa_rtx_costs
 #undef TARGET_ADDRESS_COST
Index: config/xtensa/xtensa.md
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/xtensa/xtensa.md,v
retrieving revision 1.24
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.24 xtensa.md
--- config/xtensa/xtensa.md	21 Mar 2005 18:22:42 -0000	1.24
+++ config/xtensa/xtensa.md	7 Apr 2005 21:18:22 -0000
@@ -371,7 +371,7 @@ (define_insn "muladdsf3"
 	(plus:SF (mult:SF (match_operand:SF 1 "register_operand" "%f")
 			  (match_operand:SF 2 "register_operand" "f"))
 		 (match_operand:SF 3 "register_operand" "0")))]
-  "TARGET_HARD_FLOAT && !TARGET_NO_FUSED_MADD"
+  "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
   "madd.s\t%0, %1, %2"
   [(set_attr "type"	"fmadd")
    (set_attr "mode"	"SF")
@@ -382,7 +382,7 @@ (define_insn "mulsubsf3"
 	(minus:SF (match_operand:SF 1 "register_operand" "0")
 		  (mult:SF (match_operand:SF 2 "register_operand" "%f")
 			   (match_operand:SF 3 "register_operand" "f"))))]
-  "TARGET_HARD_FLOAT && !TARGET_NO_FUSED_MADD"
+  "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
   "msub.s\t%0, %2, %3"
   [(set_attr "type"	"fmadd")
    (set_attr "mode"	"SF")
diff -u /dev/null config/xtensa/xtensa.opt
--- /dev/null	2005-03-29 10:04:47.000000000 +0100
+++ config/xtensa/xtensa.opt	2005-04-07 21:03:13.844836063 +0100
@@ -0,0 +1,40 @@
+; Options for the Tensilica Xtensa port of the compiler.
+
+; Copyright (C) 2005 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 2, 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 COPYING.  If not, write to the Free
+; Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+; 02111-1307, USA.
+
+mconst16
+Target Report Mask(CONST16)
+Use CONST16 instruction to load constants
+
+mfused-madd
+Target Report Mask(FUSED_MADD)
+Enable fused multiply/add and multiply/subtract FP instructions
+
+mtext-section-literals
+Target
+Intersperse literal pools with code in the text section
+
+mtarget-align
+Target
+Automatically align branch targets to reduce branch penalties
+
+mlongcalls
+Target
+Use indirect CALLXn instructions for large programs



More information about the Gcc-patches mailing list