Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add riscv64 backend for cranelift. #4271

Merged
merged 208 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
208 commits
Select commit Hold shift + click to select a range
a638a87
risc-v hello_work works
756445638 Apr 26, 2022
4a2c69f
virtual sp ajust
756445638 Apr 26, 2022
ee7225e
better print for Amode
756445638 Apr 26, 2022
c7dc9b8
wired..
756445638 Apr 26, 2022
62e74ae
float compare
756445638 Apr 27, 2022
60a44a1
atomic operations and op_name
756445638 Apr 27, 2022
53a3915
commit for save now.
756445638 Apr 27, 2022
90690c3
name upper snake case to camel case
756445638 Apr 28, 2022
a4dbc28
float compare and refactor int compare and ...
756445638 Apr 28, 2022
1c7c644
some regclass error
756445638 Apr 28, 2022
1592896
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok Apr 29, 2022
ff0af05
simple atomic operation
756445638 Apr 29, 2022
d1837ed
Merge branch 'risc-v' of https://github.com/yuyang-ok/wasmtime into r…
756445638 Apr 29, 2022
fb9a098
keep up with upstream
756445638 Apr 30, 2022
018448b
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok Apr 30, 2022
acdd022
save prologue register error and abi
756445638 Apr 30, 2022
1fe486d
load and store
756445638 Apr 30, 2022
075fc04
test_riscv64_binemit and abi is wried
756445638 Apr 30, 2022
61ef4f0
abi reference outdated paper
756445638 Apr 30, 2022
6490e28
atomic load and store
756445638 May 1, 2022
03d5b18
Jump -> Jal
756445638 May 1, 2022
e47480c
you cannot know patch size at lower stage,so BranchTarge::Patch is al…
756445638 May 1, 2022
3679f94
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok May 3, 2022
2dcd48a
reg alloc not working but I need merge upstream
756445638 May 3, 2022
1252292
Merge branch 'risc-v' of https://github.com/yuyang-ok/wasmtime into r…
756445638 May 3, 2022
fac524c
use alloc consumer correctly
756445638 May 4, 2022
a89e43e
missing bind label
756445638 May 4, 2022
8b3705c
lower select
756445638 May 5, 2022
c5b12b8
lower is_null
756445638 May 5, 2022
f6fc47d
i128 compare
756445638 May 5, 2022
8c730fb
brtable
756445638 May 6, 2022
5c0f12c
emit test
756445638 May 6, 2022
ba132f6
emit_test forget fcsr operations
756445638 May 6, 2022
a09120d
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok May 6, 2022
e246e89
jalr12 is not a labeluse
756445638 May 6, 2022
5ffa538
atomic cas and atomic sub
756445638 May 7, 2022
c87312c
extend integer and bool value
756445638 May 8, 2022
d0cc8e9
lower insts
756445638 May 8, 2022
2af34ca
imax ,imin ... and fadd
756445638 May 8, 2022
1247e91
float binary op generate moved different palce
756445638 May 8, 2022
289ac35
risc_v rename to riscv64
756445638 May 8, 2022
ccd2347
branch offset should contains itself
756445638 May 8, 2022
554ef78
Update main.yml
yuyang-ok May 9, 2022
1b17f30
callind
756445638 May 9, 2022
0b642eb
Merge branch 'risc-v' of https://github.com/yuyang-ok/wasmtime into r…
756445638 May 9, 2022
0842513
gen callind,look like caller save register not save,figure it out.
756445638 May 10, 2022
fe2d9a8
explicitly save ra register.
756445638 May 11, 2022
5df6e49
lower load_addr
756445638 May 11, 2022
5429858
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok May 11, 2022
2dcdb34
atomic cas test on my qemu emulator
756445638 May 12, 2022
f03b082
pass test arithmetic.clif on my local machine.
756445638 May 12, 2022
7e90d80
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok May 12, 2022
8240808
generate bool const and band
756445638 May 13, 2022
3fc2560
Merge branch 'risc-v' of https://github.com/yuyang-ok/wasmtime into r…
756445638 May 13, 2022
de1b428
i128 add implemented
756445638 May 14, 2022
4a0db0d
i12b sub implemented.
756445638 May 14, 2022
142ca99
compute_abi_loc should in params order
756445638 May 15, 2022
c825028
read and write csrs
756445638 May 16, 2022
736eb21
add bitmanip instructions
756445638 May 17, 2022
92f9d49
I need mrege upstream
756445638 May 17, 2022
e77a395
emit test for bitmanip
756445638 May 17, 2022
cf687eb
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok May 17, 2022
0466b9b
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok May 18, 2022
a8ca031
keep up with upstream
yuyang-ok May 18, 2022
df3173b
Merge branch 'risc-v' of https://github.com/yuyang-ok/wasmtime into r…
yuyang-ok May 18, 2022
5147f7d
compute args location
yuyang-ok May 19, 2022
83aa914
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok May 20, 2022
89e8f32
brbr_table
yuyang-ok May 20, 2022
1985271
uextend
yuyang-ok May 20, 2022
a3a44a0
modify the design of funct12
yuyang-ok May 20, 2022
386a5d4
implemente band_not
yuyang-ok May 21, 2022
bf222c5
lower icmp and popcnt
yuyang-ok May 21, 2022
d18f4f6
lower float compare
yuyang-ok May 22, 2022
281173c
mul high part
yuyang-ok May 22, 2022
2276e3c
lower rotl and rotr
yuyang-ok May 22, 2022
11c0599
lower i128 compare
yuyang-ok May 22, 2022
0eceee5
riscv64 add first pricise-output test
yuyang-ok May 23, 2022
c8df735
lower cls
yuyang-ok May 24, 2022
f85c4c3
lower ctz
yuyang-ok May 24, 2022
8b9bf6e
lower i128 xnor
yuyang-ok May 24, 2022
0443019
lower bits rotation.
yuyang-ok May 25, 2022
e90472b
remove function patch_taken_list.
yuyang-ok May 25, 2022
2887e37
lower float operations
yuyang-ok May 26, 2022
0c3df39
fcvt_int_sat missing save fcsr
yuyang-ok May 26, 2022
9dbc1b3
lower call
yuyang-ok May 27, 2022
1314026
lower instruction and add some test
yuyang-ok May 28, 2022
047c188
implement bitrev.
yuyang-ok May 30, 2022
a295c76
look up architecture for riscv64
yuyang-ok Jun 2, 2022
c3b7aae
lower cls
yuyang-ok Jun 2, 2022
0833064
lower i128 sshr.
yuyang-ok Jun 2, 2022
b38375a
lowering instructions.
yuyang-ok Jun 3, 2022
7ae0a77
lowring and do some testing.
yuyang-ok Jun 3, 2022
df86448
emit island for brtable emit and caculate worst instruction size.
yuyang-ok Jun 4, 2022
da1b55d
move some code.
yuyang-ok Jun 4, 2022
38bad2e
using float rounding mode in instruction instead of fcsr.
yuyang-ok Jun 4, 2022
8e82985
divide integer operation and float operation instruction.
yuyang-ok Jun 4, 2022
bf4f94c
emit call.
yuyang-ok Jun 5, 2022
93e9e43
lowering instrctions and maybe better naming.
yuyang-ok Jun 5, 2022
5d7f4ab
riscv64 mod test.
yuyang-ok Jun 7, 2022
006d1ae
remove static TRIPLE
yuyang-ok Jun 7, 2022
2e17b2d
add precise-output test.
yuyang-ok Jun 7, 2022
350211a
format uextend and sextend.
yuyang-ok Jun 7, 2022
d525770
generate settings for riscv64gc
yuyang-ok Jun 7, 2022
a4e94f3
test target shoule be riscv64gc.
yuyang-ok Jun 8, 2022
506db09
add some test for float.
yuyang-ok Jun 9, 2022
6c9cac3
add all float test for riscv64.
yuyang-ok Jun 10, 2022
b0a3ac4
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok Jun 10, 2022
6af7fb1
fix load constant bug.
yuyang-ok Jun 11, 2022
b1ab139
atomic operations.
yuyang-ok Jun 12, 2022
18fd653
pass all runtests.
yuyang-ok Jun 13, 2022
aa6fcd2
handle immediates.
yuyang-ok Jun 14, 2022
50d627e
some tests.
yuyang-ok Jun 14, 2022
fd3ce1a
Update main.yml
yuyang-ok Jun 15, 2022
68f1c80
fix LableUse max range error.
yuyang-ok Jun 16, 2022
851354c
Merge branch 'risc-v' of https://github.com/yuyang-ok/wasmtime into r…
yuyang-ok Jun 16, 2022
bd31fda
construct_auipc_and_jalr should use generate_imm and some better coding.
yuyang-ok Jun 16, 2022
788290e
reimplemented floatnot equal compare and float compare args.
yuyang-ok Jun 16, 2022
3cce489
float to int representation should use little endian.
yuyang-ok Jun 16, 2022
d154b77
comment in assembly should using '##' instead of ';;'.
yuyang-ok Jun 17, 2022
da37a7a
modify the way to construct AluRRImm12.
yuyang-ok Jun 18, 2022
67c0d55
aluRRImm12 emiting.
yuyang-ok Jun 18, 2022
570c88b
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok Jun 23, 2022
c9e487c
lower atomic rmw using ISLE.
yuyang-ok Jun 24, 2022
fa409ba
rewrite float lowering using ISLE.
yuyang-ok Jun 24, 2022
c31e977
rewrite some handwritten code to ISLE.
yuyang-ok Jun 24, 2022
f2109d3
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok Jun 26, 2022
48592cc
continue to rewritting handwritten code to ISLE.
yuyang-ok Jun 26, 2022
32c93d1
rewrite load store and fcmp to ISLE.
yuyang-ok Jun 26, 2022
80c5ec4
rewrite float convert and symbol_value ... to ISLE.
yuyang-ok Jun 27, 2022
e922f95
rewrite clz and i128 add ... to ISLE.
yuyang-ok Jun 27, 2022
933a5af
remote cls umlhi and ... to ISLE.
yuyang-ok Jun 28, 2022
4745f9c
remove parameter Type for alu_rrr.
yuyang-ok Jun 28, 2022
b9868ed
rewite i128 rorate to ISLE.
yuyang-ok Jun 28, 2022
b07a99e
lower i128 rotate remove shamt127.
yuyang-ok Jun 28, 2022
25d6ade
reimplemented cls.
yuyang-ok Jun 28, 2022
3093d1c
Merge branch 'main' of https://github.com/bytecodealliance/wasmtime i…
yuyang-ok Jun 28, 2022
02c8876
rewrite i128 shifts to ISLE.
yuyang-ok Jun 28, 2022
8bca3d2
remove term ty_unused_bits_neg.
yuyang-ok Jun 29, 2022
65f0e43
rewrite selectif trapif... to ISLE.
yuyang-ok Jul 2, 2022
f26d2db
float binary op should move to x and atomic_store.
yuyang-ok Jul 4, 2022
e599fd7
reimplemet atomic load store cas ...
yuyang-ok Jul 6, 2022
117df88
better sextend.
yuyang-ok Jul 6, 2022
8e88517
save ra register at gen_prologue_frame_setup.
yuyang-ok Jul 6, 2022
eb8dc89
lowering integer compare.
yuyang-ok Jul 7, 2022
4c0a8f3
remove gcc tool chain in emit_test.rs.
yuyang-ok Jul 7, 2022
7cef970
save return address using wrong stack offset.
yuyang-ok Jul 7, 2022
ac2219a
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok Jul 8, 2022
027bfe2
add unwindinfo for riscv64.
yuyang-ok Jul 11, 2022
c8b2142
fabs implemetation and run tests.
yuyang-ok Jul 11, 2022
67962f7
emiting nearest ceil ....
yuyang-ok Jul 13, 2022
03f377d
rename riscv64gc to riscv64
yuyang-ok Jul 13, 2022
6e6da4d
fmax-pseudo implement in riscv64 and code tidy.
yuyang-ok Jul 14, 2022
05b31d6
missing meta file for riscv64.
yuyang-ok Jul 14, 2022
ed14d45
remove function param_or_rets_xregs.
yuyang-ok Jul 16, 2022
bf5d0ad
Update run_command.rs
yuyang-ok Jul 16, 2022
64a03c7
add test fadd ... on riscv64.
yuyang-ok Jul 21, 2022
485b982
riscv64 merge upstream.
yuyang-ok Jul 23, 2022
c05c82d
Merge branch 'risc-v' of https://github.com/yuyang-ok/wasmtime into r…
yuyang-ok Jul 25, 2022
0487b9d
emit libcall.
yuyang-ok Jul 25, 2022
ddda7c6
port fiber to riscv64 but unwind not working.
yuyang-ok Aug 2, 2022
1184370
fix riscv64 fiber cfi directives.
yuyang-ok Aug 7, 2022
cd86265
keep up with upstream.
yuyang-ok Aug 8, 2022
2c0f434
Update main.yml
yuyang-ok Aug 8, 2022
ecfba31
code tidy.
yuyang-ok Aug 10, 2022
283753d
port riscv64 trampolines traphandlers ...
yuyang-ok Aug 10, 2022
6a1de05
gen probe_stack and int_zero_reg can take bool type.
yuyang-ok Aug 11, 2022
5cbaa01
riscv reloc and dwarf register mapping.
yuyang-ok Aug 13, 2022
5f66faf
implemented popcnt when extension B are absent and setup frame ...
yuyang-ok Aug 16, 2022
1dbfb79
implemented rev8... when b extension is missing.
yuyang-ok Aug 17, 2022
1260b00
remodel call convertion from x86_64.
yuyang-ok Aug 17, 2022
bf03d8a
wasmtime_system_v only use one register to store result.
yuyang-ok Aug 18, 2022
19ef4a6
riscv64 wasmtime abi only one value can in a register.
yuyang-ok Aug 18, 2022
dee6661
add HeapOutOfBounds for memory operation.
yuyang-ok Aug 18, 2022
cfb3371
re-implemented rev8 using loop.
yuyang-ok Aug 18, 2022
3ab74a5
Merge branch 'main' of https://github.com/bytecodealliance/wasmtime i…
yuyang-ok Aug 19, 2022
78a1bc6
Merge branch 'main' of https://github.com/bytecodealliance/wasmtime i…
yuyang-ok Aug 21, 2022
34477cf
riscv support atomic i8 and i16.
yuyang-ok Aug 23, 2022
8c5b50f
Merge branch 'main' of https://github.com/bytecodealliance/wasmtime i…
yuyang-ok Aug 24, 2022
940d5ea
float convert to int overflow and div by zero exceptions.
yuyang-ok Aug 25, 2022
f0d5235
fix br_table.
yuyang-ok Aug 26, 2022
0de2cd5
move i32 to f32 register use fmv.w.x instead of fmx.d.x.
yuyang-ok Aug 29, 2022
0dc632f
gen divide by zero trap at ISLE.
yuyang-ok Aug 31, 2022
b0d4930
Merge branch 'bytecodealliance:main' into risc-v
yuyang-ok Aug 31, 2022
5cf133b
Fix some errors, and disable SIMD tests on rv64gc.
cfallin Sep 13, 2022
ec084de
Merge remote-tracking branch 'upstream/main' into risc-v
cfallin Sep 13, 2022
12316b8
Test updates.
cfallin Sep 13, 2022
07e90ba
cargo-fmt.
cfallin Sep 13, 2022
28e2d8f
Miscellaneous fixups.
cfallin Sep 13, 2022
dc8b7ee
cargo-fmt.
cfallin Sep 13, 2022
73c7096
add inline_probe_stack and remove some extractor for ISLE.
yuyang-ok Sep 14, 2022
924f67f
load_ra base on if preserve_frame_pointers.
yuyang-ok Sep 14, 2022
b51a998
uadd_overflow add i8... and add for i128.
yuyang-ok Sep 15, 2022
9f283ef
Run CI on all branches
afonso360 Sep 15, 2022
e3f5de3
Add riscv64 builds
afonso360 Sep 15, 2022
d3ef08b
cranelift: Cleanup warning
afonso360 Sep 15, 2022
eb7148a
Merge branch 'main' of https://github.com/bytecodealliance/wasmtime i…
yuyang-ok Sep 16, 2022
5887d57
Merge branch 'risc-v' of https://github.com/afonso360/wasmtime into r…
yuyang-ok Sep 20, 2022
995a695
disable host_segfault async pooling-alloctor test.
yuyang-ok Sep 21, 2022
16b1b19
Merge branch 'main' of https://github.com/bytecodealliance/wasmtime i…
yuyang-ok Sep 21, 2022
862c9ad
fix accidently remove test target for urem.clif.
yuyang-ok Sep 22, 2022
e48549a
Merge branch 'main' of https://github.com/bytecodealliance/wasmtime i…
yuyang-ok Sep 22, 2022
822ebd5
fix gen_call and gen_memcpy.
yuyang-ok Sep 23, 2022
b20499a
fix riscv64 test compiler-output.
yuyang-ok Sep 23, 2022
5463532
fix test_isa_flags_mismatch test failed on riscv64.
yuyang-ok Sep 23, 2022
75ef742
fix test_isa_flags_mismatch test failed on riscv64.
yuyang-ok Sep 23, 2022
e71d655
Merge branch 'main' of https://github.com/bytecodealliance/wasmtime i…
yuyang-ok Sep 25, 2022
0aa33c1
fix ISLE formatting.
yuyang-ok Sep 25, 2022
96ef1e7
fix is_isa_compatible for riscv64.
yuyang-ok Sep 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ jobs:
gcc: s390x-linux-gnu-gcc
qemu: qemu-s390x -L /usr/s390x-linux-gnu
qemu_target: s390x-linux-user
- os: ubuntu-latest
target: riscv64gc-unknown-linux-gnu
gcc_package: gcc-riscv64-linux-gnu
gcc: riscv64-linux-gnu-gcc
qemu: qemu-riscv64 -L /usr/riscv64-linux-gnu
qemu_target: riscv64-linux-user
steps:
- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -404,6 +410,9 @@ jobs:
- build: s390x-linux
os: ubuntu-latest
target: s390x-unknown-linux-gnu
- build: riscv64gc-linux
os: ubuntu-latest
target: riscv64gc-unknown-linux-gnu
steps:
- uses: actions/checkout@v2
with:
Expand Down
7 changes: 7 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool {
// FIXME: These tests fail under qemu due to a qemu bug.
(_, "simd_f32x4_pmin_pmax") if platform_is_s390x() => return true,
(_, "simd_f64x2_pmin_pmax") if platform_is_s390x() => return true,
// riscv64 backend does not yet have a fully complete SIMD backend.
("simd", _) if platform_is_riscv64() => return true,
("memory64", "simd") if platform_is_riscv64() => return true,
_ => {}
},
_ => panic!("unrecognized strategy"),
Expand All @@ -183,3 +186,7 @@ fn ignore(testsuite: &str, testname: &str, strategy: &str) -> bool {
fn platform_is_s390x() -> bool {
env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "s390x"
}

fn platform_is_riscv64() -> bool {
env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "riscv64"
}
7 changes: 7 additions & 0 deletions ci/docker/riscv64gc-linux/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM ubuntu:22.04

RUN apt-get update -y && apt-get install -y gcc gcc-riscv64-linux-gnu ca-certificates

ENV PATH=$PATH:/rust/bin
ENV CARGO_BUILD_TARGET=riscv64gc-unknown-linux-gnu
ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc
5 changes: 3 additions & 2 deletions cranelift/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ unwind = ["gimli"]
x86 = []
arm64 = []
s390x = []

riscv64 = []
# Stub feature that does nothing, for Cargo-features compatibility: the new
# backend is the default now.
experimental_x64 = []
Expand All @@ -77,7 +77,8 @@ experimental_x64 = []
all-arch = [
"x86",
"arm64",
"s390x"
"s390x",
"riscv64"
]

# For dependent crates that want to serialize some parts of cranelift
Expand Down
12 changes: 12 additions & 0 deletions cranelift/codegen/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ fn get_isle_compilations(
let src_isa_s390x =
make_isle_source_path_relative(&cur_dir, crate_dir.join("src").join("isa").join("s390x"));

let src_isa_risc_v =
make_isle_source_path_relative(&cur_dir, crate_dir.join("src").join("isa").join("riscv64"));
// This is a set of ISLE compilation units.
//
// The format of each entry is:
Expand Down Expand Up @@ -234,6 +236,16 @@ fn get_isle_compilations(
],
untracked_inputs: vec![clif_isle.clone()],
},
// The risc-v instruction selector.
IsleCompilation {
output: out_dir.join("isle_riscv64.rs"),
inputs: vec![
prelude_isle.clone(),
src_isa_risc_v.join("inst.isle"),
src_isa_risc_v.join("lower.isle"),
],
untracked_inputs: vec![clif_isle.clone()],
},
],
})
}
Expand Down
7 changes: 6 additions & 1 deletion cranelift/codegen/meta/src/isa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::shared::Definitions as SharedDefinitions;
use std::fmt;

mod arm64;
mod riscv64;
mod s390x;
pub(crate) mod x86;

Expand All @@ -13,6 +14,7 @@ pub enum Isa {
X86,
Arm64,
S390x,
Riscv64,
}

impl Isa {
Expand All @@ -30,13 +32,14 @@ impl Isa {
"aarch64" => Some(Isa::Arm64),
"s390x" => Some(Isa::S390x),
x if ["x86_64", "i386", "i586", "i686"].contains(&x) => Some(Isa::X86),
"riscv64" | "riscv64gc" | "riscv64imac" => Some(Isa::Riscv64),
_ => None,
}
}

/// Returns all supported isa targets.
pub fn all() -> &'static [Isa] {
&[Isa::X86, Isa::Arm64, Isa::S390x]
&[Isa::X86, Isa::Arm64, Isa::S390x, Isa::Riscv64]
}
}

Expand All @@ -47,6 +50,7 @@ impl fmt::Display for Isa {
Isa::X86 => write!(f, "x86"),
Isa::Arm64 => write!(f, "arm64"),
Isa::S390x => write!(f, "s390x"),
Isa::Riscv64 => write!(f, "riscv64"),
}
}
}
Expand All @@ -57,6 +61,7 @@ pub(crate) fn define(isas: &[Isa], shared_defs: &mut SharedDefinitions) -> Vec<T
Isa::X86 => x86::define(shared_defs),
Isa::Arm64 => arm64::define(shared_defs),
Isa::S390x => s390x::define(shared_defs),
Isa::Riscv64 => riscv64::define(shared_defs),
})
.collect()
}
27 changes: 27 additions & 0 deletions cranelift/codegen/meta/src/isa/riscv64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use crate::cdsl::isa::TargetIsa;
use crate::cdsl::settings::{SettingGroup, SettingGroupBuilder};

use crate::shared::Definitions as SharedDefinitions;

fn define_settings(_shared: &SettingGroup) -> SettingGroup {
let mut setting = SettingGroupBuilder::new("riscv64");

let _has_m = setting.add_bool("has_m", "has extension M?", "", false);
let _has_a = setting.add_bool("has_a", "has extension A?", "", false);
let _has_f = setting.add_bool("has_f", "has extension F?", "", false);
let _has_d = setting.add_bool("has_d", "has extension D?", "", false);
let _has_v = setting.add_bool("has_v", "has extension V?", "", false);
let _has_b = setting.add_bool("has_b", "has extension B?", "", false);
let _has_c = setting.add_bool("has_c", "has extension C?", "", false);
let _has_zbkb = setting.add_bool("has_zbkb", "has extension zbkb?", "", false);

let _has_zicsr = setting.add_bool("has_zicsr", "has extension zicsr?", "", false);
let _has_zifencei = setting.add_bool("has_zifencei", "has extension zifencei?", "", false);

setting.build()
}

pub(crate) fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa {
let settings = define_settings(&shared_defs.settings);
TargetIsa::new("riscv64", settings)
}
8 changes: 8 additions & 0 deletions cranelift/codegen/src/binemit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ pub enum Reloc {
/// This is equivalent to `R_AARCH64_TLSGD_ADD_LO12_NC` in the [aaelf64](https://github.com/ARM-software/abi-aa/blob/2bcab1e3b22d55170c563c3c7940134089176746/aaelf64/aaelf64.rst#relocations-for-thread-local-storage)
Aarch64TlsGdAddLo12Nc,

/// procedure call.
/// call symbol
/// expands to the following assembly and relocation:
/// auipc ra, 0
/// jalr ra, ra, 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you say what ELF relocation kind this is equivalent to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not very clear, I found it in riscv-abi.pdf

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you say what ELF relocation kind this is equivalent to?

@cfallin I not quit understand the question.
I found this at riscv-abi.pdf .

image

riscv-abi.pdf

RiscvCall,

/// s390x TLS GD64 - 64-bit offset of tls_index for GD symbol in GOT
S390xTlsGd64,
/// s390x TLS GDCall - marker to enable optimization of TLS calls
Expand All @@ -87,6 +94,7 @@ impl fmt::Display for Reloc {
Self::X86GOTPCRel4 => write!(f, "GOTPCRel4"),
Self::X86SecRel => write!(f, "SecRel"),
Self::Arm32Call | Self::Arm64Call => write!(f, "Call"),
Self::RiscvCall => write!(f, "RiscvCall"),

Self::ElfX86_64TlsGd => write!(f, "ElfX86_64TlsGd"),
Self::MachOX86_64Tlv => write!(f, "MachOX86_64Tlv"),
Expand Down
4 changes: 4 additions & 0 deletions cranelift/codegen/src/isa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ pub mod x64;
#[cfg(feature = "arm64")]
pub(crate) mod aarch64;

#[cfg(feature = "riscv64")]
pub mod riscv64;

#[cfg(feature = "s390x")]
mod s390x;

Expand Down Expand Up @@ -97,6 +100,7 @@ pub fn lookup(triple: Triple) -> Result<Builder, LookupError> {
}
Architecture::Aarch64 { .. } => isa_builder!(aarch64, (feature = "arm64"), triple),
Architecture::S390x { .. } => isa_builder!(s390x, (feature = "s390x"), triple),
Architecture::Riscv64 { .. } => isa_builder!(riscv64, (feature = "riscv64"), triple),
_ => Err(LookupError::Unsupported),
}
}
Expand Down
Loading