diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-08 01:07:51 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-13 17:57:04 +0200 |
commit | 03adbff28af63f8a8d15e8b45b0ae03e40afff6c (patch) | |
tree | ebfc9c286c74d43e80f1a27fa14411dab2860ada | |
parent | 85fb62e73e82ba165fc2f1246d9096e94f268a60 (diff) | |
download | sparse-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-- | Makefile | 1 | ||||
-rw-r--r-- | machine.h | 1 | ||||
-rw-r--r-- | target-xtensa.c | 31 | ||||
-rw-r--r-- | target.c | 2 | ||||
-rw-r--r-- | target.h | 1 |
5 files changed, 36 insertions, 0 deletions
@@ -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 @@ -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, +}; @@ -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; @@ -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; |