From 5e73e881451f29fd9b7e34249b4b119cac3c4a1e Mon Sep 17 00:00:00 2001 From: Ronald Caesar Date: Sat, 17 Jan 2026 04:15:46 -0400 Subject: [PATCH] ir: fix incorrect instruction bitfield size An instruction is suppose to have 17-bit operands but it was actually 18-bit. So I reduce the bitfields by one bit and give the remaining bits to opcode. An opcode is now 13 bits. Signed-off-by: Ronald Caesar --- docs/IR_DESIGN_DOC.md | 4 ++-- src/bal_ir_emitter.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/IR_DESIGN_DOC.md b/docs/IR_DESIGN_DOC.md index 9f2eead..5fda20d 100644 --- a/docs/IR_DESIGN_DOC.md +++ b/docs/IR_DESIGN_DOC.md @@ -53,7 +53,7 @@ uint32_t instruction_count; ## Instruction Encoding ```text -63 53 52 35 34 17 16 00 +63 51 50 34 33 17 16 00 |-----------------| |----------| |----------| |----------| opc src1 src2 src3 ``` @@ -66,7 +66,7 @@ uint32_t instruction_count; <**src1**> 17-bit index for `ssa` arrays. -<**opc**> 11-bit opcode. +<**opc**> 13-bit opcode. ### Operational Information diff --git a/src/bal_ir_emitter.c b/src/bal_ir_emitter.c index 81c1a2c..3a54c85 100644 --- a/src/bal_ir_emitter.c +++ b/src/bal_ir_emitter.c @@ -1,8 +1,8 @@ #include "bal_ir_emitter.h" #include -#define BAL_OPCODE_SHIFT_POSITION 53U -#define BAL_SOURCE1_SHIFT_POSITION 35U +#define BAL_OPCODE_SHIFT_POSITION 51U +#define BAL_SOURCE1_SHIFT_POSITION 34U #define BAL_SOURCE2_SHIFT_POSITION 17U #define BAL_IS_CONSTANT_BIT_POSITION (1U << 16U)