xtensa: allow dynamic configuration
authorMax Filippov <jcmvbkbc@gmail.com>
Wed, 3 May 2017 20:13:52 +0000 (13:13 -0700)
committerMax Filippov <jcmvbkbc@gmail.com>
Tue, 29 Nov 2022 02:16:12 +0000 (18:16 -0800)
Import include/xtensa-dynconfig.h that defines XCHAL_* macros as fields
of a structure returned from the xtensa_get_config_v<x> function call.
Define that structure and fill it with default parameter values
specified in the include/xtensa-config.h.
Define reusable function xtensa_load_config that tries to load
configuration and return an address of an exported object from it.
Define functions xtensa_get_config_v{1,2} that use xtensa_load_config
to get structures xtensa_config_v{1,2}, either dynamically configured
or the default.

bfd/
* Makefile.am (BFD32_BACKENDS, BFD32_BACKENDS_CFILES): Append
xtensa-dynconfig.c.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac (xtensa_elf32_be_vec, xtensa_elf32_le_vec): Add
xtensa-dynconfig.lo to the tb.
* elf32-xtensa.c (xtensa-config.h): Replace #include with
xtensa-dynconfig.h.
(XSHAL_ABI, XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): Remove
definitions.
* xtensa-dynconfig.c: New file.
* xtensa-isa.c (xtensa-dynconfig.h): New #include.
(xtensa_get_modules): New function.
(xtensa_isa_init): Call xtensa_get_modules instead of taking
address of global xtensa_modules.

gas/
* config/tc-xtensa.c (xtensa-config.h): Replace #include with
xtensa-dynconfig.h.
(XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0, XTENSA_MARCH_EARLIEST):
Remove definitions.
* config/tc-xtensa.h (xtensa-config.h): Replace #include with
xtensa-dynconfig.h.
* config/xtensa-relax.c (xtensa-config.h): Replace #include with
xtensa-dynconfig.h.
(XCHAL_HAVE_WIDE_BRANCHES): Remove definition.

include/
* xtensa-dynconfig.h: New file.

ld/
* emultempl/xtensaelf.em (xtensa-config.h): Replace #include
with xtensa-dynconfig.h.
(XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): Remove definitions.

12 files changed:
bfd/Makefile.am
bfd/Makefile.in
bfd/configure
bfd/configure.ac
bfd/elf32-xtensa.c
bfd/xtensa-dynconfig.c [new file with mode: 0644]
bfd/xtensa-isa.c
gas/config/tc-xtensa.c
gas/config/tc-xtensa.h
gas/config/xtensa-relax.c
include/xtensa-dynconfig.h [new file with mode: 0644]
ld/emultempl/xtensaelf.em

index a88c6a0034d729644c3ae3e9934a24c42d7a5486..da55a0bb99e9569c5bca7b87468ecf6c30abf330 100644 (file)
@@ -393,6 +393,7 @@ BFD32_BACKENDS = \
        wasm-module.lo \
        xcofflink.lo \
        xsym.lo \
+       xtensa-dynconfig.lo \
        xtensa-isa.lo \
        xtensa-modules.lo
 
@@ -526,6 +527,7 @@ BFD32_BACKENDS_CFILES = \
        wasm-module.c \
        xcofflink.c \
        xsym.c \
+       xtensa-dynconfig.c \
        xtensa-isa.c \
        xtensa-modules.c
 
index d5cc5cb1e179820285a00af9fad3ce969f33c2ee..60252f2da54555de8f9b81f5171de71f0140447e 100644 (file)
@@ -862,6 +862,7 @@ BFD32_BACKENDS = \
        wasm-module.lo \
        xcofflink.lo \
        xsym.lo \
+       xtensa-dynconfig.lo \
        xtensa-isa.lo \
        xtensa-modules.lo
 
@@ -995,6 +996,7 @@ BFD32_BACKENDS_CFILES = \
        wasm-module.c \
        xcofflink.c \
        xsym.c \
+       xtensa-dynconfig.c \
        xtensa-isa.c \
        xtensa-modules.c
 
@@ -1751,6 +1753,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wasm-module.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xcofflink.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xsym.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xtensa-dynconfig.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xtensa-isa.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xtensa-modules.Plo@am__quote@
 
index 74bc5a18471f1e6aedfd0c00af6e8ba24aede53d..b532fe7e8afa20ad74aa9eb975bbebf4b9a89cf4 100755 (executable)
@@ -13863,8 +13863,8 @@ do
     x86_64_pei_vec)             tb="$tb pei-x86_64.lo pex64igen.lo $coff"; target_size=64 ;;
     xgate_elf32_vec)            tb="$tb elf32-xgate.lo elf32.lo $elf" ;;
     xstormy16_elf32_vec)        tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;;
-    xtensa_elf32_be_vec)        tb="$tb xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
-    xtensa_elf32_le_vec)        tb="$tb xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
+    xtensa_elf32_be_vec)        tb="$tb xtensa-dynconfig.lo xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
+    xtensa_elf32_le_vec)        tb="$tb xtensa-dynconfig.lo xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
     z80_coff_vec)               tb="$tb coff-z80.lo reloc16.lo $coffgen" ;;
     z80_elf32_vec)              tb="$tb elf32-z80.lo elf32.lo $elf" ;;
     z8k_coff_vec)               tb="$tb coff-z8k.lo reloc16.lo $coff" ;;
index 5d450a4ad253c767f4837a0ade1352ce6e52fb87..45a293d0bcb15250b862f75272e08346570ef57b 100644 (file)
@@ -664,8 +664,8 @@ do
     x86_64_pei_vec)             tb="$tb pei-x86_64.lo pex64igen.lo $coff"; target_size=64 ;;
     xgate_elf32_vec)            tb="$tb elf32-xgate.lo elf32.lo $elf" ;;
     xstormy16_elf32_vec)        tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;;
-    xtensa_elf32_be_vec)        tb="$tb xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
-    xtensa_elf32_le_vec)        tb="$tb xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
+    xtensa_elf32_be_vec)        tb="$tb xtensa-dynconfig.lo xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
+    xtensa_elf32_le_vec)        tb="$tb xtensa-dynconfig.lo xtensa-isa.lo xtensa-modules.lo elf32-xtensa.lo elf32.lo $elf" ;;
     z80_coff_vec)               tb="$tb coff-z80.lo reloc16.lo $coffgen" ;;
     z80_elf32_vec)              tb="$tb elf32-z80.lo elf32.lo $elf" ;;
     z8k_coff_vec)               tb="$tb coff-z8k.lo reloc16.lo $coff" ;;
index 31e2d7448b0e319d62af2a20494b2ed1cdbb3e7b..68eaada2f128d6059a68f719e09ec8dfa43c8f30 100644 (file)
 #include "elf/xtensa.h"
 #include "splay-tree.h"
 #include "xtensa-isa.h"
-#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
 
 /* All users of this file have bfd_octets_per_byte (abfd, sec) == 1.  */
 #define OCTETS_PER_BYTE(ABFD, SEC) 1
 
 #define XTENSA_NO_NOP_REMOVAL 0
 
-#ifndef XSHAL_ABI
-#define XSHAL_ABI 0
-#endif
-
 #ifndef XTHAL_ABI_UNDEFINED
 #define XTHAL_ABI_UNDEFINED -1
 #endif
 
-#ifndef XTHAL_ABI_WINDOWED
-#define XTHAL_ABI_WINDOWED 0
-#endif
-
-#ifndef XTHAL_ABI_CALL0
-#define XTHAL_ABI_CALL0 1
-#endif
-
 /* Local helper functions.  */
 
 static bool add_extra_plt_sections (struct bfd_link_info *, int);
diff --git a/bfd/xtensa-dynconfig.c b/bfd/xtensa-dynconfig.c
new file mode 100644 (file)
index 0000000..7c9ada5
--- /dev/null
@@ -0,0 +1,147 @@
+/* Xtensa configuration settings loader.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   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/>.  */
+
+#include "sysdep.h"
+#include "bfd.h"
+#include "libbfd.h"
+
+#define XTENSA_CONFIG_DEFINITION
+#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
+
+#if defined (HAVE_DLFCN_H)
+#include <dlfcn.h>
+#elif defined (HAVE_WINDOWS_H)
+#include <windows.h>
+#endif
+
+#if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
+
+#define RTLD_LAZY 0      /* Dummy value.  */
+
+static void *
+dlopen (const char *file, int mode ATTRIBUTE_UNUSED)
+{
+  return LoadLibrary (file);
+}
+
+static void *
+dlsym (void *handle, const char *name)
+{
+  return (void *) GetProcAddress ((HMODULE) handle, name);
+}
+
+static int ATTRIBUTE_UNUSED
+dlclose (void *handle)
+{
+  FreeLibrary ((HMODULE) handle);
+  return 0;
+}
+
+static const char *
+dlerror (void)
+{
+  return _("Unable to load DLL.");
+}
+
+#endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)  */
+
+#define CONFIG_ENV_NAME "XTENSA_GNU_CONFIG"
+
+const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED,
+                               const void *no_plugin_def,
+                               const void *no_name_def ATTRIBUTE_UNUSED)
+{
+  static int init;
+#if BFD_SUPPORTS_PLUGINS
+  static void *handle;
+  void *p;
+
+  if (!init)
+    {
+      const char *path = getenv (CONFIG_ENV_NAME);
+
+      init = 1;
+      if (!path)
+       return no_plugin_def;
+      handle = dlopen (path, RTLD_LAZY);
+      if (!handle)
+       {
+         _bfd_error_handler (_("%s is defined but could not be loaded: %s"),
+                             CONFIG_ENV_NAME, dlerror ());
+         abort ();
+       }
+    }
+  else if (!handle)
+    {
+      return no_plugin_def;
+    }
+
+  p = dlsym (handle, name);
+  if (!p)
+    {
+      if (no_name_def)
+       return no_name_def;
+
+      _bfd_error_handler (_("%s is loaded but symbol \"%s\" is not found: %s"),
+                         CONFIG_ENV_NAME, name, dlerror ());
+      abort ();
+    }
+  return p;
+#else
+  if (!init)
+    {
+      const char *path = getenv (CONFIG_ENV_NAME);
+
+      init = 1;
+      if (path)
+       {
+         _bfd_error_handler (_("%s is defined but plugin support is disabled"),
+                             CONFIG_ENV_NAME);
+         abort ();
+       }
+    }
+  return no_plugin_def;
+#endif
+}
+
+XTENSA_CONFIG_INSTANCE_LIST;
+
+const struct xtensa_config_v1 *xtensa_get_config_v1 (void)
+{
+  static const struct xtensa_config_v1 *config;
+
+  if (!config)
+    config = (const struct xtensa_config_v1 *) xtensa_load_config ("xtensa_config_v1",
+                                                                  &xtensa_config_v1,
+                                                                  NULL);
+  return config;
+}
+
+const struct xtensa_config_v2 *xtensa_get_config_v2 (void)
+{
+  static const struct xtensa_config_v2 *config;
+  static const struct xtensa_config_v2 def;
+
+  if (!config)
+    config = (const struct xtensa_config_v2 *) xtensa_load_config ("xtensa_config_v2",
+                                                                  &xtensa_config_v2,
+                                                                  &def);
+  return config;
+}
index 63efbd4994888fc00ebd61ad6ecac5a0ece9dd7e..9919195075d8a6ca0b65ccba4d96517acb8c7255 100644 (file)
@@ -23,6 +23,7 @@
 #include "libbfd.h"
 #include "xtensa-isa.h"
 #include "xtensa-isa-internal.h"
+#include "xtensa-dynconfig.h"
 
 static xtensa_isa_status xtisa_errno;
 static char xtisa_error_msg[1024];
@@ -232,10 +233,21 @@ xtensa_insnbuf_from_chars (xtensa_isa isa,
 
 extern xtensa_isa_internal xtensa_modules;
 
+static xtensa_isa_internal *xtensa_get_modules (void)
+{
+  static xtensa_isa_internal *modules;
+
+  if (!modules)
+    modules = (xtensa_isa_internal *) xtensa_load_config ("xtensa_modules",
+                                                         &xtensa_modules,
+                                                         NULL);
+  return modules;
+}
+
 xtensa_isa
 xtensa_isa_init (xtensa_isa_status *errno_p, char **error_msg_p)
 {
-  xtensa_isa_internal *isa = &xtensa_modules;
+  xtensa_isa_internal *isa = xtensa_get_modules ();
   int n, is_user;
 
   /* Set up the opcode name lookup table.  */
index f7a28d32d0cafc494ac4e78d5a6c48a4afac61b3..30152bbfbfdd331117652a56e46eab07ad16ac76 100644 (file)
 #include "xtensa-relax.h"
 #include "dwarf2dbg.h"
 #include "xtensa-istack.h"
-#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
 #include "elf/xtensa.h"
 
-/* Provide default values for new configuration settings.  */
-#ifndef XTHAL_ABI_WINDOWED
-#define XTHAL_ABI_WINDOWED 0
-#endif
-
-#ifndef XTHAL_ABI_CALL0
-#define XTHAL_ABI_CALL0 1
-#endif
-
-#ifndef XTENSA_MARCH_EARLIEST
-#define XTENSA_MARCH_EARLIEST 0
-#endif
-
 #ifndef uint32
 #define uint32 unsigned int
 #endif
index e67abbc9920cef4c5b2d1dd8c58d9bcee110fc67..b3a49ac8667763b3befc9ec5b758dc9f29782d4a 100644 (file)
@@ -28,7 +28,7 @@ struct fix;
 #endif
 
 #include "xtensa-isa.h"
-#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
 
 #define TARGET_BYTES_BIG_ENDIAN 0
 
index 0682b29f81571dcac9ba972635d19228db2b1026..5df220113dad4987f2c8ab20105d2601f26a9854 100644 (file)
 #include "xtensa-isa.h"
 #include "xtensa-relax.h"
 #include <stddef.h>
-#include "xtensa-config.h"
-
-#ifndef XCHAL_HAVE_WIDE_BRANCHES
-#define XCHAL_HAVE_WIDE_BRANCHES 0
-#endif
+#include "xtensa-dynconfig.h"
 
 /* Imported from bfd.  */
 extern xtensa_isa xtensa_default_isa;
diff --git a/include/xtensa-dynconfig.h b/include/xtensa-dynconfig.h
new file mode 100644 (file)
index 0000000..807a8ce
--- /dev/null
@@ -0,0 +1,442 @@
+/* Xtensa configuration settings.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+
+   This program 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.
+
+   This program 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 this program; if not, write to the Free Software
+   Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef XTENSA_DYNCONFIG_H
+#define XTENSA_DYNCONFIG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Config versioning.
+ *
+ * When new config entries need to be passed through dynconfig
+ * create new xtensa_config_v<N> structure and put them there.
+ * Declare new function xtensa_get_config_v<N> (void).
+ * Define corresponding X*HAL_* macros by accessing xtensa_get_config_v<N> ().
+ * Define macro XTENSA_CONFIG_V<N>_ENTRY_LIST by listing
+ * XTENSA_CONFIG_ENTRY for every entry in the new structure.
+ * Add constant definition for the new xtensa_config_v<N> to the
+ * XTENSA_CONFIG_INSTANCE_LIST.
+ * Add XTENSA_CONFIG_V<N>_ENTRY_LIST to the XTENSA_CONFIG_ENTRY_LIST.
+ *
+ * On the user side (gcc/binutils/...) add definition for the function
+ * xtensa_get_config_v<N> (void).
+ */
+
+struct xtensa_config_v1
+{
+  int xchal_have_be;
+  int xchal_have_density;
+  int xchal_have_const16;
+  int xchal_have_abs;
+  int xchal_have_addx;
+  int xchal_have_l32r;
+  int xshal_use_absolute_literals;
+  int xshal_have_text_section_literals;
+  int xchal_have_mac16;
+  int xchal_have_mul16;
+  int xchal_have_mul32;
+  int xchal_have_mul32_high;
+  int xchal_have_div32;
+  int xchal_have_nsa;
+  int xchal_have_minmax;
+  int xchal_have_sext;
+  int xchal_have_loops;
+  int xchal_have_threadptr;
+  int xchal_have_release_sync;
+  int xchal_have_s32c1i;
+  int xchal_have_booleans;
+  int xchal_have_fp;
+  int xchal_have_fp_div;
+  int xchal_have_fp_recip;
+  int xchal_have_fp_sqrt;
+  int xchal_have_fp_rsqrt;
+  int xchal_have_fp_postinc;
+  int xchal_have_dfp;
+  int xchal_have_dfp_div;
+  int xchal_have_dfp_recip;
+  int xchal_have_dfp_sqrt;
+  int xchal_have_dfp_rsqrt;
+  int xchal_have_windowed;
+  int xchal_num_aregs;
+  int xchal_have_wide_branches;
+  int xchal_have_predicted_branches;
+  int xchal_icache_size;
+  int xchal_dcache_size;
+  int xchal_icache_linesize;
+  int xchal_dcache_linesize;
+  int xchal_icache_linewidth;
+  int xchal_dcache_linewidth;
+  int xchal_dcache_is_writeback;
+  int xchal_have_mmu;
+  int xchal_mmu_min_pte_page_size;
+  int xchal_have_debug;
+  int xchal_num_ibreak;
+  int xchal_num_dbreak;
+  int xchal_debuglevel;
+  int xchal_max_instruction_size;
+  int xchal_inst_fetch_width;
+  int xshal_abi;
+  int xthal_abi_windowed;
+  int xthal_abi_call0;
+};
+
+struct xtensa_config_v2
+{
+  int xchal_m_stage;
+  int xtensa_march_latest;
+  int xtensa_march_earliest;
+};
+
+typedef struct xtensa_isa_internal_struct xtensa_isa_internal;
+
+extern const void *xtensa_load_config (const char *name,
+                                      const void *no_plugin_def,
+                                      const void *no_name_def);
+extern const struct xtensa_config_v1 *xtensa_get_config_v1 (void);
+extern const struct xtensa_config_v2 *xtensa_get_config_v2 (void);
+
+#ifdef XTENSA_CONFIG_DEFINITION
+
+#ifndef XCHAL_HAVE_MUL32_HIGH
+#define XCHAL_HAVE_MUL32_HIGH 0
+#endif
+
+#ifndef XCHAL_HAVE_RELEASE_SYNC
+#define XCHAL_HAVE_RELEASE_SYNC 0
+#endif
+
+#ifndef XCHAL_HAVE_S32C1I
+#define XCHAL_HAVE_S32C1I 0
+#endif
+
+#ifndef XCHAL_HAVE_THREADPTR
+#define XCHAL_HAVE_THREADPTR 0
+#endif
+
+#ifndef XCHAL_HAVE_FP_POSTINC
+#define XCHAL_HAVE_FP_POSTINC 0
+#endif
+
+#ifndef XCHAL_HAVE_DFP
+#define XCHAL_HAVE_DFP 0
+#endif
+
+#ifndef XCHAL_HAVE_DFP_DIV
+#define XCHAL_HAVE_DFP_DIV 0
+#endif
+
+#ifndef XCHAL_HAVE_DFP_RECIP
+#define XCHAL_HAVE_DFP_RECIP 0
+#endif
+
+#ifndef XCHAL_HAVE_DFP_SQRT
+#define XCHAL_HAVE_DFP_SQRT 0
+#endif
+
+#ifndef XCHAL_HAVE_DFP_RSQRT
+#define XCHAL_HAVE_DFP_RSQRT 0
+#endif
+
+#ifndef XSHAL_HAVE_TEXT_SECTION_LITERALS
+#define XSHAL_HAVE_TEXT_SECTION_LITERALS 0
+#endif
+
+#ifndef XCHAL_MMU_MIN_PTE_PAGE_SIZE
+#define XCHAL_MMU_MIN_PTE_PAGE_SIZE 1
+#endif
+
+#ifndef XTHAL_ABI_WINDOWED
+#define XTHAL_ABI_WINDOWED 0
+#endif
+
+#ifndef XTHAL_ABI_CALL0
+#define XTHAL_ABI_CALL0 1
+#endif
+
+#ifndef XCHAL_M_STAGE
+#define XCHAL_M_STAGE 0
+#endif
+
+#ifndef XTENSA_MARCH_LATEST
+#define XTENSA_MARCH_LATEST 0
+#endif
+
+#ifndef XTENSA_MARCH_EARLIEST
+#define XTENSA_MARCH_EARLIEST 0
+#endif
+
+#define XTENSA_CONFIG_ENTRY(a) a
+
+#define XTENSA_CONFIG_V1_ENTRY_LIST \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_BE), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_DENSITY), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_CONST16), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_ABS), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_ADDX), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_L32R), \
+    XTENSA_CONFIG_ENTRY(XSHAL_USE_ABSOLUTE_LITERALS), \
+    XTENSA_CONFIG_ENTRY(XSHAL_HAVE_TEXT_SECTION_LITERALS), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_MAC16), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_MUL16), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_MUL32), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_MUL32_HIGH), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_DIV32), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_NSA), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_MINMAX), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_SEXT), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_LOOPS), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_THREADPTR), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_RELEASE_SYNC), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_S32C1I), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_BOOLEANS), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_FP), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_FP_DIV), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_FP_RECIP), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_FP_SQRT), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_FP_RSQRT), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_FP_POSTINC), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_DFP), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_DFP_DIV), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_DFP_RECIP), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_DFP_SQRT), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_DFP_RSQRT), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_WINDOWED), \
+    XTENSA_CONFIG_ENTRY(XCHAL_NUM_AREGS), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_WIDE_BRANCHES), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_PREDICTED_BRANCHES), \
+    XTENSA_CONFIG_ENTRY(XCHAL_ICACHE_SIZE), \
+    XTENSA_CONFIG_ENTRY(XCHAL_DCACHE_SIZE), \
+    XTENSA_CONFIG_ENTRY(XCHAL_ICACHE_LINESIZE), \
+    XTENSA_CONFIG_ENTRY(XCHAL_DCACHE_LINESIZE), \
+    XTENSA_CONFIG_ENTRY(XCHAL_ICACHE_LINEWIDTH), \
+    XTENSA_CONFIG_ENTRY(XCHAL_DCACHE_LINEWIDTH), \
+    XTENSA_CONFIG_ENTRY(XCHAL_DCACHE_IS_WRITEBACK), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_MMU), \
+    XTENSA_CONFIG_ENTRY(XCHAL_MMU_MIN_PTE_PAGE_SIZE), \
+    XTENSA_CONFIG_ENTRY(XCHAL_HAVE_DEBUG), \
+    XTENSA_CONFIG_ENTRY(XCHAL_NUM_IBREAK), \
+    XTENSA_CONFIG_ENTRY(XCHAL_NUM_DBREAK), \
+    XTENSA_CONFIG_ENTRY(XCHAL_DEBUGLEVEL), \
+    XTENSA_CONFIG_ENTRY(XCHAL_MAX_INSTRUCTION_SIZE), \
+    XTENSA_CONFIG_ENTRY(XCHAL_INST_FETCH_WIDTH), \
+    XTENSA_CONFIG_ENTRY(XSHAL_ABI), \
+    XTENSA_CONFIG_ENTRY(XTHAL_ABI_WINDOWED), \
+    XTENSA_CONFIG_ENTRY(XTHAL_ABI_CALL0)
+
+#define XTENSA_CONFIG_V2_ENTRY_LIST \
+    XTENSA_CONFIG_ENTRY(XCHAL_M_STAGE), \
+    XTENSA_CONFIG_ENTRY(XTENSA_MARCH_LATEST), \
+    XTENSA_CONFIG_ENTRY(XTENSA_MARCH_EARLIEST)
+
+#define XTENSA_CONFIG_INSTANCE_LIST \
+const struct xtensa_config_v1 xtensa_config_v1 = { \
+    XTENSA_CONFIG_V1_ENTRY_LIST, \
+}; \
+const struct xtensa_config_v2 xtensa_config_v2 = { \
+    XTENSA_CONFIG_V2_ENTRY_LIST, \
+}
+
+#define XTENSA_CONFIG_ENTRY_LIST \
+    XTENSA_CONFIG_V1_ENTRY_LIST, \
+    XTENSA_CONFIG_V2_ENTRY_LIST
+
+#else /* XTENSA_CONFIG_DEFINITION */
+
+#undef XCHAL_HAVE_BE
+#define XCHAL_HAVE_BE                  (xtensa_get_config_v1 ()->xchal_have_be)
+
+#undef XCHAL_HAVE_DENSITY
+#define XCHAL_HAVE_DENSITY             (xtensa_get_config_v1 ()->xchal_have_density)
+
+#undef XCHAL_HAVE_CONST16
+#define XCHAL_HAVE_CONST16             (xtensa_get_config_v1 ()->xchal_have_const16)
+
+#undef XCHAL_HAVE_ABS
+#define XCHAL_HAVE_ABS                 (xtensa_get_config_v1 ()->xchal_have_abs)
+
+#undef XCHAL_HAVE_ADDX
+#define XCHAL_HAVE_ADDX                        (xtensa_get_config_v1 ()->xchal_have_addx)
+
+#undef XCHAL_HAVE_L32R
+#define XCHAL_HAVE_L32R                        (xtensa_get_config_v1 ()->xchal_have_l32r)
+
+#undef XSHAL_USE_ABSOLUTE_LITERALS
+#define XSHAL_USE_ABSOLUTE_LITERALS    (xtensa_get_config_v1 ()->xshal_use_absolute_literals)
+
+#undef XSHAL_HAVE_TEXT_SECTION_LITERALS
+#define XSHAL_HAVE_TEXT_SECTION_LITERALS (xtensa_get_config_v1 ()->xshal_have_text_section_literals)
+
+#undef XCHAL_HAVE_MAC16
+#define XCHAL_HAVE_MAC16               (xtensa_get_config_v1 ()->xchal_have_mac16)
+
+#undef XCHAL_HAVE_MUL16
+#define XCHAL_HAVE_MUL16               (xtensa_get_config_v1 ()->xchal_have_mul16)
+
+#undef XCHAL_HAVE_MUL32
+#define XCHAL_HAVE_MUL32               (xtensa_get_config_v1 ()->xchal_have_mul32)
+
+#undef XCHAL_HAVE_MUL32_HIGH
+#define XCHAL_HAVE_MUL32_HIGH          (xtensa_get_config_v1 ()->xchal_have_mul32_high)
+
+#undef XCHAL_HAVE_DIV32
+#define XCHAL_HAVE_DIV32               (xtensa_get_config_v1 ()->xchal_have_div32)
+
+#undef XCHAL_HAVE_NSA
+#define XCHAL_HAVE_NSA                 (xtensa_get_config_v1 ()->xchal_have_nsa)
+
+#undef XCHAL_HAVE_MINMAX
+#define XCHAL_HAVE_MINMAX              (xtensa_get_config_v1 ()->xchal_have_minmax)
+
+#undef XCHAL_HAVE_SEXT
+#define XCHAL_HAVE_SEXT                        (xtensa_get_config_v1 ()->xchal_have_sext)
+
+#undef XCHAL_HAVE_LOOPS
+#define XCHAL_HAVE_LOOPS               (xtensa_get_config_v1 ()->xchal_have_loops)
+
+#undef XCHAL_HAVE_THREADPTR
+#define XCHAL_HAVE_THREADPTR           (xtensa_get_config_v1 ()->xchal_have_threadptr)
+
+#undef XCHAL_HAVE_RELEASE_SYNC
+#define XCHAL_HAVE_RELEASE_SYNC                (xtensa_get_config_v1 ()->xchal_have_release_sync)
+
+#undef XCHAL_HAVE_S32C1I
+#define XCHAL_HAVE_S32C1I              (xtensa_get_config_v1 ()->xchal_have_s32c1i)
+
+#undef XCHAL_HAVE_BOOLEANS
+#define XCHAL_HAVE_BOOLEANS            (xtensa_get_config_v1 ()->xchal_have_booleans)
+
+#undef XCHAL_HAVE_FP
+#define XCHAL_HAVE_FP                  (xtensa_get_config_v1 ()->xchal_have_fp)
+
+#undef XCHAL_HAVE_FP_DIV
+#define XCHAL_HAVE_FP_DIV              (xtensa_get_config_v1 ()->xchal_have_fp_div)
+
+#undef XCHAL_HAVE_FP_RECIP
+#define XCHAL_HAVE_FP_RECIP            (xtensa_get_config_v1 ()->xchal_have_fp_recip)
+
+#undef XCHAL_HAVE_FP_SQRT
+#define XCHAL_HAVE_FP_SQRT             (xtensa_get_config_v1 ()->xchal_have_fp_sqrt)
+
+#undef XCHAL_HAVE_FP_RSQRT
+#define XCHAL_HAVE_FP_RSQRT            (xtensa_get_config_v1 ()->xchal_have_fp_rsqrt)
+
+#undef XCHAL_HAVE_FP_POSTINC
+#define XCHAL_HAVE_FP_POSTINC          (xtensa_get_config_v1 ()->xchal_have_fp_postinc)
+
+#undef XCHAL_HAVE_DFP
+#define XCHAL_HAVE_DFP                 (xtensa_get_config_v1 ()->xchal_have_dfp)
+
+#undef XCHAL_HAVE_DFP_DIV
+#define XCHAL_HAVE_DFP_DIV             (xtensa_get_config_v1 ()->xchal_have_dfp_div)
+
+#undef XCHAL_HAVE_DFP_RECIP
+#define XCHAL_HAVE_DFP_RECIP           (xtensa_get_config_v1 ()->xchal_have_dfp_recip)
+
+#undef XCHAL_HAVE_DFP_SQRT
+#define XCHAL_HAVE_DFP_SQRT            (xtensa_get_config_v1 ()->xchal_have_dfp_sqrt)
+
+#undef XCHAL_HAVE_DFP_RSQRT
+#define XCHAL_HAVE_DFP_RSQRT           (xtensa_get_config_v1 ()->xchal_have_dfp_rsqrt)
+
+#undef XCHAL_HAVE_WINDOWED
+#define XCHAL_HAVE_WINDOWED            (xtensa_get_config_v1 ()->xchal_have_windowed)
+
+#undef XCHAL_NUM_AREGS
+#define XCHAL_NUM_AREGS                        (xtensa_get_config_v1 ()->xchal_num_aregs)
+
+#undef XCHAL_HAVE_WIDE_BRANCHES
+#define XCHAL_HAVE_WIDE_BRANCHES       (xtensa_get_config_v1 ()->xchal_have_wide_branches)
+
+#undef XCHAL_HAVE_PREDICTED_BRANCHES
+#define XCHAL_HAVE_PREDICTED_BRANCHES  (xtensa_get_config_v1 ()->xchal_have_predicted_branches)
+
+
+#undef XCHAL_ICACHE_SIZE
+#define XCHAL_ICACHE_SIZE              (xtensa_get_config_v1 ()->xchal_icache_size)
+
+#undef XCHAL_DCACHE_SIZE
+#define XCHAL_DCACHE_SIZE              (xtensa_get_config_v1 ()->xchal_dcache_size)
+
+#undef XCHAL_ICACHE_LINESIZE
+#define XCHAL_ICACHE_LINESIZE          (xtensa_get_config_v1 ()->xchal_icache_linesize)
+
+#undef XCHAL_DCACHE_LINESIZE
+#define XCHAL_DCACHE_LINESIZE          (xtensa_get_config_v1 ()->xchal_dcache_linesize)
+
+#undef XCHAL_ICACHE_LINEWIDTH
+#define XCHAL_ICACHE_LINEWIDTH         (xtensa_get_config_v1 ()->xchal_icache_linewidth)
+
+#undef XCHAL_DCACHE_LINEWIDTH
+#define XCHAL_DCACHE_LINEWIDTH         (xtensa_get_config_v1 ()->xchal_dcache_linewidth)
+
+#undef XCHAL_DCACHE_IS_WRITEBACK
+#define XCHAL_DCACHE_IS_WRITEBACK      (xtensa_get_config_v1 ()->xchal_dcache_is_writeback)
+
+
+#undef XCHAL_HAVE_MMU
+#define XCHAL_HAVE_MMU                 (xtensa_get_config_v1 ()->xchal_have_mmu)
+
+#undef XCHAL_MMU_MIN_PTE_PAGE_SIZE
+#define XCHAL_MMU_MIN_PTE_PAGE_SIZE    (xtensa_get_config_v1 ()->xchal_mmu_min_pte_page_size)
+
+
+#undef XCHAL_HAVE_DEBUG
+#define XCHAL_HAVE_DEBUG               (xtensa_get_config_v1 ()->xchal_have_debug)
+
+#undef XCHAL_NUM_IBREAK
+#define XCHAL_NUM_IBREAK               (xtensa_get_config_v1 ()->xchal_num_ibreak)
+
+#undef XCHAL_NUM_DBREAK
+#define XCHAL_NUM_DBREAK               (xtensa_get_config_v1 ()->xchal_num_dbreak)
+
+#undef XCHAL_DEBUGLEVEL
+#define XCHAL_DEBUGLEVEL               (xtensa_get_config_v1 ()->xchal_debuglevel)
+
+
+#undef XCHAL_MAX_INSTRUCTION_SIZE
+#define XCHAL_MAX_INSTRUCTION_SIZE     (xtensa_get_config_v1 ()->xchal_max_instruction_size)
+
+#undef XCHAL_INST_FETCH_WIDTH
+#define XCHAL_INST_FETCH_WIDTH         (xtensa_get_config_v1 ()->xchal_inst_fetch_width)
+
+
+#undef XSHAL_ABI
+#undef XTHAL_ABI_WINDOWED
+#undef XTHAL_ABI_CALL0
+#define XSHAL_ABI                      (xtensa_get_config_v1 ()->xshal_abi)
+#define XTHAL_ABI_WINDOWED             (xtensa_get_config_v1 ()->xthal_abi_windowed)
+#define XTHAL_ABI_CALL0                        (xtensa_get_config_v1 ()->xthal_abi_call0)
+
+
+#undef XCHAL_M_STAGE
+#define XCHAL_M_STAGE                  (xtensa_get_config_v2 ()->xchal_m_stage)
+
+#undef XTENSA_MARCH_LATEST
+#define XTENSA_MARCH_LATEST            (xtensa_get_config_v2 ()->xtensa_march_latest)
+
+#undef XTENSA_MARCH_EARLIEST
+#define XTENSA_MARCH_EARLIEST          (xtensa_get_config_v2 ()->xtensa_march_earliest)
+
+#endif /* XTENSA_CONFIG_DEFINITION */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !XTENSA_DYNCONFIG_H */
index 9d527daea95b1edb63894664ebf5d7969b1f4583..09ce2589d84ab44d15b4f74f33bc9ead7f4d3726 100644 (file)
@@ -24,7 +24,7 @@
 #
 fragment <<EOF
 
-#include <xtensa-config.h>
+#include <xtensa-dynconfig.h>
 #include "../bfd/elf-bfd.h"
 #include "elf/xtensa.h"
 #include "bfd.h"
@@ -34,14 +34,6 @@ fragment <<EOF
 #define XTHAL_ABI_UNDEFINED -1
 #endif
 
-#ifndef XTHAL_ABI_WINDOWED
-#define XTHAL_ABI_WINDOWED 0
-#endif
-
-#ifndef XTHAL_ABI_CALL0
-#define XTHAL_ABI_CALL0 1
-#endif
-
 static void xtensa_wild_group_interleave (lang_statement_union_type *);
 static void xtensa_colocate_output_literals (lang_statement_union_type *);
 static void xtensa_strip_inconsistent_linkonce_sections