From ced500fc94ad7b4adfd797d916a43a179609b7a2 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 14 Jun 2026 21:52:14 +0100 Subject: [PATCH] Add fmt formatting to the `Instruction.operands` --- core/rexcode/arm32/instructions.odin | 14 +++++++------- core/rexcode/arm64/instructions.odin | 12 ++++++------ core/rexcode/mips/instructions.odin | 12 ++++++------ core/rexcode/mos6502/instructions.odin | 12 ++++++------ core/rexcode/mos65816/instructions.odin | 12 ++++++------ core/rexcode/ppc/instructions.odin | 14 +++++++------- core/rexcode/ppc_vle/instructions.odin | 2 +- core/rexcode/riscv/instructions.odin | 12 ++++++------ core/rexcode/rsp/instructions.odin | 12 ++++++------ core/rexcode/x86/instructions.odin | 12 ++++++------ 10 files changed, 57 insertions(+), 57 deletions(-) diff --git a/core/rexcode/arm32/instructions.odin b/core/rexcode/arm32/instructions.odin index 419dbc05f..c4972bbe8 100644 --- a/core/rexcode/arm32/instructions.odin +++ b/core/rexcode/arm32/instructions.odin @@ -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 diff --git a/core/rexcode/arm64/instructions.odin b/core/rexcode/arm64/instructions.odin index 311af7109..811be0bb4 100644 --- a/core/rexcode/arm64/instructions.odin +++ b/core/rexcode/arm64/instructions.odin @@ -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 } // ============================================================================= diff --git a/core/rexcode/mips/instructions.odin b/core/rexcode/mips/instructions.odin index f0decf091..f6672f610 100644 --- a/core/rexcode/mips/instructions.odin +++ b/core/rexcode/mips/instructions.odin @@ -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) diff --git a/core/rexcode/mos6502/instructions.odin b/core/rexcode/mos6502/instructions.odin index 95e9cc573..916b82179 100644 --- a/core/rexcode/mos6502/instructions.odin +++ b/core/rexcode/mos6502/instructions.odin @@ -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) diff --git a/core/rexcode/mos65816/instructions.odin b/core/rexcode/mos65816/instructions.odin index 7d80b8db3..320d71cf6 100644 --- a/core/rexcode/mos65816/instructions.odin +++ b/core/rexcode/mos65816/instructions.odin @@ -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) diff --git a/core/rexcode/ppc/instructions.odin b/core/rexcode/ppc/instructions.odin index 8b619106e..ca7853f9c 100644 --- a/core/rexcode/ppc/instructions.odin +++ b/core/rexcode/ppc/instructions.odin @@ -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) diff --git a/core/rexcode/ppc_vle/instructions.odin b/core/rexcode/ppc_vle/instructions.odin index 59e0d60c4..056e73a0a 100644 --- a/core/rexcode/ppc_vle/instructions.odin +++ b/core/rexcode/ppc_vle/instructions.odin @@ -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, diff --git a/core/rexcode/riscv/instructions.odin b/core/rexcode/riscv/instructions.odin index fa11a66ef..509f7294e 100644 --- a/core/rexcode/riscv/instructions.odin +++ b/core/rexcode/riscv/instructions.odin @@ -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) diff --git a/core/rexcode/rsp/instructions.odin b/core/rexcode/rsp/instructions.odin index 3724a037a..858789ad2 100644 --- a/core/rexcode/rsp/instructions.odin +++ b/core/rexcode/rsp/instructions.odin @@ -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) diff --git a/core/rexcode/x86/instructions.odin b/core/rexcode/x86/instructions.odin index 9ab3d0c08..f85b443fa 100644 --- a/core/rexcode/x86/instructions.odin +++ b/core/rexcode/x86/instructions.odin @@ -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)