mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-29 01:57:57 +00:00
update 64bit target flags (#113)
This commit is contained in:
@@ -15,7 +15,12 @@ doctest = false
|
||||
|
||||
[features]
|
||||
riscv-zbb = []
|
||||
riscv-64 = []
|
||||
riscv-64 = [
|
||||
"revive-linker/riscv-64",
|
||||
"revive-builtins/riscv-64",
|
||||
"revive-runtime-api/riscv-64",
|
||||
"revive-common/riscv-64",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
|
||||
@@ -138,7 +138,7 @@ where
|
||||
for import in revive_runtime_api::polkavm_imports::IMPORTS {
|
||||
module
|
||||
.get_function(import)
|
||||
.expect("should be declared")
|
||||
.unwrap_or_else(|| panic!("{import} import should be declared"))
|
||||
.set_linkage(inkwell::module::Linkage::External);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ const TARGET_FLAG: &str = "--target=riscv32";
|
||||
const TARGET_FLAG: &str = "--target=riscv64";
|
||||
|
||||
#[cfg(not(feature = "riscv-64"))]
|
||||
const TARGET_ARCH_FLAG: &str = "-march=rv32em";
|
||||
const TARGET_ARCH_FLAG: &str = "-march=rv32emac";
|
||||
#[cfg(feature = "riscv-64")]
|
||||
const TARGET_ARCH_FLAG: &str = "-march=rv64em";
|
||||
const TARGET_ARCH_FLAG: &str = "-march=rv64emac";
|
||||
|
||||
#[cfg(not(feature = "riscv-64"))]
|
||||
const TARGET_ABI_FLAG: &str = "-mabi=ilp32e";
|
||||
@@ -36,6 +36,10 @@ fn compile(source_path: &str, bitcode_path: &str) {
|
||||
TARGET_TRIPLE_FLAG,
|
||||
TARGET_ARCH_FLAG,
|
||||
TARGET_ABI_FLAG,
|
||||
"-Xclang",
|
||||
"-target-feature",
|
||||
"-Xclang",
|
||||
"+fast-unaligned-access,+xtheadcondmov",
|
||||
"-fno-exceptions",
|
||||
"-ffreestanding",
|
||||
"-Wall",
|
||||
|
||||
@@ -9,7 +9,11 @@
|
||||
|
||||
#define POLKAVM_REGS_FOR_TY_void 0
|
||||
#define POLKAVM_REGS_FOR_TY_i32 1
|
||||
#define POLKAVM_REGS_FOR_TY_i64 2
|
||||
#ifdef _LP64
|
||||
#define POLKAVM_REGS_FOR_TY_i64 1
|
||||
#else
|
||||
#define POLKAVM_REGS_FOR_TY_i64 2
|
||||
#endif
|
||||
|
||||
#define POLKAVM_REGS_FOR_TY_int8_t POLKAVM_REGS_FOR_TY_i32
|
||||
#define POLKAVM_REGS_FOR_TY_uint8_t POLKAVM_REGS_FOR_TY_i32
|
||||
@@ -107,6 +111,26 @@ struct PolkaVM_Metadata {
|
||||
unsigned char output_regs;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#ifdef _LP64
|
||||
#define POLKAVM_EXPORT_DEF() \
|
||||
".quad %[metadata]\n" \
|
||||
".quad %[function]\n"
|
||||
#else
|
||||
#define POLKAVM_EXPORT_DEF() \
|
||||
".word %[metadata]\n" \
|
||||
".word %[function]\n"
|
||||
#endif
|
||||
|
||||
#ifdef _LP64
|
||||
#define POLKAVM_IMPORT_DEF() \
|
||||
".word 0x0000000b\n" \
|
||||
".quad %[metadata]\n"
|
||||
#else
|
||||
#define POLKAVM_IMPORT_DEF() \
|
||||
".word 0x0000000b\n" \
|
||||
".word %[metadata]\n"
|
||||
#endif
|
||||
|
||||
#define POLKAVM_EXPORT(arg_return_ty, fn_name, ...) \
|
||||
static struct PolkaVM_Metadata POLKAVM_JOIN(fn_name, __EXPORT_METADATA) __attribute__ ((section(".polkavm_metadata"))) = { \
|
||||
1, 0, sizeof(#fn_name) - 1, #fn_name, POLKAVM_COUNT_REGS(__VA_ARGS__), POLKAVM_COUNT_REGS(arg_return_ty) \
|
||||
@@ -115,8 +139,7 @@ static void __attribute__ ((naked, used)) POLKAVM_UNIQUE(polkavm_export_dummy)()
|
||||
__asm__( \
|
||||
".pushsection .polkavm_exports,\"R\",@note\n" \
|
||||
".byte 1\n" \
|
||||
".word %[metadata]\n" \
|
||||
".word %[function]\n" \
|
||||
POLKAVM_EXPORT_DEF() \
|
||||
".popsection\n" \
|
||||
: \
|
||||
: \
|
||||
@@ -130,10 +153,9 @@ static void __attribute__ ((naked, used)) POLKAVM_UNIQUE(polkavm_export_dummy)()
|
||||
static struct PolkaVM_Metadata POLKAVM_JOIN(fn_name, __IMPORT_METADATA) __attribute__ ((section(".polkavm_metadata"))) = { \
|
||||
1, 0, sizeof(#fn_name) - 1, #fn_name, POLKAVM_COUNT_REGS(__VA_ARGS__), POLKAVM_COUNT_REGS(arg_return_ty) \
|
||||
}; \
|
||||
static arg_return_ty __attribute__ ((naked, used)) fn_name(POLKAVM_IMPORT_ARGS_IMPL(__VA_ARGS__)) { \
|
||||
static arg_return_ty __attribute__ ((used, naked)) fn_name(POLKAVM_IMPORT_ARGS_IMPL(__VA_ARGS__)) { \
|
||||
__asm__( \
|
||||
".word 0x0000000b\n" \
|
||||
".word %[metadata]\n" \
|
||||
POLKAVM_IMPORT_DEF() \
|
||||
"ret\n" \
|
||||
: \
|
||||
: \
|
||||
|
||||
Reference in New Issue
Block a user