mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 13:58:40 +00:00
fix set-space ir extension instruction; expand ctrlbits to u16, so that it can encode modern register sized decodes
This commit is contained in:
@@ -67,14 +67,14 @@ e_interpret(String8 bytecode)
|
|||||||
{
|
{
|
||||||
// rjf: consume next opcode
|
// rjf: consume next opcode
|
||||||
RDI_EvalOp op = (RDI_EvalOp)*ptr;
|
RDI_EvalOp op = (RDI_EvalOp)*ptr;
|
||||||
U8 ctrlbits = 0;
|
U16 ctrlbits = 0;
|
||||||
if(op < RDI_EvalOp_COUNT)
|
if(op < RDI_EvalOp_COUNT)
|
||||||
{
|
{
|
||||||
ctrlbits = rdi_eval_op_ctrlbits_table[op];
|
ctrlbits = rdi_eval_op_ctrlbits_table[op];
|
||||||
}
|
}
|
||||||
else switch(op)
|
else switch(op)
|
||||||
{
|
{
|
||||||
case E_IRExtKind_SetSpace:{ctrlbits = RDI_EVAL_CTRLBITS(16, 0, 0);}break;
|
case E_IRExtKind_SetSpace:{ctrlbits = RDI_EVAL_CTRLBITS(32, 0, 0);}break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
result.code = E_InterpretationCode_BadOp;
|
result.code = E_InterpretationCode_BadOp;
|
||||||
|
|||||||
+4
-4
@@ -78,7 +78,7 @@ e_select_ir_ctx(E_IRCtx *ctx)
|
|||||||
internal void
|
internal void
|
||||||
e_oplist_push_op(Arena *arena, E_OpList *list, RDI_EvalOp opcode, E_Value value)
|
e_oplist_push_op(Arena *arena, E_OpList *list, RDI_EvalOp opcode, E_Value value)
|
||||||
{
|
{
|
||||||
U8 ctrlbits = rdi_eval_op_ctrlbits_table[opcode];
|
U16 ctrlbits = rdi_eval_op_ctrlbits_table[opcode];
|
||||||
U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||||
E_Op *node = push_array_no_zero(arena, E_Op, 1);
|
E_Op *node = push_array_no_zero(arena, E_Op, 1);
|
||||||
node->opcode = opcode;
|
node->opcode = opcode;
|
||||||
@@ -149,7 +149,7 @@ internal void
|
|||||||
e_oplist_push_string_literal(Arena *arena, E_OpList *list, String8 string)
|
e_oplist_push_string_literal(Arena *arena, E_OpList *list, String8 string)
|
||||||
{
|
{
|
||||||
RDI_EvalOp opcode = RDI_EvalOp_ConstString;
|
RDI_EvalOp opcode = RDI_EvalOp_ConstString;
|
||||||
U8 ctrlbits = rdi_eval_op_ctrlbits_table[opcode];
|
U16 ctrlbits = rdi_eval_op_ctrlbits_table[opcode];
|
||||||
U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||||
E_Op *node = push_array_no_zero(arena, E_Op, 1);
|
E_Op *node = push_array_no_zero(arena, E_Op, 1);
|
||||||
node->opcode = opcode;
|
node->opcode = opcode;
|
||||||
@@ -1383,7 +1383,7 @@ e_append_oplist_from_irtree(Arena *arena, E_IRNode *root, E_OpList *out)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// rjf: append ops for all children
|
// rjf: append ops for all children
|
||||||
U8 ctrlbits = rdi_eval_op_ctrlbits_table[op];
|
U16 ctrlbits = rdi_eval_op_ctrlbits_table[op];
|
||||||
U64 child_count = RDI_POPN_FROM_CTRLBITS(ctrlbits);
|
U64 child_count = RDI_POPN_FROM_CTRLBITS(ctrlbits);
|
||||||
U64 idx = 0;
|
U64 idx = 0;
|
||||||
for(E_IRNode *child = root->first;
|
for(E_IRNode *child = root->first;
|
||||||
@@ -1428,7 +1428,7 @@ e_bytecode_from_oplist(Arena *arena, E_OpList *oplist)
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// rjf: compute bytecode advance
|
// rjf: compute bytecode advance
|
||||||
U8 ctrlbits = rdi_eval_op_ctrlbits_table[opcode];
|
U16 ctrlbits = rdi_eval_op_ctrlbits_table[opcode];
|
||||||
U64 extra_byte_count = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
U64 extra_byte_count = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||||
U8 *next_ptr = ptr + 1 + extra_byte_count;
|
U8 *next_ptr = ptr + 1 + extra_byte_count;
|
||||||
Assert(next_ptr <= opl);
|
Assert(next_ptr <= opl);
|
||||||
|
|||||||
@@ -1385,7 +1385,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
U8 ctrlbits = rdi_eval_op_ctrlbits_table[op];
|
U16 ctrlbits = rdi_eval_op_ctrlbits_table[op];
|
||||||
U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||||
bytecode_size += 1+p_size;
|
bytecode_size += 1+p_size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ RDI_U8 rdi_section_is_required_table[37] =
|
|||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
|
||||||
RDI_U8 rdi_eval_op_ctrlbits_table[49] =
|
RDI_U16 rdi_eval_op_ctrlbits_table[49] =
|
||||||
{
|
{
|
||||||
RDI_EVAL_CTRLBITS(0, 0, 0),
|
RDI_EVAL_CTRLBITS(0, 0, 0),
|
||||||
RDI_EVAL_CTRLBITS(0, 0, 0),
|
RDI_EVAL_CTRLBITS(0, 0, 0),
|
||||||
|
|||||||
@@ -997,10 +997,10 @@ typedef RDI_U32_Table RDI_U32_NameMapBuckets;
|
|||||||
typedef RDI_U32_Table RDI_U32_NameMapNodes;
|
typedef RDI_U32_Table RDI_U32_NameMapNodes;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) ((decodeN) | ((popN) << 5) | ((pushN) << 7))
|
#define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) (((decodeN) << 8) | ((popN) << 4) | ((pushN) << 0))
|
||||||
#define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) ((ctrlbits) & 0x1f)
|
#define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 8) & 0xff)
|
||||||
#define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 5) & 0x3)
|
#define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 4) & 0xf)
|
||||||
#define RDI_PUSHN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 7) & 0x1)
|
#define RDI_PUSHN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 0) & 0xf)
|
||||||
#define RDI_EncodeRegReadParam(reg,bytesize,bytepos) ((reg)|((bytesize)<<8)|((bytepos)<<16))
|
#define RDI_EncodeRegReadParam(reg,bytesize,bytepos) ((reg)|((bytesize)<<8)|((bytepos)<<16))
|
||||||
|
|
||||||
typedef struct RDI_Header RDI_Header;
|
typedef struct RDI_Header RDI_Header;
|
||||||
@@ -1361,6 +1361,6 @@ RDI_PROC RDI_U8 *rdi_explanation_string_from_eval_conversion_kind(RDI_EvalConver
|
|||||||
|
|
||||||
extern RDI_U16 rdi_section_element_size_table[37];
|
extern RDI_U16 rdi_section_element_size_table[37];
|
||||||
extern RDI_U8 rdi_section_is_required_table[37];
|
extern RDI_U8 rdi_section_is_required_table[37];
|
||||||
extern RDI_U8 rdi_eval_op_ctrlbits_table[49];
|
extern RDI_U16 rdi_eval_op_ctrlbits_table[49];
|
||||||
|
|
||||||
#endif // RDI_FORMAT_H
|
#endif // RDI_FORMAT_H
|
||||||
|
|||||||
@@ -970,7 +970,7 @@ rdim_scope_push_local(RDIM_Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope
|
|||||||
RDI_PROC void
|
RDI_PROC void
|
||||||
rdim_bytecode_push_op(RDIM_Arena *arena, RDIM_EvalBytecode *bytecode, RDI_EvalOp op, RDI_U64 p)
|
rdim_bytecode_push_op(RDIM_Arena *arena, RDIM_EvalBytecode *bytecode, RDI_EvalOp op, RDI_U64 p)
|
||||||
{
|
{
|
||||||
RDI_U8 ctrlbits = rdi_eval_op_ctrlbits_table[op];
|
RDI_U16 ctrlbits = rdi_eval_op_ctrlbits_table[op];
|
||||||
RDI_U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
RDI_U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||||
|
|
||||||
RDIM_EvalBytecodeOp *node = rdim_push_array(arena, RDIM_EvalBytecodeOp, 1);
|
RDIM_EvalBytecodeOp *node = rdim_push_array(arena, RDIM_EvalBytecodeOp, 1);
|
||||||
|
|||||||
@@ -1337,14 +1337,14 @@ RDI_EvalConversionKindTable:
|
|||||||
|
|
||||||
@gen(enums)
|
@gen(enums)
|
||||||
```
|
```
|
||||||
#define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) ((decodeN) | ((popN) << 5) | ((pushN) << 7))
|
#define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) (((decodeN) << 8) | ((popN) << 4) | ((pushN) << 0))
|
||||||
#define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) ((ctrlbits) & 0x1f)
|
#define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 8) & 0xff)
|
||||||
#define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 5) & 0x3)
|
#define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 4) & 0xf)
|
||||||
#define RDI_PUSHN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 7) & 0x1)
|
#define RDI_PUSHN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 0) & 0xf)
|
||||||
#define RDI_EncodeRegReadParam(reg,bytesize,bytepos) ((reg)|((bytesize)<<8)|((bytepos)<<16))
|
#define RDI_EncodeRegReadParam(reg,bytesize,bytepos) ((reg)|((bytesize)<<8)|((bytepos)<<16))
|
||||||
```
|
```
|
||||||
|
|
||||||
@data(RDI_U8) rdi_eval_op_ctrlbits_table:
|
@data(RDI_U16) rdi_eval_op_ctrlbits_table:
|
||||||
{
|
{
|
||||||
@expand(RDI_EvalOpTable a) `RDI_EVAL_CTRLBITS($(a.num_decodes), $(a.num_pops), $(a.num_pushes))`;
|
@expand(RDI_EvalOpTable a) `RDI_EVAL_CTRLBITS($(a.num_decodes), $(a.num_pops), $(a.num_pushes))`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user