eval2: leaf bytecode in ir tree

This commit is contained in:
Ryan Fleury
2026-06-28 07:36:24 -07:00
parent 96cfb441fd
commit 16c447bb79
3 changed files with 19 additions and 5 deletions
+17 -3
View File
@@ -3196,9 +3196,14 @@ e2_bytecode_from_irnode(Arena *arena, E2_IRNode *irnode)
E2_IRNode *ir = t->ir; E2_IRNode *ir = t->ir;
//- rjf: unpack this op //- rjf: unpack this op
U16 ctrlbits = rdi_eval_op_ctrlbits_table[ir->op]; U16 ctrlbits = 0;
U64 child_count = RDI_POPN_FROM_CTRLBITS(ctrlbits); U64 child_count = 0;
if(ir->op == 0) if(0 < ir->op && ir->op < RDI_EvalOp_COUNT)
{
ctrlbits = rdi_eval_op_ctrlbits_table[ir->op];
child_count = RDI_POPN_FROM_CTRLBITS(ctrlbits);
}
else
{ {
child_count = ir->child_count; child_count = ir->child_count;
} }
@@ -3235,6 +3240,15 @@ e2_bytecode_from_irnode(Arena *arena, E2_IRNode *irnode)
{ {
ctrlbits = rdi_eval_op_ctrlbits_table[ir->op]; ctrlbits = rdi_eval_op_ctrlbits_table[ir->op];
} }
else switch(ir->op)
{
default:{}break;
case E2_EvalOp_SetCtxID:
case E2_EvalOp_LeafBytecode:
{
ctrlbits = RDI_EVAL_CTRLBITS(8, 0, 0);
}break;
}
U64 decode_byte_count = RDI_DECODEN_FROM_CTRLBITS(ctrlbits); U64 decode_byte_count = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
U64 op_size = 1 + decode_byte_count; U64 op_size = 1 + decode_byte_count;
U8 *op_buffer = push_array(scratch.arena, U8, op_size); U8 *op_buffer = push_array(scratch.arena, U8, op_size);
+1 -1
View File
@@ -26,7 +26,7 @@ E2_ExprParseKind;
enum enum
{ {
E2_EvalOp_SetCtxID = RDI_EvalOp_COUNT, E2_EvalOp_SetCtxID = RDI_EvalOp_COUNT,
E2_EvalOp_LeafMacroArgument, E2_EvalOp_LeafBytecode,
}; };
//////////////////////////////// ////////////////////////////////
+1 -1
View File
@@ -44,7 +44,6 @@ entry_point(CmdLine *cmdline)
// int & B // int & B
// (1 + (int)&B) // (1 + (int)&B)
s("int32(*)(int32, int32)"), s("int32(*)(int32, int32)"),
#if 0
s("123(1, 2, 3)"), s("123(1, 2, 3)"),
s("int32 (*) [100]"), s("int32 (*) [100]"),
s("(3 * 4) + 2"), s("(3 * 4) + 2"),
@@ -85,6 +84,7 @@ entry_point(CmdLine *cmdline)
s("123 + "), s("123 + "),
s("-123"), s("-123"),
s("sizeof 123"), s("sizeof 123"),
#if 0
// TODO(rjf): these are ambiguous with regular C type expressions with a naive parse: // TODO(rjf): these are ambiguous with regular C type expressions with a naive parse:
// s("float32(111)"), // s("float32(111)"),
// s("float64(111)"), // s("float64(111)"),