Fil-C on Nix

Filnix wiki

mbrock/filnix/nanofil

amd64_contract.pl

Audited machine forms for the scalar stack cache. Unknown forms fail, selecting the unchanged implementation, rather than guessing effects. Reads name register families. write(Family,Bits) records partial writes: 32 bits zero-extend, 8/16 preserve the rest. Memory effects include addressing-register reads; flags and control/frame effects are separate. This describes selected instructions, not IR liveness or GC roots. Calls are unconditional cache boundaries; their ABI argument reads are not enumerated. Do not use this as a general call-liveness contract.

useslists
12:- discontiguousinstruction_effects/2

Concrete names index directly; family/width queries generate the name without searching every family for every operand in a large function.

register
16raxrax64
16eaxrax32
17axrax16
17alrax8
18rcxrcx64
18ecxrcx32
19cxrcx16
19clrcx8
20rdxrdx64
20edxrdx32
21dxrdx16
21dlrdx8
22rbxrbx64
22ebxrbx32
23bxrbx16
23blrbx8
24rsirsi64
24esirsi32
25sirsi16
25silrsi8
26rdirdi64
26edirdi32
27dirdi16
27dilrdi8
28rbprbp64
28ebprbp32
29bprbp16
29bplrbp8
30rsprsp64
30esprsp32
31sprsp16
31splrsp8
32r8r864
32r8dr832
33r8wr816
33r8br88
34r9r964
34r9dr932
35r9wr916
35r9br98
36r10r1064
36r10dr1032
37r10wr1016
37r10br108
38r11r1164
38r11dr1132
39r11wr1116
39r11br118
40r12r1264
40r12dr1232
41r12wr1216
41r12br128
42r13r1364
42r13dr1332
43r13wr1316
43r13br138
44r14r1464
44r14dr1432
45r14wr1416
45r14br148
46r15r1564
46r15dr1532
47r15wr1516
47r15br158
48xmm0xmm0128
48xmm1xmm1128
49xmm2xmm2128
49xmm3xmm3128
50xmm4xmm4128
50xmm5xmm5128
51xmm6xmm6128
51xmm7xmm7128
width
53b8
53w16
53l32
53q64
54expressionE ←
integerE
!
55expressionE ←
atomE
!
56expressionA + B ←
57addressmemD, B, B ←
integerD
registerB, B, 64
58addressmemD, B, I, B, I ←
integerD
registerB, B, 64
registerI, I, 64
59addressripE, [] ←
60addressgotpcrelS, [] ←
atomS
62explicit_registersins_, _, Os, Rs ←
!
findallR,
memberO, Os
,
Rs
64explicit_registers_, []
65operand_registerregN, F ←
registerN, F, _
66operand_registerO, R ←
addressO, Rs
memberR, Rs
67operand_registerindO, R ←
69sourceregR, W, F, [] ←
registerR, F, W
70sourceimmE, _, [], [] ←
71sourceM, W, Rs, readM, N ←
addressM, Rs
N is W//8
72destinationregR, W, [], writeF, W, [] ←
registerR, F, W
73destinationM, W, Rs, [], writeM, N ←
addressM, Rs
N is W//8

x86 does not admit a memory-to-memory two-operand instruction.

75not_two_memoryA, B ←
¬
77instruction_effectsinsmov, S, A, B, effectRs, Ws, preserve, Ms, next ←
widthS, W
sourceA, W, R1, M1
destinationB, W, R2, Ws, M2
appendR1, R2, Rs
appendM1, M2, Ms
80instruction_effectsinsmovabs, q, immN, regR, effect[], writeF, 64, preserve, [], next ←
integerN
registerR, F, 64
83instruction_effectsinsOp, S, A, regR, effectRs, writeF, W, preserve, Ms, next ←
extensionOp, From
widthS, W
W > From
sourceA, From, Rs, Ms
A ≠ imm_
registerR, F, W
86instruction_effectsinslea, q, M, regR, effectRs, writeF, 64, preserve, [], next ←
addressM, Rs
registerR, F, 64
88instruction_effectsinsOp, S, A, B, effectRs, Ws, write, Ms, next ←
memberchkOp, add, sub, and, or, xor, imul, btc
widthS, W
memberchkOp, imul, btc
→
W ≥ 16
B = reg_
else
true
sourceA, W, R1, M1
sourceB, W, R2, M2
B ≠ imm_
destinationB, W, _, Ws, M3
appendR1, R2, Rs
appendM1, M2, M3, Ms
94instruction_effectsinsOp, S, A, B, effectRs, [], write, Ms, next ←
memberchkOp, cmp, test
widthS, W
sourceA, W, R1, M1
sourceB, W, R2, M2
B ≠ imm_
appendR1, R2, Rs
appendM1, M2, Ms
98instruction_effectsinsneg, S, A, effectRs, Ws, write, Ms, next ←
widthS, W
sourceA, W, Rs, M1
destinationA, W, _, Ws, M2
appendM1, M2, Ms
101instruction_effectsinsOp, S, Count, A, effectRs, Ws, read_write, Ms, next ←
memberchkOp, shl, shr, sar
widthS, W
shift_countCount, R1
sourceA, W, R2, M1
destinationA, W, _, Ws, M2
appendR1, R2, Rs
appendM1, M2, Ms
105instruction_effectsinsOp, none, regR, effectF, writeF, 8, read, [], next ←
atom_concatset, CC, Op
registerR, F, 8
107instruction_effectsinscltd, none, [], effectrax, writerdx, 32, preserve, [], next
108instruction_effectsinscqto, none, [], effectrax, writerdx, 64, preserve, [], next
109instruction_effectsinsOp, S, A, effectrax, rdx|Rs, Ws, write, Ms, next ←
memberchkOp, div, idiv
widthS, W
memberchkW, 32, 64
sourceA, W, Rs, Ms
A ≠ imm_
Ws = writerax, W, writerdx, W
extension
113movzb8
113movsb8
114movzw16
114movsw16
114movsl32
115shift_countregcl, rcx
116shift_countimmN, [] ←
integerN
N ≥ 0
N ≤ 255
117conditionCC ←
memberchkCC, e, ne, z, nz, b, be, a, ae, l, le, g, ge, s, ns, p, np

SSE forms use full-family symbolic outputs: the cache never changes one, so the validator need not emulate floating arithmetic or lanes.

121instruction_effectsinsOp, none, A, B, effectRs, Ws, preserve, Ms, next ←
sse_transferA, B, W, Rs, Ws, Ms
123instruction_effectsinsOp, S, regA, regB, effectA, B, writeB, 128, preserve, [], next ←
memberchkOp, add, sub, mul, div
memberchkS, ss, sd
registerA, A, 128
registerB, B, 128
127instruction_effectsinsOp, none, regA, regB, effectA, B, [], write, [], next ←
memberchkOp, ucomiss, ucomisd
registerA, A, 128
registerB, B, 128
129instruction_effectsinsOp, none, regA, regB, effectA, B, writeB, 128, preserve, [], next ←
memberchkOp, cvtss2sd, cvtsd2ss
registerA, A, 128
registerB, B, 128
132instruction_effectsinsOp, S, regA, regB, effectA, writeF, W, preserve, [], next ←
memberchkOp, cvttss2si, cvttsd2si
widthS, W
memberchkW, 32, 64
registerA, A, 128
registerB, F, W
136instruction_effectsinsOp, S, regA, regB, effectF, B, writeB, 128, preserve, [], next ←
memberchkOp, cvtsi2ss, cvtsi2sd
widthS, W
memberchkW, 32, 64
registerA, F, W
registerB, B, 128
140sse_movemovd, 32
140sse_movemovq, 64
141sse_transferregA, regB, W, F, writeB, 128, [] ←
registerA, F, W
registerB, B, 128
143sse_transferregA, regB, W, A, writeF, W, [] ←
registerA, A, 128
registerB, F, W
146instruction_effectsinsjmp, none, T, effectRs, [], preserve, Ms, branch ←
targetT, Rs, Ms
148instruction_effectsinsOp, none, T, effect[], [], read, [], branch ←
atom_concatj, CC, Op
targetT, [], []
150instruction_effectsinscall, S, T, effectrsp|Rs, Ws, write, Ms, call ←
memberchkS, none, q
targetT, Rs, M
findallwriteR, W, caller_clobberR, W, Ws
appendM, read_writeruntime, unknown, Ms
154instruction_effectsinspush, q, regR, effectF, rsp, writersp, 64, preserve, writestack, 8, frame ←
registerR, F, 64
157instruction_effectsinspop, q, regR, effectrsp, writeF, 64, writersp, 64, preserve, readstack, 8, frame ←
registerR, F, 64
160instruction_effectsinsleave, none, [], effectrbp, writerbp, 64, writersp, 64, preserve, readstack, 8, frame
162instruction_effectsinsret, none, [], effectrsp, writersp, 64, preserve, readstack, 8, terminal
164instruction_effectsinsud2, none, [], effect[], [], preserve, [], terminal
165instruction_effectslabelS, effect[], [], preserve, [], label ←
atomS
166instruction_effectsD, effect[], [], preserve, [], directive ←
168targetsymS, [], [] ←
atomS
169targetpltS, [], [] ←
atomS
170targetindO, Rs, Ms ←
sourceO, 64, Rs, Ms
O ≠ imm_
171caller_clobberR, 64 ←
memberR, rax, rcx, rdx, rsi, rdi, r8, r9, r10, r11, rsp
172caller_clobberR, 128 ←
registerR, R, 128
173directivesectiontext
174directivep2alignN ←
integerN
175directivegloblS ←
atomS
176directivetypeS, function ←
atomS
177directivesizeS ←
atomS