diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-06-10 18:22:46 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-06-12 21:41:32 +0200 |
commit | 1e07ab5a09162538501033316580d71cecc0ccae (patch) | |
tree | f75d1a5f164b294a27d106f641b4abac74326500 | |
parent | f72b16c3864a0072748b955dfa5e9126d998f08b (diff) | |
download | sparse-1e07ab5a09162538501033316580d71cecc0ccae.tar.gz |
arch: add specificities for Nios2
The real goal here is, in fact, to move the nios2-specfic
builtins out of the main builtins table.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | builtin.c | 5 | ||||
-rw-r--r-- | machine.h | 1 | ||||
-rw-r--r-- | target-nios2.c | 31 | ||||
-rw-r--r-- | target.c | 2 | ||||
-rw-r--r-- | target.h | 1 |
6 files changed, 36 insertions, 5 deletions
@@ -70,6 +70,7 @@ LIB_OBJS += target-arm64.o LIB_OBJS += target-default.o LIB_OBJS += target-m68k.o LIB_OBJS += target-mips.o +LIB_OBJS += target-nios2.o LIB_OBJS += target-ppc.o LIB_OBJS += target-riscv.o LIB_OBJS += target-s390.o @@ -578,11 +578,6 @@ static const struct builtin_fn builtins_common[] = { { "__builtin_bfin_ssync", &void_ctype, 0 }, { "__builtin_bfin_norm_fr1x32", &int_ctype, 0, { &int_ctype }}, - // Nios-II-specific - { "__builtin_rdctl", &int_ctype, 0, { &int_ctype }}, - { "__builtin_wrctl", &void_ctype, 0, { &int_ctype, &int_ctype }}, - { "__builtin_custom_ini", &int_ctype, 0, { &int_ctype }}, - { } }; @@ -33,6 +33,7 @@ enum machine { MACH_SPARC32, MACH_SPARC64, MACH_S390, MACH_S390X, MACH_M68K, + MACH_NIOS2, MACH_UNKNOWN }; diff --git a/target-nios2.c b/target-nios2.c new file mode 100644 index 00000000..05f0926e --- /dev/null +++ b/target-nios2.c @@ -0,0 +1,31 @@ +#include "symbol.h" +#include "target.h" +#include "machine.h" +#include "builtin.h" + + +static void predefine_nios2(const struct target *self) +{ + predefine("__NIOS2__", 1, "1"); + predefine("__nios2__", 1, "1"); + + if (arch_big_endian) + predefine("__nios2_big_endian__", 1, "1"); + else + predefine("__nios2_little_endian__", 1, "1"); +} + +static const struct builtin_fn builtins_nios2[] = { + { "__builtin_rdctl", &int_ctype, 0, { &int_ctype }}, + { "__builtin_wrctl", &void_ctype, 0, { &int_ctype, &int_ctype }}, + { "__builtin_custom_ini", &int_ctype, 0, { &int_ctype }}, + { } +}; + +const struct target target_nios2 = { + .mach = MACH_NIOS2, + .bitness = ARCH_LP32, + + .predefine = predefine_nios2, + .builtins = builtins_nios2, +}; @@ -63,6 +63,7 @@ static const struct target *targets[] = { [MACH_X86_64] = &target_x86_64, [MACH_MIPS32] = &target_mips32, [MACH_MIPS64] = &target_mips64, + [MACH_NIOS2] = &target_nios2, [MACH_PPC32] = &target_ppc32, [MACH_PPC64] = &target_ppc64, [MACH_RISCV32] = &target_riscv32, @@ -89,6 +90,7 @@ enum machine target_parse(const char *name) { "i386", MACH_I386, 32, }, { "m68k", MACH_M68K, 32, }, { "mips", MACH_MIPS32, 0, }, + { "nios2", MACH_NIOS2, 32, }, { "powerpc", MACH_PPC32, 0, }, { "ppc", MACH_PPC32, 0, }, { "riscv", MACH_RISCV32, 0, }, @@ -85,6 +85,7 @@ extern const struct target target_arm64; extern const struct target target_m68k; extern const struct target target_mips32; extern const struct target target_mips64; +extern const struct target target_nios2; extern const struct target target_ppc32; extern const struct target target_ppc64; extern const struct target target_riscv32; |