Add fmt formatting to the Instruction.operands

This commit is contained in:
gingerBill
2026-06-14 21:52:14 +01:00
parent c8ed0d89ed
commit ced500fc94
10 changed files with 57 additions and 57 deletions

View File

@@ -19,13 +19,13 @@ Instruction_Flags :: bit_field u8 {
}
Instruction :: struct #packed {
ops: [4]Operand, // 4 * 17 = 68
mnemonic: Mnemonic, // 2
cond: u8, // 0..15 (AL=14)
operand_count: u8, // 0..4
flags: Instruction_Flags, // 1
mode: Mode, // 1 (A32 or T32)
length: u8, // 2 or 4 bytes
ops: [4]Operand `fmt:"v,operand_count"`, // 4 * 17 = 68
mnemonic: Mnemonic, // 2
cond: u8, // 0..15 (AL=14)
operand_count: u8, // 0..4
flags: Instruction_Flags, // 1
mode: Mode, // 1 (A32 or T32)
length: u8, // 2 or 4 bytes
// Form-id hint: when non-zero, this is (1 + the index into
// ENCODING_TABLE[mnemonic]) of the form the decoder produced. The encoder
// uses it as a tie-breaker for shape-ambiguous entries (NEON size variants

View File

@@ -9,12 +9,12 @@ Instruction_Flags :: bit_field u8 {
}
Instruction :: struct #packed {
ops: [4]Operand, // 4 * size_of(Operand)
mnemonic: Mnemonic, // 2
operand_count: u8, // 1
flags: Instruction_Flags, // 1
length: u8, // 1 -- always 4
_: [3]u8, // 3
ops: [4]Operand `fmt:"v,operand_count"`, // 4 * size_of(Operand)
mnemonic: Mnemonic, // 2
operand_count: u8, // 1
flags: Instruction_Flags, // 1
length: u8, // 1 -- always 4
_: [3]u8, // 3
}
// =============================================================================

View File

@@ -13,12 +13,12 @@ Instruction_Flags :: bit_field u8 {
}
Instruction :: struct #packed {
ops: [4]Operand, // 64 bytes
mnemonic: Mnemonic, // 2 bytes
operand_count: u8, // 1 byte
flags: Instruction_Flags, // 1 byte
length: u8, // 1 byte — always 4 for now; will be 2 for future μMIPS / MIPS16e
_: [3]u8, // 3 bytes
ops: [4]Operand `fmt:"v,operand_count"`, // 64 bytes
mnemonic: Mnemonic, // 2 bytes
operand_count: u8, // 1 byte
flags: Instruction_Flags, // 1 byte
length: u8, // 1 byte — always 4 for now; will be 2 for future μMIPS / MIPS16e
_: [3]u8, // 3 bytes
}
#assert(size_of(Instruction) == 72)

View File

@@ -12,12 +12,12 @@ Instruction_Flags :: bit_field u8 {
}
Instruction :: struct #packed {
ops: [3]Operand, // 48 bytes
mnemonic: Mnemonic, // 2
operand_count: u8, // 1
flags: Instruction_Flags, // 1
length: u8, // 1 (filled by decoder; 1..7)
_: [3]u8, // 3
ops: [3]Operand `fmt:"v,operand_count"`, // 48 bytes
mnemonic: Mnemonic, // 2
operand_count: u8, // 1
flags: Instruction_Flags, // 1
length: u8, // 1 (filled by decoder; 1..7)
_: [3]u8, // 3
}
#assert(size_of(Instruction) == 56)

View File

@@ -9,12 +9,12 @@ Instruction_Flags :: bit_field u8 {
}
Instruction :: struct #packed {
ops: [2]Operand, // 32 bytes (only MVN/MVP use 2; rest use 0 or 1)
mnemonic: Mnemonic, // 2
operand_count: u8, // 1
flags: Instruction_Flags, // 1
length: u8, // 1
_: [3]u8, // 3
ops: [2]Operand `fmt:"v,operand_count"`, // 32 bytes (only MVN/MVP use 2; rest use 0 or 1)
mnemonic: Mnemonic, // 2
operand_count: u8, // 1
flags: Instruction_Flags, // 1
length: u8, // 1
_: [3]u8, // 3
}
#assert(size_of(Instruction) == 40)

View File

@@ -18,13 +18,13 @@ Instruction_Flags :: bit_field u8 {
}
Instruction :: struct #packed {
ops: [4]Operand, // 4 * 16 = 64
mnemonic: Mnemonic, // 2
operand_count: u8, // 0..4
flags: Instruction_Flags, // 1
mode: Mode, // 1 (PPC32 / PPC64)
length: u8, // 4 or 8 (prefixed)
form_id: u16, // 0 = no hint; otherwise 1 + form index
ops: [4]Operand `fmt:"v,operand_count"`, // 4 * 16 = 64
mnemonic: Mnemonic, // 2
operand_count: u8, // 0..4
flags: Instruction_Flags, // 1
mode: Mode, // 1 (PPC32 / PPC64)
length: u8, // 4 or 8 (prefixed)
form_id: u16, // 0 = no hint; otherwise 1 + form index
}
// 64 + 7 = 71 bytes (packed)

View File

@@ -16,7 +16,7 @@ Instruction_Flags :: bit_field u8 {
}
Instruction :: struct #packed {
ops: [4]Operand,
ops: [4]Operand `fmt:"v,operand_count"`,
mnemonic: Mnemonic,
operand_count: u8,
flags: Instruction_Flags,

View File

@@ -13,12 +13,12 @@ Instruction_Flags :: bit_field u8 {
}
Instruction :: struct #packed {
ops: [4]Operand, // 64 bytes
mnemonic: Mnemonic, // 2
operand_count: u8, // 1
flags: Instruction_Flags, // 1
length: u8, // 1 -- always 4 for non-C
_: [3]u8, // 3
ops: [4]Operand `fmt:"v,operand_count"`, // 64 bytes
mnemonic: Mnemonic, // 2
operand_count: u8, // 1
flags: Instruction_Flags, // 1
length: u8, // 1 -- always 4 for non-C
_: [3]u8, // 3
}
#assert(size_of(Instruction) == 72)

View File

@@ -9,12 +9,12 @@ Instruction_Flags :: bit_field u8 {
}
Instruction :: struct #packed {
ops: [4]Operand, // 64 bytes
mnemonic: Mnemonic, // 2 bytes
operand_count: u8, // 1 byte
flags: Instruction_Flags, // 1 byte
length: u8, // 1 byte (always 4)
_: [3]u8, // 3 bytes
ops: [4]Operand `fmt:"v,operand_count"`, // 64 bytes
mnemonic: Mnemonic, // 2 bytes
operand_count: u8, // 1 byte
flags: Instruction_Flags, // 1 byte
length: u8, // 1 byte (always 4)
_: [3]u8, // 3 bytes
}
#assert(size_of(Instruction) == 72)

View File

@@ -28,12 +28,12 @@ Rep :: enum u8 {
// -----------------------------------------------------------------------------
Instruction :: struct #packed {
ops: [4]Operand, // 64 bytes
mnemonic: Mnemonic, // 2 bytes
operand_count: u8, // 1 byte
flags: Instruction_Flags, // 1 byte
length: u8, // 1 byte (filled by decoder, used for iteration)
_pad: [3]u8, // 3 bytes
ops: [4]Operand `fmt:"v,operand_count`, // 64 bytes
mnemonic: Mnemonic, // 2 bytes
operand_count: u8, // 1 byte
flags: Instruction_Flags, // 1 byte
length: u8, // 1 byte (filled by decoder, used for iteration)
_pad: [3]u8, // 3 bytes
}
#assert(size_of(Instruction) == 72)