public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: linux-xtensa@linux-xtensa.org,
	Sterling Augustine <augustine.sterling@gmail.com>,
	Max Filippov <jcmvbkbc@gmail.com>
Subject: [RFC 4/5] gcc: xtensa: add __XCHAL_* builtins
Date: Mon, 22 May 2017 21:09:00 -0000	[thread overview]
Message-ID: <1495487362-18969-5-git-send-email-jcmvbkbc@gmail.com> (raw)
In-Reply-To: <1495487362-18969-1-git-send-email-jcmvbkbc@gmail.com>

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

  parent reply	other threads:[~2017-05-22 21:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-22 21:09 [RFC 0/5] xtensa: support dynamic configuration Max Filippov
2017-05-22 21:09 ` [RFC 5/5] libgcc: xtensa: use built-in configuration Max Filippov
2017-05-22 21:09 ` [RFC 3/5] gcc: xtensa: support dynconfig on windows 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 ` Max Filippov [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1495487362-18969-5-git-send-email-jcmvbkbc@gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=augustine.sterling@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=linux-xtensa@linux-xtensa.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).