This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[ColdFire 12/63] Add new predefined macros
This patch adds some new cpp macros. Specifically:
- it adds __mcfv[2345]__ macros, to go alongside the existing __mcfv4e__.
- it defines __mcffpu__ when the ColdFire FPU is enabled
- it defines __mcf_cpu_CPU and __mcf_family_FAMILY when a ColdFire CPU
is selected. (These macros are used in the libgloss crt code.)
The patch also documents some existing macros in invoke.texi.
Richard
gcc/
200x-xx-xx Nathan Sidwell <nathan@codesourcery.com>
Richard Sandiford <richard@codesourcery.com>
* doc/invoke.texi: Document the macros that are defined by
m68k's -mtune and -mhard-float options.
* config/m68k/m68k-protos.h (m68k_cpp_cpu_ident) Declare.
(m68k_cpp_cpu_family): Likewise.
* config/m68k/m68k.h (TARGET_CPU_CPP_BUILTINS): Add a full set
of __ucfv*__ macros. Define __mcffpu__ if generating code for
ColdFire FPUs. Define __mcf_cpu_* and __mcf_family_* macros.
* config/m68k/m68k.c (m68k_cpp_cpu_ident): New function.
(m68k_cpp_cpu_family): Likewise.
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi 2007-01-09 15:01:52.000000000 +0000
+++ gcc/doc/invoke.texi 2007-01-09 15:01:54.000000000 +0000
@@ -10284,6 +10284,10 @@ below, which also classifies the CPUs in
@var{arch} is compatible with @var{cpu}. Other combinations of
@option{-mcpu} and @option{-march} are rejected.
+gcc defines the macro @samp{__mcf_cpu_@var{cpu}} when ColdFire target
+@var{cpu} is selected. It also defines @samp{__mcf_family_@var{family}},
+where the value of @var{family} is given by the table above.
+
@item -mtune=@var{tune}
@opindex mtune
Tune the code for a particular microarchitecture, within the
@@ -10299,6 +10303,17 @@ to run relatively well on 68020, 68030 a
as well. These two options select the same tuning decisions as
@option{-m68020-40} and @option{-m68020-60} respectively.
+gcc defines the macros @samp{__mc@var{arch}} and @samp{__mc@var{arch}__}
+when tuning for 680x0 architecture @var{arch}. It also defines
+@samp{mc@var{arch}} unless either @option{-ansi} or a non-GNU @option{-std}
+option is used. If gcc is tuning for a range of architectures,
+as selected by @option{-mtune=68020-40} or @option{-mtune=68020-60},
+it defines the macros for every architecture in the range.
+
+gcc also defines the macro @samp{__m@var{uarch}__} when tuning for
+ColdFire microarchitecture @var{uarch}, where @var{uarch} is one
+of the arguments given above.
+
@item -m68000
@itemx -mc68000
@opindex m68000
@@ -10421,7 +10436,9 @@ The option is equivalent to @option{-mar
@opindex mhard-float
@opindex m68881
Generate floating-point instructions. This is the default for 68020
-and above, and for ColdFire devices that have an FPU.
+and above, and for ColdFire devices that have an FPU. It defines the
+macro @samp{__HAVE_68881__} on M680x0 targets and @samp{__mcffpu__}
+on ColdFire targets.
@item -msoft-float
@opindex msoft-float
Index: gcc/config/m68k/m68k-protos.h
===================================================================
--- gcc/config/m68k/m68k-protos.h 2007-01-09 15:01:42.000000000 +0000
+++ gcc/config/m68k/m68k-protos.h 2007-01-09 15:01:54.000000000 +0000
@@ -61,5 +61,7 @@ extern bool m68k_regno_mode_ok (int, enu
extern int flags_in_68881 (void);
extern bool use_return_insn (void);
extern void override_options (void);
+extern const char *m68k_cpp_cpu_ident (const char *);
+extern const char *m68k_cpp_cpu_family (const char *);
extern void init_68881_table (void);
extern int m68k_hard_regno_rename_ok(unsigned int, unsigned int);
Index: gcc/config/m68k/m68k.h
===================================================================
--- gcc/config/m68k/m68k.h 2007-01-09 15:01:54.000000000 +0000
+++ gcc/config/m68k/m68k.h 2007-01-09 15:01:54.000000000 +0000
@@ -107,6 +107,26 @@ #define TARGET_CPU_CPP_BUILTINS() \
builtin_define_std ("mc68020"); \
break; \
\
+ case ucfv2: \
+ builtin_define ("__mcfv2__"); \
+ break; \
+ \
+ case ucfv3: \
+ builtin_define ("__mcfv3__"); \
+ break; \
+ \
+ case ucfv4: \
+ builtin_define ("__mcfv4__"); \
+ break; \
+ \
+ case ucfv4e: \
+ builtin_define ("__mcfv4e__"); \
+ break; \
+ \
+ case ucfv5: \
+ builtin_define ("__mcfv5__"); \
+ break; \
+ \
default: \
break; \
} \
@@ -116,7 +136,16 @@ #define TARGET_CPU_CPP_BUILTINS() \
\
if (TARGET_COLDFIRE) \
{ \
+ const char *tmp; \
+ \
+ tmp = m68k_cpp_cpu_ident ("cf"); \
+ if (tmp) \
+ builtin_define (tmp); \
+ tmp = m68k_cpp_cpu_family ("cf"); \
+ if (tmp) \
+ builtin_define (tmp); \
builtin_define ("__mcoldfire__"); \
+ \
if (TARGET_ISAC) \
builtin_define ("__mcfisac__"); \
else if (TARGET_ISAB) \
@@ -152,10 +181,11 @@ #define TARGET_CPU_CPP_BUILTINS() \
break; \
} \
} \
- if (m68k_tune == ucfv4e) \
- builtin_define ("__mcfv4e__"); \
} \
\
+ if (TARGET_COLDFIRE_FPU) \
+ builtin_define ("__mcffpu__"); \
+ \
if (TARGET_CF_HWDIV) \
builtin_define ("__mcfhwdiv__"); \
\
Index: gcc/config/m68k/m68k.c
===================================================================
--- gcc/config/m68k/m68k.c 2007-01-09 15:01:53.000000000 +0000
+++ gcc/config/m68k/m68k.c 2007-01-09 15:01:54.000000000 +0000
@@ -540,6 +540,30 @@ override_options (void)
SUBTARGET_OVERRIDE_OPTIONS;
}
+
+/* Generate a macro of the form __mPREFIX_cpu_NAME, where PREFIX is the
+ given argument and NAME is the argument passed to -mcpu. Return NULL
+ if -mcpu was not passed. */
+
+const char *
+m68k_cpp_cpu_ident (const char *prefix)
+{
+ if (!m68k_cpu_entry)
+ return NULL;
+ return concat ("__m", prefix, "_cpu_", m68k_cpu_entry->name, NULL);
+}
+
+/* Generate a macro of the form __mPREFIX_family_NAME, where PREFIX is the
+ given argument and NAME is the name of the representative device for
+ the -mcpu argument's family. Return NULL if -mcpu was not passed. */
+
+const char *
+m68k_cpp_cpu_family (const char *prefix)
+{
+ if (!m68k_cpu_entry)
+ return NULL;
+ return concat ("__m", prefix, "_family_", m68k_cpu_entry->family, NULL);
+}
/* Return nonzero if FUNC is an interrupt function as specified by the
"interrupt_handler" attribute. */