From 8d12174db5a92005143deae74b57e553cfa97266 Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Mon, 26 Sep 2011 19:04:35 +0000 Subject: [PATCH] Move target CPP macro handling to C file and add __VIS/__VIS__. * config/sparc/sparc-c.c: New file implementing sparc_target_macros, which will now define __VIS and __VIS__ when -mvis is enabled. * config/sparc/t-sparc: Likewise. * config.gcc: Add sparc-c.o to c_target_objs and cxx_target_objs, and add t-sparc to tmake_file for all sparc targets. * config/sparc/sparc-protos.h (sparc_target_macros): Declare. * config/sparc/sparc.h (TARGE_CPU_CPP_BUILTINS): Call it. From-SVN: r179210 --- gcc/ChangeLog | 10 +++++++ gcc/config.gcc | 30 +++++++++++-------- gcc/config/sparc/sparc-c.c | 53 +++++++++++++++++++++++++++++++++ gcc/config/sparc/sparc-protos.h | 1 + gcc/config/sparc/sparc.h | 20 +------------ gcc/config/sparc/t-sparc | 36 ++++++++++++++++++++++ 6 files changed, 119 insertions(+), 31 deletions(-) create mode 100644 gcc/config/sparc/sparc-c.c create mode 100644 gcc/config/sparc/t-sparc diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 71a8d88d7a1..309eca549df 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2011-09-26 David S. Miller + + * config/sparc/sparc-c.c: New file implementing sparc_target_macros, + which will now define __VIS and __VIS__ when -mvis is enabled. + * config/sparc/t-sparc: Likewise. + * config.gcc: Add sparc-c.o to c_target_objs and cxx_target_objs, + and add t-sparc to tmake_file for all sparc targets. + * config/sparc/sparc-protos.h (sparc_target_macros): Declare. + * config/sparc/sparc.h (TARGE_CPU_CPP_BUILTINS): Call it. + 2011-09-26 Georg-Johann Lay * config/avr/avr.md (peephole casesi+2): Use -1 instead of 65536. diff --git a/gcc/config.gcc b/gcc/config.gcc index 7183f269c48..cf11364fd95 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -422,6 +422,8 @@ score*-*-*) ;; sparc*-*-*) cpu_type=sparc + c_target_objs="sparc-c.o" + cxx_target_objs="sparc-c.o" extra_headers="visintrin.h" need_64bit_hwint=yes ;; @@ -2457,32 +2459,32 @@ sparc-*-elf*) tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h sparc/sysv4.h sparc/sp-elf.h" case ${target} in *-leon-*) - tmake_file="sparc/t-leon" + tmake_file="sparc/t-sparc sparc/t-leon" ;; *-leon[3-9]*) - tmake_file="sparc/t-leon3" + tmake_file="sparc/t-sparc sparc/t-leon3" ;; *) - tmake_file="sparc/t-elf" + tmake_file="sparc/t-sparc sparc/t-elf" ;; esac ;; sparc-*-rtems*) tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h sparc/sp-elf.h sparc/rtemself.h rtems.h newlib-stdint.h" - tmake_file="sparc/t-elf t-rtems" + tmake_file="sparc/t-sparc sparc/t-elf t-rtems" ;; sparc-*-linux*) tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h gnu-user.h linux.h glibc-stdint.h" extra_options="${extra_options} sparc/long-double-switch.opt" case ${target} in *-leon-*) - tmake_file="${tmake_file} sparc/t-leon" + tmake_file="${tmake_file} sparc/t-sparc sparc/t-leon" ;; *-leon[3-9]*) - tmake_file="${tmake_file} sparc/t-leon3" + tmake_file="${tmake_file} sparc/t-sparc sparc/t-leon3" ;; *) - tmake_file="${tmake_file} sparc/t-linux" + tmake_file="${tmake_file} sparc/t-sparc sparc/t-linux" ;; esac if test x$enable_targets = xall; then @@ -2497,6 +2499,7 @@ sparc-*-netbsdelf*) tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h netbsd.h netbsd-elf.h sparc/netbsd-elf.h" extra_options="${extra_options} netbsd.opt netbsd-elf.opt" extra_options="${extra_options} sparc/long-double-switch.opt" + tmake_file="${tmake_file} sparc/t-sparc" ;; sparc*-*-solaris2*) tm_file="sparc/biarch64.h ${tm_file} ${sol2_tm_file} sol2-bi.h" @@ -2508,25 +2511,26 @@ sparc*-*-solaris2*) test x$with_cpu != x || with_cpu=v9 ;; esac - tmake_file="${tmake_file} sparc/t-sol2-64" + tmake_file="${tmake_file} sparc/t-sparc sparc/t-sol2-64" ;; sparc-wrs-vxworks) tm_file="${tm_file} elfos.h sparc/sysv4.h vx-common.h vxworks.h sparc/vxworks.h" - tmake_file="${tmake_file} sparc/t-vxworks" + tmake_file="${tmake_file} sparc/t-sparc sparc/t-vxworks" ;; sparc64-*-elf*) tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h sparc/sysv4.h sparc/sp64-elf.h" extra_options="${extra_options} sparc/little-endian.opt" + tmake_file="${tmake_file} sparc/t-sparc" ;; sparc64-*-rtems*) tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h sparc/sysv4.h sparc/sp64-elf.h sparc/rtemself.h rtems.h" extra_options="${extra_options} sparc/little-endian.opt" - tmake_file="${tmake_file} t-rtems" + tmake_file="${tmake_file} sparc/t-sparc t-rtems" ;; sparc64-*-linux*) tm_file="sparc/biarch64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h gnu-user.h linux.h glibc-stdint.h sparc/default-64.h sparc/linux64.h" extra_options="${extra_options} sparc/long-double-switch.opt" - tmake_file="${tmake_file} sparc/t-linux sparc/t-linux64" + tmake_file="${tmake_file} sparc/t-sparc sparc/t-linux sparc/t-linux64" extra_parts="${extra_parts} crtfastmath.o" ;; sparc64-*-freebsd*|ultrasparc-*-freebsd*) @@ -2538,13 +2542,14 @@ sparc64-*-freebsd*|ultrasparc-*-freebsd*) *) echo "$with_cpu not supported for freebsd target"; exit 1 ;; esac extra_parts="${extra_parts} crtfastmath.o" + tmake_file="${tmake_file} sparc/t-sparc" ;; sparc64-*-netbsd*) tm_file="sparc/biarch64.h ${tm_file}" tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h netbsd.h netbsd-elf.h sparc/netbsd-elf.h" extra_options="${extra_options} netbsd.opt netbsd-elf.opt" extra_options="${extra_options} sparc/long-double-switch.opt" - tmake_file="${tmake_file} sparc/t-netbsd64" + tmake_file="${tmake_file} sparc/t-sparc sparc/t-netbsd64" ;; sparc64-*-openbsd*) tm_file="sparc/openbsd1-64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h sparc/sp64-elf.h" @@ -2553,6 +2558,7 @@ sparc64-*-openbsd*) extra_options="${extra_options} sparc/little-endian.opt" gas=yes gnu_ld=yes with_cpu=ultrasparc + tmake_file="${tmake_file} sparc/t-sparc" ;; spu-*-elf*) tm_file="dbxelf.h elfos.h spu/spu-elf.h spu/spu.h newlib-stdint.h" diff --git a/gcc/config/sparc/sparc-c.c b/gcc/config/sparc/sparc-c.c new file mode 100644 index 00000000000..6e30950df0f --- /dev/null +++ b/gcc/config/sparc/sparc-c.c @@ -0,0 +1,53 @@ +/* Subroutines used for macro/preprocessor support on SPARC. + Copyright (C) 2011 + 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 +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "tree.h" +#include "tm_p.h" +#include "flags.h" +#include "c-family/c-common.h" +#include "c-family/c-pragma.h" +#include "cpplib.h" + +void +sparc_target_macros (void) +{ + builtin_define_std ("sparc"); + + if (TARGET_64BIT) + { + cpp_assert (parse_in, "cpu=sparc64"); + cpp_assert (parse_in, "machine=sparc64"); + } + else + { + cpp_assert (parse_in, "cpu=sparc"); + cpp_assert (parse_in, "machine=sparc"); + } + + if (TARGET_VIS) + { + cpp_define (parse_in, "__VIS__=0x100"); + cpp_define (parse_in, "__VIS=0x100"); + } +} diff --git a/gcc/config/sparc/sparc-protos.h b/gcc/config/sparc/sparc-protos.h index a5e25879793..dfa461a5f58 100644 --- a/gcc/config/sparc/sparc-protos.h +++ b/gcc/config/sparc/sparc-protos.h @@ -47,6 +47,7 @@ extern int short_branch (int, int); extern void sparc_profile_hook (int); extern void sparc_override_options (void); extern void sparc_output_scratch_registers (FILE *); +extern void sparc_target_macros (void); #ifdef RTX_CODE extern enum machine_mode select_cc_mode (enum rtx_code, rtx, rtx); diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index ad1e0eff435..cccd4446c91 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -105,25 +105,7 @@ struct processor_costs { extern const struct processor_costs *sparc_costs; -/* Target CPU builtins. FIXME: Defining sparc is for the benefit of - Solaris only; otherwise just define __sparc__. Sadly the headers - are such a mess there is no Solaris-specific header. */ -#define TARGET_CPU_CPP_BUILTINS() \ - do \ - { \ - builtin_define_std ("sparc"); \ - if (TARGET_64BIT) \ - { \ - builtin_assert ("cpu=sparc64"); \ - builtin_assert ("machine=sparc64"); \ - } \ - else \ - { \ - builtin_assert ("cpu=sparc"); \ - builtin_assert ("machine=sparc"); \ - } \ - } \ - while (0) +#define TARGET_CPU_CPP_BUILTINS() sparc_target_macros () /* Specify this in a cover file to provide bi-architecture (32/64) support. */ /* #define SPARC_BI_ARCH */ diff --git a/gcc/config/sparc/t-sparc b/gcc/config/sparc/t-sparc new file mode 100644 index 00000000000..ea9d0e824e2 --- /dev/null +++ b/gcc/config/sparc/t-sparc @@ -0,0 +1,36 @@ +# General rules that all sparc/ targets must have. +# +# Copyright (C) 2011 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 +# . + +sparc.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ + $(TREE_H) $(RTL_H) $(REGS_H) hard-reg-set.h insn-config.h \ + insn-codes.h conditions.h output.h $(INSN_ATTR_H) $(FLAGS_H) \ + $(FUNCTION_H) $(EXCEPT_H) $(EXPR_H) $(OPTABS_H) $(RECOG_H) \ + $(DIAGNOSTIC_CORE_H) $(GGC_H) $(TM_P_H) debug.h $(TARGET_H) \ + $(TARGET_DEF_H) $(COMMON_TARGET_H) $(CFGLAYOUT_H) $(GIMPLE_H) \ + langhooks.h reload.h $(PARAMS_H) $(DF_H) dwarf2out.h $(OPTS_H) \ + gt-sparc.h + +sparc-c.o: $(srcdir)/config/sparc/sparc-c.c \ + $(srcdir)/config/sparc/sparc-protos.h \ + $(CONFIG_H) $(SYSTEM_H) $(CPPLIB_H) $(FLAGS_H) \ + $(TM_P_H) coretypes.h $(TM_H) $(TREE_H) \ + $(C_COMMON_H) $(C_PRAGMA_H) + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(srcdir)/config/sparc/sparc-c.c