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] [ARC] Clean up arc header file.


This patch revamps the arc's header file by means of using separate
headers for different tool targets. Each target header file holds the
specific compiler backend macros definitions. Thus, we have:
 - elf.h is used for bare metal type of toolchains.
 - linux.h is used by our Linux type of toolchains.
 - big.h is used by big-endians toolchains.

This patch also cleans up arc specifics from config.gcc, consolidating
everything in one of the above new header files.


OK to apply?
Claudiu

gcc/
2016-07-29  Claudiu Zissulescu  <claziss@synopsys.com>

	* config.gcc (arc*-): Clean up, use arc/big.h, arc/elf.h, and
	arc/linux.h headers.
	* config/arc/arc.h (TARGET_OS_CPP_BUILTINS): Remove.
	(LINK_SPEC): Likewise.
	(ARC_TLS_EXTRA_START_SPEC): Likewise.
	(EXTRA_SPECS): Likewise.
	(STARTFILE_SPEC): Likewise.
	(ENDFILE_SPEC): Likewise.
	(LIB_SPEC): Likewise.
	(TARGET_SDATA_DEFAULT): Likewise.
	(TARGET_MMEDIUM_CALLS_DEFAULT): Likewise.
	(MULTILIB_DEFAULTS): Likewise.
	(DWARF2_UNWIND_INFO): Likewise.
	* config/arc/big.h: New file.
	* config/arc/elf.h: Likewise.
	* config/arc/linux.h: Likewise.
	* config/arc/t-uClibc: Remove.
---
 gcc/config.gcc          |  15 +++---
 gcc/config/arc/arc.h    | 120 +++++-------------------------------------------
 gcc/config/arc/big.h    |  22 +++++++++
 gcc/config/arc/elf.h    |  55 ++++++++++++++++++++++
 gcc/config/arc/linux.h  |  76 ++++++++++++++++++++++++++++++
 gcc/config/arc/t-uClibc |  20 --------
 6 files changed, 171 insertions(+), 137 deletions(-)
 create mode 100644 gcc/config/arc/big.h
 create mode 100644 gcc/config/arc/elf.h
 create mode 100644 gcc/config/arc/linux.h
 delete mode 100644 gcc/config/arc/t-uClibc

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 7c27546..8e41b31 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -319,6 +319,7 @@ arc*-*-*)
 	c_target_objs="arc-c.o"
 	cxx_target_objs="arc-c.o"
 	extra_options="${extra_options} arc/arc-tables.opt"
+	extra_headers="arc-simd.h"
 	;;
 arm*-*-*)
 	cpu_type=arm
@@ -1003,8 +1004,7 @@ alpha*-dec-*vms*)
 	tmake_file="${tmake_file} alpha/t-vms alpha/t-alpha"
 	;;
 arc*-*-elf*)
-	extra_headers="arc-simd.h"
-	tm_file="arc/arc-arch.h dbxelf.h elfos.h newlib-stdint.h ${tm_file}"
+	tm_file="arc/arc-arch.h dbxelf.h elfos.h newlib-stdint.h arc/elf.h ${tm_file}"
 	tmake_file="arc/t-multilib arc/t-arc"
 	extra_gcc_objs="driver-arc.o"
 	if test "x$with_cpu" != x; then
@@ -1021,15 +1021,12 @@ arc*-*-elf*)
 	*)	echo "with_endian=${with_endian} not supported."; exit 1 ;;
 	esac
 	case ${with_endian} in
-	big*)	tm_defines="DRIVER_ENDIAN_SELF_SPECS=\\\"%{!EL:%{!mlittle-endian:-mbig-endian}}\\\" ${tm_defines}"
+	big*)	tm_file="arc/big.h ${tm_file}"
 	esac
 	;;
 arc*-*-linux-uclibc*)
-	extra_headers="arc-simd.h"
-	tm_file="arc/arc-arch.h dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h ${tm_file}"
-	tmake_file="${tmake_file} arc/t-uClibc arc/t-arc"
-	tm_defines="${tm_defines} TARGET_SDATA_DEFAULT=0"
-	tm_defines="${tm_defines} TARGET_MMEDIUM_CALLS_DEFAULT=1"
+	tm_file="arc/arc-arch.h dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h arc/linux.h ${tm_file}"
+	tmake_file="${tmake_file} arc/t-arc"
 	extra_gcc_objs="driver-arc.o"
 	if test "x$with_cpu" != x; then
 		tm_defines="${tm_defines} TARGET_CPU_BUILD=PROCESSOR_$with_cpu"
@@ -1045,7 +1042,7 @@ arc*-*-linux-uclibc*)
 	*)	echo "with_endian=${with_endian} not supported."; exit 1 ;;
 	esac
 	case ${with_endian} in
-	big*)	tm_defines="DRIVER_ENDIAN_SELF_SPECS=\\\"%{!EL:%{!mlittle-endian:-mbig-endian}}\\\" ${tm_defines}"
+	big*)	tm_file="arc/big.h ${tm_file}"
 	esac
         ;;
 arm-wrs-vxworks)
diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
index da13ea1..549e698 100644
--- a/gcc/config/arc/arc.h
+++ b/gcc/config/arc/arc.h
@@ -1,14 +1,6 @@
 /* Definitions of target machine for GNU compiler, Synopsys DesignWare ARC cpu.
    Copyright (C) 1994-2017 Free Software Foundation, Inc.
 
-   Sources derived from work done by Sankhya Technologies (www.sankhya.com) on
-   behalf of Synopsys Inc.
-
-   Position Independent Code support added,Code cleaned up,
-   Comments and Support For ARC700 instructions added by
-   Saurabh Verma (saurabh.verma@codito.com)
-   Ramana Radhakrishnan(ramana.radhakrishnan@codito.com)
-
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify
@@ -57,32 +49,9 @@ along with GCC; see the file COPYING3.  If not see
 #define SYMBOL_REF_SHORT_CALL_P(X)	\
 	((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_SHORT_CALL) != 0)
 
-#undef ASM_SPEC
-#undef LINK_SPEC
-#undef STARTFILE_SPEC
-#undef ENDFILE_SPEC
-#undef SIZE_TYPE
-#undef PTRDIFF_TYPE
-#undef WCHAR_TYPE
-#undef WCHAR_TYPE_SIZE
-#undef ASM_APP_ON
-#undef ASM_APP_OFF
-#undef CC1_SPEC
-
 /* Names to predefine in the preprocessor for this target machine.  */
 #define TARGET_CPU_CPP_BUILTINS() arc_cpu_cpp_builtins (pfile)
 
-#if DEFAULT_LIBC == LIBC_UCLIBC
-
-#define TARGET_OS_CPP_BUILTINS() \
-  do \
-    { \
-      GNU_USER_TARGET_OS_CPP_BUILTINS (); \
-    } \
-  while (0)
-
-#endif /* DEFAULT_LIBC == LIBC_UCLIBC */
-
 /* Macros enabled by specific command line option.  FIXME: to be
    deprecatd.  */
 #define CPP_SPEC "\
@@ -95,6 +64,7 @@ along with GCC; see the file COPYING3.  If not see
 %{mlock:-D__Xlock} %{mswape:-D__Xswape} %{mrtsc:-D__Xrtsc} \
 %{mcpu=nps400:-D__NPS400__}"
 
+#undef CC1_SPEC
 #define CC1_SPEC "\
 %{EB:%{EL:%emay not use both -EB and -EL}} \
 %{EB:-mbig-endian} %{EL:-mlittle-endian} \
@@ -104,71 +74,16 @@ extern const char *arc_cpu_to_as (int argc, const char **argv);
 #define EXTRA_SPEC_FUNCTIONS			\
   { "cpu_to_as", arc_cpu_to_as },
 
+#undef ASM_SPEC
 #define ASM_SPEC  "%{mbig-endian|EB:-EB} %{EL} "			\
   "%:cpu_to_as(%{mcpu=*:%*}) %{mspfp*} %{mdpfp*} %{mfpu=fpuda*:-mfpuda}"
 
 #define OPTION_DEFAULT_SPECS						\
   {"cpu", "%{!mcpu=*:%{!mARC*:%{!marc*:%{!mA7:%{!mA6:-mcpu=%(VALUE)}}}}}" }
 
-#if DEFAULT_LIBC == LIBC_UCLIBC
-/* Note that the default is to link against dynamic libraries, if they are
-   available.  Override with -static.  */
-#define LINK_SPEC "%{h*} \
-		   %{static:-Bstatic} \
-		   %{symbolic:-Bsymbolic} \
-		   %{rdynamic:-export-dynamic}\
-		   -dynamic-linker /lib/ld-uClibc.so.0 \
-		   -X %{mbig-endian:-EB} \
-		   %{EB} %{EL} \
-		   %{marclinux*} \
-		   %{!marclinux*: -marclinux} \
-		   %{!z:-z max-page-size=0x2000 -z common-page-size=0x2000} \
-		   %{shared:-shared}"
-#else
-#define LINK_SPEC "%{mbig-endian:-EB} %{EB} %{EL}"
-#endif
-
-#if DEFAULT_LIBC != LIBC_UCLIBC
-#define ARC_TLS_EXTRA_START_SPEC "crttls.o%s"
-
-#define EXTRA_SPECS \
-  { "arc_tls_extra_start_spec", ARC_TLS_EXTRA_START_SPEC }, \
-
-#define STARTFILE_SPEC "%{pg|p:gcrt0.o%s}%{!pg:%{!p:crt0.o%s}} crti%O%s " \
-  "%(arc_tls_extra_start_spec) crtbegin.o%s"
-#else
-#define STARTFILE_SPEC							\
-  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC)
-#endif
-
-#if DEFAULT_LIBC != LIBC_UCLIBC
-#define ENDFILE_SPEC "crtend.o%s crtn%O%s"
-#else
-#define ENDFILE_SPEC							\
-  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
-#endif
-
-#if DEFAULT_LIBC == LIBC_UCLIBC
-#undef LIB_SPEC
-#define LIB_SPEC  \
-  "%{pthread:-lpthread} \
-   %{shared:-lc} \
-   %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
-#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
-#else
-#undef LIB_SPEC
-#define LIB_SPEC "%{!shared:%{g*:-lg} -lc}"
-#endif
-
 #ifndef DRIVER_ENDIAN_SELF_SPECS
 #define DRIVER_ENDIAN_SELF_SPECS ""
 #endif
-#ifndef TARGET_SDATA_DEFAULT
-#define TARGET_SDATA_DEFAULT 1
-#endif
-#ifndef TARGET_MMEDIUM_CALLS_DEFAULT
-#define TARGET_MMEDIUM_CALLS_DEFAULT 0
-#endif
 
 #define DRIVER_SELF_SPECS DRIVER_ENDIAN_SELF_SPECS		   \
   "%{mARC600|mA6: -mcpu=arc600 %<mARC600 %<mA6 %<mARC600}"	   \
@@ -226,12 +141,6 @@ extern enum base_architecture arc_base_cpu;
 #define TARGET_HS (arc_base_cpu == BASE_ARCH_hs)
 #define TARGET_V2 (TARGET_EM || TARGET_HS)
 
-#ifdef ARC_MULTILIB_CPU_DEFAULT
-# ifndef MULTILIB_DEFAULTS
-#  define MULTILIB_DEFAULTS { "mcpu=" ARC_MULTILIB_CPU_DEFAULT }
-# endif
-#endif
-
 #ifndef UNALIGNED_ACCESS_DEFAULT
 #define UNALIGNED_ACCESS_DEFAULT 0
 #endif
@@ -314,15 +223,12 @@ if (GET_MODE_CLASS (MODE) == MODE_INT		\
    `BIGGEST_ALIGNMENT' and `BIGGEST_FIELD_ALIGNMENT' to the
    alignment) is COMPUTED.  It overrides alignment only if the field
    alignment has not been set by the `__attribute__ ((aligned (N)))'
-   construct.
-*/
+   construct.  */
 
 #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \
 (TYPE_MODE (strip_array_types (TREE_TYPE (FIELD))) == DFmode \
  ? MIN ((COMPUTED), 32) : (COMPUTED))
 
-
-
 /* No data type wants to be aligned rounder than this.  */
 /* This is bigger than currently necessary for the ARC.  If 8 byte floats are
    ever added it's not clear whether they'll need such alignment or not.  For
@@ -373,13 +279,18 @@ if (GET_MODE_CLASS (MODE) == MODE_INT		\
 /* Define this as 1 if `char' should by default be signed; else as 0.  */
 #define DEFAULT_SIGNED_CHAR 0
 
+#undef SIZE_TYPE
 #define SIZE_TYPE "unsigned int"
+
+#undef PTRDIFF_TYPE
 #define PTRDIFF_TYPE "int"
+
+#undef WCHAR_TYPE
 #define WCHAR_TYPE "int"
-#define WCHAR_TYPE_SIZE 32
 
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
 
-/* ashwin : shifted from arc.c:102 */
 #define PROGRAM_COUNTER_REGNO 63
 
 /* Standard register usage.  */
@@ -1162,10 +1073,12 @@ arc_select_cc_mode (OP, X, Y)
 
 /* Output to assembler file text saying following lines
    may contain character constants, extra white space, comments, etc.  */
+#undef ASM_APP_ON
 #define ASM_APP_ON ""
 
 /* Output to assembler file text saying following lines
    no longer contain unusual constructs.  */
+#undef ASM_APP_OFF
 #define ASM_APP_OFF ""
 
 /* Globalizing directive for a label.  */
@@ -1461,15 +1374,6 @@ extern int arc_return_address_regs[4];
 
 /* Frame info.  */
 
-/* Define this macro to 0 if your target supports DWARF 2 frame unwind
-   information, but it does not yet work with exception handling.  */
-/* N.B. the below test is valid in an #if, but not in a C expression.  */
-#if DEFAULT_LIBC == LIBC_UCLIBC
-#define DWARF2_UNWIND_INFO 1
-#else
-#define DWARF2_UNWIND_INFO 0
-#endif
-
 #define EH_RETURN_DATA_REGNO(N)  ((N) < 2 ? (N) : INVALID_REGNUM)
 
 #define EH_RETURN_STACKADJ_RTX   gen_rtx_REG (Pmode, 2)
diff --git a/gcc/config/arc/big.h b/gcc/config/arc/big.h
new file mode 100644
index 0000000..2ddad85
--- /dev/null
+++ b/gcc/config/arc/big.h
@@ -0,0 +1,22 @@
+/* Definition of big endian ARC machine for GNU compiler.
+
+   Copyright (C) 2016 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/>.  */
+
+#undef DRIVER_ENDIAN_SELF_SPECS
+#define DRIVER_ENDIAN_SELF_SPECS "%{!EL:%{!mlittle-endian:-mbig-endian}}"
diff --git a/gcc/config/arc/elf.h b/gcc/config/arc/elf.h
new file mode 100644
index 0000000..96565e5
--- /dev/null
+++ b/gcc/config/arc/elf.h
@@ -0,0 +1,55 @@
+/* Target macros for arc*-elf targets.
+
+   Copyright (C) 2016 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/>.  */
+
+#undef DWARF2_UNWIND_INFO
+#define DWARF2_UNWIND_INFO 0
+
+#undef LINK_SPEC
+#define LINK_SPEC "%{mbig-endian:-EB} %{EB} %{EL}"
+
+#define ARC_TLS_EXTRA_START_SPEC "crttls.o%s"
+
+#define EXTRA_SPECS \
+  { "arc_tls_extra_start_spec", ARC_TLS_EXTRA_START_SPEC }, \
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "%{pg|p:gcrt0.o%s}%{!pg:%{!p:crt0.o%s}} crti%O%s " \
+  "%(arc_tls_extra_start_spec) crtbegin.o%s"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC "crtend.o%s crtn%O%s"
+
+/* Leave the linker script to choose the appropriate libraries.  */
+#undef LIB_SPEC
+#define LIB_SPEC ""
+
+/* SDATA default for elf.  */
+#undef TARGET_SDATA_DEFAULT
+#define TARGET_SDATA_DEFAULT 1
+
+/* We no medium calls.  */
+#undef TARGET_MMEDIUM_CALLS_DEFAULT
+#define TARGET_MMEDIUM_CALLS_DEFAULT 0
+
+#ifdef ARC_MULTILIB_CPU_DEFAULT
+# ifndef MULTILIB_DEFAULTS
+#  define MULTILIB_DEFAULTS { "mcpu=" ARC_MULTILIB_CPU_DEFAULT }
+# endif
+#endif
diff --git a/gcc/config/arc/linux.h b/gcc/config/arc/linux.h
new file mode 100644
index 0000000..e4a881f
--- /dev/null
+++ b/gcc/config/arc/linux.h
@@ -0,0 +1,76 @@
+/* Target macros for arc*-*-linux targets.
+
+   Copyright (C) 2016 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/>.  */
+
+/* Enable DWARF 2 exceptions.  */
+#undef DWARF2_UNWIND_INFO
+#define DWARF2_UNWIND_INFO 1
+
+#define TARGET_OS_CPP_BUILTINS()		\
+  do						\
+    {						\
+      GNU_USER_TARGET_OS_CPP_BUILTINS ();	\
+    }						\
+  while (0)
+
+#define GLIBC_DYNAMIC_LINKER   "/lib/ld-linux.so.2"
+#define UCLIBC_DYNAMIC_LINKER  "/lib/ld-uClibc.so.0"
+
+/* Note that the default is to link against dynamic libraries, if they are
+   available.  Override with -static.  */
+#undef LINK_SPEC
+#define LINK_SPEC "%{h*} \
+  %{static:-Bstatic} \
+  %{shared:-shared} \
+  %{symbolic:-Bsymbolic} \
+  %{!static: \
+    %{rdynamic:-export-dynamic} \
+    %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
+  -X \
+  %{mbig-endian:-EB} %{EB} %{EL} \
+  %{!z:-z max-page-size=0x2000 -z common-page-size=0x2000} \
+  -marclinux"
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC							\
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_STARTFILE_SPEC, ANDROID_STARTFILE_SPEC)
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC							\
+  LINUX_OR_ANDROID_LD (GNU_USER_TARGET_ENDFILE_SPEC, ANDROID_ENDFILE_SPEC)
+
+#undef LIB_SPEC
+#define LIB_SPEC  \
+  "%{pthread:-lpthread} \
+   %{shared:-lc} \
+   %{!shared:%{profile:-lc_p}%{!profile:-lc}}"
+
+#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
+
+/* No SDATA default for linux.  */
+#undef TARGET_SDATA_DEFAULT
+#define TARGET_SDATA_DEFAULT 0
+
+/* We have medium calls.  */
+#undef TARGET_MMEDIUM_CALLS_DEFAULT
+#define TARGET_MMEDIUM_CALLS_DEFAULT 1
+
+/* We do not have any MULTILIB_OPTIONS specified, so there are no
+   MULTILIB_DEFAULTS.  */
+#undef  MULTILIB_DEFAULTS
diff --git a/gcc/config/arc/t-uClibc b/gcc/config/arc/t-uClibc
deleted file mode 100644
index 96417a0..0000000
--- a/gcc/config/arc/t-uClibc
+++ /dev/null
@@ -1,20 +0,0 @@
-# GCC Makefile fragment for Synopsys DesignWare ARC with uClibc
-
-# Copyright (C) 2007-2017 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/>.
-
-MULTILIB_EXTRA_OPTS = mno-sdata
-- 
1.9.1


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