public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] gcc: xtensa: allow dynamic configuration
@ 2022-11-29  0:45 Max Filippov
  2022-11-29  0:45 ` [PATCH v2 1/2] " Max Filippov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Max Filippov @ 2022-11-29  0:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ian Lance Taylor, Max Filippov

Hello,

this series addresses the long standing issue with xtensa configuration
support by adding a way to configure toolchain for a specific xtensa
core at runtime using the xtensa-dynconfig [1] library as a plugin.
On a platform with shared library support single toolchain binary
becomes capable of building code for arbitrary xtensa configuration.
At the same time it fully preserves the traditional way of configuring
the toolchain using the xtensa configuration overlay.

Currently xtensa toolchain needs to be patched and rebuilt for every
new xtensa processor configuration. This has a number of downsides:
- toolchain builders need to change the toolchain source code, and
  because xtensa configuration overlay is not a patch, this change is
  special, embedding it into the toolchain build process gets
  backpressure.
- toolchain built for one configuration is usually not usable for any
  other configuration. It's not possible for a distribution to provide
  reusable prebuilt xtensa toolchain.

This series allows building the toolchain (including target libraries)
without its source code modification. Built toolchain takes configuration
parameters from the shared object specified in the environment variable.
That shared object may be built by the xtensa-dynconfig project [1].

The same shared object is used for gcc, all binutils and for gdb.
Xtensa core specific information needed to build that shared object is
taken from the configuration overlay.

Both gcc and binutils-gdb get new shared header file
include/xtensa-dynconfig.h that provides definition of configuration
data structure, initialization macros, redefines XCHAL_* macros to
access this structure and declares function for loading configuration
dynamically.

This is not the first submission of this series, it was first
submitted in 2017 [2]. This version has improved configuration
versioning and GPL-compatibility check that was suggested in comments
for the v1.

[1] https://github.com/jcmvbkbc/xtensa-dynconfig
[2] https://gcc.gnu.org/pipermail/gcc-patches/2017-May/475109.html

Max Filippov (2):
  gcc: xtensa: allow dynamic configuration
  libgcc: xtensa: use built-in configuration

 gcc/config.gcc                               |   1 +
 gcc/config/xtensa/t-xtensa                   |   8 +-
 gcc/config/xtensa/xtensa-dynconfig.c         | 170 +++++++
 gcc/config/xtensa/xtensa-protos.h            |   1 +
 gcc/config/xtensa/xtensa.h                   |  22 +-
 include/xtensa-dynconfig.h                   | 442 +++++++++++++++++++
 libgcc/config/xtensa/crti.S                  |   2 +-
 libgcc/config/xtensa/crtn.S                  |   2 +-
 libgcc/config/xtensa/lib1funcs.S             |   2 +-
 libgcc/config/xtensa/lib2funcs.S             |   2 +-
 libgcc/config/xtensa/xtensa-config-builtin.h | 198 +++++++++
 11 files changed, 828 insertions(+), 22 deletions(-)
 create mode 100644 gcc/config/xtensa/xtensa-dynconfig.c
 create mode 100644 include/xtensa-dynconfig.h
 create mode 100644 libgcc/config/xtensa/xtensa-config-builtin.h

-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] gcc: xtensa: allow dynamic configuration
  2022-11-29  0:45 [PATCH v2 0/2] gcc: xtensa: allow dynamic configuration Max Filippov
@ 2022-11-29  0:45 ` Max Filippov
  2022-11-29  0:45 ` [PATCH v2 2/2] libgcc: xtensa: use built-in configuration Max Filippov
  2022-12-07 18:03 ` [PATCH v2 0/2] gcc: xtensa: allow dynamic configuration Max Filippov
  2 siblings, 0 replies; 4+ messages in thread
From: Max Filippov @ 2022-11-29  0:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ian Lance Taylor, Max Filippov

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 the function xtensa_get_config_v1 that uses xtensa_load_config
to get structure xtensa_config_v1, either dynamically configured or the
default.

Provide essential XCHAL_* configuration parameters as __XCHAL_* built-in
macros. This way it will be possible to use them in libgcc and libc
without need to patch libgcc or libc source for the specific xtensa core
configuration.

gcc/
	* config.gcc (xtensa*-*-*): Add xtensa-dynconfig.o to extra_objs.
	* config/xtensa/t-xtensa (TM_H): Add xtensa-dynconfig.h.
	(xtensa-dynconfig.o): New rule.
	* config/xtensa/xtensa-dynconfig.c: New file.
	* config/xtensa/xtensa-protos.h (xtensa_get_config_strings): New
	declaration.
	* config/xtensa/xtensa.h (xtensa-config.h): Replace #include
	with xtensa-dynconfig.h
	(XCHAL_HAVE_MUL32_HIGH, XCHAL_HAVE_RELEASE_SYNC,
	 XCHAL_HAVE_S32C1I, XCHAL_HAVE_THREADPTR,
	 XCHAL_HAVE_FP_POSTINC): Drop definitions.
	(TARGET_DIV32): Replace with __XCHAL_HAVE_DIV32.
	(TARGET_CPU_CPP_BUILTINS): Add new 'builtin' variable and loop
	through string array returned by the xtensa_get_config_strings
	function call.

include/
	* xtensa-dynconfig.h: New file.
---
 gcc/config.gcc                       |   1 +
 gcc/config/xtensa/t-xtensa           |   8 +-
 gcc/config/xtensa/xtensa-dynconfig.c | 170 +++++++++++
 gcc/config/xtensa/xtensa-protos.h    |   1 +
 gcc/config/xtensa/xtensa.h           |  22 +-
 include/xtensa-dynconfig.h           | 442 +++++++++++++++++++++++++++
 6 files changed, 626 insertions(+), 18 deletions(-)
 create mode 100644 gcc/config/xtensa/xtensa-dynconfig.c
 create mode 100644 include/xtensa-dynconfig.h

diff --git a/gcc/config.gcc b/gcc/config.gcc
index b5eda0460331..951902338205 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -561,6 +561,7 @@ tic6x-*-*)
 	;;
 xtensa*-*-*)
 	extra_options="${extra_options} fused-madd.opt"
+	extra_objs="xtensa-dynconfig.o"
 	;;
 esac
 
diff --git a/gcc/config/xtensa/t-xtensa b/gcc/config/xtensa/t-xtensa
index 6d43b370e5a8..4e5b7dec1bce 100644
--- a/gcc/config/xtensa/t-xtensa
+++ b/gcc/config/xtensa/t-xtensa
@@ -16,5 +16,11 @@
 # along with GCC; see the file COPYING3.  If not see
 # <http://www.gnu.org/licenses/>.
 
-TM_H += $(srcdir)/../include/xtensa-config.h
+TM_H += $(srcdir)/../include/xtensa-config.h \
+	$(srcdir)/../include/xtensa-dynconfig.h
 $(out_object_file): gt-xtensa.h
+
+xtensa-dynconfig.o: $(srcdir)/config/xtensa/xtensa-dynconfig.c \
+  $(CONFIG_H) $(SYSTEM_H) $(srcdir)/../include/xtensa-dynconfig.h \
+  $(srcdir)/../include/xtensa-config.h
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $<
diff --git a/gcc/config/xtensa/xtensa-dynconfig.c b/gcc/config/xtensa/xtensa-dynconfig.c
new file mode 100644
index 000000000000..056204ae9463
--- /dev/null
+++ b/gcc/config/xtensa/xtensa-dynconfig.c
@@ -0,0 +1,170 @@
+/* Xtensa configuration settings loader.
+   Copyright (C) 2022 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/>.  */
+
+#include <config.h>
+#include <system.h>
+#include <coretypes.h>
+#include <diagnostic.h>
+#include <intl.h>
+#define XTENSA_CONFIG_DEFINITION
+#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
+
+#if defined (HAVE_DLFCN_H)
+#include <dlfcn.h>
+#elif defined (_WIN32)
+#include <windows.h>
+#define ENABLE_PLUGIN
+#endif
+
+#if !defined (HAVE_DLFCN_H) && defined (_WIN32)
+
+#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 (_WIN32)  */
+
+#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;
+#ifdef ENABLE_PLUGIN
+  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)
+	{
+	  fatal_error (input_location,
+		       _("%qs is defined but could not be loaded: %s"),
+		       CONFIG_ENV_NAME, dlerror ());
+	  exit (FATAL_EXIT_CODE);
+	}
+      if (dlsym (handle, "plugin_is_GPL_compatible") == NULL)
+	{
+	  fatal_error (input_location,
+		       _("%qs plugin is not licensed under a GPL-compatible license"),
+		       CONFIG_ENV_NAME);
+	  exit (FATAL_EXIT_CODE);
+	}
+    }
+  else if (!handle)
+    {
+      return no_plugin_def;
+    }
+
+  p = dlsym (handle, name);
+  if (!p)
+    {
+      if (no_name_def)
+	return no_name_def;
+
+      fatal_error (input_location,
+		   _("%qs is loaded but symbol %qs is not found: %s"),
+		   CONFIG_ENV_NAME, name, dlerror ());
+      exit (FATAL_EXIT_CODE);
+    }
+  return p;
+#else
+  if (!init)
+    {
+      const char *path = getenv (CONFIG_ENV_NAME);
+
+      init = 1;
+      if (path)
+	{
+	  fatal_error (input_location,
+		       _("%qs is defined but plugin support is disabled"),
+		       CONFIG_ENV_NAME);
+	  exit (FATAL_EXIT_CODE);
+	}
+    }
+  return no_plugin_def;
+#endif
+}
+
+XTENSA_CONFIG_INSTANCE_LIST;
+
+#define _STRINGIFY(a) #a
+#define STRINGIFY(a) _STRINGIFY(a)
+
+#undef XTENSA_CONFIG_ENTRY
+#define XTENSA_CONFIG_ENTRY(a) "__" #a "=" STRINGIFY(a)
+
+static const char * const xtensa_config_strings[] = {
+    XTENSA_CONFIG_ENTRY_LIST,
+    NULL,
+};
+
+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 char * const *xtensa_get_config_strings (void)
+{
+  static const char * const *config_strings;
+
+  if (!config_strings)
+    config_strings = (const char * const *) xtensa_load_config ("xtensa_config_strings",
+								&xtensa_config_strings,
+								NULL);
+
+  return config_strings;
+}
diff --git a/gcc/config/xtensa/xtensa-protos.h b/gcc/config/xtensa/xtensa-protos.h
index bc75ad9698ae..91a215e535d7 100644
--- a/gcc/config/xtensa/xtensa-protos.h
+++ b/gcc/config/xtensa/xtensa-protos.h
@@ -81,5 +81,6 @@ extern void xtensa_expand_epilogue (bool);
 extern void order_regs_for_local_alloc (void);
 extern enum reg_class xtensa_regno_to_class (int regno);
 extern HOST_WIDE_INT xtensa_initial_elimination_offset (int from, int to);
+extern const char **xtensa_get_config_strings (void);
 
 #endif /* !__XTENSA_PROTOS_H__ */
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index 2275fe6d426f..7e193068431c 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -19,27 +19,12 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 /* Get Xtensa configuration settings */
-#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
 
 /* External variables defined in xtensa.cc.  */
 
 /* Macros used in the machine description to select various Xtensa
    configuration options.  */
-#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
 #define TARGET_BIG_ENDIAN	XCHAL_HAVE_BE
 #define TARGET_DENSITY		XCHAL_HAVE_DENSITY
 #define TARGET_MAC16		XCHAL_HAVE_MAC16
@@ -76,7 +61,7 @@ along with GCC; see the file COPYING3.  If not see
 #endif
 
 /* Define this if the target has no hardware divide instructions.  */
-#if !TARGET_DIV32
+#if !__XCHAL_HAVE_DIV32
 #define TARGET_HAS_NO_HW_DIVIDE
 #endif
 
@@ -84,6 +69,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Target CPU builtins.  */
 #define TARGET_CPU_CPP_BUILTINS()					\
   do {									\
+    const char **builtin;						\
     builtin_assert ("cpu=xtensa");					\
     builtin_assert ("machine=xtensa");					\
     builtin_define ("__xtensa__");					\
@@ -93,6 +79,8 @@ along with GCC; see the file COPYING3.  If not see
     builtin_define (TARGET_BIG_ENDIAN ? "__XTENSA_EB__" : "__XTENSA_EL__"); \
     if (!TARGET_HARD_FLOAT)						\
       builtin_define ("__XTENSA_SOFT_FLOAT__");				\
+    for (builtin = xtensa_get_config_strings (); *builtin; ++builtin)	\
+      builtin_define (*builtin);					\
   } while (0)
 
 #define CPP_SPEC " %(subtarget_cpp_spec) "
diff --git a/include/xtensa-dynconfig.h b/include/xtensa-dynconfig.h
new file mode 100644
index 000000000000..807a8ce61178
--- /dev/null
+++ b/include/xtensa-dynconfig.h
@@ -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 */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] libgcc: xtensa: use built-in configuration
  2022-11-29  0:45 [PATCH v2 0/2] gcc: xtensa: allow dynamic configuration Max Filippov
  2022-11-29  0:45 ` [PATCH v2 1/2] " Max Filippov
@ 2022-11-29  0:45 ` Max Filippov
  2022-12-07 18:03 ` [PATCH v2 0/2] gcc: xtensa: allow dynamic configuration Max Filippov
  2 siblings, 0 replies; 4+ messages in thread
From: Max Filippov @ 2022-11-29  0:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ian Lance Taylor, Max Filippov

Now that gcc provides __XCHAL_* definitions use them instead of XCHAL_*
definitions from the include/xtensa-config.h. That makes libgcc
dynamically configurable for the target xtensa core.

libgcc/
	* config/xtensa/crti.S (xtensa-config.h): Replace #inlcude with
	xtensa-config-builtin.h.
	* config/xtensa/crtn.S: Likewise.
	* config/xtensa/lib1funcs.S: Likewise.
	* config/xtensa/lib2funcs.S: Likewise.
	* config/xtensa/xtensa-config-builtin.h: New File.
---
 libgcc/config/xtensa/crti.S                  |   2 +-
 libgcc/config/xtensa/crtn.S                  |   2 +-
 libgcc/config/xtensa/lib1funcs.S             |   2 +-
 libgcc/config/xtensa/lib2funcs.S             |   2 +-
 libgcc/config/xtensa/xtensa-config-builtin.h | 198 +++++++++++++++++++
 5 files changed, 202 insertions(+), 4 deletions(-)
 create mode 100644 libgcc/config/xtensa/xtensa-config-builtin.h

diff --git a/libgcc/config/xtensa/crti.S b/libgcc/config/xtensa/crti.S
index 3de7bc101f4d..2452a88a0351 100644
--- a/libgcc/config/xtensa/crti.S
+++ b/libgcc/config/xtensa/crti.S
@@ -24,7 +24,7 @@
 # .init sections.  Users may put any desired instructions in those
 # sections.
 
-#include "xtensa-config.h"
+#include "xtensa-config-builtin.h"
 
 	.section .init
 	.globl _init
diff --git a/libgcc/config/xtensa/crtn.S b/libgcc/config/xtensa/crtn.S
index 06b932edb14d..8520945fbd7c 100644
--- a/libgcc/config/xtensa/crtn.S
+++ b/libgcc/config/xtensa/crtn.S
@@ -25,7 +25,7 @@
 # fact return.  Users may put any desired instructions in those sections.
 # This file is the last thing linked into any executable.
 
-#include "xtensa-config.h"
+#include "xtensa-config-builtin.h"
 
 	.section .init
 #if XCHAL_HAVE_WINDOWED && !__XTENSA_CALL0_ABI__
diff --git a/libgcc/config/xtensa/lib1funcs.S b/libgcc/config/xtensa/lib1funcs.S
index 3932d206256f..e5a35aa7dcc8 100644
--- a/libgcc/config/xtensa/lib1funcs.S
+++ b/libgcc/config/xtensa/lib1funcs.S
@@ -23,7 +23,7 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#include "xtensa-config.h"
+#include "xtensa-config-builtin.h"
 
 /* Define macros for the ABS and ADDX* instructions to handle cases
    where they are not included in the Xtensa processor configuration.  */
diff --git a/libgcc/config/xtensa/lib2funcs.S b/libgcc/config/xtensa/lib2funcs.S
index 681bac1be8cf..ef2a83251352 100644
--- a/libgcc/config/xtensa/lib2funcs.S
+++ b/libgcc/config/xtensa/lib2funcs.S
@@ -23,7 +23,7 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
-#include "xtensa-config.h"
+#include "xtensa-config-builtin.h"
 
 /* __xtensa_libgcc_window_spill: This function flushes out all but the
    current register window.  This is used to set up the stack so that
diff --git a/libgcc/config/xtensa/xtensa-config-builtin.h b/libgcc/config/xtensa/xtensa-config-builtin.h
new file mode 100644
index 000000000000..36d4d9db330b
--- /dev/null
+++ b/libgcc/config/xtensa/xtensa-config-builtin.h
@@ -0,0 +1,198 @@
+/* Xtensa configuration settings.
+   Copyright (C) 2022 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.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef XTENSA_CONFIG_BUILTIN_H
+#define XTENSA_CONFIG_BUILTIN_H
+
+/* The macros defined here match those with the same names in the Xtensa
+   compile-time HAL (Hardware Abstraction Layer).  Please refer to the
+   Xtensa System Software Reference Manual for documentation of these
+   macros.  */
+
+#undef XCHAL_HAVE_BE
+#define XCHAL_HAVE_BE			__XCHAL_HAVE_BE
+
+#undef XCHAL_HAVE_DENSITY
+#define XCHAL_HAVE_DENSITY		__XCHAL_HAVE_DENSITY
+
+#undef XCHAL_HAVE_CONST16
+#define XCHAL_HAVE_CONST16		__XCHAL_HAVE_CONST16
+
+#undef XCHAL_HAVE_ABS
+#define XCHAL_HAVE_ABS			__XCHAL_HAVE_ABS
+
+#undef XCHAL_HAVE_ADDX
+#define XCHAL_HAVE_ADDX			__XCHAL_HAVE_ADDX
+
+#undef XCHAL_HAVE_L32R
+#define XCHAL_HAVE_L32R			__XCHAL_HAVE_L32R
+
+#undef XSHAL_USE_ABSOLUTE_LITERALS
+#define XSHAL_USE_ABSOLUTE_LITERALS	__XSHAL_USE_ABSOLUTE_LITERALS
+
+#undef XSHAL_HAVE_TEXT_SECTION_LITERALS
+#define XSHAL_HAVE_TEXT_SECTION_LITERALS __XSHAL_HAVE_TEXT_SECTION_LITERALS
+
+#undef XCHAL_HAVE_MAC16
+#define XCHAL_HAVE_MAC16		__XCHAL_HAVE_MAC16
+
+#undef XCHAL_HAVE_MUL16
+#define XCHAL_HAVE_MUL16		__XCHAL_HAVE_MUL16
+
+#undef XCHAL_HAVE_MUL32
+#define XCHAL_HAVE_MUL32		__XCHAL_HAVE_MUL32
+
+#undef XCHAL_HAVE_MUL32_HIGH
+#define XCHAL_HAVE_MUL32_HIGH		__XCHAL_HAVE_MUL32_HIGH
+
+#undef XCHAL_HAVE_DIV32
+#define XCHAL_HAVE_DIV32		__XCHAL_HAVE_DIV32
+
+#undef XCHAL_HAVE_NSA
+#define XCHAL_HAVE_NSA			__XCHAL_HAVE_NSA
+
+#undef XCHAL_HAVE_MINMAX
+#define XCHAL_HAVE_MINMAX		__XCHAL_HAVE_MINMAX
+
+#undef XCHAL_HAVE_SEXT
+#define XCHAL_HAVE_SEXT			__XCHAL_HAVE_SEXT
+
+#undef XCHAL_HAVE_LOOPS
+#define XCHAL_HAVE_LOOPS		__XCHAL_HAVE_LOOPS
+
+#undef XCHAL_HAVE_THREADPTR
+#define XCHAL_HAVE_THREADPTR		__XCHAL_HAVE_THREADPTR
+
+#undef XCHAL_HAVE_RELEASE_SYNC
+#define XCHAL_HAVE_RELEASE_SYNC		__XCHAL_HAVE_RELEASE_SYNC
+
+#undef XCHAL_HAVE_S32C1I
+#define XCHAL_HAVE_S32C1I		__XCHAL_HAVE_S32C1I
+
+#undef XCHAL_HAVE_BOOLEANS
+#define XCHAL_HAVE_BOOLEANS		__XCHAL_HAVE_BOOLEANS
+
+#undef XCHAL_HAVE_FP
+#define XCHAL_HAVE_FP			__XCHAL_HAVE_FP
+
+#undef XCHAL_HAVE_FP_DIV
+#define XCHAL_HAVE_FP_DIV		__XCHAL_HAVE_FP_DIV
+
+#undef XCHAL_HAVE_FP_RECIP
+#define XCHAL_HAVE_FP_RECIP		__XCHAL_HAVE_FP_RECIP
+
+#undef XCHAL_HAVE_FP_SQRT
+#define XCHAL_HAVE_FP_SQRT		__XCHAL_HAVE_FP_SQRT
+
+#undef XCHAL_HAVE_FP_RSQRT
+#define XCHAL_HAVE_FP_RSQRT		__XCHAL_HAVE_FP_RSQRT
+
+#undef XCHAL_HAVE_FP_POSTINC
+#define XCHAL_HAVE_FP_POSTINC		__XCHAL_HAVE_FP_POSTINC
+
+#undef XCHAL_HAVE_DFP
+#define XCHAL_HAVE_DFP			__XCHAL_HAVE_DFP
+
+#undef XCHAL_HAVE_DFP_DIV
+#define XCHAL_HAVE_DFP_DIV		__XCHAL_HAVE_DFP_DIV
+
+#undef XCHAL_HAVE_DFP_RECIP
+#define XCHAL_HAVE_DFP_RECIP		__XCHAL_HAVE_DFP_RECIP
+
+#undef XCHAL_HAVE_DFP_SQRT
+#define XCHAL_HAVE_DFP_SQRT		__XCHAL_HAVE_DFP_SQRT
+
+#undef XCHAL_HAVE_DFP_RSQRT
+#define XCHAL_HAVE_DFP_RSQRT		__XCHAL_HAVE_DFP_RSQRT
+
+#undef XCHAL_HAVE_WINDOWED
+#define XCHAL_HAVE_WINDOWED		__XCHAL_HAVE_WINDOWED
+
+#undef XCHAL_NUM_AREGS
+#define XCHAL_NUM_AREGS			__XCHAL_NUM_AREGS2
+
+#undef XCHAL_HAVE_WIDE_BRANCHES
+#define XCHAL_HAVE_WIDE_BRANCHES	__XCHAL_HAVE_WIDE_BRANCHES
+
+#undef XCHAL_HAVE_PREDICTED_BRANCHES
+#define XCHAL_HAVE_PREDICTED_BRANCHES	__XCHAL_HAVE_PREDICTED_BRANCHES
+
+
+#undef XCHAL_ICACHE_SIZE
+#define XCHAL_ICACHE_SIZE		__XCHAL_ICACHE_SIZE6384
+
+#undef XCHAL_DCACHE_SIZE
+#define XCHAL_DCACHE_SIZE		__XCHAL_DCACHE_SIZE6384
+
+#undef XCHAL_ICACHE_LINESIZE
+#define XCHAL_ICACHE_LINESIZE		__XCHAL_ICACHE_LINESIZE2
+
+#undef XCHAL_DCACHE_LINESIZE
+#define XCHAL_DCACHE_LINESIZE		__XCHAL_DCACHE_LINESIZE2
+
+#undef XCHAL_ICACHE_LINEWIDTH
+#define XCHAL_ICACHE_LINEWIDTH		__XCHAL_ICACHE_LINEWIDTH
+
+#undef XCHAL_DCACHE_LINEWIDTH
+#define XCHAL_DCACHE_LINEWIDTH		__XCHAL_DCACHE_LINEWIDTH
+
+#undef XCHAL_DCACHE_IS_WRITEBACK
+#define XCHAL_DCACHE_IS_WRITEBACK	__XCHAL_DCACHE_IS_WRITEBACK
+
+
+#undef XCHAL_HAVE_MMU
+#define XCHAL_HAVE_MMU			__XCHAL_HAVE_MMU
+
+#undef XCHAL_MMU_MIN_PTE_PAGE_SIZE
+#define XCHAL_MMU_MIN_PTE_PAGE_SIZE	__XCHAL_MMU_MIN_PTE_PAGE_SIZE2
+
+
+#undef XCHAL_HAVE_DEBUG
+#define XCHAL_HAVE_DEBUG		__XCHAL_HAVE_DEBUG
+
+#undef XCHAL_NUM_IBREAK
+#define XCHAL_NUM_IBREAK		__XCHAL_NUM_IBREAK
+
+#undef XCHAL_NUM_DBREAK
+#define XCHAL_NUM_DBREAK		__XCHAL_NUM_DBREAK
+
+#undef XCHAL_DEBUGLEVEL
+#define XCHAL_DEBUGLEVEL		__XCHAL_DEBUGLEVEL
+
+
+#undef XCHAL_MAX_INSTRUCTION_SIZE
+#define XCHAL_MAX_INSTRUCTION_SIZE	__XCHAL_MAX_INSTRUCTION_SIZE
+
+#undef XCHAL_INST_FETCH_WIDTH
+#define XCHAL_INST_FETCH_WIDTH		__XCHAL_INST_FETCH_WIDTH
+
+
+#undef XSHAL_ABI
+#undef XTHAL_ABI_WINDOWED
+#undef XTHAL_ABI_CALL0
+#define XSHAL_ABI			__XSHAL_ABITHAL_ABI_WINDOWED
+#define XTHAL_ABI_WINDOWED		__XTHAL_ABI_WINDOWED
+#define XTHAL_ABI_CALL0			__XTHAL_ABI_CALL0
+
+#endif /* !XTENSA_CONFIG_BUILTIN_H */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] gcc: xtensa: allow dynamic configuration
  2022-11-29  0:45 [PATCH v2 0/2] gcc: xtensa: allow dynamic configuration Max Filippov
  2022-11-29  0:45 ` [PATCH v2 1/2] " Max Filippov
  2022-11-29  0:45 ` [PATCH v2 2/2] libgcc: xtensa: use built-in configuration Max Filippov
@ 2022-12-07 18:03 ` Max Filippov
  2 siblings, 0 replies; 4+ messages in thread
From: Max Filippov @ 2022-12-07 18:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: Ian Lance Taylor, Alexey Lapshin

On Mon, Nov 28, 2022 at 4:46 PM Max Filippov <jcmvbkbc@gmail.com> wrote:
>
> Hello,
>
> this series addresses the long standing issue with xtensa configuration
> support by adding a way to configure toolchain for a specific xtensa
> core at runtime using the xtensa-dynconfig [1] library as a plugin.
> On a platform with shared library support single toolchain binary
> becomes capable of building code for arbitrary xtensa configuration.
> At the same time it fully preserves the traditional way of configuring
> the toolchain using the xtensa configuration overlay.
>
> Currently xtensa toolchain needs to be patched and rebuilt for every
> new xtensa processor configuration. This has a number of downsides:
> - toolchain builders need to change the toolchain source code, and
>   because xtensa configuration overlay is not a patch, this change is
>   special, embedding it into the toolchain build process gets
>   backpressure.
> - toolchain built for one configuration is usually not usable for any
>   other configuration. It's not possible for a distribution to provide
>   reusable prebuilt xtensa toolchain.
>
> This series allows building the toolchain (including target libraries)
> without its source code modification. Built toolchain takes configuration
> parameters from the shared object specified in the environment variable.
> That shared object may be built by the xtensa-dynconfig project [1].
>
> The same shared object is used for gcc, all binutils and for gdb.
> Xtensa core specific information needed to build that shared object is
> taken from the configuration overlay.
>
> Both gcc and binutils-gdb get new shared header file
> include/xtensa-dynconfig.h that provides definition of configuration
> data structure, initialization macros, redefines XCHAL_* macros to
> access this structure and declares function for loading configuration
> dynamically.
>
> This is not the first submission of this series, it was first
> submitted in 2017 [2]. This version has improved configuration
> versioning and GPL-compatibility check that was suggested in comments
> for the v1.
>
> [1] https://github.com/jcmvbkbc/xtensa-dynconfig
> [2] https://gcc.gnu.org/pipermail/gcc-patches/2017-May/475109.html
>
> Max Filippov (2):
>   gcc: xtensa: allow dynamic configuration
>   libgcc: xtensa: use built-in configuration
>
>  gcc/config.gcc                               |   1 +
>  gcc/config/xtensa/t-xtensa                   |   8 +-
>  gcc/config/xtensa/xtensa-dynconfig.c         | 170 +++++++
>  gcc/config/xtensa/xtensa-protos.h            |   1 +
>  gcc/config/xtensa/xtensa.h                   |  22 +-
>  include/xtensa-dynconfig.h                   | 442 +++++++++++++++++++
>  libgcc/config/xtensa/crti.S                  |   2 +-
>  libgcc/config/xtensa/crtn.S                  |   2 +-
>  libgcc/config/xtensa/lib1funcs.S             |   2 +-
>  libgcc/config/xtensa/lib2funcs.S             |   2 +-
>  libgcc/config/xtensa/xtensa-config-builtin.h | 198 +++++++++
>  11 files changed, 828 insertions(+), 22 deletions(-)
>  create mode 100644 gcc/config/xtensa/xtensa-dynconfig.c
>  create mode 100644 include/xtensa-dynconfig.h
>  create mode 100644 libgcc/config/xtensa/xtensa-config-builtin.h

Series regtested for target=xtensa-linux-uclibc, no new regressions.
Committed to master.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-07 18:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29  0:45 [PATCH v2 0/2] gcc: xtensa: allow dynamic configuration Max Filippov
2022-11-29  0:45 ` [PATCH v2 1/2] " Max Filippov
2022-11-29  0:45 ` [PATCH v2 2/2] libgcc: xtensa: use built-in configuration Max Filippov
2022-12-07 18:03 ` [PATCH v2 0/2] gcc: xtensa: allow dynamic configuration Max Filippov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).