* [PATCH] xtensa: add minimal support
@ 2020-07-09 0:26 Luc Van Oostenryck
0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2020-07-09 0:26 UTC (permalink / raw)
To: linux-sparse; +Cc: Luc Van Oostenryck
This is one of the architecture needing a specific predefine
set in order to correctly process byteorder.h.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
Makefile | 1 +
machine.h | 1 +
target-xtensa.c | 31 +++++++++++++++++++++++++++++++
target.c | 2 ++
target.h | 1 +
5 files changed, 36 insertions(+)
create mode 100644 target-xtensa.c
diff --git a/Makefile b/Makefile
index 35098940080b..8b68cb69c896 100644
--- a/Makefile
+++ b/Makefile
@@ -82,6 +82,7 @@ LIB_OBJS += target-riscv.o
LIB_OBJS += target-s390.o
LIB_OBJS += target-sparc.o
LIB_OBJS += target-x86.o
+LIB_OBJS += target-xtensa.o
LIB_OBJS += tokenize.o
LIB_OBJS += unssa.o
LIB_OBJS += utils.o
diff --git a/machine.h b/machine.h
index 7407e71627e1..22da9c781a8a 100644
--- a/machine.h
+++ b/machine.h
@@ -37,6 +37,7 @@ enum machine {
MACH_M68K,
MACH_MICROBLAZE,
MACH_NIOS2,
+ MACH_XTENSA,
MACH_UNKNOWN
};
diff --git a/target-xtensa.c b/target-xtensa.c
new file mode 100644
index 000000000000..3e5781c86d82
--- /dev/null
+++ b/target-xtensa.c
@@ -0,0 +1,31 @@
+#include "symbol.h"
+#include "target.h"
+#include "machine.h"
+
+
+static void init_xtensa(const struct target *self)
+{
+ wchar_ctype = &long_ctype;
+}
+
+static void predefine_xtensa(const struct target *self)
+{
+ predefine("__XTENSA__", 1, "1");
+ predefine("__xtensa__", 1, "1");
+
+ if (arch_big_endian)
+ predefine("__XTENSA_EB__", 1, "1");
+ else
+ predefine("__XTENSA_EL__", 1, "1");
+}
+
+const struct target target_xtensa = {
+ .mach = MACH_XTENSA,
+ .bitness = ARCH_LP32,
+ .big_endian = true,
+
+ .bits_in_longdouble = 64,
+
+ .init = init_xtensa,
+ .predefine = predefine_xtensa,
+};
diff --git a/target.c b/target.c
index e512f7f1b618..f6203942a307 100644
--- a/target.c
+++ b/target.c
@@ -76,6 +76,7 @@ static const struct target *targets[] = {
[MACH_SPARC32] = &target_sparc32,
[MACH_SPARC64] = &target_sparc64,
[MACH_X86_64] = &target_x86_64,
+ [MACH_XTENSA] = &target_xtensa,
[MACH_UNKNOWN] = &target_default,
};
const struct target *arch_target = &target_default;
@@ -105,6 +106,7 @@ enum machine target_parse(const char *name)
{ "sparc", MACH_SPARC32, 0, },
{ "x86_64", MACH_X86_64, 64, },
{ "x86-64", MACH_X86_64, 64, },
+ { "xtensa", MACH_XTENSA, 32, },
{ NULL },
};
const struct arch *p;
diff --git a/target.h b/target.h
index 8f79426c096a..839d8600758a 100644
--- a/target.h
+++ b/target.h
@@ -100,6 +100,7 @@ extern const struct target target_sparc32;
extern const struct target target_sparc64;
extern const struct target target_i386;
extern const struct target target_x86_64;
+extern const struct target target_xtensa;
/* target.c */
extern const struct target *arch_target;
base-commit: bb372492c40d71cc27952e815612db36aadf65bb
--
2.27.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-07-09 0:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 0:26 [PATCH] xtensa: add minimal support Luc Van Oostenryck
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 NNTP newsgroup(s).