From 13f4aefdb21d033f0b56fdcf111473781348217f Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Fri, 10 Jul 2020 14:21:21 +0200 Subject: openrisc: add minimal support Signed-off-by: Luc Van Oostenryck --- Makefile | 1 + machine.h | 1 + target-openrisc.c | 26 ++++++++++++++++++++++++++ target.c | 2 ++ target.h | 1 + 5 files changed, 31 insertions(+) create mode 100644 target-openrisc.c diff --git a/Makefile b/Makefile index 46bdb0e6..fea2d74f 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,7 @@ LIB_OBJS += target-microblaze.o LIB_OBJS += target-mips.o LIB_OBJS += target-nds32.o LIB_OBJS += target-nios2.o +LIB_OBJS += target-openrisc.o LIB_OBJS += target-ppc.o LIB_OBJS += target-riscv.o LIB_OBJS += target-s390.o diff --git a/machine.h b/machine.h index 170bdb50..e3433739 100644 --- a/machine.h +++ b/machine.h @@ -39,6 +39,7 @@ enum machine { MACH_MICROBLAZE, MACH_NDS32, MACH_NIOS2, + MACH_OPENRISC, MACH_SH, MACH_XTENSA, MACH_UNKNOWN diff --git a/target-openrisc.c b/target-openrisc.c new file mode 100644 index 00000000..553963c0 --- /dev/null +++ b/target-openrisc.c @@ -0,0 +1,26 @@ +#include "symbol.h" +#include "target.h" +#include "machine.h" + + +static void init_openrisc(const struct target *self) +{ + wchar_ctype = &uint_ctype; +} + +static void predefine_openrisc(const struct target *self) +{ + predefine_weak("__OR1K__"); + predefine_weak("__or1k__"); +} + +const struct target target_openrisc = { + .mach = MACH_NDS32, + .bitness = ARCH_LP32, + .big_endian = true, + + .bits_in_longdouble = 64, + + .init = init_openrisc, + .predefine = predefine_openrisc, +}; diff --git a/target.c b/target.c index 857ae367..10914846 100644 --- a/target.c +++ b/target.c @@ -69,6 +69,7 @@ static const struct target *targets[] = { [MACH_MIPS64] = &target_mips64, [MACH_NDS32] = &target_nds32, [MACH_NIOS2] = &target_nios2, + [MACH_OPENRISC] = &target_openrisc, [MACH_PPC32] = &target_ppc32, [MACH_PPC64] = &target_ppc64, [MACH_RISCV32] = &target_riscv32, @@ -103,6 +104,7 @@ enum machine target_parse(const char *name) { "mips", MACH_MIPS32, 0, }, { "nds32", MACH_NDS32, 32, }, { "nios2", MACH_NIOS2, 32, }, + { "openrisc", MACH_OPENRISC, 32, }, { "powerpc", MACH_PPC32, 0, }, { "ppc", MACH_PPC32, 0, }, { "riscv", MACH_RISCV32, 0, }, diff --git a/target.h b/target.h index 8eb52806..2ce88413 100644 --- a/target.h +++ b/target.h @@ -92,6 +92,7 @@ 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_openrisc; extern const struct target target_ppc32; extern const struct target target_ppc64; extern const struct target target_riscv32; -- cgit 1.2.3-korg