nx_riscv.nx
buildroot/runtime/nx_riscv.nx
about
riscv.nx -- RV64 codegen backend, in NishiLang.
Takes a Function + its ValueLoc table and emits RV64 assembly
text to an output buffer. Pairs with regalloc.nx and ir.nx.
Scope: the opcodes our benchmarks emit. Full backend parity is
mechanical extension of the switch statement.
Output format: raw asm text, same as riscv.c emits today, so the
output of this NishiLang codegen is byte-compatible with gcc `as`
(verified at compile time by reading its IR output).
dependencies 4 imports · 12 importers
diagram shows first 10 each side; +0 more imports, +2 more importers in the complete lists below.
imports: nx_syscalls.nxnx_types.nxnx_ir.nxnx_outbuf.nx
imported by: nx_main.nxnx_nxc.nxnx_rv64_atomic_gate.nxnx_smoke_nxc_pipeline.nxnx_smoke_nxc_pipeline10.nxnx_smoke_nxc_pipeline2.nxnx_smoke_nxc_pipeline7.nxnx_smoke_nxc_pipeline8.nxnx_smoke_nxc_pipeline9.nxnx_smoke_nxc_tilde.nxnxc.nxriscv.nx
structs
| none |
consts
| none |
functions
| 50 | func loc_at(locs: *ValueLoc, id: i64) -> *ValueLoc { |
| 70 | func reg_name(o: *OutBuf, idx: i64) -> i64 {
called by 33: materialisematerialise_valuefmaterialiserv_emit_fbinoprv_emit_vbinoprv_emit_binop+27 calls 2: out_strout_i64 |
| 157 | func fits_imm12(off: i64) -> i64 { |
| 164 | func emit_sp_adjust(o: *OutBuf, off: i64) -> i64 { |
| 180 | func emit_sp_ld(o: *OutBuf, dst: *u8, off: i64) -> i64 { |
| 203 | func sp_is_reg(name: *u8, a: i64, b: i64) -> i64 {
called by 1: emit_sp_sd |
| 224 | func emit_sp_sd(o: *OutBuf, src: *u8, off: i64) -> i64 { |
| 256 | func emit_sp_addi(o: *OutBuf, dst: *u8, off: i64) -> i64 { |
| 293 | func emit_sp_flw(o: *OutBuf, dst: *u8, off: i64) -> i64 { |
| 312 | func emit_sp_fsw(o: *OutBuf, src: *u8, off: i64) -> i64 {
called by 4: rv_emit_fbinoprv_emit_callrv_emit_call_indirectrv_emit_fcast calls 4: fits_imm12out_strout_i64out_char |
| 336 | func emit_sp_fld(o: *OutBuf, dst: *u8, off: i64) -> i64 { |
| 355 | func emit_sp_fsd(o: *OutBuf, src: *u8, off: i64) -> i64 {
called by 4: rv_emit_fbinoprv_emit_callrv_emit_call_indirectrv_emit_fcast calls 4: fits_imm12out_strout_i64out_char |
| 380 | func emit_fbinop_mnem(o: *OutBuf, op: i64, is_double: i64) -> i64 { |
| 411 | func emit_binop_mnem(o: *OutBuf, op: i64) -> i64 { |
| 437 | func materialise(f: *Function, locs: *ValueLoc, o: *OutBuf, |
| 513 | func materialise_value(f: *Function, locs: *ValueLoc, o: *OutBuf, |
| 603 | func fmaterialise(f: *Function, locs: *ValueLoc, o: *OutBuf, |
| 661 | func rv_emit_fbinop(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 708 | func emit_vbinop_mnem(o: *OutBuf, op: i64) -> i64 { |
| 734 | func rv_emit_vbinop(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 757 | func rv_emit_binop(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 815 | func popcount(x: i64) -> i64 {
called by 1: emit_function |
| 833 | func emit_save_gpr(o: *OutBuf, mask: i64, save_base: i64, |
| 867 | func emit_restore_gpr(o: *OutBuf, mask: i64, save_base: i64) -> i64 { |
| 908 | func emit_save_fpr(o: *OutBuf, mask: i64, save_base: i64, |
| 945 | func emit_restore_fpr(o: *OutBuf, mask: i64, save_base: i64) -> i64 { |
| 982 | func rv_emit_return(f: *Function, locs: *ValueLoc, o: *OutBuf, |
| 1033 | func emit_branch(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr, |
| 1078 | func rv_emit_fcmp(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr, is_d: i64) -> i64 { |
| 1138 | func rv_emit_cmp(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 1224 | func target_reg_name(o: *OutBuf, k: i64) -> i64 { |
| 1233 | func target_freg_name(o: *OutBuf, k: i64) -> i64 { |
| 1239 | func rv_emit_call(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 1360 | func rv_emit_call_indirect(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 1478 | func load_mnem_name(o: *OutBuf, sz: i64, is_signed: i64) -> i64 { |
| 1495 | func store_mnem_name(o: *OutBuf, sz: i64) -> i64 { |
| 1504 | func type_kind_is_signed(k: i64) -> i64 { |
| 1515 | func rv_home_t6(locs: *ValueLoc, o: *OutBuf, id: i64) -> i64 { |
| 1528 | func rv_emit_load(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 1555 | func rv_emit_addr_of(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 1569 | func rv_emit_store(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 1590 | func rv_emit_gep(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 1632 | func rv_emit_tail_call(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr, |
| 1689 | func rv_emit_fcast(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 1749 | func compute_alloca_offsets(f: *Function, spill_bytes: i64, |
| 1786 | func rv_emit_alloca(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr, |
| 1828 | func rv_emit_simd_vdot_i16(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 1903 | func rv_emit_simd_vreduce_minmax_i16(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr, is_max: i64) -> i64 { |
| 1939 | func rv_emit_simd_vbinop_i16(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr, enc_word: i64) -> i64 {
called by 2: rv_emit_simd_vsadd_i16emit_instr calls 7: materialiseout_strout_i64out_charloc_atreg_name+1 |
| 1964 | func rv_emit_simd_vsadd_i16(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 {
calls 1: rv_emit_simd_vbinop_i16 |
| 1981 | func rv_emit_simd_vshift_i16(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr, enc_word: i64) -> i64 { |
| 2014 | func rv_emit_simd_vreduce_sum_i16(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 2046 | func rv_emit_simd_vbroadcast_i16(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 2071 | func rv_emit_simd_vbinop_i8(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr, enc_word: i64) -> i64 { |
| 2100 | func rv_emit_simd_vreduce_sum_i8(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 2133 | func rv_emit_simd_vbroadcast_i8(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 2156 | func rv_emit_simd_vbinop_i32(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr, enc_word: i64) -> i64 { |
| 2184 | func rv_emit_simd_vreduce_sum_i32(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 2214 | func rv_emit_simd_vbroadcast_i32(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 2235 | func rv_emit_simd_vbinop_i64(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr, enc_word: i64) -> i64 { |
| 2261 | func rv_emit_simd_vreduce_sum_i64(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 2282 | func rv_emit_simd_vbroadcast_i64(f: *Function, locs: *ValueLoc, o: *OutBuf, i: *Instr) -> i64 { |
| 2302 | func emit_instr(f: *Function, locs: *ValueLoc, o: *OutBuf, |
| 2648 | func emit_function(f: *Function, locs: *ValueLoc, o: *OutBuf,
called by 12: nxc_compilemaincompilecompilenxc_compilega_compile+6 calls 17: sys_mmaploc_atcompute_alloca_offsetspopcountout_strout_char+11 |
| 2882 | func emit_return_instr(bb: *BasicBlock, v: i64) -> i64 { |