This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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] gas/arc: Allow --with-cpu configure option to change default cpu


The motivation for the patch below is to allow a vendor of a specific
arc variant toolchain to build an assembler that, by default, does the
right thing.  By this, I mean, assembles for their prefered choice of cpu.

The solution I propose is to add a --with-cpu=NAME configure option (a
similar flag is already used by other targets in GCC) that sets up a
default value in config.h, this default is then used in
config/tc-arc.c if the user of the built tools does not explicitly
select a cpu type.

If there's a better solution, or if I've gone wrong with the autotools
side of things, then all suggestions for improvements are welcome.

Thanks,
Andrew

---

Add a new configure time option --with-cpu=CPU that can be used to
change the default cpu selection.

If the user specifies --with-cpu=FOO at configure time then the constant
TARGET_WITH_CPU will be defined to "FOO" in config.h, the
TARGET_WITH_CPU constant can then be used in the config/tc-*.c code as a
default string to select an appropriate cpu if the user does not
explicitly select a cpu at gas run-time.

This commit only implements the default cpu selection for arc.

gas/ChangeLog:

	* config.in (TARGET_WITH_CPU): Undefine.
	* configure.ac: Add --with-cpu support, and define in config.h.
	* configure: Regenerate.
	* config/tc-arc.c: Use TARGET_WITH_CPU to select default CPU.
---
 gas/ChangeLog       |  7 +++++++
 gas/config.in       |  3 +++
 gas/config/tc-arc.c |  6 +++++-
 gas/configure       | 18 ++++++++++++++++--
 gas/configure.ac    |  5 +++++
 5 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/gas/config.in b/gas/config.in
index e06f160..5129c28 100644
--- a/gas/config.in
+++ b/gas/config.in
@@ -318,6 +318,9 @@
 /* Target vendor. */
 #undef TARGET_VENDOR
 
+/* Target specific CPU. */
+#undef TARGET_WITH_CPU
+
 /* Use b modifier when opening binary files? */
 #undef USE_BINARY_FOPEN
 
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index a5b9a98..a939565 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -51,6 +51,10 @@
 /* Equal to MAX_PRECISION in atof-ieee.c.  */
 #define MAX_LITTLENUMS 6
 
+#ifndef TARGET_WITH_CPU
+#define TARGET_WITH_CPU "arc700"
+#endif /* TARGET_WITH_CPU */
+
 /* Enum used to enumerate the relaxable ins operands.  */
 enum rlx_operand_type
 {
@@ -2461,7 +2465,7 @@ md_begin (void)
   const struct arc_opcode *opcode = arc_opcodes;
 
   if (!mach_type_specified_p)
-    arc_select_cpu ("arc700");
+    arc_select_cpu (TARGET_WITH_CPU);
 
   /* The endianness can be chosen "at the factory".  */
   target_big_endian = byte_order == BIG_ENDIAN;
diff --git a/gas/configure b/gas/configure
index b6298b5..12064d5 100755
--- a/gas/configure
+++ b/gas/configure
@@ -771,6 +771,7 @@ enable_x86_relax_relocations
 enable_elf_stt_common
 enable_werror
 enable_build_warnings
+with_cpu
 enable_nls
 enable_maintainer_mode
 with_system_zlib
@@ -1435,6 +1436,7 @@ Optional Packages:
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-cpu=CPU          default cpu variant is CPU
   --with-system-zlib      use installed libz
 
 Some influential environment variables:
@@ -10982,7 +10984,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10985 "configure"
+#line 10987 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11088,7 +11090,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11091 "configure"
+#line 11093 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11828,6 +11830,13 @@ fi
 ac_config_headers="$ac_config_headers config.h:config.in"
 
 
+
+# Check whether --with-cpu was given.
+if test "${with_cpu+set}" = set; then :
+  withval=$with_cpu;
+fi
+
+
 # PR 14072
 
 
@@ -12870,6 +12879,11 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
+cat >>confdefs.h <<_ACEOF
+#define TARGET_WITH_CPU "${with_cpu}"
+_ACEOF
+
+
 for ac_prog in 'bison -y' byacc
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
diff --git a/gas/configure.ac b/gas/configure.ac
index 8f71825..2bd0e02 100644
--- a/gas/configure.ac
+++ b/gas/configure.ac
@@ -106,6 +106,10 @@ AM_BINUTILS_WARNINGS
 # Generate a header file
 AC_CONFIG_HEADERS(config.h:config.in)
 
+AC_ARG_WITH(cpu,
+            AS_HELP_STRING([--with-cpu=CPU],[default cpu variant is CPU]),
+            [],[])
+
 # PR 14072
 AH_VERBATIM([00_CONFIG_H_CHECK],
 [/* Check that config.h is #included before system headers
@@ -780,6 +784,7 @@ AC_DEFINE_UNQUOTED(TARGET_CANONICAL,	"${target}",       [Canonical target.])
 AC_DEFINE_UNQUOTED(TARGET_CPU,		"${target_cpu}",   [Target CPU.])
 AC_DEFINE_UNQUOTED(TARGET_VENDOR,	"${target_vendor}", [Target vendor.])
 AC_DEFINE_UNQUOTED(TARGET_OS,		"${target_os}",    [Target OS.])
+AC_DEFINE_UNQUOTED(TARGET_WITH_CPU,	"${with_cpu}",     [Target specific CPU.])
 
 AC_PROG_YACC
 AM_PROG_LEX
-- 
2.5.1


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