aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-08 01:07:51 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-13 17:57:04 +0200
commit03adbff28af63f8a8d15e8b45b0ae03e40afff6c (patch)
treeebfc9c286c74d43e80f1a27fa14411dab2860ada
parent85fb62e73e82ba165fc2f1246d9096e94f268a60 (diff)
downloadsparse-03adbff28af63f8a8d15e8b45b0ae03e40afff6c.tar.gz
xtensa: add minimal support
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>
-rw-r--r--Makefile1
-rw-r--r--machine.h1
-rw-r--r--target-xtensa.c31
-rw-r--r--target.c2
-rw-r--r--target.h1
5 files changed, 36 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index d7cfe4f5..1dbea8c5 100644
--- a/Makefile
+++ b/Makefile
@@ -83,6 +83,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 1b8b862a..7396aeb4 100644
--- a/machine.h
+++ b/machine.h
@@ -38,6 +38,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 00000000..3e5781c8
--- /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 b3966151..3c0588ab 100644
--- a/target.c
+++ b/target.c
@@ -77,6 +77,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;
@@ -107,6 +108,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 45ee40f1..4106a6a8 100644
--- a/target.h
+++ b/target.h
@@ -101,6 +101,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;