interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / ng / a64 / tests / enc.cases

289 lines · 10475 bytes Raw Blame History
1@ng a64-enc
2; Encoder cases for seed/ng/a64/gate.om. One case per line: FORM operands | expected disassembly.
3; The expected text is written by hand from Arm ARM DDI 0487 M.d (encoding diagram and preferred
4; disassembly alias of each form); GNU objdump is the referee that must print the same text.
5; Comparison: blanks collapsed, objdump's trailing `// ...` comment dropped, `@+N` / `@-N` means the case's own
6; address plus / minus N bytes. Operands: decimal, -decimal (two's complement) or lowercase 0x hex.
7; ---- shifted register ----
8addx 1 2 3 | add x1, x2, x3
9addx 1 2 3 0 4 | add x1, x2, x3, lsl #4
10addx 9 10 11 2 63 | add x9, x10, x11, asr #63
11addw 1 2 3 | add w1, w2, w3
12subx 1 2 3 | sub x1, x2, x3
13subx 1 31 3 | neg x1, x3
14subw 4 5 6 1 3 | sub w4, w5, w6, lsr #3
15addsx 1 2 3 | adds x1, x2, x3
16addsx 31 2 3 | cmn x2, x3
17addsw 1 2 3 | adds w1, w2, w3
18subsx 1 2 3 | subs x1, x2, x3
19subsx 31 2 3 | cmp x2, x3
20subsx 31 16 0 2 63 | cmp x16, x0, asr #63
21subsw 31 2 3 | cmp w2, w3
22andx 1 2 3 | and x1, x2, x3
23andw 1 2 3 | and w1, w2, w3
24orrx 1 2 3 | orr x1, x2, x3
25orrx 1 31 3 | mov x1, x3
26orrw 1 31 3 | mov w1, w3
27eorx 1 2 3 | eor x1, x2, x3
28eorw 1 2 3 | eor w1, w2, w3
29andsx 1 2 3 | ands x1, x2, x3
30andsx 31 2 3 | tst x2, x3
31bicx 1 2 3 | bic x1, x2, x3
32ornx 1 31 3 | mvn x1, x3
33; ---- multiply, divide, variable shift ----
34mulx 1 2 3 | mul x1, x2, x3
35mulw 1 2 3 | mul w1, w2, w3
36smulh 1 2 3 | smulh x1, x2, x3
37umulh 1 2 3 | umulh x1, x2, x3
38sdivx 1 2 3 | sdiv x1, x2, x3
39udivx 1 2 3 | udiv x1, x2, x3
40sdivw 1 2 3 | sdiv w1, w2, w3
41udivw 1 2 3 | udiv w1, w2, w3
42lslvx 1 2 3 | lsl x1, x2, x3
43lsrvx 1 2 3 | lsr x1, x2, x3
44asrvx 1 2 3 | asr x1, x2, x3
45rorvx 1 2 3 | ror x1, x2, x3
46lslvw 1 2 3 | lsl w1, w2, w3
47lsrvw 1 2 3 | lsr w1, w2, w3
48asrvw 1 2 3 | asr w1, w2, w3
49maddx 1 2 3 4 | madd x1, x2, x3, x4
50msubx 1 2 3 4 | msub x1, x2, x3, x4
51; ---- extended register ----
52addxe 1 2 3 6 0 | add x1, x2, w3, sxtw
53subsxe 31 2 3 6 0 | cmp x2, w3, sxtw
54subsxe 31 2 3 4 0 | cmp x2, w3, sxtb
55subsxe 31 2 3 5 0 | cmp x2, w3, sxth
56; ---- immediate ----
57addxi 1 2 4095 0 | add x1, x2, #0xfff
58addxi 1 2 1 1 | add x1, x2, #0x1, lsl #12
59addxi 31 16 0 0 | mov sp, x16
60addxi 27 31 0 0 | mov x27, sp
61addwi 1 2 5 0 | add w1, w2, #0x5
62subxi 1 2 16 0 | sub x1, x2, #0x10
63subxi 31 31 32 0 | sub sp, sp, #0x20
64subwi 1 2 16 0 | sub w1, w2, #0x10
65addsxi 1 2 3 0 | adds x1, x2, #0x3
66addsxi 31 2 1 0 | cmn x2, #0x1
67subsxi 31 2 9 0 | cmp x2, #0x9
68subsxi 1 2 9 0 | subs x1, x2, #0x9
69subswi 31 2 9 0 | cmp w2, #0x9
70addswi 1 2 3 0 | adds w1, w2, #0x3
71; ---- logical immediate (bitmask) ----
72andxi 1 2 0xff | and x1, x2, #0xff
73andxi 1 2 0xff00ff00ff00ff00 | and x1, x2, #0xff00ff00ff00ff00
74andxi 1 2 0x5555555555555555 | and x1, x2, #0x5555555555555555
75andxi 1 2 0x8000000000000000 | and x1, x2, #0x8000000000000000
76andxi 1 2 0xfffffffffffffffe | and x1, x2, #0xfffffffffffffffe
77andxi 1 2 0x7ffffffffffffff0 | and x1, x2, #0x7ffffffffffffff0
78orrxi 1 2 0xf0 | orr x1, x2, #0xf0
79orrxi 1 31 0xffff0000ffff0000 | mov x1, #0xffff0000ffff0000
80eorxi 1 2 0x1 | eor x1, x2, #0x1
81andsxi 31 2 0x1 | tst x2, #0x1
82andwi 1 2 0xff | and w1, w2, #0xff
83orrwi 1 2 0xf0f0f0f0 | orr w1, w2, #0xf0f0f0f0
84eorwi 1 2 0x80000000 | eor w1, w2, #0x80000000
85; ---- move wide ----
86movzx 1 5 0 | mov x1, #0x5
87movzx 28 0x1000 1 | mov x28, #0x10000000
88movzx 1 0x1234 3 | mov x1, #0x1234000000000000
89movnx 1 0 0 | mov x1, #0xffffffffffffffff
90movnx 1 5 0 | mov x1, #0xfffffffffffffffa
91movkx 1 0x1234 2 | movk x1, #0x1234, lsl #32
92movzw 1 7 0 | mov w1, #0x7
93movnw 1 0 0 | mov w1, #0xffffffff
94; ---- bitfield, extract ----
95ubfmx 1 2 1 63 | lsr x1, x2, #1
96ubfmx 1 2 60 59 | lsl x1, x2, #4
97ubfmx 1 2 0 7 | ubfx x1, x2, #0, #8
98sbfmx 1 2 0 31 | sxtw x1, w2
99sbfmx 1 2 63 63 | asr x1, x2, #63
100sbfmx 1 2 0 7 | sxtb x1, w2
101sbfmx 1 2 0 15 | sxth x1, w2
102ubfmw 1 2 0 7 | uxtb w1, w2
103ubfmw 1 2 0 15 | uxth w1, w2
104sbfmw 1 2 0 7 | sxtb w1, w2
105extrx 1 2 3 8 | extr x1, x2, x3, #8
106extrx 1 2 2 8 | ror x1, x2, #8
107; ---- conditional select ----
108cselx 1 2 3 0 | csel x1, x2, x3, eq
109csincx 1 31 31 1 | cset x1, eq
110csincx 1 2 2 0 | cinc x1, x2, ne
111csincx 1 2 3 11 | csinc x1, x2, x3, lt
112csinvx 1 31 31 0 | csetm x1, ne
113csnegx 1 2 2 10 | cneg x1, x2, lt
114csnegx 1 2 3 0 | csneg x1, x2, x3, eq
115; ---- loads and stores, unsigned offset (offset operand in access-size units) ----
116strb 1 2 3 | strb w1, [x2, #3]
117strb 1 2 0 | strb w1, [x2]
118ldrb 1 2 4095 | ldrb w1, [x2, #4095]
119ldrsbx 1 2 1 | ldrsb x1, [x2, #1]
120strh 1 2 1 | strh w1, [x2, #2]
121ldrh 1 2 2 | ldrh w1, [x2, #4]
122ldrshx 1 2 1 | ldrsh x1, [x2, #2]
123strw 1 2 1 | str w1, [x2, #4]
124ldrw 1 2 1 | ldr w1, [x2, #4]
125ldrsw 1 2 1 | ldrsw x1, [x2, #4]
126strx 30 31 3 | str x30, [sp, #24]
127ldrx 1 2 4095 | ldr x1, [x2, #32760]
128strs 1 2 1 | str s1, [x2, #4]
129ldrs 1 2 1 | ldr s1, [x2, #4]
130strd 16 31 1 | str d16, [sp, #8]
131ldrd 1 2 0 | ldr d1, [x2]
132; ---- loads and stores, register offset (s 1 = scaled by the access size) ----
133strbr 1 2 3 0 | strb w1, [x2, x3]
134ldrbr 1 2 3 0 | ldrb w1, [x2, x3]
135ldrsbxr 1 2 3 0 | ldrsb x1, [x2, x3]
136strhr 1 2 3 1 | strh w1, [x2, x3, lsl #1]
137ldrhr 1 2 3 1 | ldrh w1, [x2, x3, lsl #1]
138ldrshxr 1 2 3 1 | ldrsh x1, [x2, x3, lsl #1]
139strwr 1 2 3 1 | str w1, [x2, x3, lsl #2]
140ldrwr 1 2 3 0 | ldr w1, [x2, x3]
141ldrswr 1 2 3 1 | ldrsw x1, [x2, x3, lsl #2]
142strxr 1 2 3 1 | str x1, [x2, x3, lsl #3]
143ldrxr 1 2 3 1 | ldr x1, [x2, x3, lsl #3]
144strsr 1 2 3 1 | str s1, [x2, x3, lsl #2]
145ldrsr 1 2 3 0 | ldr s1, [x2, x3]
146strdr 1 2 3 1 | str d1, [x2, x3, lsl #3]
147ldrdr 1 2 3 0 | ldr d1, [x2, x3]
148; ---- pairs (signed byte offset) ----
149stpx 29 30 31 -16 | stp x29, x30, [sp, #-16]
150ldpx 19 20 31 16 | ldp x19, x20, [sp, #16]
151stpxpre 29 30 31 -32 | stp x29, x30, [sp, #-32]!
152ldpxpre 1 2 3 8 | ldp x1, x2, [x3, #8]!
153stpxpost 1 2 3 16 | stp x1, x2, [x3], #16
154ldpxpost 29 30 31 32 | ldp x29, x30, [sp], #32
155stpd 8 9 31 504 | stp d8, d9, [sp, #504]
156ldpd 8 9 31 -512 | ldp d8, d9, [sp, #-512]
157; ---- branches (distances in words; ADR in bytes) ----
158b 3 | b @+12
159b -1 | b @-4
160bl 2 | bl @+8
161bcond 6 5 | b.vs @+20
162bcond 0 1 | b.eq @+4
163bcond 1 1 | b.ne @+4
164bcond 8 -3 | b.hi @-12
165bcond 11 2 | b.lt @+8
166cbzx 1 4 | cbz x1, @+16
167cbnzx 1 -2 | cbnz x1, @-8
168cbzw 1 1 | cbz w1, @+4
169cbnzw 1 1 | cbnz w1, @+4
170tbz 1 3 2 | tbz w1, #3, @+8
171tbz 1 40 2 | tbz x1, #40, @+8
172tbnz 1 63 -1 | tbnz x1, #63, @-4
173ret 30 | ret
174ret 1 | ret x1
175br 16 | br x16
176blr 16 | blr x16
177svc 0 | svc #0x0
178adr 1 8 | adr x1, @+8
179adr 1 -4 | adr x1, @-4
180; ---- scalar floating point ----
181faddd 1 2 3 | fadd d1, d2, d3
182fsubd 1 2 3 | fsub d1, d2, d3
183fmuld 1 2 3 | fmul d1, d2, d3
184fdivd 1 2 3 | fdiv d1, d2, d3
185fmaxd 1 2 3 | fmax d1, d2, d3
186fmind 1 2 3 | fmin d1, d2, d3
187fmaxnmd 1 2 3 | fmaxnm d1, d2, d3
188fminnmd 1 2 3 | fminnm d1, d2, d3
189fadds 1 2 3 | fadd s1, s2, s3
190fsubs 1 2 3 | fsub s1, s2, s3
191fmuls 1 2 3 | fmul s1, s2, s3
192fdivs 1 2 3 | fdiv s1, s2, s3
193fmaxs 1 2 3 | fmax s1, s2, s3
194fmins 1 2 3 | fmin s1, s2, s3
195fmaxnms 1 2 3 | fmaxnm s1, s2, s3
196fminnms 1 2 3 | fminnm s1, s2, s3
197fsqrtd 1 2 | fsqrt d1, d2
198fabsd 1 2 | fabs d1, d2
199fnegd 1 2 | fneg d1, d2
200fmovd 1 2 | fmov d1, d2
201fsqrts 1 2 | fsqrt s1, s2
202fabss 1 2 | fabs s1, s2
203fnegs 1 2 | fneg s1, s2
204fmovs 1 2 | fmov s1, s2
205fcmpd 1 2 | fcmp d1, d2
206fcmps 1 2 | fcmp s1, s2
207fmaddd 1 2 3 4 | fmadd d1, d2, d3, d4
208fmadds 1 2 3 4 | fmadd s1, s2, s3, s4
209fcvtds 1 2 | fcvt d1, s2
210fcvtsd 1 2 | fcvt s1, d2
211fmovxd 1 2 | fmov x1, d2
212fmovdx 1 2 | fmov d1, x2
213fmovws 1 2 | fmov w1, s2
214fmovsw 1 2 | fmov s1, w2
215scvtfdx 1 2 | scvtf d1, x2
216ucvtfdx 1 2 | ucvtf d1, x2
217scvtfsx 1 2 | scvtf s1, x2
218ucvtfsx 1 2 | ucvtf s1, x2
219fcvtzsxd 1 2 | fcvtzs x1, d2
220fcvtzuxd 1 2 | fcvtzu x1, d2
221fcvtzsxs 1 2 | fcvtzs x1, s2
222fcvtzuxs 1 2 | fcvtzu x1, s2
223rorvw 1 2 3 | ror w1, w2, w3
224; Scalar floats (NgFloatFill): FCSEL S/D (kind 8) and MSR FPCR, Xt (kind 22), then the operand shapes the float
225; selection emits with existing forms (FPCR RMode value, exponent extracts, D saves and spills, FMOV of scratch v31).
226fcseld 1 2 3 1 | fcsel d1, d2, d3, ne
227fcsels 4 5 6 11 | fcsel s4, s5, s6, lt
228fcseld 31 29 30 15 | fcsel d31, d29, d30, nv
229msrfpcr 3 | msr fpcr, x3
230msrfpcr 15 | msr fpcr, x15
231msrfpcr 31 | msr fpcr, xzr
232movzx 15 192 1 | mov x15, #0xc00000
233ubfmx 15 16 23 30 | ubfx x15, x16, #23, #8
234ubfmx 17 17 52 62 | ubfx x17, x17, #52, #11
235stpd 8 9 31 24 | stp d8, d9, [sp, #24]
236ldpd 14 15 31 496 | ldp d14, d15, [sp, #496]
237strd 31 31 511 | str d31, [sp, #4088]
238ldrd 29 31 0 | ldr d29, [sp]
239fmovdx 31 16 | fmov d31, x16
240fmovxd 17 29 | fmov x17, d29
241; Fill (NgFloatFill): DUP Vd.2D, Xn (kind 19) and STR Qt register offset (kind 10), then the existing forms in the
242; shapes the fill emits (pattern replication, byte count, tails).
243dup2d 31 17 | dup v31.2d, x17
244dup2d 0 30 | dup v0.2d, x30
245strqr 31 1 15 0 | str q31, [x1, x15]
246strqr 2 3 4 1 | str q2, [x3, x4, lsl #4]
247orrx 17 17 17 0 8 | orr x17, x17, x17, lsl #8
248andxi 17 3 255 | and x17, x3, #0xff
249addx 15 31 9 0 3 | add x15, xzr, x9, lsl #3
250tbz 15 3 3 | tbz w15, #3, @+12
251; Packed 16-byte float vectors (NgVecA64, DESIGN.md section 12): STR/LDR Qt (unsigned offset and register offset),
252; ORR Vd.16B (MOV alias when Vn = Vm), DUP element (vector 4S/2D and scalar S/D), and FADD/FSUB/FMUL/FMLA 4S/2D.
253strq 1 2 0 | str q1, [x2]
254strq 31 31 1 | str q31, [sp, #16]
255strq 3 31 4095 | str q3, [sp, #65520]
256ldrq 1 2 0 | ldr q1, [x2]
257ldrq 29 31 2 | ldr q29, [sp, #32]
258ldrq 4 31 4095 | ldr q4, [sp, #65520]
259ldrqr 1 2 3 0 | ldr q1, [x2, x3]
260ldrqr 2 3 4 1 | ldr q2, [x3, x4, lsl #4]
261orr16b 1 2 2 | mov v1.16b, v2.16b
262orr16b 1 2 3 | orr v1.16b, v2.16b, v3.16b
263dupv4s 1 2 0 | dup v1.4s, v2.s[0]
264dupv4s 3 4 3 | dup v3.4s, v4.s[3]
265dupv2d 1 2 0 | dup v1.2d, v2.d[0]
266dupv2d 3 4 1 | dup v3.2d, v4.d[1]
267dups 1 2 0 | mov s1, v2.s[0]
268dups 1 2 2 | mov s1, v2.s[2]
269dups 5 6 3 | mov s5, v6.s[3]
270dupd 1 2 0 | mov d1, v2.d[0]
271dupd 1 2 1 | mov d1, v2.d[1]
272fadd4s 1 2 3 | fadd v1.4s, v2.4s, v3.4s
273fadd2d 1 2 3 | fadd v1.2d, v2.2d, v3.2d
274fsub4s 1 2 3 | fsub v1.4s, v2.4s, v3.4s
275fsub2d 1 2 3 | fsub v1.2d, v2.2d, v3.2d
276fmul4s 1 2 3 | fmul v1.4s, v2.4s, v3.4s
277fmul2d 1 2 3 | fmul v1.2d, v2.2d, v3.2d
278fmla4s 1 2 3 | fmla v1.4s, v2.4s, v3.4s
279fmla2d 1 2 3 | fmla v1.2d, v2.2d, v3.2d
280; Boundaries next to the refusals of tests/enc-refuse.cases: the largest in-field value each form accepts.
281orrx 1 2 3 3 5 | orr x1, x2, x3, ror #5
282addw 1 2 3 0 31 | add w1, w2, w3, lsl #31
283subw 1 2 3 2 31 | sub w1, w2, w3, asr #31
284movzx 1 5 3 | mov x1, #0x5000000000000
285movzw 1 5 1 | mov w1, #0x50000
286ubfmx 1 2 40 3 | ubfiz x1, x2, #24, #4
287ubfmw 1 2 31 31 | lsr w1, w2, #31
288extrx 1 2 3 63 | extr x1, x2, x3, #63
289cbzx 1 262143 | cbz x1, @+1048572