Every synth block in asm/ now says 'metric flat', so the seven block bodies are optimised without the .tp walk and therefore do not depend on where the caller puts its cells. The resulting bodies are cached in .r8forge_cache/ and the cache is committed, so a fresh clone assembles the library without waiting for a single search. asm/test.r8asm: 1674 -> 1666 characters. The seven tables were re-derived after the switch and all match the hand written implementations bit for bit (bit_raw_add still 0 9 10 19 12 21 22 31 repeated, bit_raw_inc 0 5 6 11, and so on), so this is a pure length win. One caveat: bit_raw_add's flat search still runs out of state budget (700M, the table stops fitting in a laptop) and falls back to the layer answer, which is what got cached for it. The other six converge in milliseconds; the whole warm up took 396 seconds, almost all of it that one block.
82 lines
1.1 KiB
Plaintext
82 lines
1.1 KiB
Plaintext
%include "asm/lib.r8asm"
|
|
|
|
; bit 宏由 %synth 合成,stat 是用 r8forge_derive 从旧实现里跑出来的。
|
|
|
|
; Macro clb_bit_or
|
|
; %1: CellBit arg1
|
|
; %2: CellBit arg2
|
|
; %3: CellBit ans
|
|
%synth clb_bit_or_synth
|
|
params 3
|
|
stat 0 4 4 4 0 4 4 4
|
|
metric flat
|
|
mode tape
|
|
%endsynth
|
|
|
|
%macro clb_bit_or 3
|
|
.tp %3
|
|
set_0
|
|
clb_bit_or_synth %1 %2 %3
|
|
%endmacro
|
|
|
|
; Macro clb_or
|
|
; %1: Cell arg1
|
|
; %2: Cell arg2
|
|
; %3: Cell ans
|
|
%macro clb_or 3
|
|
.anchor before_clb_or
|
|
|
|
%rep _CELL_SIZE
|
|
clb_bit_or %1 %2 %3
|
|
.tp %1
|
|
ror
|
|
.tp %2
|
|
ror
|
|
.tp %3
|
|
ror
|
|
%endrep
|
|
.tp before_clb_or
|
|
%endmacro
|
|
|
|
|
|
; Macro bit_raw_or
|
|
; %1: CellBit arg1
|
|
; %2: CellBit arg2
|
|
; %3: CellBit ans
|
|
; %4: CellBit tmp
|
|
%synth bit_raw_or_synth
|
|
params 4
|
|
stat 0 5 6 7 0 5 6 7 0 5 6 7 0 5 6 7
|
|
metric flat
|
|
mode tape
|
|
%endsynth
|
|
|
|
%macro bit_raw_or 4
|
|
.tp %3
|
|
set_0
|
|
.tp %4
|
|
set_0
|
|
bit_raw_or_synth %1 %2 %3 %4
|
|
%endmacro
|
|
|
|
|
|
; Macro raw_or
|
|
; %1: Cell arg1
|
|
; %2: Cell arg2
|
|
; %3: Cell ans
|
|
; %4: CellBit tmp
|
|
%macro raw_or 4
|
|
.anchor before_raw_or
|
|
|
|
%rep _CELL_SIZE
|
|
bit_raw_or %1 %2 %3 %4
|
|
.tp %1
|
|
ror
|
|
.tp %2
|
|
ror
|
|
.tp %3
|
|
ror
|
|
%endrep
|
|
.tp before_raw_or
|
|
%endmacro
|