added call site value opcode to RDI format

This commit is contained in:
Nikita Smith
2025-03-26 12:19:16 -07:00
parent 8551e8c3ec
commit d137d928c9
4 changed files with 70 additions and 56 deletions
+2 -1
View File
@@ -92,7 +92,7 @@ RDI_U8 rdi_section_is_required_table[37] =
0, 0,
}; };
RDI_U16 rdi_eval_op_ctrlbits_table[49] = RDI_U16 rdi_eval_op_ctrlbits_table[50] =
{ {
RDI_EVAL_CTRLBITS(0, 0, 0), RDI_EVAL_CTRLBITS(0, 0, 0),
RDI_EVAL_CTRLBITS(0, 0, 0), RDI_EVAL_CTRLBITS(0, 0, 0),
@@ -142,6 +142,7 @@ RDI_EVAL_CTRLBITS(0, 1, 0),
RDI_EVAL_CTRLBITS(1, 0, 0), RDI_EVAL_CTRLBITS(1, 0, 0),
RDI_EVAL_CTRLBITS(1, 2, 1), RDI_EVAL_CTRLBITS(1, 2, 1),
RDI_EVAL_CTRLBITS(1, 1, 1), RDI_EVAL_CTRLBITS(1, 1, 1),
RDI_EVAL_CTRLBITS(4, 0, 0),
RDI_EVAL_CTRLBITS(0, 0, 0), RDI_EVAL_CTRLBITS(0, 0, 0),
}; };
+4 -2
View File
@@ -488,7 +488,8 @@ RDI_EvalOp_Pop = 44,
RDI_EvalOp_Insert = 45, RDI_EvalOp_Insert = 45,
RDI_EvalOp_ValueRead = 46, RDI_EvalOp_ValueRead = 46,
RDI_EvalOp_ByteSwap = 47, RDI_EvalOp_ByteSwap = 47,
RDI_EvalOp_COUNT = 48, RDI_EvalOp_CallSiteValue = 48,
RDI_EvalOp_COUNT = 49,
} RDI_EvalOpEnum; } RDI_EvalOpEnum;
typedef RDI_U8 RDI_EvalTypeGroup; typedef RDI_U8 RDI_EvalTypeGroup;
@@ -1066,6 +1067,7 @@ X(Pop)\
X(Insert)\ X(Insert)\
X(ValueRead)\ X(ValueRead)\
X(ByteSwap)\ X(ByteSwap)\
X(CallSiteValue)\
#define RDI_EvalTypeGroup_XList \ #define RDI_EvalTypeGroup_XList \
X(Other)\ X(Other)\
@@ -1537,6 +1539,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_U16 rdi_eval_op_ctrlbits_table[49]; extern RDI_U16 rdi_eval_op_ctrlbits_table[50];
#endif // RDI_FORMAT_H #endif // RDI_FORMAT_H
+14 -4
View File
@@ -166,9 +166,10 @@ d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input
internal RDIM_EvalBytecode internal RDIM_EvalBytecode
d2r_bytecode_from_expression(Arena *arena, U64 image_base, U64 address_size, RDI_Arch arch, DW_ListUnit *addr_lu, String8 expr) d2r_bytecode_from_expression(Arena *arena, U64 image_base, U64 address_size, RDI_Arch arch, DW_ListUnit *addr_lu, String8 expr, B32 *is_addr_out)
{ {
RDIM_EvalBytecode bc = {0}; RDIM_EvalBytecode bc = {0};
*is_addr_out = 1;
for (U64 cursor = 0; cursor < expr.size; ) { for (U64 cursor = 0; cursor < expr.size; ) {
U8 op = 0; U8 op = 0;
@@ -415,7 +416,13 @@ d2r_bytecode_from_expression(Arena *arena, U64 image_base, U64 address_size, RDI
String8 entry_value_expr = {0}; String8 entry_value_expr = {0};
cursor += str8_deserial_read_block(expr, cursor, block_size, &entry_value_expr); cursor += str8_deserial_read_block(expr, cursor, block_size, &entry_value_expr);
RDIM_EvalBytecode entry_value_bc = d2r_bytecode_from_expression(arena, image_base, address_size, arch, addr_lu, entry_value_expr); B32 dummy = 0;
RDIM_EvalBytecode call_site_bc = d2r_bytecode_from_expression(arena, image_base, address_size, arch, addr_lu, entry_value_expr, &dummy);
U32 encoded_size32 = safe_cast_u32(call_site_bc.encoded_size);
rdim_bytecode_push_op(arena, &bc, RDI_EvalOp_CallSiteValue, encoded_size32);
rdim_bytecode_concat_in_place(&bc, &call_site_bc);
} break; } break;
case DW_ExprOp_Addrx: { case DW_ExprOp_Addrx: {
@@ -575,9 +582,12 @@ d2r_transpile_expression(Arena *arena, U64 image_base, U64 address_size, RDI_Arc
{ {
RDIM_Location *loc = 0; RDIM_Location *loc = 0;
if (expr.size) { if (expr.size) {
B32 is_addr = 0;
RDIM_EvalBytecode bytecode = d2r_bytecode_from_expression(arena, image_base, address_size, arch, addr_lu, expr, &is_addr);
loc = push_array(arena, RDIM_Location, 1); loc = push_array(arena, RDIM_Location, 1);
loc->kind = RDI_LocationKind_AddrBytecodeStream; loc->kind = is_addr ? RDI_LocationKind_AddrBytecodeStream : RDI_LocationKind_ValBytecodeStream;
loc->bytecode = d2r_bytecode_from_expression(arena, image_base, address_size, arch, addr_lu, expr); loc->bytecode = bytecode;
} }
return loc; return loc;
} }
+2 -1
View File
@@ -1293,7 +1293,8 @@ RDI_EvalOpTable:
{Insert 45 1 0 0} {Insert 45 1 0 0}
{ValueRead 46 1 2 1} {ValueRead 46 1 2 1}
{ByteSwap 47 1 1 1} {ByteSwap 47 1 1 1}
{COUNT 48 0 0 0} {CallSiteValue 48 4 0 0}
{COUNT 49 0 0 0}
} }
// NOTE(rjf): "ck" -> "conversion kind, when converted to type group", used in square matrix form // NOTE(rjf): "ck" -> "conversion kind, when converted to type group", used in square matrix form