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]

RFA: Use .opt files for the v850 port


This patch makes the v850 port define its options using .opt files.
Main points:

  - The arguments of -msda[-=], -mtda[-=] and -mzda[-=] are now parsed
    by the handle_option hook rather than by OVERRIDE_OPTIONS.  Because
    the port supports both the "-" and "=" forms (which would get mapped
    to the same OPT_* enum), I've listed the options as -msda, -mtda and
    -mzda and treated the "-" and "=" as part of the argument.

    I see the options scripts are hard-coded to accept both
    -finline-limit- and -finline-limit=.  It might be worthwhile
    generalising that somehow.  We could then list both the "-"
    and "=" forms of these options in the .opt file and tag them
    as UIntegers.  It's on my list of "maybe"s.

  - I've changed MASK/TARGET_NO_APP_REGS to MASK/TARGET_APP_REGS
    and added MASK_APP_REGS to the default options.

Tested by building v850-elf.  It ICEs soon into the build of libgcc2
for unrelated reasons.  I checked each option by hand to make sure it
was having the desired effect, although:

  - -mstrict-align is a no-op (the mask is always set by
    OPTIMIZATION_OPTIONS).

  - although -msmall, -mep and -mprolog-function seem to be optimisation
    options, they only have an effect at -O0.  OPTIMIZATION_OPTIONS
    will otherwise enforce -msmall itself.

  - the values set by -msda, -mtda and -mzda aren't used.

OK to install?

Richard


	* config/v850/v850-protos.h (override_options): Delete.
	* config/v850/v850.h (target_flags, MASK_GHS, MASK_LONG_CALLS, MASK_EP)
	(MASK_PROLOG_FUNCTION, MASK_DEBUG, MASK_V850, MASK_V850E)
	(MASK_SMALL_SLD, MASK_BIG_SWITCH, MASK_NO_APP_REGS, MASK_DISABLE_CALLT)
	(MASK_STRICT_ALIGN, MASK_US_BIT_SET, MASK_US_MASK_SET, TARGET_GHS)
	(TARGET_LONG_CALLS, TARGET_EP, TARGET_PROLOG_FUNCTION, TARGET_V850)
	(TARGET_BIG_SWITCH, TARGET_DEBUG, TARGET_V850E, TARGET_US_BIT_SET)
	(TARGET_SMALL_SLD, TARGET_DISABLE_CALLT, TARGET_NO_APP_REGS)
	(TARGET_STRICT_ALIGN, TARGET_SWITCHES, TARGET_OPTIONS)
	(OVERRIDE_OPTIONS): Delete.
	(MASK_CPU): Redefine as MASK_V850 | MASK_V850E.
	(small_memory_info): Remove the value field.
	(CONDITIONAL_REGISTER_USAGE): Check !TARGET_APP_REGS rather than
	TARGET_NO_APP_REGS.
	* config/v850/v850.c (small_memory): Remove the value field.
	(TARGET_DEFAULT_TARGET_FLAGS, TARGET_HANDLE_OPTION): Override defaults.
	(override_options): Delete.
	(v850_handle_memory_option, v850_handle_option): New functions.
	* config/v850/v850.opt: New file.

Index: config/v850/v850-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/v850/v850-protos.h,v
retrieving revision 1.25
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.25 v850-protos.h
*** config/v850/v850-protos.h	21 Mar 2005 18:01:28 -0000	1.25
--- config/v850/v850-protos.h	6 Apr 2005 05:56:38 -0000
*************** extern void   zdata_section             
*** 35,41 ****
  extern void   rozdata_section               (void);
  extern void   zbss_section                  (void);
  extern int    v850_handle_pragma            (int (*)(void), void (*)(int), char *);
- extern void   override_options              (void);
  extern int    compute_register_save_size    (long *);
  extern int    compute_frame_size            (int, long *);
  extern void   v850_init_expanders           (void);
--- 35,40 ----
Index: config/v850/v850.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/v850/v850.h,v
retrieving revision 1.102
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.102 v850.h
*** config/v850/v850.h	21 Mar 2005 18:01:29 -0000	1.102
--- config/v850/v850.h	6 Apr 2005 05:56:38 -0000
*************** #define TARGET_CPU_CPP_BUILTINS() do {		
*** 83,219 ****
    builtin_assert( "cpu=v850" );			\
  } while(0)
  
! /* Run-time compilation parameters selecting different hardware subsets.  */
! 
! extern int target_flags;
! 
! /* Target flags bits, see below for an explanation of the bits.  */
! #define MASK_GHS		0x00000001
! #define MASK_LONG_CALLS		0x00000002
! #define MASK_EP			0x00000004
! #define MASK_PROLOG_FUNCTION	0x00000008
! #define MASK_DEBUG		0x40000000
! 
! #define MASK_CPU                0x00000030
! #define MASK_V850               0x00000010
! #define MASK_V850E              0x00000020
! #define MASK_SMALL_SLD          0x00000040
! 
! #define MASK_BIG_SWITCH		0x00000100
! #define MASK_NO_APP_REGS        0x00000200
! #define MASK_DISABLE_CALLT      0x00000400
! #define MASK_STRICT_ALIGN       0x00000800
! 
! #define MASK_US_BIT_SET         0x00001000
! #define MASK_US_MASK_SET        0x00002000
! 
! /* Macros used in the machine description to test the flags.  */
! 
! /* The GHS calling convention support doesn't really work,
!    mostly due to a lack of documentation.  Outstanding issues:
! 
!      * How do varargs & stdarg really work.  How to they handle
!      passing structures (if at all).
! 
!      * Doubles are normally 4 byte aligned, except in argument
!      lists where they are 8 byte aligned.  Is the alignment
!      in the argument list based on the first parameter,
!      first stack parameter, etc etc.
! 
!      * Passing/returning of large structures probably isn't the same
!      as GHS.  We don't have enough documentation on their conventions
!      to be compatible.
! 
!      * Tests of TARGET_SETUP_INCOMING_VARARGS need to be made runtime checks
!      since it depends on TARGET_GHS.  */
! #define TARGET_GHS (target_flags & MASK_GHS)
!  
! /* Don't do PC-relative calls, instead load the address of the target
!    function into a register and perform a register indirect call.  */
! #define TARGET_LONG_CALLS (target_flags & MASK_LONG_CALLS)
! 
! /* Whether to optimize space by using ep (r30) for pointers with small offsets
!    in basic blocks.  */
! #define TARGET_EP (target_flags & MASK_EP)
! 
! /* Whether to call out-of-line functions to save registers or not.  */
! #define TARGET_PROLOG_FUNCTION (target_flags & MASK_PROLOG_FUNCTION)
! 
! #define TARGET_V850    		((target_flags & MASK_CPU) == MASK_V850)
! 
! /* Whether to emit 2 byte per entry or 4 byte per entry switch tables.  */
! #define TARGET_BIG_SWITCH (target_flags & MASK_BIG_SWITCH)
! 
! /* General debug flag.  */
! #define TARGET_DEBUG 		(target_flags & MASK_DEBUG)
! #define TARGET_V850E   		((target_flags & MASK_V850E) == MASK_V850E)
! 
! #define TARGET_US_BIT_SET	(target_flags & MASK_US_BIT_SET)
! 
! /* Whether to assume that the SLD.B and SLD.H instructions only have small
!    displacement fields, thus allowing the generated code to run on any of
!    the V850 range of processors.  */
! #define TARGET_SMALL_SLD 	(target_flags & MASK_SMALL_SLD)
! 
! /* True if callt will not be used for function prolog & epilog.  */
! #define TARGET_DISABLE_CALLT 	(target_flags & MASK_DISABLE_CALLT)
! 
! /* False if r2 and r5 can be used by the compiler.  True if r2
!    and r5 are to be fixed registers (for compatibility with GHS).  */
! #define TARGET_NO_APP_REGS  	(target_flags & MASK_NO_APP_REGS)
! 
! #define TARGET_STRICT_ALIGN 	(target_flags & MASK_STRICT_ALIGN)
! 
! /* Macro to define tables used to set the flags.
!    This is a list in braces of pairs in braces,
!    each pair being { "NAME", VALUE }
!    where VALUE is the bits to set or minus the bits to clear.
!    An empty string NAME is used to identify the default VALUE.  */
! 
! #define TARGET_SWITCHES							\
!   {{ "ghs",			 MASK_GHS, N_("Support Green Hills ABI") }, \
!    { "no-ghs",			-MASK_GHS, "" },			\
!    { "long-calls",		 MASK_LONG_CALLS, 			\
!        				N_("Prohibit PC relative function calls") },\
!    { "no-long-calls",		-MASK_LONG_CALLS, "" },			\
!    { "ep",			 MASK_EP,				\
!                                 N_("Reuse r30 on a per function basis") }, \
!    { "no-ep",			-MASK_EP, "" },				\
!    { "prolog-function",		 MASK_PROLOG_FUNCTION, 			\
!        				N_("Use stubs for function prologues") }, \
!    { "no-prolog-function",	-MASK_PROLOG_FUNCTION, "" },		\
!    { "space",			 MASK_EP | MASK_PROLOG_FUNCTION, 	\
!        				N_("Same as: -mep -mprolog-function") }, \
!    { "debug",			 MASK_DEBUG, N_("Enable backend debugging") }, \
!    { "v850",		 	 MASK_V850,				\
!                                 N_("Compile for the v850 processor") },	\
!    { "v850",		 	 -(MASK_V850 ^ MASK_CPU), "" },		\
!    { "v850e1",			 MASK_V850E, N_("Compile for v850e1 processor") }, \
!    { "v850e1",		        -(MASK_V850E ^ MASK_CPU), "" }, /* Make sure that the other bits are cleared.  */ \
!    { "v850e",			 MASK_V850E, N_("Compile for v850e processor") }, \
!    { "v850e",		        -(MASK_V850E ^ MASK_CPU), "" }, /* Make sure that the other bits are cleared.  */ \
!    { "small-sld",		 MASK_SMALL_SLD, N_("Enable the use of the short load instructions") },	\
!    { "no-small-sld",		-MASK_SMALL_SLD, "" },			\
!    { "disable-callt",            MASK_DISABLE_CALLT, 			\
!        				N_("Do not use the callt instruction") },   \
!    { "no-disable-callt",        -MASK_DISABLE_CALLT, "" },             	\
!    { "US-bit-set",		 (MASK_US_BIT_SET | MASK_US_MASK_SET), "" },	\
!    { "no-US-bit-set",		-MASK_US_BIT_SET, "" },			\
!    { "no-US-bit-set",		 MASK_US_MASK_SET, "" },		\
!    { "app-regs",                -MASK_NO_APP_REGS, ""  },               \
!    { "no-app-regs",              MASK_NO_APP_REGS, 			\
!        				N_("Do not use registers r2 and r5") }, \
!    { "strict-align",             MASK_STRICT_ALIGN,			\
! 				N_("Enforce strict alignment") },       \
!    { "no-strict-align",         -MASK_STRICT_ALIGN, "" },		\
!    { "big-switch",		 MASK_BIG_SWITCH, 			\
!        				N_("Use 4 byte entries in switch tables") },\
!    { "",			 MASK_DEFAULT, ""}}
  
  /* Information about the various small memory areas.  */
  struct small_memory_info {
    const char *name;
-   const char *value;
    long max;
    long physical_max;
  };
--- 83,93 ----
    builtin_assert( "cpu=v850" );			\
  } while(0)
  
! #define MASK_CPU (MASK_V850 | MASK_V850E)
  
  /* Information about the various small memory areas.  */
  struct small_memory_info {
    const char *name;
    long max;
    long physical_max;
  };
*************** enum small_memory_type {
*** 230,259 ****
  
  extern struct small_memory_info small_memory[(int)SMALL_MEMORY_max];
  
- #define TARGET_OPTIONS							\
- {									\
-   { "tda=",	&small_memory[ (int)SMALL_MEMORY_TDA ].value,		\
-       N_("Set the max size of data eligible for the TDA area"), 0},	\
-   { "tda-",	&small_memory[ (int)SMALL_MEMORY_TDA ].value, "", 0},	\
-   { "sda=",	&small_memory[ (int)SMALL_MEMORY_SDA ].value, 		\
-       N_("Set the max size of data eligible for the SDA area"), 0},	\
-   { "sda-",	&small_memory[ (int)SMALL_MEMORY_SDA ].value, "", 0},	\
-   { "zda=",	&small_memory[ (int)SMALL_MEMORY_ZDA ].value, 		\
-       N_("Set the max size of data eligible for the ZDA area"), 0},	\
-   { "zda-",	&small_memory[ (int)SMALL_MEMORY_ZDA ].value, "", 0},	\
- }
- 
- /* Sometimes certain combinations of command options do not make
-    sense on a particular target machine.  You can define a macro
-    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
-    defined, is executed once just after all the command options have
-    been parsed.
- 
-    Don't use this macro to turn on various extra optimizations for
-    `-O'.  That is what `OPTIMIZATION_OPTIONS' is for.  */
- #define OVERRIDE_OPTIONS override_options ()
- 
- 
  /* Show we can debug even without a frame pointer.  */
  #define CAN_DEBUG_WITHOUT_FP
  
--- 104,109 ----
*************** #define REG_ALLOC_ORDER							\
*** 400,413 ****
     0,  1,  3,  4,  5, 30, 32, 33	/* fixed registers */		\
  }
  
! /* If TARGET_NO_APP_REGS is not defined then add r2 and r5 to
     the pool of fixed registers. See PR 14505.  */
  #define CONDITIONAL_REGISTER_USAGE  \
  {                                                       \
!   if (TARGET_NO_APP_REGS)                               \
      {                                                   \
!      fixed_regs[2] = 1;  call_used_regs[2] = 1;         \
!      fixed_regs[5] = 1;  call_used_regs[5] = 1;         \
      }                                                   \
  }
  
--- 250,263 ----
     0,  1,  3,  4,  5, 30, 32, 33	/* fixed registers */		\
  }
  
! /* If TARGET_APP_REGS is not defined then add r2 and r5 to
     the pool of fixed registers. See PR 14505.  */
  #define CONDITIONAL_REGISTER_USAGE  \
  {                                                       \
!   if (!TARGET_APP_REGS)                                 \
      {                                                   \
!       fixed_regs[2] = 1;  call_used_regs[2] = 1;        \
!       fixed_regs[5] = 1;  call_used_regs[5] = 1;        \
      }                                                   \
  }
  
Index: config/v850/v850.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/v850/v850.c,v
retrieving revision 1.98
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.98 v850.c
*** config/v850/v850.c	21 Mar 2005 18:01:28 -0000	1.98
--- config/v850/v850.c	6 Apr 2005 05:56:39 -0000
*************** #define streq(a,b) (strcmp (a, b) == 0)
*** 49,54 ****
--- 49,55 ----
  #endif
  
  /* Function prototypes for stupid compilers:  */
+ static bool v850_handle_option       (size_t, const char *, int);
  static void const_double_split       (rtx, HOST_WIDE_INT *, HOST_WIDE_INT *);
  static int  const_costs_int          (HOST_WIDE_INT, int);
  static int  const_costs		     (rtx, enum rtx_code);
*************** static int v850_arg_partial_bytes (CUMUL
*** 75,84 ****
  /* Information about the various small memory areas.  */
  struct small_memory_info small_memory[ (int)SMALL_MEMORY_max ] =
  {
!   /* name	value		max		physical max */
!   { "tda",	(char *)0,	0,		256 },
!   { "sda",	(char *)0,	0,		65536 },
!   { "zda",	(char *)0,	0,		32768 },
  };
  
  /* Names of the various data areas used on the v850.  */
--- 76,85 ----
  /* Information about the various small memory areas.  */
  struct small_memory_info small_memory[ (int)SMALL_MEMORY_max ] =
  {
!   /* name	max	physical max */
!   { "tda",	0,		256 },
!   { "sda",	0,		65536 },
!   { "zda",	0,		32768 },
  };
  
  /* Names of the various data areas used on the v850.  */
*************** #define TARGET_ENCODE_SECTION_INFO v850_
*** 115,120 ****
--- 116,126 ----
  #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
  #define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
  
+ #undef TARGET_DEFAULT_TARGET_FLAGS
+ #define TARGET_DEFAULT_TARGET_FLAGS (MASK_DEFAULT | MASK_APP_REGS)
+ #undef TARGET_HANDLE_OPTION
+ #define TARGET_HANDLE_OPTION v850_handle_option
+ 
  #undef TARGET_RTX_COSTS
  #define TARGET_RTX_COSTS v850_rtx_costs
  
*************** #define TARGET_ARG_PARTIAL_BYTES v850_ar
*** 144,192 ****
  
  struct gcc_target targetm = TARGET_INITIALIZER;
  
! /* Sometimes certain combinations of command options do not make
!    sense on a particular target machine.  You can define a macro
!    `OVERRIDE_OPTIONS' to take account of this.  This macro, if
!    defined, is executed once just after all the command options have
!    been parsed.
! 
!    Don't use this macro to turn on various extra optimizations for
!    `-O'.  That is what `OPTIMIZATION_OPTIONS' is for.  */
  
! void
! override_options (void)
  {
!   int i;
!   extern int atoi (const char *);
  
!   /* Parse -m{s,t,z}da=nnn switches */
!   for (i = 0; i < (int)SMALL_MEMORY_max; i++)
!     {
!       if (small_memory[i].value)
! 	{
! 	  if (!ISDIGIT (*small_memory[i].value))
! 	    error ("%s=%s is not numeric",
! 		   small_memory[i].name,
! 		   small_memory[i].value);
! 	  else
! 	    {
! 	      small_memory[i].max = atoi (small_memory[i].value);
! 	      if (small_memory[i].max > small_memory[i].physical_max)
! 		error ("%s=%s is too large",
! 		   small_memory[i].name,
! 		   small_memory[i].value);
! 	    }
! 	}
!     }
  
!   /* Make sure that the US_BIT_SET mask has been correctly initialized.  */
!   if ((target_flags & MASK_US_MASK_SET) == 0)
      {
!       target_flags |= MASK_US_MASK_SET;
!       target_flags &= ~MASK_US_BIT_SET;
      }
  }
- 
  
  static bool
  v850_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
--- 150,213 ----
  
  struct gcc_target targetm = TARGET_INITIALIZER;
  
! /* Set the maximum size of small memory area TYPE to the value given
!    by VALUE.  Return true if VALUE was syntactically correct.  VALUE
!    starts with the argument separator: either "-" or "=".  */
  
! static bool
! v850_handle_memory_option (enum small_memory_type type, const char *value)
  {
!   int i, size;
  
!   if (*value != '-' && *value != '=')
!     return false;
! 
!   value++;
!   for (i = 0; value[i]; i++)
!     if (!ISDIGIT (value[i]))
!       return false;
! 
!   size = atoi (value);
!   if (size > small_memory[type].physical_max)
!     error ("value passed to %<-m%s%> is too large", small_memory[type].name);
!   else
!     small_memory[type].max = size;
!   return true;
! }
  
! /* Implement TARGET_HANDLE_OPTION.  */
! 
! static bool
! v850_handle_option (size_t code, const char *arg, int value ATTRIBUTE_UNUSED)
! {
!   switch (code)
      {
!     case OPT_mspace:
!       target_flags |= MASK_EP | MASK_PROLOG_FUNCTION;
!       return true;
! 
!     case OPT_mv850:
!       target_flags &= ~(MASK_CPU ^ MASK_V850);
!       return true;
! 
!     case OPT_mv850e:
!     case OPT_mv850e1:
!       target_flags &= ~(MASK_CPU ^ MASK_V850E);
!       return true;
! 
!     case OPT_mtda:
!       return v850_handle_memory_option (SMALL_MEMORY_TDA, arg);
! 
!     case OPT_msda:
!       return v850_handle_memory_option (SMALL_MEMORY_SDA, arg);
! 
!     case OPT_mzda:
!       return v850_handle_memory_option (SMALL_MEMORY_ZDA, arg);
! 
!     default:
!       return true;
      }
  }
  
  static bool
  v850_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
diff -c /dev/null config/v850/v850.opt
*** /dev/null	2005-03-29 10:04:47.000000000 +0100
--- config/v850/v850.opt	2005-04-06 06:42:26.220553842 +0100
***************
*** 0 ****
--- 1,91 ----
+ ; Options for the NEC V850 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.
+ 
+ mapp-regs
+ Target Report Mask(APP_REGS)
+ Use registers r2 and r5
+ 
+ mbig-switch
+ Target Report Mask(BIG_SWITCH)
+ Use 4 byte entries in switch tables
+ 
+ mdebug
+ Target Report Mask(DEBUG)
+ Enable backend debugging
+ 
+ mdisable-callt
+ Target Report Mask(DISABLE_CALLT)
+ Do not use the callt instruction
+ 
+ mep
+ Target Report Mask(EP)
+ Reuse r30 on a per function basis
+ 
+ mghs
+ Target Report Mask(GHS)
+ Support Green Hills ABI
+ 
+ mlong-calls
+ Target Report Mask(LONG_CALLS)
+ Prohibit PC relative function calls
+ 
+ mprolog-function
+ Target Report Mask(PROLOG_FUNCTION)
+ Use stubs for function prologues
+ 
+ msda
+ Target RejectNegative Joined
+ Set the max size of data eligible for the SDA area
+ 
+ msmall-sld
+ Target Report Mask(SMALL_SLD)
+ Enable the use of the short load instructions
+ 
+ mspace
+ Target RejectNegative
+ Same as: -mep -mprolog-function
+ 
+ mtda
+ Target RejectNegative Joined
+ Set the max size of data eligible for the TDA area
+ 
+ mstrict-align
+ Target Report Mask(STRICT_ALIGN)
+ Enforce strict alignment
+ 
+ mUS-bit-set
+ Target Report Mask(US_BIT_SET)
+ 
+ mv850
+ Target Report RejectNegative Mask(V850)
+ Compile for the v850 processor
+ 
+ mv850e
+ Target Report RejectNegative Mask(V850E)
+ Compile for v850e processor
+ 
+ mv850e1
+ Target RejectNegative Mask(V850E) MaskExists
+ Compile for v850e1 processor
+ 
+ mzda
+ Target RejectNegative Joined
+ Set the max size of data eligible for the ZDA area


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