public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC 2/5] gcc: xtensa: make configuration dynamic
  2017-05-22 21:09 [RFC 0/5] xtensa: support dynamic configuration Max Filippov
  2017-05-22 21:09 ` [RFC 4/5] gcc: xtensa: add __XCHAL_* builtins Max Filippov
@ 2017-05-22 21:09 ` Max Filippov
  2017-05-25 18:25   ` augustine.sterling
  2017-05-22 21:09 ` [RFC 3/5] gcc: xtensa: support dynconfig on windows Max Filippov
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Max Filippov @ 2017-05-22 21:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov

Now that XCHAL_* macros don't have to be preprocessor constants add
include/xtensa-dynconfig.h that defines them as fields of a structure
returned from the xtensa_get_config function.
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 that uses xtensa_load_config to
get structure xtensa_config, either dynamically configured or the
default.

2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
gcc/
	* Makefile.in (PLUGIN_HEADERS): Add include/xtensa-dynconfig.h.
	* config.gcc (xtensa*-*-*): Add xtensa-config.o to extra_objs.
	* gcc/config/xtensa/t-xtensa (xtensa-config.o): New rule.
	* gcc/config/xtensa/xtensa-config.c: New file.
	* gcc/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.

include/
	* xtensa-dynconfig.h: New file.
---
 gcc/Makefile.in                   |   2 +-
 gcc/config.gcc                    |   1 +
 gcc/config/xtensa/t-xtensa        |   5 +
 gcc/config/xtensa/xtensa-config.c |  79 ++++++++
 gcc/config/xtensa/xtensa.h        |  17 +-
 include/xtensa-dynconfig.h        | 373 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 460 insertions(+), 17 deletions(-)
 create mode 100644 gcc/config/xtensa/xtensa-config.c
 create mode 100644 include/xtensa-dynconfig.h

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 2411671..f59a29f 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3433,7 +3433,7 @@ PLUGIN_HEADERS = $(TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
   tree-ssa-threadupdate.h inchash.h wide-int.h signop.h hash-map.h \
   hash-set.h dominance.h cfg.h cfgrtl.h cfganal.h cfgbuild.h cfgcleanup.h \
   lcm.h cfgloopmanip.h builtins.def chkp-builtins.def pass-instances.def \
-  params.list
+  params.list $(srcdir)/../include/xtensa-dynconfig.h
 
 # generate the 'build fragment' b-header-vars
 s-header-vars: Makefile
diff --git a/gcc/config.gcc b/gcc/config.gcc
index b8bb4d6..f65bb2e 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -489,6 +489,7 @@ tic6x-*-*)
 	;;
 xtensa*-*-*)
 	extra_options="${extra_options} fused-madd.opt"
+	extra_objs="xtensa-config.o"
 	;;
 tilegx*-*-*)
 	cpu_type=tilegx
diff --git a/gcc/config/xtensa/t-xtensa b/gcc/config/xtensa/t-xtensa
index f762873..28d3756 100644
--- a/gcc/config/xtensa/t-xtensa
+++ b/gcc/config/xtensa/t-xtensa
@@ -17,3 +17,8 @@
 # <http://www.gnu.org/licenses/>.
 
 $(out_object_file): gt-xtensa.h
+
+xtensa-config.o: $(srcdir)/config/xtensa/xtensa-config.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-config.c b/gcc/config/xtensa/xtensa-config.c
new file mode 100644
index 0000000..296caf4
--- /dev/null
+++ b/gcc/config/xtensa/xtensa-config.c
@@ -0,0 +1,79 @@
+#include <config.h>
+#include <system.h>
+#define XTENSA_CONFIG_DEFINITION
+#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
+
+static struct xtensa_config xtensa_defconfig = XTENSA_CONFIG_INITIALIZER;
+
+void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED, void *def)
+{
+  static int init;
+#ifdef ENABLE_PLUGIN
+  static void *handle;
+  void *p;
+
+  if (!init)
+    {
+      char *path = getenv ("XTENSA_GNU_CONFIG");
+
+      init = 1;
+      if (!path)
+	return def;
+      handle = dlopen (path, RTLD_LAZY);
+      if (!handle)
+	{
+	  fprintf (stderr,
+		   "XTENSA_GNU_CONFIG is defined but could not be loaded: %s\n",
+		   dlerror ());
+	  abort ();
+	}
+    }
+  else if (!handle)
+    {
+      return def;
+    }
+
+  p = dlsym (handle, name);
+  if (!p)
+    {
+      fprintf (stderr,
+	       "XTENSA_GNU_CONFIG is loaded but symbol \"%s\" is not found: %s\n",
+	       name, dlerror ());
+      abort ();
+    }
+  return p;
+#else
+  if (!init)
+    {
+      char *path = getenv ("XTENSA_GNU_CONFIG");
+
+      init = 1;
+      if (path)
+	{
+	  fprintf (stderr,
+		   "XTENSA_GNU_CONFIG is defined but plugin support is disabled\n");
+	  abort ();
+	}
+    }
+  return def;
+#endif
+}
+
+struct xtensa_config *xtensa_get_config (void)
+{
+  static struct xtensa_config *config;
+
+  if (!config)
+    config = (struct xtensa_config *) xtensa_load_config ("xtensa_config",
+							  &xtensa_defconfig);
+
+  if (config->config_size < sizeof(struct xtensa_config))
+    {
+      fprintf (stderr,
+	       "Old or incompatible configuration is loaded: config_size = %ld, expected: %ld\n",
+	       config->config_size, sizeof (struct xtensa_config));
+      abort ();
+    }
+  return config;
+}
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index 59d6b00..7852f44 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.c.  */
 
 /* 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
diff --git a/include/xtensa-dynconfig.h b/include/xtensa-dynconfig.h
new file mode 100644
index 0000000..12181be
--- /dev/null
+++ b/include/xtensa-dynconfig.h
@@ -0,0 +1,373 @@
+/* Xtensa configuration settings.
+   Copyright (C) 2017 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_DYNAMIC_CONFIG_H
+#define XTENSA_DYNAMIC_CONFIG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct xtensa_config {
+    unsigned long config_size;
+    unsigned int xchal_have_be;
+    unsigned int xchal_have_density;
+    unsigned int xchal_have_const16;
+    unsigned int xchal_have_abs;
+    unsigned int xchal_have_addx;
+    unsigned int xchal_have_l32r;
+    unsigned int xshal_use_absolute_literals;
+    unsigned int xshal_have_text_section_literals;
+    unsigned int xchal_have_mac16;
+    unsigned int xchal_have_mul16;
+    unsigned int xchal_have_mul32;
+    unsigned int xchal_have_mul32_high;
+    unsigned int xchal_have_div32;
+    unsigned int xchal_have_nsa;
+    unsigned int xchal_have_minmax;
+    unsigned int xchal_have_sext;
+    unsigned int xchal_have_loops;
+    unsigned int xchal_have_threadptr;
+    unsigned int xchal_have_release_sync;
+    unsigned int xchal_have_s32c1i;
+    unsigned int xchal_have_booleans;
+    unsigned int xchal_have_fp;
+    unsigned int xchal_have_fp_div;
+    unsigned int xchal_have_fp_recip;
+    unsigned int xchal_have_fp_sqrt;
+    unsigned int xchal_have_fp_rsqrt;
+    unsigned int xchal_have_fp_postinc;
+    unsigned int xchal_have_dfp;
+    unsigned int xchal_have_dfp_div;
+    unsigned int xchal_have_dfp_recip;
+    unsigned int xchal_have_dfp_sqrt;
+    unsigned int xchal_have_dfp_rsqrt;
+    unsigned int xchal_have_windowed;
+    unsigned int xchal_num_aregs;
+    unsigned int xchal_have_wide_branches;
+    unsigned int xchal_have_predicted_branches;
+    unsigned int xchal_icache_size;
+    unsigned int xchal_dcache_size;
+    unsigned int xchal_icache_linesize;
+    unsigned int xchal_dcache_linesize;
+    unsigned int xchal_icache_linewidth;
+    unsigned int xchal_dcache_linewidth;
+    unsigned int xchal_dcache_is_writeback;
+    unsigned int xchal_have_mmu;
+    unsigned int xchal_mmu_min_pte_page_size;
+    unsigned int xchal_have_debug;
+    unsigned int xchal_num_ibreak;
+    unsigned int xchal_num_dbreak;
+    unsigned int xchal_debuglevel;
+    unsigned int xchal_max_instruction_size;
+    unsigned int xchal_inst_fetch_width;
+    unsigned int xshal_abi;
+    unsigned int xthal_abi_windowed;
+    unsigned int xthal_abi_call0;
+};
+
+typedef struct xtensa_isa_internal_struct xtensa_isa_internal;
+
+extern void *xtensa_load_config (const char *name, void *def);
+extern struct xtensa_config *xtensa_get_config (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
+
+#define XTENSA_CONFIG_ENTRY(a) a
+
+#define XTENSA_CONFIG_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_INITIALIZER { \
+    sizeof (struct xtensa_config), \
+    XTENSA_CONFIG_ENTRY_LIST, \
+}
+
+#else /* XTENSA_CONFIG_DEFINITION */
+
+#undef XCHAL_HAVE_BE
+#define XCHAL_HAVE_BE			(xtensa_get_config ()->xchal_have_be)
+
+#undef XCHAL_HAVE_DENSITY
+#define XCHAL_HAVE_DENSITY		(xtensa_get_config ()->xchal_have_density)
+
+#undef XCHAL_HAVE_CONST16
+#define XCHAL_HAVE_CONST16		(xtensa_get_config ()->xchal_have_const16)
+
+#undef XCHAL_HAVE_ABS
+#define XCHAL_HAVE_ABS			(xtensa_get_config ()->xchal_have_abs)
+
+#undef XCHAL_HAVE_ADDX
+#define XCHAL_HAVE_ADDX			(xtensa_get_config ()->xchal_have_addx)
+
+#undef XCHAL_HAVE_L32R
+#define XCHAL_HAVE_L32R			(xtensa_get_config ()->xchal_have_l32r)
+
+#undef XSHAL_USE_ABSOLUTE_LITERALS
+#define XSHAL_USE_ABSOLUTE_LITERALS	(xtensa_get_config ()->xshal_use_absolute_literals)
+
+#undef XSHAL_HAVE_TEXT_SECTION_LITERALS
+#define XSHAL_HAVE_TEXT_SECTION_LITERALS (xtensa_get_config ()->xshal_have_text_section_literals)
+
+#undef XCHAL_HAVE_MAC16
+#define XCHAL_HAVE_MAC16		(xtensa_get_config ()->xchal_have_mac16)
+
+#undef XCHAL_HAVE_MUL16
+#define XCHAL_HAVE_MUL16		(xtensa_get_config ()->xchal_have_mul16)
+
+#undef XCHAL_HAVE_MUL32
+#define XCHAL_HAVE_MUL32		(xtensa_get_config ()->xchal_have_mul32)
+
+#undef XCHAL_HAVE_MUL32_HIGH
+#define XCHAL_HAVE_MUL32_HIGH		(xtensa_get_config ()->xchal_have_mul32_high)
+
+#undef XCHAL_HAVE_DIV32
+#define XCHAL_HAVE_DIV32		(xtensa_get_config ()->xchal_have_div32)
+
+#undef XCHAL_HAVE_NSA
+#define XCHAL_HAVE_NSA			(xtensa_get_config ()->xchal_have_nsa)
+
+#undef XCHAL_HAVE_MINMAX
+#define XCHAL_HAVE_MINMAX		(xtensa_get_config ()->xchal_have_minmax)
+
+#undef XCHAL_HAVE_SEXT
+#define XCHAL_HAVE_SEXT			(xtensa_get_config ()->xchal_have_sext)
+
+#undef XCHAL_HAVE_LOOPS
+#define XCHAL_HAVE_LOOPS		(xtensa_get_config ()->xchal_have_loops)
+
+#undef XCHAL_HAVE_THREADPTR
+#define XCHAL_HAVE_THREADPTR		(xtensa_get_config ()->xchal_have_threadptr)
+
+#undef XCHAL_HAVE_RELEASE_SYNC
+#define XCHAL_HAVE_RELEASE_SYNC		(xtensa_get_config ()->xchal_have_release_sync)
+
+#undef XCHAL_HAVE_S32C1I
+#define XCHAL_HAVE_S32C1I		(xtensa_get_config ()->xchal_have_s32c1i)
+
+#undef XCHAL_HAVE_BOOLEANS
+#define XCHAL_HAVE_BOOLEANS		(xtensa_get_config ()->xchal_have_booleans)
+
+#undef XCHAL_HAVE_FP
+#define XCHAL_HAVE_FP			(xtensa_get_config ()->xchal_have_fp)
+
+#undef XCHAL_HAVE_FP_DIV
+#define XCHAL_HAVE_FP_DIV		(xtensa_get_config ()->xchal_have_fp_div)
+
+#undef XCHAL_HAVE_FP_RECIP
+#define XCHAL_HAVE_FP_RECIP		(xtensa_get_config ()->xchal_have_fp_recip)
+
+#undef XCHAL_HAVE_FP_SQRT
+#define XCHAL_HAVE_FP_SQRT		(xtensa_get_config ()->xchal_have_fp_sqrt)
+
+#undef XCHAL_HAVE_FP_RSQRT
+#define XCHAL_HAVE_FP_RSQRT		(xtensa_get_config ()->xchal_have_fp_rsqrt)
+
+#undef XCHAL_HAVE_FP_POSTINC
+#define XCHAL_HAVE_FP_POSTINC		(xtensa_get_config ()->xchal_have_fp_postinc)
+
+#undef XCHAL_HAVE_DFP
+#define XCHAL_HAVE_DFP			(xtensa_get_config ()->xchal_have_dfp)
+
+#undef XCHAL_HAVE_DFP_DIV
+#define XCHAL_HAVE_DFP_DIV		(xtensa_get_config ()->xchal_have_dfp_div)
+
+#undef XCHAL_HAVE_DFP_RECIP
+#define XCHAL_HAVE_DFP_RECIP		(xtensa_get_config ()->xchal_have_dfp_recip)
+
+#undef XCHAL_HAVE_DFP_SQRT
+#define XCHAL_HAVE_DFP_SQRT		(xtensa_get_config ()->xchal_have_dfp_sqrt)
+
+#undef XCHAL_HAVE_DFP_RSQRT
+#define XCHAL_HAVE_DFP_RSQRT		(xtensa_get_config ()->xchal_have_dfp_rsqrt)
+
+#undef XCHAL_HAVE_WINDOWED
+#define XCHAL_HAVE_WINDOWED		(xtensa_get_config ()->xchal_have_windowed)
+
+#undef XCHAL_NUM_AREGS
+#define XCHAL_NUM_AREGS			(xtensa_get_config ()->xchal_num_aregs)
+
+#undef XCHAL_HAVE_WIDE_BRANCHES
+#define XCHAL_HAVE_WIDE_BRANCHES	(xtensa_get_config ()->xchal_have_wide_branches)
+
+#undef XCHAL_HAVE_PREDICTED_BRANCHES
+#define XCHAL_HAVE_PREDICTED_BRANCHES	(xtensa_get_config ()->xchal_have_predicted_branches)
+
+
+#undef XCHAL_ICACHE_SIZE
+#define XCHAL_ICACHE_SIZE		(xtensa_get_config ()->xchal_icache_size)
+
+#undef XCHAL_DCACHE_SIZE
+#define XCHAL_DCACHE_SIZE		(xtensa_get_config ()->xchal_dcache_size)
+
+#undef XCHAL_ICACHE_LINESIZE
+#define XCHAL_ICACHE_LINESIZE		(xtensa_get_config ()->xchal_icache_linesize)
+
+#undef XCHAL_DCACHE_LINESIZE
+#define XCHAL_DCACHE_LINESIZE		(xtensa_get_config ()->xchal_dcache_linesize)
+
+#undef XCHAL_ICACHE_LINEWIDTH
+#define XCHAL_ICACHE_LINEWIDTH		(xtensa_get_config ()->xchal_icache_linewidth)
+
+#undef XCHAL_DCACHE_LINEWIDTH
+#define XCHAL_DCACHE_LINEWIDTH		(xtensa_get_config ()->xchal_dcache_linewidth)
+
+#undef XCHAL_DCACHE_IS_WRITEBACK
+#define XCHAL_DCACHE_IS_WRITEBACK	(xtensa_get_config ()->xchal_dcache_is_writeback)
+
+
+#undef XCHAL_HAVE_MMU
+#define XCHAL_HAVE_MMU			(xtensa_get_config ()->xchal_have_mmu)
+
+#undef XCHAL_MMU_MIN_PTE_PAGE_SIZE
+#define XCHAL_MMU_MIN_PTE_PAGE_SIZE	(xtensa_get_config ()->xchal_mmu_min_pte_page_size)
+
+
+#undef XCHAL_HAVE_DEBUG
+#define XCHAL_HAVE_DEBUG		(xtensa_get_config ()->xchal_have_debug)
+
+#undef XCHAL_NUM_IBREAK
+#define XCHAL_NUM_IBREAK		(xtensa_get_config ()->xchal_num_ibreak)
+
+#undef XCHAL_NUM_DBREAK
+#define XCHAL_NUM_DBREAK		(xtensa_get_config ()->xchal_num_dbreak)
+
+#undef XCHAL_DEBUGLEVEL
+#define XCHAL_DEBUGLEVEL		(xtensa_get_config ()->xchal_debuglevel)
+
+
+#undef XCHAL_MAX_INSTRUCTION_SIZE
+#define XCHAL_MAX_INSTRUCTION_SIZE	(xtensa_get_config ()->xchal_max_instruction_size)
+
+#undef XCHAL_INST_FETCH_WIDTH
+#define XCHAL_INST_FETCH_WIDTH		(xtensa_get_config ()->xchal_inst_fetch_width)
+
+
+#undef XSHAL_ABI
+#undef XTHAL_ABI_WINDOWED
+#undef XTHAL_ABI_CALL0
+#define XSHAL_ABI			(xtensa_get_config ()->xshal_abi)
+#define XTHAL_ABI_WINDOWED		(xtensa_get_config ()->xthal_abi_windowed)
+#define XTHAL_ABI_CALL0			(xtensa_get_config ()->xthal_abi_call0)
+
+#endif /* XTENSA_CONFIG_DEFINITION */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !XTENSA_DYNAMIC_CONFIG_H */
-- 
2.1.4

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

* [RFC 5/5] libgcc: xtensa: use built-in configuration
  2017-05-22 21:09 [RFC 0/5] xtensa: support dynamic configuration Max Filippov
                   ` (2 preceding siblings ...)
  2017-05-22 21:09 ` [RFC 3/5] gcc: xtensa: support dynconfig on windows Max Filippov
@ 2017-05-22 21:09 ` Max Filippov
  2017-05-22 21:31 ` [RFC 1/5] gcc: xtensa: allow XCHAL_* macros to be non-constant Max Filippov
  4 siblings, 0 replies; 14+ messages in thread
From: Max Filippov @ 2017-05-22 21:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, 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.

2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
include/
	* xtensa-config-builtin.h: New File.

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.
---
 include/xtensa-config-builtin.h  | 191 +++++++++++++++++++++++++++++++++++++++
 libgcc/config/xtensa/crti.S      |   2 +-
 libgcc/config/xtensa/crtn.S      |   2 +-
 libgcc/config/xtensa/lib1funcs.S |   2 +-
 libgcc/config/xtensa/lib2funcs.S |   2 +-
 5 files changed, 195 insertions(+), 4 deletions(-)
 create mode 100644 include/xtensa-config-builtin.h

diff --git a/include/xtensa-config-builtin.h b/include/xtensa-config-builtin.h
new file mode 100644
index 0000000..785d62c
--- /dev/null
+++ b/include/xtensa-config-builtin.h
@@ -0,0 +1,191 @@
+/* Xtensa configuration settings.
+   Copyright (C) 2017 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_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 */
diff --git a/libgcc/config/xtensa/crti.S b/libgcc/config/xtensa/crti.S
index 58bb19a..0e23bfc 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 27e5253..85d0bc1 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 e0ea2dc..02f066c 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 2e047a8..3076eeb 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
-- 
2.1.4

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

* [RFC 4/5] gcc: xtensa: add __XCHAL_* builtins
  2017-05-22 21:09 [RFC 0/5] xtensa: support dynamic configuration Max Filippov
@ 2017-05-22 21:09 ` Max Filippov
  2017-05-22 21:09 ` [RFC 2/5] gcc: xtensa: make configuration dynamic Max Filippov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Max Filippov @ 2017-05-22 21:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov

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.

2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
gcc/
	* config/xtensa/xtensa-config.c (_STRINGIFY, STRINGIFY,
	XTENSA_CONFIG_ENTRY): New definitions.
	(xtensa_config_strings): New array with default __XCHAL_*
	macros.
	(xtensa_get_config_strings): New function.
	* config/xtensa/xtensa-protos.h (xtensa_get_config_strings): New
	declaration.
	* gcc/config/xtensa/xtensa.h (TARGET_CPU_CPP_BUILTINS): Add new
	'builtin' variable and loop through string array returned by the
	xtensa_get_config_strings function call.
---
 gcc/config/xtensa/xtensa-config.c | 22 ++++++++++++++++++++++
 gcc/config/xtensa/xtensa-protos.h |  1 +
 gcc/config/xtensa/xtensa.h        |  3 +++
 3 files changed, 26 insertions(+)

diff --git a/gcc/config/xtensa/xtensa-config.c b/gcc/config/xtensa/xtensa-config.c
index 3259867..3d242d1 100644
--- a/gcc/config/xtensa/xtensa-config.c
+++ b/gcc/config/xtensa/xtensa-config.c
@@ -13,6 +13,17 @@
 
 static struct xtensa_config xtensa_defconfig = XTENSA_CONFIG_INITIALIZER;
 
+#define _STRINGIFY(a) #a
+#define STRINGIFY(a) _STRINGIFY(a)
+
+#undef XTENSA_CONFIG_ENTRY
+#define XTENSA_CONFIG_ENTRY(a) "__" #a "=" STRINGIFY(a)
+
+static const char *xtensa_config_strings[] = {
+    XTENSA_CONFIG_ENTRY_LIST,
+    NULL,
+};
+
 #if !defined (HAVE_DLFCN_H) && defined (_WIN32)
 
 #define RTLD_LAZY 0      /* Dummy value.  */
@@ -115,3 +126,14 @@ struct xtensa_config *xtensa_get_config (void)
     }
   return config;
 }
+
+const char **xtensa_get_config_strings (void)
+{
+  static const char **config_strings;
+
+  if (!config_strings)
+    config_strings = (const char **) xtensa_load_config ("xtensa_config_strings",
+							 &xtensa_config_strings);
+
+  return config_strings;
+}
diff --git a/gcc/config/xtensa/xtensa-protos.h b/gcc/config/xtensa/xtensa-protos.h
index 38901b7..d8eba73 100644
--- a/gcc/config/xtensa/xtensa-protos.h
+++ b/gcc/config/xtensa/xtensa-protos.h
@@ -73,5 +73,6 @@ extern void xtensa_expand_prologue (void);
 extern void xtensa_expand_epilogue (void);
 extern void order_regs_for_local_alloc (void);
 extern enum reg_class xtensa_regno_to_class (int regno);
+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 7852f44..e1d2e74 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -63,6 +63,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__");					\
@@ -72,6 +73,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) "
-- 
2.1.4

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

* [RFC 3/5] gcc: xtensa: support dynconfig on windows
  2017-05-22 21:09 [RFC 0/5] xtensa: support dynamic configuration Max Filippov
  2017-05-22 21:09 ` [RFC 4/5] gcc: xtensa: add __XCHAL_* builtins Max Filippov
  2017-05-22 21:09 ` [RFC 2/5] gcc: xtensa: make configuration dynamic Max Filippov
@ 2017-05-22 21:09 ` Max Filippov
  2017-05-22 21:09 ` [RFC 5/5] libgcc: xtensa: use built-in configuration Max Filippov
  2017-05-22 21:31 ` [RFC 1/5] gcc: xtensa: allow XCHAL_* macros to be non-constant Max Filippov
  4 siblings, 0 replies; 14+ messages in thread
From: Max Filippov @ 2017-05-22 21:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov

2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
gcc/
	* config/xtensa/xtensa-config.c (dlfcn.h, windows.h): New
	#include'd headers.
	(RTLD_LAZY): New macro definition.
	(dlopen, dlsym, dlclose, dlerror): New function definitions.
---
 gcc/config/xtensa/xtensa-config.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/gcc/config/xtensa/xtensa-config.c b/gcc/config/xtensa/xtensa-config.c
index 296caf4..3259867 100644
--- a/gcc/config/xtensa/xtensa-config.c
+++ b/gcc/config/xtensa/xtensa-config.c
@@ -4,8 +4,46 @@
 #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
+
 static struct xtensa_config xtensa_defconfig = XTENSA_CONFIG_INITIALIZER;
 
+#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)  */
+
 void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED, void *def)
 {
   static int init;
-- 
2.1.4

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

* [RFC 0/5] xtensa: support dynamic configuration
@ 2017-05-22 21:09 Max Filippov
  2017-05-22 21:09 ` [RFC 4/5] gcc: xtensa: add __XCHAL_* builtins Max Filippov
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Max Filippov @ 2017-05-22 21:09 UTC (permalink / raw)
  To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov

Hi Sterling,

this is an RFC series that makes xtensa gcc dynamically configurable,
i.e. 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
using 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 following project:

  https://github.com/jcmvbkbc/xtensa-dynconfig

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.

Max Filippov (5):
  gcc: xtensa: allow XCHAL_* macros to be non-constant
  gcc: xtensa: make configuration dynamic
  gcc: xtensa: support dynconfig on windows
  gcc: xtensa: add __XCHAL_* builtins
  libgcc: xtensa: use built-in configuration

 gcc/Makefile.in                   |   2 +-
 gcc/config.gcc                    |   1 +
 gcc/config/xtensa/t-xtensa        |   5 +
 gcc/config/xtensa/xtensa-config.c | 139 ++++++++++++++
 gcc/config/xtensa/xtensa-protos.h |   1 +
 gcc/config/xtensa/xtensa.c        |  18 +-
 gcc/config/xtensa/xtensa.h        |  31 ++--
 include/xtensa-config-builtin.h   | 191 +++++++++++++++++++
 include/xtensa-dynconfig.h        | 373 ++++++++++++++++++++++++++++++++++++++
 libgcc/config/xtensa/crti.S       |   2 +-
 libgcc/config/xtensa/crtn.S       |   2 +-
 libgcc/config/xtensa/lib1funcs.S  |   2 +-
 libgcc/config/xtensa/lib2funcs.S  |   2 +-
 13 files changed, 736 insertions(+), 33 deletions(-)
 create mode 100644 gcc/config/xtensa/xtensa-config.c
 create mode 100644 include/xtensa-config-builtin.h
 create mode 100644 include/xtensa-dynconfig.h

-- 
2.1.4

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

* [RFC 1/5] gcc: xtensa: allow XCHAL_* macros to be non-constant
  2017-05-22 21:09 [RFC 0/5] xtensa: support dynamic configuration Max Filippov
                   ` (3 preceding siblings ...)
  2017-05-22 21:09 ` [RFC 5/5] libgcc: xtensa: use built-in configuration Max Filippov
@ 2017-05-22 21:31 ` Max Filippov
  2017-05-22 21:49   ` augustine.sterling
  2017-05-25 18:24   ` augustine.sterling
  4 siblings, 2 replies; 14+ messages in thread
From: Max Filippov @ 2017-05-22 21:31 UTC (permalink / raw)
  To: gcc-patches; +Cc: linux-xtensa, Sterling Augustine, Max Filippov

XCHAL_* macros from the xtensa-config.h are used in a number of places
that require them to be preprocessor constants. Rewrite these places so
that non-constant XCHAL_* definitions could be used there.

2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
gcc/
	* config/xtensa/xtensa.c (xtensa_option_override): Append
	MASK_CONST16 to target_flags in the absence of TARGET_L32R.
	(hwloop_optimize, hwloop_fail, hwloop_pattern_reg,
	 xtensa_doloop_hooks): Define unconditionally.
	(xtensa_reorg_loops): Only call reorg_loops in the presence of
	TARGET_LOOPS.
	* config/xtensa/xtensa.h (TARGET_L32R): New definition.
	(TARGET_DEFAULT): Remove XCHAL_HAVE_L32R condition and account
	for it in xtensa_option_override.
	(HARD_FRAME_POINTER_IS_FRAME_POINTER,
	 HARD_FRAME_POINTER_IS_ARG_POINTER): New definitions.
---
 gcc/config/xtensa/xtensa.c | 18 +++++++++---------
 gcc/config/xtensa/xtensa.h | 11 ++++++++---
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c
index 0181dde..8b20c64 100644
--- a/gcc/config/xtensa/xtensa.c
+++ b/gcc/config/xtensa/xtensa.c
@@ -2181,6 +2181,13 @@ xtensa_option_override (void)
   int regno;
   machine_mode mode;
 
+  /* Use CONST16 in the absence of L32R.
+     Set it in the TARGET_OPTION_OVERRIDE to avoid dependency on xtensa
+     configuration in the xtensa-common.c  */
+
+  if (!TARGET_L32R)
+    target_flags |= MASK_CONST16;
+
   if (!TARGET_BOOLEANS && TARGET_HARD_FLOAT)
     error ("boolean registers required for the floating-point option");
 
@@ -4053,8 +4060,6 @@ xtensa_invalid_within_doloop (const rtx_insn *insn)
 
 /* Optimize LOOP.  */
 
-#if TARGET_LOOPS
-
 static bool
 hwloop_optimize (hwloop_info loop)
 {
@@ -4241,14 +4246,9 @@ static struct hw_doloop_hooks xtensa_doloop_hooks =
 static void
 xtensa_reorg_loops (void)
 {
-  reorg_loops (false, &xtensa_doloop_hooks);
-}
-#else
-static inline void
-xtensa_reorg_loops (void)
-{
+  if (TARGET_LOOPS)
+    reorg_loops (false, &xtensa_doloop_hooks);
 }
-#endif
 
 /* Implement the TARGET_MACHINE_DEPENDENT_REORG pass.  */
 
diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h
index c32e8ca..59d6b00 100644
--- a/gcc/config/xtensa/xtensa.h
+++ b/gcc/config/xtensa/xtensa.h
@@ -66,10 +66,9 @@ along with GCC; see the file COPYING3.  If not see
 #define TARGET_LOOPS	        XCHAL_HAVE_LOOPS
 #define TARGET_WINDOWED_ABI	(XSHAL_ABI == XTHAL_ABI_WINDOWED)
 #define TARGET_DEBUG		XCHAL_HAVE_DEBUG
+#define TARGET_L32R		XCHAL_HAVE_L32R
 
-#define TARGET_DEFAULT \
-  ((XCHAL_HAVE_L32R	? 0 : MASK_CONST16) |				\
-   MASK_SERIALIZE_VOLATILE)
+#define TARGET_DEFAULT (MASK_SERIALIZE_VOLATILE)
 
 #ifndef HAVE_AS_TLS
 #define HAVE_AS_TLS 0
@@ -362,6 +361,12 @@ extern char xtensa_hard_regno_mode_ok[][FIRST_PSEUDO_REGISTER];
 /* Base register for access to arguments of the function.  */
 #define ARG_POINTER_REGNUM (GP_REG_FIRST + 17)
 
+/* Hard frame pointer is neither frame nor arg pointer.
+   The definitions are here because actual hard frame pointer register
+   definition is not a preprocessor constant.  */
+#define HARD_FRAME_POINTER_IS_FRAME_POINTER 0
+#define HARD_FRAME_POINTER_IS_ARG_POINTER 0
+
 /* For now we don't try to use the full set of boolean registers.  Without
    software pipelining of FP operations, there's not much to gain and it's
    a real pain to get them reloaded.  */
-- 
2.1.4

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

* Re: [RFC 1/5] gcc: xtensa: allow XCHAL_* macros to be non-constant
  2017-05-22 21:31 ` [RFC 1/5] gcc: xtensa: allow XCHAL_* macros to be non-constant Max Filippov
@ 2017-05-22 21:49   ` augustine.sterling
  2017-05-23  2:19     ` Max Filippov
  2017-05-25 18:24   ` augustine.sterling
  1 sibling, 1 reply; 14+ messages in thread
From: augustine.sterling @ 2017-05-22 21:49 UTC (permalink / raw)
  To: Max Filippov; +Cc: gcc-patches, linux-xtensa

On Mon, May 22, 2017 at 2:09 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> XCHAL_* macros from the xtensa-config.h are used in a number of places
> that require them to be preprocessor constants. Rewrite these places so
> that non-constant XCHAL_* definitions could be used there.

This whole series of patches is going to take quite a bit of time to
sort through, so sit tight if you would.

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

* Re: [RFC 1/5] gcc: xtensa: allow XCHAL_* macros to be non-constant
  2017-05-22 21:49   ` augustine.sterling
@ 2017-05-23  2:19     ` Max Filippov
  0 siblings, 0 replies; 14+ messages in thread
From: Max Filippov @ 2017-05-23  2:19 UTC (permalink / raw)
  To: augustine.sterling; +Cc: gcc-patches, linux-xtensa

On Mon, May 22, 2017 at 2:30 PM, augustine.sterling@gmail.com
<augustine.sterling@gmail.com> wrote:
> On Mon, May 22, 2017 at 2:09 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> XCHAL_* macros from the xtensa-config.h are used in a number of places
>> that require them to be preprocessor constants. Rewrite these places so
>> that non-constant XCHAL_* definitions could be used there.
>
> This whole series of patches is going to take quite a bit of time to
> sort through, so sit tight if you would.

Sure, there's no rush. Thank you for doing it.

-- Max

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

* Re: [RFC 1/5] gcc: xtensa: allow XCHAL_* macros to be non-constant
  2017-05-22 21:31 ` [RFC 1/5] gcc: xtensa: allow XCHAL_* macros to be non-constant Max Filippov
  2017-05-22 21:49   ` augustine.sterling
@ 2017-05-25 18:24   ` augustine.sterling
  2017-06-14 17:23     ` Max Filippov
  1 sibling, 1 reply; 14+ messages in thread
From: augustine.sterling @ 2017-05-25 18:24 UTC (permalink / raw)
  To: Max Filippov; +Cc: gcc-patches, linux-xtensa

On Mon, May 22, 2017 at 2:09 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> XCHAL_* macros from the xtensa-config.h are used in a number of places
> that require them to be preprocessor constants. Rewrite these places so
> that non-constant XCHAL_* definitions could be used there.
>
> 2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
> gcc/
>         * config/xtensa/xtensa.c (xtensa_option_override): Append
>         MASK_CONST16 to target_flags in the absence of TARGET_L32R.
>         (hwloop_optimize, hwloop_fail, hwloop_pattern_reg,
>          xtensa_doloop_hooks): Define unconditionally.
>         (xtensa_reorg_loops): Only call reorg_loops in the presence of
>         TARGET_LOOPS.
>         * config/xtensa/xtensa.h (TARGET_L32R): New definition.
>         (TARGET_DEFAULT): Remove XCHAL_HAVE_L32R condition and account
>         for it in xtensa_option_override.
>         (HARD_FRAME_POINTER_IS_FRAME_POINTER,
>          HARD_FRAME_POINTER_IS_ARG_POINTER): New definitions.

This is OK. Please apply.

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

* Re: [RFC 2/5] gcc: xtensa: make configuration dynamic
  2017-05-22 21:09 ` [RFC 2/5] gcc: xtensa: make configuration dynamic Max Filippov
@ 2017-05-25 18:25   ` augustine.sterling
  2017-05-25 20:57     ` Max Filippov
  0 siblings, 1 reply; 14+ messages in thread
From: augustine.sterling @ 2017-05-25 18:25 UTC (permalink / raw)
  To: Max Filippov; +Cc: gcc-patches, linux-xtensa

On Mon, May 22, 2017 at 2:09 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> Now that XCHAL_* macros don't have to be preprocessor constants add
> include/xtensa-dynconfig.h that defines them as fields of a structure
> returned from the xtensa_get_config function.
> 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 that uses xtensa_load_config to
> get structure xtensa_config, either dynamically configured or the
> default.
>
> 2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
> gcc/
>         * Makefile.in (PLUGIN_HEADERS): Add include/xtensa-dynconfig.h.
>         * config.gcc (xtensa*-*-*): Add xtensa-config.o to extra_objs.
>         * gcc/config/xtensa/t-xtensa (xtensa-config.o): New rule.
>         * gcc/config/xtensa/xtensa-config.c: New file.
>         * gcc/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.

This almost certainly should go through the normal gcc plugin
mechanism instead of the hand-rolled one you have here.

https://gcc.gnu.org/onlinedocs/gccint/Plugins.html#Plugins

If there is a reason it can't (and I'm not sufficiently familiar with
the issues here), then you need to ensure that the various protections
enforced by the normal plugin mechanism is used--and someone more
knowledgeable than me needs to review it.

Please note that by using a plugin mechanism, there are licensing
issues that come into play, that are different from the usual
licensing issues. I would be absolutely sure that you all are OK with
how the runtime exception applies to this new situation.

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

* Re: [RFC 2/5] gcc: xtensa: make configuration dynamic
  2017-05-25 18:25   ` augustine.sterling
@ 2017-05-25 20:57     ` Max Filippov
  2017-05-26 15:04       ` Ian Lance Taylor via gcc-patches
  0 siblings, 1 reply; 14+ messages in thread
From: Max Filippov @ 2017-05-25 20:57 UTC (permalink / raw)
  To: augustine.sterling; +Cc: gcc-patches, linux-xtensa, Le-Chun Wu

On Thu, May 25, 2017 at 11:24 AM, augustine.sterling@gmail.com
<augustine.sterling@gmail.com> wrote:
> On Mon, May 22, 2017 at 2:09 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> Now that XCHAL_* macros don't have to be preprocessor constants add
>> include/xtensa-dynconfig.h that defines them as fields of a structure
>> returned from the xtensa_get_config function.
>> 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 that uses xtensa_load_config to
>> get structure xtensa_config, either dynamically configured or the
>> default.
>>
>> 2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
>> gcc/
>>         * Makefile.in (PLUGIN_HEADERS): Add include/xtensa-dynconfig.h.
>>         * config.gcc (xtensa*-*-*): Add xtensa-config.o to extra_objs.
>>         * gcc/config/xtensa/t-xtensa (xtensa-config.o): New rule.
>>         * gcc/config/xtensa/xtensa-config.c: New file.
>>         * gcc/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.
>
> This almost certainly should go through the normal gcc plugin
> mechanism instead of the hand-rolled one you have here.
>
> https://gcc.gnu.org/onlinedocs/gccint/Plugins.html#Plugins
>
> If there is a reason it can't (and I'm not sufficiently familiar with
> the issues here), then you need to ensure that the various protections
> enforced by the normal plugin mechanism is used--and someone more
> knowledgeable than me needs to review it.

(adding Le-Chun Wu, current reviewer of the plugin code)

I tried to use plugins initially, but the following considerations made me
lean towards this implementation:
- we don't actually need any of the functionality available to gcc plugins,
  we only need to provide a data structure that the compiler knows how
  to use;
- using environment variable makes configuration transparent for gcc, all
  binutils and gdb, whereas using gcc plugin would require changing gcc
  invocation command line, which is not always possible;
- this implementation is shared between gcc and binutils. OTOH using
  plugin with gcc suggests using plugin with binutils, where it's substantially
  different and not universally supported across different binutils components
  (particularly neither assembler nor objdump have any support for it);
- gcc does not support plugins when built for windows host using MinGW;

Does the above justify this implementation? If no, are there any suggestions
how the above points may be addressed?

> Please note that by using a plugin mechanism, there are licensing
> issues that come into play, that are different from the usual
> licensing issues. I would be absolutely sure that you all are OK with
> how the runtime exception applies to this new situation.

All code used for building the configuration shared object is either GPL
(part of binutils) or MIT (xtensa configuration overlay), so it should be ok?

-- 
Thanks.
-- Max

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

* Re: [RFC 2/5] gcc: xtensa: make configuration dynamic
  2017-05-25 20:57     ` Max Filippov
@ 2017-05-26 15:04       ` Ian Lance Taylor via gcc-patches
  2017-05-26 18:48         ` Max Filippov
  0 siblings, 1 reply; 14+ messages in thread
From: Ian Lance Taylor via gcc-patches @ 2017-05-26 15:04 UTC (permalink / raw)
  To: Max Filippov; +Cc: augustine.sterling, gcc-patches, linux-xtensa, Le-Chun Wu

On Thu, May 25, 2017 at 1:31 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
> On Thu, May 25, 2017 at 11:24 AM, augustine.sterling@gmail.com
> <augustine.sterling@gmail.com> wrote:
>
>> Please note that by using a plugin mechanism, there are licensing
>> issues that come into play, that are different from the usual
>> licensing issues. I would be absolutely sure that you all are OK with
>> how the runtime exception applies to this new situation.
>
> All code used for building the configuration shared object is either GPL
> (part of binutils) or MIT (xtensa configuration overlay), so it should be ok?

You are in effect introducing a new kind of plugin mechanism.  I won't
comment on whether it should use the existing plugin mechanism or not,
but it's important to stress that the GCC Runtime Library Exception
(https://www.gnu.org/licenses/gcc-exception-3.1.en.html) has rules
that apply here.  In effect, if you want to distribute the binary
produced by GCC, all the plugins that you use must be available under
a GPL-compatible license.  The people to whom you distribute the
binary produced by GCC must be able to themselves build the plugin
used to create the binary.  The plugin may not have any proprietary
source code.

One way that the GCC plugin mechanism makes that clear is by requiring
the plugin to define a symbol named, literally,
"plugin_is_GPL_compatible".  While there is no enforcement mechanism
as such, this ensures that the person creating the plugin acknowledges
that at the very least the plugin is supposed to be under a GPL
compatible license.  I think that if you are going to introduce a new
plugin mechanism, you should adopt the same approach.

Ian

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

* Re: [RFC 2/5] gcc: xtensa: make configuration dynamic
  2017-05-26 15:04       ` Ian Lance Taylor via gcc-patches
@ 2017-05-26 18:48         ` Max Filippov
  0 siblings, 0 replies; 14+ messages in thread
From: Max Filippov @ 2017-05-26 18:48 UTC (permalink / raw)
  To: Ian Lance Taylor
  Cc: augustine.sterling, gcc-patches, linux-xtensa, Le-Chun Wu

On Fri, May 26, 2017 at 7:44 AM, Ian Lance Taylor <iant@google.com> wrote:
> On Thu, May 25, 2017 at 1:31 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> On Thu, May 25, 2017 at 11:24 AM, augustine.sterling@gmail.com
>> <augustine.sterling@gmail.com> wrote:
>>
>>> Please note that by using a plugin mechanism, there are licensing
>>> issues that come into play, that are different from the usual
>>> licensing issues. I would be absolutely sure that you all are OK with
>>> how the runtime exception applies to this new situation.
>>
>> All code used for building the configuration shared object is either GPL
>> (part of binutils) or MIT (xtensa configuration overlay), so it should be ok?
>
> You are in effect introducing a new kind of plugin mechanism.  I won't
> comment on whether it should use the existing plugin mechanism or not,
> but it's important to stress that the GCC Runtime Library Exception
> (https://www.gnu.org/licenses/gcc-exception-3.1.en.html) has rules
> that apply here.  In effect, if you want to distribute the binary
> produced by GCC, all the plugins that you use must be available under
> a GPL-compatible license.  The people to whom you distribute the
> binary produced by GCC must be able to themselves build the plugin
> used to create the binary.  The plugin may not have any proprietary
> source code.

Thanks, that's how I understood that. I've added a note to the plugin
README: https://github.com/jcmvbkbc/xtensa-dynconfig/blob/master/README

> One way that the GCC plugin mechanism makes that clear is by requiring
> the plugin to define a symbol named, literally,
> "plugin_is_GPL_compatible".  While there is no enforcement mechanism
> as such, this ensures that the person creating the plugin acknowledges
> that at the very least the plugin is supposed to be under a GPL
> compatible license.  I think that if you are going to introduce a new
> plugin mechanism, you should adopt the same approach.

Sure I can add such requirement to this mechanism and implement that
check.

-- 
Thanks.
-- Max

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

* Re: [RFC 1/5] gcc: xtensa: allow XCHAL_* macros to be non-constant
  2017-05-25 18:24   ` augustine.sterling
@ 2017-06-14 17:23     ` Max Filippov
  0 siblings, 0 replies; 14+ messages in thread
From: Max Filippov @ 2017-06-14 17:23 UTC (permalink / raw)
  To: augustine.sterling; +Cc: gcc-patches, linux-xtensa

On Thu, May 25, 2017 at 11:15 AM, augustine.sterling@gmail.com
<augustine.sterling@gmail.com> wrote:
> On Mon, May 22, 2017 at 2:09 PM, Max Filippov <jcmvbkbc@gmail.com> wrote:
>> XCHAL_* macros from the xtensa-config.h are used in a number of places
>> that require them to be preprocessor constants. Rewrite these places so
>> that non-constant XCHAL_* definitions could be used there.
>>
>> 2017-05-22  Max Filippov  <jcmvbkbc@gmail.com>
>> gcc/
>>         * config/xtensa/xtensa.c (xtensa_option_override): Append
>>         MASK_CONST16 to target_flags in the absence of TARGET_L32R.
>>         (hwloop_optimize, hwloop_fail, hwloop_pattern_reg,
>>          xtensa_doloop_hooks): Define unconditionally.
>>         (xtensa_reorg_loops): Only call reorg_loops in the presence of
>>         TARGET_LOOPS.
>>         * config/xtensa/xtensa.h (TARGET_L32R): New definition.
>>         (TARGET_DEFAULT): Remove XCHAL_HAVE_L32R condition and account
>>         for it in xtensa_option_override.
>>         (HARD_FRAME_POINTER_IS_FRAME_POINTER,
>>          HARD_FRAME_POINTER_IS_ARG_POINTER): New definitions.
>
> This is OK. Please apply.

Applied this one to trunk. Thanks!

-- Max

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

end of thread, other threads:[~2017-06-14 17:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-22 21:09 [RFC 0/5] xtensa: support dynamic configuration Max Filippov
2017-05-22 21:09 ` [RFC 4/5] gcc: xtensa: add __XCHAL_* builtins Max Filippov
2017-05-22 21:09 ` [RFC 2/5] gcc: xtensa: make configuration dynamic Max Filippov
2017-05-25 18:25   ` augustine.sterling
2017-05-25 20:57     ` Max Filippov
2017-05-26 15:04       ` Ian Lance Taylor via gcc-patches
2017-05-26 18:48         ` Max Filippov
2017-05-22 21:09 ` [RFC 3/5] gcc: xtensa: support dynconfig on windows Max Filippov
2017-05-22 21:09 ` [RFC 5/5] libgcc: xtensa: use built-in configuration Max Filippov
2017-05-22 21:31 ` [RFC 1/5] gcc: xtensa: allow XCHAL_* macros to be non-constant Max Filippov
2017-05-22 21:49   ` augustine.sterling
2017-05-23  2:19     ` Max Filippov
2017-05-25 18:24   ` augustine.sterling
2017-06-14 17:23     ` 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).