aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-10 03:45:18 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-07-13 17:58:20 +0200
commite7ff2c6b8ad26b53deb18cf6589d5dc88629b6bd (patch)
treec5c3941dbfb691b7d2487caafa467d6e09b5365d
parent03adbff28af63f8a8d15e8b45b0ae03e40afff6c (diff)
downloadsparse-e7ff2c6b8ad26b53deb18cf6589d5dc88629b6bd.tar.gz
nds32: add minimal support
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--Makefile1
-rw-r--r--machine.h1
-rw-r--r--target-nds32.c28
-rw-r--r--target.c2
-rw-r--r--target.h1
5 files changed, 33 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 1dbea8c5..7fc93dfc 100644
--- a/Makefile
+++ b/Makefile
@@ -77,6 +77,7 @@ LIB_OBJS += target-h8300.o
LIB_OBJS += target-m68k.o
LIB_OBJS += target-microblaze.o
LIB_OBJS += target-mips.o
+LIB_OBJS += target-nds32.o
LIB_OBJS += target-nios2.o
LIB_OBJS += target-ppc.o
LIB_OBJS += target-riscv.o
diff --git a/machine.h b/machine.h
index 7396aeb4..030c422f 100644
--- a/machine.h
+++ b/machine.h
@@ -37,6 +37,7 @@ enum machine {
MACH_H8300,
MACH_M68K,
MACH_MICROBLAZE,
+ MACH_NDS32,
MACH_NIOS2,
MACH_XTENSA,
MACH_UNKNOWN
diff --git a/target-nds32.c b/target-nds32.c
new file mode 100644
index 00000000..0dc483b2
--- /dev/null
+++ b/target-nds32.c
@@ -0,0 +1,28 @@
+#include "symbol.h"
+#include "target.h"
+#include "machine.h"
+
+
+static void init_nds32(const struct target *self)
+{
+ wchar_ctype = &uint_ctype;
+}
+
+static void predefine_nds32(const struct target *self)
+{
+ predefine("__NDS32__", 1, "1");
+ predefine("__nds32__", 1, "1");
+
+ predefine_weak("__NDS32_E%c__", arch_big_endian ? 'B' : 'L');
+}
+
+const struct target target_nds32 = {
+ .mach = MACH_NDS32,
+ .bitness = ARCH_LP32,
+ .big_endian = false,
+
+ .bits_in_longdouble = 64,
+
+ .init = init_nds32,
+ .predefine = predefine_nds32,
+};
diff --git a/target.c b/target.c
index 3c0588ab..f744de8d 100644
--- a/target.c
+++ b/target.c
@@ -67,6 +67,7 @@ static const struct target *targets[] = {
[MACH_MICROBLAZE] = &target_microblaze,
[MACH_MIPS32] = &target_mips32,
[MACH_MIPS64] = &target_mips64,
+ [MACH_NDS32] = &target_nds32,
[MACH_NIOS2] = &target_nios2,
[MACH_PPC32] = &target_ppc32,
[MACH_PPC64] = &target_ppc64,
@@ -99,6 +100,7 @@ enum machine target_parse(const char *name)
{ "m68k", MACH_M68K, 32, },
{ "microblaze", MACH_MICROBLAZE,32, },
{ "mips", MACH_MIPS32, 0, },
+ { "nds32", MACH_NDS32, 32, },
{ "nios2", MACH_NIOS2, 32, },
{ "powerpc", MACH_PPC32, 0, },
{ "ppc", MACH_PPC32, 0, },
diff --git a/target.h b/target.h
index 4106a6a8..4fbdfbdf 100644
--- a/target.h
+++ b/target.h
@@ -90,6 +90,7 @@ extern const struct target target_m68k;
extern const struct target target_microblaze;
extern const struct target target_mips32;
extern const struct target target_mips64;
+extern const struct target target_nds32;
extern const struct target target_nios2;
extern const struct target target_ppc32;
extern const struct target target_ppc64;