code wiki / _hdl_build / nx_superopt_emit.nx
nx_superopt_emit.nx
buildroot/runtime/_hdl_build/nx_superopt_emit.nx
about
nx_superopt_emit.nx -- emit COMPETITIVE x86-64 machine code for a superoptimized
program (the slot/op/a/b form from nx_superopt_opt). This is the team building UP from
machine code: SYNTHESIZE the optimal op sequence, then EMIT it as tight assembly to
race gcc -O2. Tightness comes from the same register-allocation insight proved in
nx_regalloc_calls: keep the running result in one register (reuse a dead operand's
register in place), and use `lea` to fuse a shift/add with its move so each op is ~1
instruction -- exactly how gcc's strength reduction emits. Input x in %rdi, result in
%rax. license_tier: ORIGINAL
op/a/b: op[t] in {ADD,SUB,MUL,SHL,SAR,XOR,AND,OR}; a[t],b[t] are slot indices
(0=x, 1=const0, 2=const1, t+3=result of op t); for shifts b[t] is the shift amount.
dependencies 1 imports · 13 importers
diagram shows first 10 each side; +0 more imports, +3 more importers in the complete lists below.
imports: nx_superopt_opt.nx
imported by: nx_author.nxnx_autoopt_library_test.nxnx_autorace_test.nxnx_builder.nxnx_cost_race_test.nxnx_horizontal_test.nxnx_layer_campaign.nxnx_levels_test.nxnx_mulchain_test.nxnx_overnight.nxnx_selfix.nxnx_superopt_race_test.nxnx_team_tick.nx
structs
| none |
consts
| none |
functions
| 16 | func se_rn(buf: *u8, oi: i64, id: i64) -> i64 |
| 26 | func se_str(buf: *u8, oi: i64, s: *u8) -> i64 { var j: i64 = 0; while s[j] != (0 as u8) { buf[oi] = s[j]; oi = oi + 1; j = j + 1 } return oi } |
| 27 | func se_num(buf: *u8, oi: i64, v: i64) -> i64 |
| 36 | func se_opmn(o: i64) -> *u8 called by 1: se_emit_synth |
| 47 | func se_slot(buf: *u8, oi: i64, slot: i64, sreg: *i64) -> i64 |
| 52 | func se_slot_isreg(slot: i64) -> i64 { if slot == 1 { return 0 } if slot == 2 { return 0 } return 1 } called by 1: se_emit_synth |
| 56 | func se_emit_synth(op: *i64, a: *i64, b: *i64, L: i64, buf: *u8, oi: i64, icnt: *i64) -> i64 |
| 188 | func se_emit_imul_full(c: i64, inputs: *i64, nin: i64, buf: *u8, icnt: *i64) -> i64 |
| 205 | func se_emit_full(op: *i64, a: *i64, b: *i64, L: i64, inputs: *i64, nin: i64, buf: *u8, icnt: *i64) -> i64 called by 12: opt_onerace_onebd_build_onecr_onehz_mullc_have_codegen+6 calls 3: se_strse_numse_emit_synth |