Prepare riscv64

This commit is contained in:
Daniil Gentili 2023-06-01 22:03:15 +02:00
parent 3b0de17cdd
commit 5100e84134
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
6 changed files with 23 additions and 2 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
ir_fold_hash.h
ir_emit_x86.h
ir_emit_aarch64.h
ir_emit_riscv64.h
minilua
gen_ir_fold_hash
ir_test

View File

@ -1,5 +1,5 @@
# TRAGET may be "x86_64" or "x86" or "aarch64"
TARGET = x86_64
# TRAGET may be "x86_64" or "x86" or "aarch64" or "riscv64"
TARGET = riscv64
# BUILD can be "debug" or "release"
BUILD = debug
BUILD_DIR = .
@ -40,6 +40,13 @@ ifeq (aarch64, $(TARGET))
DASM_FLAGS =
endif
ifeq (riscv64, $(TARGET))
CC= riscv64-linux-gnu-gcc --sysroot=$(HOME)/php/RISCV64
CFLAGS += -DIR_TARGET_RISCV64
DASM_ARCH = riscv64
DASM_FLAGS =
endif
OBJS_COMMON = $(BUILD_DIR)/ir.o $(BUILD_DIR)/ir_strtab.o $(BUILD_DIR)/ir_cfg.o \
$(BUILD_DIR)/ir_sccp.o $(BUILD_DIR)/ir_gcm.o $(BUILD_DIR)/ir_ra.o $(BUILD_DIR)/ir_emit.o \
$(BUILD_DIR)/ir_load.o $(BUILD_DIR)/ir_save.o $(BUILD_DIR)/ir_emit_c.o $(BUILD_DIR)/ir_dump.o \

2
ir.h
View File

@ -46,6 +46,8 @@ extern "C" {
# endif
#elif defined(IR_TARGET_AARCH64)
# define IR_TARGET "aarch64"
#elif defined(IR_TARGET_RISCV64)
# define IR_TARGET "riscv64"
#else
# error "Unknown IR target"
#endif

View File

@ -11,6 +11,8 @@
# include "ir_x86.h"
#elif defined(IR_TARGET_AARCH64)
# include "ir_aarch64.h"
#elif defined(IR_TARGET_RISCV64)
# include "ir_riscv.h"
#else
# error "Unknown IR target"
#endif
@ -326,6 +328,9 @@ static void *ir_jmp_addr(ir_ctx *ctx, ir_insn *insn, ir_insn *addr_insn)
#elif defined(IR_TARGET_AARCH64)
# include "dynasm/dasm_proto.h"
# include "dynasm/dasm_arm64.h"
#elif defined(IR_TARGET_RISCV64)
# include "dynasm/dasm_proto.h"
# include "dynasm/dasm_riscv64.h"
#else
# error "Unknown IR target"
#endif
@ -343,6 +348,8 @@ static void ir_emit_dessa_moves(ir_ctx *ctx, int b, ir_block *bb);
# include "ir_emit_x86.h"
#elif defined(IR_TARGET_AARCH64)
# include "ir_emit_aarch64.h"
#elif defined(IR_TARGET_RISCV64)
# include "ir_emit_riscv64.h"
#else
# error "Unknown IR target"
#endif

View File

@ -154,6 +154,8 @@ static const ir_elf_header ir_elfhdr_template = {
.machine = 62,
#elif defined(IR_TARGET_AARCH64)
.machine = 183,
#elif defined(IR_TARGET_RISCV64)
.machine = 243,
#else
# error "Unsupported target architecture"
#endif

View File

@ -21,6 +21,8 @@
# include "ir_x86.h"
#elif defined(IR_TARGET_AARCH64)
# include "ir_aarch64.h"
#elif defined(IR_TARGET_RISCV64)
# include "ir_riscv64.h"
#else
# error "Unknown IR target"
#endif