authorgravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-04-11 20:27:38+07:00
committergravatar for koachan@protonmail.comKoakuma <koachan@protonmail.com> 2022-04-14 22:18:06+07:00
logdcb12a7941371cee3b62cc3215d89c1f96577372
treea559c12bda0e647adb623de4c628f2c8cd560bff
parent1467590e402b5b198ce7c81540263a8e08329e3c

stage2: sparcv9: Use regular structs to encode instructions

Currently packed structs still has endian-dependent behavior, so it results in code that is not portable across platforms (see also issue 10113).

3 files changed, 60 insertions(+), 54 deletions(-)

src/arch/sparcv9/Emit.zig+1-1
...@@ -290,7 +290,7 @@ fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {...@@ -290,7 +290,7 @@ fn fail(emit: *Emit, comptime format: []const u8, args: anytype) InnerError {
290290
291fn writeInstruction(emit: *Emit, instruction: Instruction) !void {291fn writeInstruction(emit: *Emit, instruction: Instruction) !void {
292 // SPARCv9 instructions are always arranged in BE regardless of the292 // SPARCv9 instructions are always arranged in BE regardless of the
293 // endianness mode the CPU is running in.293 // endianness mode the CPU is running in (Section 3.1 of the ISA specification).
294 // This is to ease porting in case someone wants to do a LE SPARCv9 backend.294 // This is to ease porting in case someone wants to do a LE SPARCv9 backend.
295 const endian = Endian.Big;295 const endian = Endian.Big;
296296
src/arch/sparcv9/Mir.zig+1-1
...@@ -62,7 +62,7 @@ pub const Inst = struct {...@@ -62,7 +62,7 @@ pub const Inst = struct {
6262
63 /// A.27 Load Integer63 /// A.27 Load Integer
64 /// Those uses the arithmetic_3op field.64 /// Those uses the arithmetic_3op field.
65 /// Note that the ldd variant of this instruction is deprecated, do not emit65 /// Note that the ldd variant of this instruction is deprecated, so do not emit
66 /// it unless specifically requested (e.g. by inline assembly).66 /// it unless specifically requested (e.g. by inline assembly).
67 // TODO add other operations.67 // TODO add other operations.
68 ldub,68 ldub,
src/arch/sparcv9/bits.zig+58-52
...@@ -164,27 +164,33 @@ pub const Instruction = union(enum) {...@@ -164,27 +164,33 @@ pub const Instruction = union(enum) {
164 // name them with letters since there's no official naming scheme.164 // name them with letters since there's no official naming scheme.
165 // TODO: need to rename the minor formats to a more descriptive name.165 // TODO: need to rename the minor formats to a more descriptive name.
166166
167 // I am using regular structs instead of packed ones to avoid
168 // endianness-dependent behavior when constructing the actual
169 // assembly instructions.
170 // See also: https://github.com/ziglang/zig/issues/10113
171 // TODO: change it back to packed structs once the issue is resolved.
172
167 // Format 1 (op = 1): CALL173 // Format 1 (op = 1): CALL
168 format_1: packed struct {174 format_1: struct {
169 op: u2 = 0b01,175 op: u2 = 0b01,
170 disp30: u30,176 disp30: u30,
171 },177 },
172178
173 // Format 2 (op = 0): SETHI & Branches (Bicc, BPcc, BPr, FBfcc, FBPfcc)179 // Format 2 (op = 0): SETHI & Branches (Bicc, BPcc, BPr, FBfcc, FBPfcc)
174 format_2a: packed struct {180 format_2a: struct {
175 op: u2 = 0b00,181 op: u2 = 0b00,
176 rd: u5,182 rd: u5,
177 op2: u3,183 op2: u3,
178 imm22: u22,184 imm22: u22,
179 },185 },
180 format_2b: packed struct {186 format_2b: struct {
181 op: u2 = 0b00,187 op: u2 = 0b00,
182 a: u1,188 a: u1,
183 cond: u4,189 cond: u4,
184 op2: u3,190 op2: u3,
185 disp22: u22,191 disp22: u22,
186 },192 },
187 format_2c: packed struct {193 format_2c: struct {
188 op: u2 = 0b00,194 op: u2 = 0b00,
189 a: u1,195 a: u1,
190 cond: u4,196 cond: u4,
...@@ -194,7 +200,7 @@ pub const Instruction = union(enum) {...@@ -194,7 +200,7 @@ pub const Instruction = union(enum) {
194 p: u1,200 p: u1,
195 disp19: u19,201 disp19: u19,
196 },202 },
197 format_2d: packed struct {203 format_2d: struct {
198 op: u2 = 0b00,204 op: u2 = 0b00,
199 a: u1,205 a: u1,
200 fixed: u1 = 0b0,206 fixed: u1 = 0b0,
...@@ -207,7 +213,7 @@ pub const Instruction = union(enum) {...@@ -207,7 +213,7 @@ pub const Instruction = union(enum) {
207 },213 },
208214
209 // Format 3 (op = 2 or 3): Arithmetic, Logical, MOVr, MEMBAR, Load, and Store215 // Format 3 (op = 2 or 3): Arithmetic, Logical, MOVr, MEMBAR, Load, and Store
210 format_3a: packed struct {216 format_3a: struct {
211 op: u2,217 op: u2,
212 rd: u5,218 rd: u5,
213 op3: u6,219 op3: u6,
...@@ -224,7 +230,7 @@ pub const Instruction = union(enum) {...@@ -224,7 +230,7 @@ pub const Instruction = union(enum) {
224 i: u1 = 0b1,230 i: u1 = 0b1,
225 simm13: u13,231 simm13: u13,
226 },232 },
227 format_3c: packed struct {233 format_3c: struct {
228 op: u2,234 op: u2,
229 reserved1: u5 = 0b00000,235 reserved1: u5 = 0b00000,
230 op3: u6,236 op3: u6,
...@@ -241,7 +247,7 @@ pub const Instruction = union(enum) {...@@ -241,7 +247,7 @@ pub const Instruction = union(enum) {
241 i: u1 = 0b1,247 i: u1 = 0b1,
242 simm13: u13,248 simm13: u13,
243 },249 },
244 format_3e: packed struct {250 format_3e: struct {
245 op: u2,251 op: u2,
246 rd: u5,252 rd: u5,
247 op3: u6,253 op3: u6,
...@@ -260,7 +266,7 @@ pub const Instruction = union(enum) {...@@ -260,7 +266,7 @@ pub const Instruction = union(enum) {
260 rcond: u3,266 rcond: u3,
261 simm10: u10,267 simm10: u10,
262 },268 },
263 format_3g: packed struct {269 format_3g: struct {
264 op: u2,270 op: u2,
265 rd: u5,271 rd: u5,
266 op3: u6,272 op3: u6,
...@@ -269,7 +275,7 @@ pub const Instruction = union(enum) {...@@ -269,7 +275,7 @@ pub const Instruction = union(enum) {
269 reserved: u8 = 0b00000000,275 reserved: u8 = 0b00000000,
270 rs2: u5,276 rs2: u5,
271 },277 },
272 format_3h: packed struct {278 format_3h: struct {
273 op: u2 = 0b10,279 op: u2 = 0b10,
274 fixed1: u5 = 0b00000,280 fixed1: u5 = 0b00000,
275 op3: u6 = 0b101000,281 op3: u6 = 0b101000,
...@@ -279,7 +285,7 @@ pub const Instruction = union(enum) {...@@ -279,7 +285,7 @@ pub const Instruction = union(enum) {
279 cmask: u3,285 cmask: u3,
280 mmask: u4,286 mmask: u4,
281 },287 },
282 format_3i: packed struct {288 format_3i: struct {
283 op: u2,289 op: u2,
284 rd: u5,290 rd: u5,
285 op3: u6,291 op3: u6,
...@@ -288,13 +294,13 @@ pub const Instruction = union(enum) {...@@ -288,13 +294,13 @@ pub const Instruction = union(enum) {
288 imm_asi: u8,294 imm_asi: u8,
289 rs2: u5,295 rs2: u5,
290 },296 },
291 format_3j: packed struct {297 format_3j: struct {
292 op: u2,298 op: u2,
293 impl_dep1: u5,299 impl_dep1: u5,
294 op3: u6,300 op3: u6,
295 impl_dep2: u19,301 impl_dep2: u19,
296 },302 },
297 format_3k: packed struct {303 format_3k: struct {
298 op: u2,304 op: u2,
299 rd: u5,305 rd: u5,
300 op3: u6,306 op3: u6,
...@@ -304,7 +310,7 @@ pub const Instruction = union(enum) {...@@ -304,7 +310,7 @@ pub const Instruction = union(enum) {
304 reserved: u7 = 0b0000000,310 reserved: u7 = 0b0000000,
305 rs2: u5,311 rs2: u5,
306 },312 },
307 format_3l: packed struct {313 format_3l: struct {
308 op: u2,314 op: u2,
309 rd: u5,315 rd: u5,
310 op3: u6,316 op3: u6,
...@@ -314,7 +320,7 @@ pub const Instruction = union(enum) {...@@ -314,7 +320,7 @@ pub const Instruction = union(enum) {
314 reserved: u7 = 0b0000000,320 reserved: u7 = 0b0000000,
315 shcnt32: u5,321 shcnt32: u5,
316 },322 },
317 format_3m: packed struct {323 format_3m: struct {
318 op: u2,324 op: u2,
319 rd: u5,325 rd: u5,
320 op3: u6,326 op3: u6,
...@@ -324,7 +330,7 @@ pub const Instruction = union(enum) {...@@ -324,7 +330,7 @@ pub const Instruction = union(enum) {
324 reserved: u6 = 0b000000,330 reserved: u6 = 0b000000,
325 shcnt64: u6,331 shcnt64: u6,
326 },332 },
327 format_3n: packed struct {333 format_3n: struct {
328 op: u2,334 op: u2,
329 rd: u5,335 rd: u5,
330 op3: u6,336 op3: u6,
...@@ -332,7 +338,7 @@ pub const Instruction = union(enum) {...@@ -332,7 +338,7 @@ pub const Instruction = union(enum) {
332 opf: u9,338 opf: u9,
333 rs2: u5,339 rs2: u5,
334 },340 },
335 format_3o: packed struct {341 format_3o: struct {
336 op: u2,342 op: u2,
337 fixed: u3 = 0b000,343 fixed: u3 = 0b000,
338 cc1: u1,344 cc1: u1,
...@@ -342,7 +348,7 @@ pub const Instruction = union(enum) {...@@ -342,7 +348,7 @@ pub const Instruction = union(enum) {
342 opf: u9,348 opf: u9,
343 rs2: u5,349 rs2: u5,
344 },350 },
345 format_3p: packed struct {351 format_3p: struct {
346 op: u2,352 op: u2,
347 rd: u5,353 rd: u5,
348 op3: u6,354 op3: u6,
...@@ -350,20 +356,20 @@ pub const Instruction = union(enum) {...@@ -350,20 +356,20 @@ pub const Instruction = union(enum) {
350 opf: u9,356 opf: u9,
351 rs2: u5,357 rs2: u5,
352 },358 },
353 format_3q: packed struct {359 format_3q: struct {
354 op: u2,360 op: u2,
355 rd: u5,361 rd: u5,
356 op3: u6,362 op3: u6,
357 rs1: u5,363 rs1: u5,
358 reserved: u14 = 0b00000000000000,364 reserved: u14 = 0b00000000000000,
359 },365 },
360 format_3r: packed struct {366 format_3r: struct {
361 op: u2,367 op: u2,
362 fcn: u5,368 fcn: u5,
363 op3: u6,369 op3: u6,
364 reserved: u19 = 0b0000000000000000000,370 reserved: u19 = 0b0000000000000000000,
365 },371 },
366 format_3s: packed struct {372 format_3s: struct {
367 op: u2,373 op: u2,
368 rd: u5,374 rd: u5,
369 op3: u6,375 op3: u6,
...@@ -371,7 +377,7 @@ pub const Instruction = union(enum) {...@@ -371,7 +377,7 @@ pub const Instruction = union(enum) {
371 },377 },
372378
373 //Format 4 (op = 2): MOVcc, FMOVr, FMOVcc, and Tcc379 //Format 4 (op = 2): MOVcc, FMOVr, FMOVcc, and Tcc
374 format_4a: packed struct {380 format_4a: struct {
375 op: u2 = 0b10,381 op: u2 = 0b10,
376 rd: u5,382 rd: u5,
377 op3: u6,383 op3: u6,
...@@ -392,7 +398,7 @@ pub const Instruction = union(enum) {...@@ -392,7 +398,7 @@ pub const Instruction = union(enum) {
392 cc0: u1,398 cc0: u1,
393 simm11: u11,399 simm11: u11,
394 },400 },
395 format_4c: packed struct {401 format_4c: struct {
396 op: u2 = 0b10,402 op: u2 = 0b10,
397 rd: u5,403 rd: u5,
398 op3: u6,404 op3: u6,
...@@ -415,7 +421,7 @@ pub const Instruction = union(enum) {...@@ -415,7 +421,7 @@ pub const Instruction = union(enum) {
415 cc0: u1,421 cc0: u1,
416 simm11: u11,422 simm11: u11,
417 },423 },
418 format_4e: packed struct {424 format_4e: struct {
419 op: u2 = 0b10,425 op: u2 = 0b10,
420 rd: u5,426 rd: u5,
421 op3: u6,427 op3: u6,
...@@ -426,7 +432,7 @@ pub const Instruction = union(enum) {...@@ -426,7 +432,7 @@ pub const Instruction = union(enum) {
426 reserved: u4 = 0b0000,432 reserved: u4 = 0b0000,
427 sw_trap: u7,433 sw_trap: u7,
428 },434 },
429 format_4f: packed struct {435 format_4f: struct {
430 op: u2 = 0b10,436 op: u2 = 0b10,
431 rd: u5,437 rd: u5,
432 op3: u6,438 op3: u6,
...@@ -436,7 +442,7 @@ pub const Instruction = union(enum) {...@@ -436,7 +442,7 @@ pub const Instruction = union(enum) {
436 opf_low: u5,442 opf_low: u5,
437 rs2: u5,443 rs2: u5,
438 },444 },
439 format_4g: packed struct {445 format_4g: struct {
440 op: u2 = 0b10,446 op: u2 = 0b10,
441 rd: u5,447 rd: u5,
442 op3: u6,448 op3: u6,
...@@ -512,37 +518,37 @@ pub const Instruction = union(enum) {...@@ -512,37 +518,37 @@ pub const Instruction = union(enum) {
512 pub fn toU32(self: Instruction) u32 {518 pub fn toU32(self: Instruction) u32 {
513 // TODO: Remove this once packed structs work.519 // TODO: Remove this once packed structs work.
514 return switch (self) {520 return switch (self) {
515 .format_1 => |v| @bitCast(u32, v),521 .format_1 => |v| (@as(u32, v.op) << 30) | @as(u32, v.disp30),
516 .format_2a => |v| @bitCast(u32, v),522 .format_2a => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op2) << 22) | @as(u32, v.imm22),
517 .format_2b => |v| @bitCast(u32, v),523 .format_2b => |v| (@as(u32, v.op) << 30) | (@as(u32, v.a) << 29) | (@as(u32, v.cond) << 25) | (@as(u32, v.op2) << 22) | @as(u32, v.disp22),
518 .format_2c => |v| @bitCast(u32, v),524 .format_2c => |v| (@as(u32, v.op) << 30) | (@as(u32, v.a) << 29) | (@as(u32, v.cond) << 25) | (@as(u32, v.op2) << 22) | (@as(u32, v.cc1) << 21) | (@as(u32, v.cc0) << 20) | (@as(u32, v.p) << 19) | @as(u32, v.disp19),
519 .format_2d => |v| @bitCast(u32, v),525 .format_2d => |v| (@as(u32, v.op) << 30) | (@as(u32, v.a) << 29) | (@as(u32, v.fixed) << 28) | (@as(u32, v.rcond) << 25) | (@as(u32, v.op2) << 22) | (@as(u32, v.d16hi) << 20) | (@as(u32, v.p) << 19) | (@as(u32, v.rs1) << 14) | @as(u32, v.d16lo),
520 .format_3a => |v| @bitCast(u32, v),526 .format_3a => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.reserved) << 5) | @as(u32, v.rs2),
521 .format_3b => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | @as(u32, v.simm13),527 .format_3b => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | @as(u32, v.simm13),
522 .format_3c => |v| @bitCast(u32, v),528 .format_3c => |v| (@as(u32, v.op) << 30) | (@as(u32, v.reserved1) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.reserved2) << 5) | @as(u32, v.rs2),
523 .format_3d => |v| (@as(u32, v.op) << 30) | (@as(u32, v.reserved) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | @as(u32, v.simm13),529 .format_3d => |v| (@as(u32, v.op) << 30) | (@as(u32, v.reserved) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | @as(u32, v.simm13),
524 .format_3e => |v| @bitCast(u32, v),530 .format_3e => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.rcond) << 10) | (@as(u32, v.reserved) << 5) | @as(u32, v.rs2),
525 .format_3f => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.rcond) << 10) | @as(u32, v.simm10),531 .format_3f => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.rcond) << 10) | @as(u32, v.simm10),
526 .format_3g => |v| @bitCast(u32, v),532 .format_3g => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.reserved) << 5) | @as(u32, v.rs2),
527 .format_3h => |v| @bitCast(u32, v),533 .format_3h => |v| (@as(u32, v.op) << 30) | (@as(u32, v.fixed1) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.fixed2) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.reserved) << 7) | (@as(u32, v.cmask) << 4) | @as(u32, v.mmask),
528 .format_3i => |v| @bitCast(u32, v),534 .format_3i => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.imm_asi) << 5) | @as(u32, v.rs2),
529 .format_3j => |v| @bitCast(u32, v),535 .format_3j => |v| (@as(u32, v.op) << 30) | (@as(u32, v.impl_dep1) << 25) | (@as(u32, v.op3) << 19) | @as(u32, v.impl_dep2),
530 .format_3k => |v| @bitCast(u32, v),536 .format_3k => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.x) << 12) | (@as(u32, v.reserved) << 5) | @as(u32, v.rs2),
531 .format_3l => |v| @bitCast(u32, v),537 .format_3l => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.x) << 12) | (@as(u32, v.reserved) << 5) | @as(u32, v.shcnt32),
532 .format_3m => |v| @bitCast(u32, v),538 .format_3m => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.x) << 12) | (@as(u32, v.reserved) << 6) | @as(u32, v.shcnt64),
533 .format_3n => |v| @bitCast(u32, v),539 .format_3n => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.reserved) << 14) | (@as(u32, v.opf) << 5) | @as(u32, v.rs2),
534 .format_3o => |v| @bitCast(u32, v),540 .format_3o => |v| (@as(u32, v.op) << 30) | (@as(u32, v.fixed) << 27) | (@as(u32, v.cc1) << 26) | (@as(u32, v.cc0) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.opf) << 5) | @as(u32, v.rs2),
535 .format_3p => |v| @bitCast(u32, v),541 .format_3p => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.opf) << 5) | @as(u32, v.rs2),
536 .format_3q => |v| @bitCast(u32, v),542 .format_3q => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | @as(u32, v.reserved),
537 .format_3r => |v| @bitCast(u32, v),543 .format_3r => |v| (@as(u32, v.op) << 30) | (@as(u32, v.fcn) << 25) | (@as(u32, v.op3) << 19) | @as(u32, v.reserved),
538 .format_3s => |v| @bitCast(u32, v),544 .format_3s => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | @as(u32, v.reserved),
539 .format_4a => |v| @bitCast(u32, v),545 .format_4a => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.cc1) << 12) | (@as(u32, v.cc0) << 11) | (@as(u32, v.reserved) << 5) | @as(u32, v.rs2),
540 .format_4b => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.cc1) << 12) | (@as(u32, v.cc0) << 11) | @as(u32, v.simm11),546 .format_4b => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.cc1) << 12) | (@as(u32, v.cc0) << 11) | @as(u32, v.simm11),
541 .format_4c => |v| @bitCast(u32, v),547 .format_4c => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.cc2) << 18) | (@as(u32, v.cond) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.cc1) << 12) | (@as(u32, v.cc0) << 11) | (@as(u32, v.reserved) << 5) | @as(u32, v.rs2),
542 .format_4d => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.cc2) << 18) | (@as(u32, v.cond) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.cc1) << 12) | (@as(u32, v.cc0) << 11) | @as(u32, v.simm11),548 .format_4d => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.cc2) << 18) | (@as(u32, v.cond) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.cc1) << 12) | (@as(u32, v.cc0) << 11) | @as(u32, v.simm11),
543 .format_4e => |v| @bitCast(u32, v),549 .format_4e => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.i) << 13) | (@as(u32, v.cc1) << 12) | (@as(u32, v.cc0) << 11) | (@as(u32, v.reserved) << 7) | @as(u32, v.sw_trap),
544 .format_4f => |v| @bitCast(u32, v),550 .format_4f => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.rs1) << 14) | (@as(u32, v.fixed) << 13) | (@as(u32, v.rcond) << 10) | (@as(u32, v.opf_low) << 5) | @as(u32, v.rs2),
545 .format_4g => |v| @bitCast(u32, v),551 .format_4g => |v| (@as(u32, v.op) << 30) | (@as(u32, v.rd) << 25) | (@as(u32, v.op3) << 19) | (@as(u32, v.fixed) << 18) | (@as(u32, v.cond) << 14) | (@as(u32, v.opf_cc) << 11) | (@as(u32, v.opf_low) << 5) | @as(u32, v.rs2),
546 };552 };
547 }553 }
548554