mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-10 03:21:37 -07:00
first pass at filesystem evaluation in eval system
This commit is contained in:
@@ -3799,7 +3799,7 @@ internal B32
|
||||
ctrl_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
|
||||
{
|
||||
B32 result = 0;
|
||||
CTRL_Entity *entity = (CTRL_Entity *)space;
|
||||
CTRL_Entity *entity = (CTRL_Entity *)space.u64[1];
|
||||
{
|
||||
switch(entity->kind)
|
||||
{
|
||||
@@ -4687,7 +4687,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
eval_modules[eval_module_idx].arch = arch;
|
||||
eval_modules[eval_module_idx].rdi = di_rdi_from_key(di_scope, &dbgi_key, max_U64);
|
||||
eval_modules[eval_module_idx].vaddr_range = mod->vaddr_range;
|
||||
eval_modules[eval_module_idx].space = (U64)process;
|
||||
eval_modules[eval_module_idx].space.u64[1]= (U64)process;
|
||||
if(mod == module)
|
||||
{
|
||||
eval_modules_primary = &eval_modules[eval_module_idx];
|
||||
@@ -4719,7 +4719,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
E_ParseCtx *ctx = &parse_ctx;
|
||||
ctx->ip_vaddr = thread_rip_vaddr;
|
||||
ctx->ip_voff = thread_rip_voff;
|
||||
ctx->ip_thread_space = (E_Space)thread;
|
||||
ctx->ip_thread_space.u64[1] = (U64)thread;
|
||||
ctx->modules = eval_modules;
|
||||
ctx->modules_count = eval_modules_count;
|
||||
ctx->primary_module = eval_modules_primary;
|
||||
@@ -4744,7 +4744,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
ctx->space_read = ctrl_eval_space_read;
|
||||
ctx->primary_space = eval_modules_primary->space;
|
||||
ctx->reg_arch = eval_modules_primary->arch;
|
||||
ctx->reg_space = (E_Space)thread;
|
||||
ctx->reg_space.u64[1] = (U64)thread;
|
||||
ctx->module_base = push_array(temp.arena, U64, 1);
|
||||
ctx->module_base[0]= module->vaddr_range.min;
|
||||
ctx->tls_base = push_array(temp.arena, U64, 1);
|
||||
|
||||
+48
-10
@@ -3729,13 +3729,51 @@ df_ctrl_last_stop_event(void)
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation Context
|
||||
|
||||
internal DF_Entity *
|
||||
df_entity_from_eval_space(E_Space space)
|
||||
{
|
||||
DF_Entity *entity = &df_g_nil_entity;
|
||||
if(space.u64[0] == 0 && space.u64[1] != 0)
|
||||
{
|
||||
entity = (DF_Entity *)space.u64[1];
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
internal E_Space
|
||||
df_eval_space_from_entity(DF_Entity *entity)
|
||||
{
|
||||
E_Space space = {0};
|
||||
space.u64[1] = (U64)entity;
|
||||
return space;
|
||||
}
|
||||
|
||||
internal B32
|
||||
df_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
|
||||
{
|
||||
B32 result = 0;
|
||||
DF_Entity *entity = (DF_Entity *)space;
|
||||
DF_Entity *entity = df_entity_from_eval_space(space);
|
||||
switch(entity->kind)
|
||||
{
|
||||
//- rjf: nil-space -> fall back to file system
|
||||
case DF_EntityKind_Nil:
|
||||
{
|
||||
U128 key = space;
|
||||
U128 hash = hs_hash_from_key(key, 0);
|
||||
HS_Scope *scope = hs_scope_open();
|
||||
{
|
||||
String8 data = hs_data_from_hash(scope, hash);
|
||||
Rng1U64 legal_range = r1u64(0, data.size);
|
||||
Rng1U64 read_range = intersect_1u64(range, legal_range);
|
||||
if(read_range.min < read_range.max)
|
||||
{
|
||||
result = 1;
|
||||
MemoryCopy(out, data.str + read_range.min, dim_1u64(read_range));
|
||||
}
|
||||
}
|
||||
hs_scope_close(scope);
|
||||
}break;
|
||||
|
||||
//- rjf: default -> evaluating a debugger entity; read from entity POD evaluation
|
||||
default:
|
||||
{
|
||||
@@ -3799,7 +3837,7 @@ internal B32
|
||||
df_eval_space_write(void *u, E_Space space, void *in, Rng1U64 range)
|
||||
{
|
||||
B32 result = 0;
|
||||
DF_Entity *entity = (DF_Entity *)space;
|
||||
DF_Entity *entity = df_entity_from_eval_space(space);
|
||||
switch(entity->kind)
|
||||
{
|
||||
//- rjf: default -> making commits to entity evaluation
|
||||
@@ -4307,8 +4345,8 @@ df_string_from_simple_typed_eval(Arena *arena, DF_EvalVizStringFlags flags, U32
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
U64 min_digits = (radix == 16) ? type_byte_size*2 : 0;
|
||||
String8 upper64 = str8_from_u64(scratch.arena, eval.value.u128[0], radix, min_digits, digit_group_separator);
|
||||
String8 lower64 = str8_from_u64(scratch.arena, eval.value.u128[1], radix, min_digits, digit_group_separator);
|
||||
String8 upper64 = str8_from_u64(scratch.arena, eval.value.u128.u64[0], radix, min_digits, digit_group_separator);
|
||||
String8 lower64 = str8_from_u64(scratch.arena, eval.value.u128.u64[1], radix, min_digits, digit_group_separator);
|
||||
result = push_str8f(arena, "%S:%S", upper64, lower64);
|
||||
scratch_end(scratch);
|
||||
}break;
|
||||
@@ -5013,7 +5051,7 @@ df_expr_from_eval_viz_block_index(Arena *arena, DF_EvalVizBlock *block, U64 inde
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(module->rdi, Scopes, procedure->root_scope_idx);
|
||||
U64 voff = *rdi_element_from_name_idx(module->rdi, ScopeVOffData, scope->voff_range_first);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, voff);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, e_value_u64(voff));
|
||||
String8 bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = procedure->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(module->rdi, TypeNodes, type_idx);
|
||||
@@ -5030,7 +5068,7 @@ df_expr_from_eval_viz_block_index(Arena *arena, DF_EvalVizBlock *block, U64 inde
|
||||
RDI_GlobalVariable *gvar = rdi_element_from_name_idx(module->rdi, GlobalVariables, element_idx);
|
||||
U64 voff = gvar->voff;
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, voff);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, e_value_u64(voff));
|
||||
String8 bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = gvar->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(module->rdi, TypeNodes, type_idx);
|
||||
@@ -5046,7 +5084,7 @@ df_expr_from_eval_viz_block_index(Arena *arena, DF_EvalVizBlock *block, U64 inde
|
||||
{
|
||||
RDI_ThreadVariable *tvar = rdi_element_from_name_idx(module->rdi, ThreadVariables, element_idx);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, tvar->tls_off);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, e_value_u64(tvar->tls_off));
|
||||
String8 bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = tvar->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(module->rdi, TypeNodes, type_idx);
|
||||
@@ -8389,7 +8427,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
||||
eval_modules[eval_module_idx].arch = df_architecture_from_entity(m);
|
||||
eval_modules[eval_module_idx].rdi = di_rdi_from_key(df_state->frame_di_scope, &dbgi_key, 0);
|
||||
eval_modules[eval_module_idx].vaddr_range = m->vaddr_rng;
|
||||
eval_modules[eval_module_idx].space = (U64)df_entity_ancestor_from_kind(m, DF_EntityKind_Process);
|
||||
eval_modules[eval_module_idx].space = df_eval_space_from_entity(df_entity_ancestor_from_kind(m, DF_EntityKind_Process));
|
||||
if(module == m)
|
||||
{
|
||||
eval_modules_primary = &eval_modules[eval_module_idx];
|
||||
@@ -8435,7 +8473,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
||||
E_ParseCtx *ctx = parse_ctx;
|
||||
ctx->ip_vaddr = rip_vaddr;
|
||||
ctx->ip_voff = rip_voff;
|
||||
ctx->ip_thread_space = (E_Space)thread;
|
||||
ctx->ip_thread_space = df_eval_space_from_entity(thread);
|
||||
ctx->modules = eval_modules;
|
||||
ctx->modules_count = eval_modules_count;
|
||||
ctx->primary_module = eval_modules_primary;
|
||||
@@ -8496,7 +8534,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
||||
ctx->space_write = df_eval_space_write;
|
||||
ctx->primary_space = eval_modules_primary->space;
|
||||
ctx->reg_arch = eval_modules_primary->arch;
|
||||
ctx->reg_space = (E_Space)thread;
|
||||
ctx->reg_space = df_eval_space_from_entity(thread);
|
||||
ctx->reg_unwind_count = unwind_count;
|
||||
ctx->module_base = push_array(arena, U64, 1);
|
||||
ctx->module_base[0] = module->vaddr_rng.min;
|
||||
|
||||
@@ -1573,6 +1573,8 @@ internal CTRL_Event df_ctrl_last_stop_event(void);
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation Context
|
||||
|
||||
internal DF_Entity *df_entity_from_eval_space(E_Space space);
|
||||
internal E_Space df_eval_space_from_entity(DF_Entity *entity);
|
||||
internal B32 df_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range);
|
||||
internal B32 df_eval_space_write(void *u, E_Space space, void *in, Rng1U64 range);
|
||||
internal E_Eval df_eval_from_eval_cfg_table(Arena *arena, E_Eval eval, DF_CfgTable *cfg);
|
||||
|
||||
+2
-3
@@ -6135,7 +6135,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
DF_ExpandKey parent_key = df_expand_key_make(5381, 1);
|
||||
DF_ExpandKey key = df_expand_key_make(df_hash_from_expand_key(parent_key), 1);
|
||||
DF_EvalVizBlockList viz_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(scratch.arena, eval_view, &top_level_cfg_table, expr, parent_key, key);
|
||||
DF_Entity *entity = eval.space ? (DF_Entity *)eval.space : &df_g_nil_entity;
|
||||
DF_Entity *entity = df_entity_from_eval_space(eval.space);
|
||||
U32 default_radix = (entity->kind == DF_EntityKind_Thread ? 16 : 10);
|
||||
DF_EvalVizWindowedRowList viz_rows = df_eval_viz_windowed_row_list_from_viz_block_list(scratch.arena, eval_view, r1s64(0, 50), &viz_blocks);
|
||||
|
||||
@@ -6241,9 +6241,8 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
|
||||
{
|
||||
default:{}break;
|
||||
case E_Mode_Offset:
|
||||
if(row_eval.space >= E_Space_FIXED_COUNT)
|
||||
{
|
||||
DF_Entity *space_entity = (DF_Entity *)row_eval.space;
|
||||
DF_Entity *space_entity = df_entity_from_eval_space(row_eval.space);
|
||||
if(space_entity->kind == DF_EntityKind_Process)
|
||||
{
|
||||
U64 size = e_type_byte_size_from_key(row_eval.type_key);
|
||||
|
||||
@@ -1527,7 +1527,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
E_Expr *bp_expr = e_push_expr(scratch.arena, E_ExprKind_LeafID, 0);
|
||||
bp_expr->type_key = bp_type;
|
||||
bp_expr->mode = E_Mode_Offset;
|
||||
bp_expr->space = (U64)bp;
|
||||
bp_expr->space = df_eval_space_from_entity(bp);
|
||||
df_append_viz_blocks_for_parent__rec(scratch.arena, eval_view, parent_key, key, title, bp_expr, &top_level_cfg_table, 0, &blocks);
|
||||
}
|
||||
}
|
||||
@@ -1562,7 +1562,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
E_Expr *wp_expr = e_push_expr(scratch.arena, E_ExprKind_LeafID, 0);
|
||||
wp_expr->type_key = wp_type;
|
||||
wp_expr->mode = E_Mode_Offset;
|
||||
wp_expr->space = (U64)wp;
|
||||
wp_expr->space = df_eval_space_from_entity(wp);
|
||||
df_append_viz_blocks_for_parent__rec(scratch.arena, eval_view, parent_key, key, title, wp_expr, &top_level_cfg_table, 0, &blocks);
|
||||
}
|
||||
}
|
||||
@@ -1625,12 +1625,12 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
}
|
||||
U64 row_vaddr = regs_rip_from_arch_block(arch, row->regs);
|
||||
E_OpList ops = {0};
|
||||
e_oplist_push_op(scratch.arena, &ops, RDI_EvalOp_ConstU64, row_vaddr);
|
||||
e_oplist_push_op(scratch.arena, &ops, RDI_EvalOp_ConstU64, e_value_u64(row_vaddr));
|
||||
String8 bytecode = e_bytecode_from_oplist(scratch.arena, &ops);
|
||||
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafBytecode, 0);
|
||||
expr->bytecode = bytecode;
|
||||
expr->mode = E_Mode_Value;
|
||||
expr->space = (U64)process;
|
||||
expr->space = df_eval_space_from_entity(process);
|
||||
expr->type_key = type_key;
|
||||
block->expr = expr;
|
||||
block->visual_idx_range = r1u64(row_idx, row_idx+1);
|
||||
@@ -2657,9 +2657,8 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
{
|
||||
default:{}break;
|
||||
case E_Mode_Offset:
|
||||
if(row_eval.space >= E_Space_FIXED_COUNT)
|
||||
{
|
||||
DF_Entity *space_entity = (DF_Entity *)row_eval.space;
|
||||
DF_Entity *space_entity = df_entity_from_eval_space(row_eval.space);
|
||||
if(space_entity->kind == DF_EntityKind_Process)
|
||||
{
|
||||
U64 size = e_type_byte_size_from_key(row_eval.type_key);
|
||||
@@ -3215,7 +3214,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS
|
||||
case E_IRExtKind_Bytecode:{ext = str8_lit("[bytecode]");}break;
|
||||
default:
|
||||
{
|
||||
ext = str8_from_u64(scratch.arena, op->u64, 16, 0, 0);
|
||||
ext = str8_from_u64(scratch.arena, op->value.u64, 16, 0, 0);
|
||||
}break;
|
||||
}
|
||||
ui_labelf(" %S%s%S", op_string, ext.size ? " " : "", ext);
|
||||
|
||||
+17
-10
@@ -36,6 +36,21 @@ struct E_MsgList
|
||||
U64 count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Register-Sized Value Type
|
||||
|
||||
typedef union E_Value E_Value;
|
||||
union E_Value
|
||||
{
|
||||
U64 u512[8];
|
||||
U64 u256[4];
|
||||
U128 u128;
|
||||
U64 u64;
|
||||
S64 s64;
|
||||
F64 f64;
|
||||
F32 f32;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Operator Info
|
||||
|
||||
@@ -60,7 +75,7 @@ struct E_OpInfo
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation Spaces
|
||||
|
||||
typedef U64 E_Space;
|
||||
typedef U128 E_Space;
|
||||
//
|
||||
// NOTE(rjf): Evaluations occur within the context of a "space". Each "space"
|
||||
// refers to a different offset/address-space, but it's a bit looser of a
|
||||
@@ -71,15 +86,6 @@ typedef U64 E_Space;
|
||||
// Effectively, when considering the result of an evaluation, you use the
|
||||
// value for understanding a key *into* a space, e.g. 1+2 -> 3, in a null
|
||||
// space, or &foo, in the space of PID: 1234.
|
||||
//
|
||||
// The values in the E_Space enum are reserved, but apart from those, any
|
||||
// arbitrary value can be used, and then later interpreted.
|
||||
//
|
||||
enum
|
||||
{
|
||||
E_Space_Null,
|
||||
E_Space_FIXED_COUNT
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation Modes
|
||||
@@ -114,6 +120,7 @@ struct E_Module
|
||||
|
||||
internal U64 e_hash_from_string(U64 seed, String8 string);
|
||||
internal String8 e_raw_from_escaped_string(Arena *arena, String8 string);
|
||||
#define e_value_u64(v) (E_Value){.u64 = (v)}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Message Functions
|
||||
|
||||
+11
-18
@@ -24,15 +24,9 @@ e_space_read(E_Space space, void *out, Rng1U64 range)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
B32 result = 0;
|
||||
switch(space)
|
||||
if(e_interpret_ctx->space_read != 0)
|
||||
{
|
||||
case E_Space_FIXED_COUNT:
|
||||
case E_Space_Null:{}break;
|
||||
default:
|
||||
if(e_interpret_ctx->space_read != 0)
|
||||
{
|
||||
result = e_interpret_ctx->space_read(e_interpret_ctx->space_rw_user_data, space, out, range);
|
||||
}break;
|
||||
result = e_interpret_ctx->space_read(e_interpret_ctx->space_rw_user_data, space, out, range);
|
||||
}
|
||||
ProfEnd();
|
||||
return result;
|
||||
@@ -43,15 +37,9 @@ e_space_write(E_Space space, void *in, Rng1U64 range)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
B32 result = 0;
|
||||
switch(space)
|
||||
if(e_interpret_ctx->space_write != 0)
|
||||
{
|
||||
case E_Space_FIXED_COUNT:
|
||||
case E_Space_Null:{}break;
|
||||
default:
|
||||
if(e_interpret_ctx->space_write != 0)
|
||||
{
|
||||
result = e_interpret_ctx->space_write(e_interpret_ctx->space_rw_user_data, space, in, range);
|
||||
}break;
|
||||
result = e_interpret_ctx->space_write(e_interpret_ctx->space_rw_user_data, space, in, range);
|
||||
}
|
||||
ProfEnd();
|
||||
return result;
|
||||
@@ -86,7 +74,7 @@ e_interpret(String8 bytecode)
|
||||
}
|
||||
else switch(op)
|
||||
{
|
||||
case E_IRExtKind_SetSpace:{ctrlbits = RDI_EVAL_CTRLBITS(8, 0, 0);}break;
|
||||
case E_IRExtKind_SetSpace:{ctrlbits = RDI_EVAL_CTRLBITS(16, 0, 0);}break;
|
||||
default:
|
||||
{
|
||||
result.code = E_InterpretationCode_BadOp;
|
||||
@@ -139,7 +127,7 @@ e_interpret(String8 bytecode)
|
||||
{
|
||||
case E_IRExtKind_SetSpace:
|
||||
{
|
||||
selected_space = imm;
|
||||
MemoryCopy(&selected_space, ptr, sizeof(E_Space));
|
||||
}break;
|
||||
|
||||
case RDI_EvalOp_Stop:
|
||||
@@ -251,6 +239,11 @@ e_interpret(String8 bytecode)
|
||||
nval.u64 = imm;
|
||||
}break;
|
||||
|
||||
case RDI_EvalOp_ConstU128:
|
||||
{
|
||||
MemoryCopy(&nval, ptr, 16);
|
||||
}break;
|
||||
|
||||
case RDI_EvalOp_ConstString:
|
||||
{
|
||||
MemoryCopy(&nval, ptr, imm);
|
||||
|
||||
@@ -7,18 +7,6 @@
|
||||
////////////////////////////////
|
||||
//~ rjf: Bytecode Interpretation Types
|
||||
|
||||
typedef union E_Value E_Value;
|
||||
union E_Value
|
||||
{
|
||||
U64 u512[8];
|
||||
U64 u256[4];
|
||||
U64 u128[2];
|
||||
U64 u64;
|
||||
S64 s64;
|
||||
F64 f64;
|
||||
F32 f32;
|
||||
};
|
||||
|
||||
typedef struct E_Interpretation E_Interpretation;
|
||||
struct E_Interpretation
|
||||
{
|
||||
|
||||
+80
-53
@@ -76,13 +76,13 @@ e_select_ir_ctx(E_IRCtx *ctx)
|
||||
//- rjf: op list functions
|
||||
|
||||
internal void
|
||||
e_oplist_push_op(Arena *arena, E_OpList *list, RDI_EvalOp opcode, U64 p)
|
||||
e_oplist_push_op(Arena *arena, E_OpList *list, RDI_EvalOp opcode, E_Value value)
|
||||
{
|
||||
U8 ctrlbits = rdi_eval_op_ctrlbits_table[opcode];
|
||||
U32 p_size = RDI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||
E_Op *node = push_array_no_zero(arena, E_Op, 1);
|
||||
node->opcode = opcode;
|
||||
node->u64 = p;
|
||||
node->value = value;
|
||||
SLLQueuePush(list->first, list->last, node);
|
||||
list->op_count += 1;
|
||||
list->encoded_size += 1 + p_size;
|
||||
@@ -92,10 +92,10 @@ internal void
|
||||
e_oplist_push_uconst(Arena *arena, E_OpList *list, U64 x)
|
||||
{
|
||||
if(0){}
|
||||
else if(x <= 0xFF) { e_oplist_push_op(arena, list, RDI_EvalOp_ConstU8, x); }
|
||||
else if(x <= 0xFFFF) { e_oplist_push_op(arena, list, RDI_EvalOp_ConstU16, x); }
|
||||
else if(x <= 0xFFFFFFFF) { e_oplist_push_op(arena, list, RDI_EvalOp_ConstU32, x); }
|
||||
else { e_oplist_push_op(arena, list, RDI_EvalOp_ConstU64, x); }
|
||||
else if(x <= 0xFF) { e_oplist_push_op(arena, list, RDI_EvalOp_ConstU8, e_value_u64(x)); }
|
||||
else if(x <= 0xFFFF) { e_oplist_push_op(arena, list, RDI_EvalOp_ConstU16, e_value_u64(x)); }
|
||||
else if(x <= 0xFFFFFFFF) { e_oplist_push_op(arena, list, RDI_EvalOp_ConstU32, e_value_u64(x)); }
|
||||
else { e_oplist_push_op(arena, list, RDI_EvalOp_ConstU64, e_value_u64(x)); }
|
||||
}
|
||||
|
||||
internal void
|
||||
@@ -103,22 +103,22 @@ e_oplist_push_sconst(Arena *arena, E_OpList *list, S64 x)
|
||||
{
|
||||
if(-0x80 <= x && x <= 0x7F)
|
||||
{
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_ConstU8, (U64)x);
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_TruncSigned, 8);
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_ConstU8, e_value_u64((U64)x));
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_TruncSigned, e_value_u64(8));
|
||||
}
|
||||
else if(-0x8000 <= x && x <= 0x7FFF)
|
||||
{
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_ConstU16, (U64)x);
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_TruncSigned, 16);
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_ConstU16, e_value_u64((U64)x));
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_TruncSigned, e_value_u64(16));
|
||||
}
|
||||
else if(-0x80000000ll <= x && x <= 0x7FFFFFFFll)
|
||||
{
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_ConstU32, (U64)x);
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_TruncSigned, 32);
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_ConstU32, e_value_u64((U64)x));
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_TruncSigned, e_value_u64(32));
|
||||
}
|
||||
else
|
||||
{
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_ConstU64, (U64)x);
|
||||
e_oplist_push_op(arena, list, RDI_EvalOp_ConstU64, e_value_u64((U64)x));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ e_oplist_push_set_space(Arena *arena, E_OpList *list, E_Space space)
|
||||
{
|
||||
E_Op *node = push_array_no_zero(arena, E_Op, 1);
|
||||
node->opcode = E_IRExtKind_SetSpace;
|
||||
node->u64 = space;
|
||||
node->value.u128 = space;
|
||||
SLLQueuePush(list->first, list->last, node);
|
||||
list->op_count += 1;
|
||||
list->encoded_size += 1 + sizeof(space);
|
||||
@@ -153,10 +153,10 @@ e_oplist_push_string_literal(Arena *arena, E_OpList *list, String8 string)
|
||||
E_Op *node = push_array_no_zero(arena, E_Op, 1);
|
||||
node->opcode = opcode;
|
||||
node->string = string;
|
||||
node->u64 = Min(string.size, 64);
|
||||
node->value.u64 = Min(string.size, 64);
|
||||
SLLQueuePush(list->first, list->last, node);
|
||||
list->op_count += 1;
|
||||
list->encoded_size += 1 + p_size + node->u64;
|
||||
list->encoded_size += 1 + p_size + node->value.u64;
|
||||
}
|
||||
|
||||
internal void
|
||||
@@ -206,7 +206,7 @@ e_irtree_const_u(Arena *arena, U64 v)
|
||||
|
||||
// rjf: build
|
||||
E_IRNode *n = e_push_irnode(arena, op);
|
||||
n->u64 = v;
|
||||
n->value.u64 = v;
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ internal E_IRNode *
|
||||
e_irtree_unary_op(Arena *arena, RDI_EvalOp op, RDI_EvalTypeGroup group, E_IRNode *c)
|
||||
{
|
||||
E_IRNode *n = e_push_irnode(arena, op);
|
||||
n->u64 = group;
|
||||
n->value.u64 = group;
|
||||
e_irnode_push_child(n, c);
|
||||
return n;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ internal E_IRNode *
|
||||
e_irtree_binary_op(Arena *arena, RDI_EvalOp op, RDI_EvalTypeGroup group, E_IRNode *l, E_IRNode *r)
|
||||
{
|
||||
E_IRNode *n = e_push_irnode(arena, op);
|
||||
n->u64 = group;
|
||||
n->value.u64 = group;
|
||||
e_irnode_push_child(n, l);
|
||||
e_irnode_push_child(n, r);
|
||||
return n;
|
||||
@@ -266,7 +266,7 @@ internal E_IRNode *
|
||||
e_irtree_set_space(Arena *arena, E_Space space, E_IRNode *c)
|
||||
{
|
||||
E_IRNode *root = e_push_irnode(arena, E_IRExtKind_SetSpace);
|
||||
root->u64 = space;
|
||||
root->value.u128 = space;
|
||||
e_irnode_push_child(root, c);
|
||||
return root;
|
||||
}
|
||||
@@ -280,7 +280,7 @@ e_irtree_mem_read_type(Arena *arena, E_Space space, E_IRNode *c, E_TypeKey type_
|
||||
|
||||
// rjf: build the read node
|
||||
E_IRNode *read_node = e_push_irnode(arena, RDI_EvalOp_MemRead);
|
||||
read_node->u64 = byte_size;
|
||||
read_node->value.u64 = byte_size;
|
||||
e_irnode_push_child(read_node, c);
|
||||
|
||||
// rjf: build a signed trunc node if needed
|
||||
@@ -290,7 +290,7 @@ e_irtree_mem_read_type(Arena *arena, E_Space space, E_IRNode *c, E_TypeKey type_
|
||||
if(bit_size < 64 && e_type_kind_is_signed(kind))
|
||||
{
|
||||
with_trunc = e_push_irnode(arena, RDI_EvalOp_TruncSigned);
|
||||
with_trunc->u64 = bit_size;
|
||||
with_trunc->value.u64 = bit_size;
|
||||
e_irnode_push_child(with_trunc, read_node);
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ internal E_IRNode *
|
||||
e_irtree_convert_lo(Arena *arena, E_IRNode *c, RDI_EvalTypeGroup out, RDI_EvalTypeGroup in)
|
||||
{
|
||||
E_IRNode *n = e_push_irnode(arena, RDI_EvalOp_Convert);
|
||||
n->u64 = in | (out << 8);
|
||||
n->value.u64 = in | (out << 8);
|
||||
e_irnode_push_child(n, c);
|
||||
return n;
|
||||
}
|
||||
@@ -327,7 +327,7 @@ e_irtree_trunc(Arena *arena, E_IRNode *c, E_TypeKey type_key)
|
||||
}
|
||||
U64 bit_size = byte_size << 3;
|
||||
result = e_push_irnode(arena, op);
|
||||
result->u64 = bit_size;
|
||||
result->value.u64 = bit_size;
|
||||
e_irnode_push_child(result, c);
|
||||
}
|
||||
return result;
|
||||
@@ -358,22 +358,11 @@ e_irtree_convert_hi(Arena *arena, E_IRNode *c, E_TypeKey out, E_TypeKey in)
|
||||
internal E_IRNode *
|
||||
e_irtree_resolve_to_value(Arena *arena, E_Space from_space, E_Mode from_mode, E_IRNode *tree, E_TypeKey type_key)
|
||||
{
|
||||
// TODO(rjf): @spaces double check that this path is working for register spaces
|
||||
E_IRNode *result = tree;
|
||||
if(from_mode == E_Mode_Offset)
|
||||
{
|
||||
switch(from_space)
|
||||
{
|
||||
#if 0
|
||||
case E_Space_Regs:
|
||||
{
|
||||
result = e_irtree_unary_op(arena, RDI_EvalOp_RegReadDyn, RDI_EvalTypeGroup_U, tree);
|
||||
}break;
|
||||
#endif
|
||||
default:
|
||||
{
|
||||
result = e_irtree_mem_read_type(arena, from_space, tree, type_key);
|
||||
}break;
|
||||
}
|
||||
result = e_irtree_mem_read_type(arena, from_space, tree, type_key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -491,7 +480,7 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
||||
|
||||
// rjf: ops to push stack value, push offset, + read from stack value
|
||||
new_tree = e_push_irnode(arena, RDI_EvalOp_ValueRead);
|
||||
new_tree->u64 = direct_type_size;
|
||||
new_tree->value.u64 = direct_type_size;
|
||||
e_irnode_push_child(new_tree, offset_tree);
|
||||
e_irnode_push_child(new_tree, l.root);
|
||||
}break;
|
||||
@@ -964,7 +953,12 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
||||
result.root = new_tree;
|
||||
result.type_key = final_type_key;
|
||||
result.mode = E_Mode_Value;
|
||||
result.space = l_tree.space ? l_tree.space : r_tree.space;
|
||||
result.space = l_tree.space;
|
||||
E_Space zero_space = {0};
|
||||
if(MemoryMatchStruct(&result.space, &zero_space))
|
||||
{
|
||||
result.space = r_tree.space;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
@@ -1008,7 +1002,12 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
||||
result.root = new_root;
|
||||
result.type_key = ptr_type;
|
||||
result.mode = E_Mode_Value;
|
||||
result.space = l_tree.space ? l_tree.space : r_tree.space;
|
||||
result.space = l_tree.space;
|
||||
E_Space zero_space = {0};
|
||||
if(MemoryMatchStruct(&result.space, &zero_space))
|
||||
{
|
||||
result.space = r_tree.space;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
@@ -1040,7 +1039,12 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
||||
result.root = new_tree;
|
||||
result.type_key = e_type_key_basic(E_TypeKind_U64);
|
||||
result.mode = E_Mode_Value;
|
||||
result.space = l_tree.space ? l_tree.space : r_tree.space;
|
||||
result.space = l_tree.space;
|
||||
E_Space zero_space = {0};
|
||||
if(MemoryMatchStruct(&result.space, &zero_space))
|
||||
{
|
||||
result.space = r_tree.space;
|
||||
}
|
||||
}break;
|
||||
|
||||
//- rjf: pointer array comparison
|
||||
@@ -1069,7 +1073,12 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
||||
result.root = e_irtree_binary_op(arena, op, RDI_EvalTypeGroup_Other, mem_root, arr_root);
|
||||
result.type_key = e_type_key_basic(E_TypeKind_Bool);
|
||||
result.mode = E_Mode_Value;
|
||||
result.space = ptr_tree->space ? ptr_tree->space : arr_tree->space;
|
||||
result.space = ptr_tree->space;
|
||||
E_Space zero_space = {0};
|
||||
if(MemoryMatchStruct(&result.space, &zero_space))
|
||||
{
|
||||
result.space = arr_tree->space;
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}break;
|
||||
@@ -1120,7 +1129,12 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
||||
result.root = new_tree;
|
||||
result.type_key = result_type;
|
||||
result.mode = E_Mode_Value;
|
||||
result.space = l_expr->space ? l_expr->space : r_expr->space;
|
||||
result.space = l_expr->space;
|
||||
E_Space zero_space = {0};
|
||||
if(MemoryMatchStruct(&result.space, &zero_space))
|
||||
{
|
||||
result.space = r_expr->space;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
@@ -1207,13 +1221,26 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
||||
case E_ExprKind_LeafID:
|
||||
{
|
||||
E_IRNode *new_tree = e_push_irnode(arena, RDI_EvalOp_ConstU64);
|
||||
new_tree->u64 = expr->u64;
|
||||
new_tree->value.u64 = expr->u64;
|
||||
result.root = new_tree;
|
||||
result.type_key = expr->type_key;
|
||||
result.mode = E_Mode_Offset;
|
||||
result.space = expr->space;
|
||||
}break;
|
||||
|
||||
//- rjf: leaf file paths
|
||||
case E_ExprKind_LeafFilePath:
|
||||
{
|
||||
U128 key = fs_key_from_path(expr->string);
|
||||
U64 size = fs_size_from_path(expr->string);
|
||||
E_IRNode *base_offset = e_irtree_const_u(arena, 0);
|
||||
E_IRNode *set_space = e_irtree_set_space(arena, key, base_offset);
|
||||
result.root = set_space;
|
||||
result.type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), size);
|
||||
result.mode = E_Mode_Offset;
|
||||
result.space = key;
|
||||
}break;
|
||||
|
||||
//- rjf: types
|
||||
case E_ExprKind_TypeIdent:
|
||||
{
|
||||
@@ -1269,7 +1296,7 @@ e_append_oplist_from_irtree(Arena *arena, E_IRNode *root, E_OpList *out)
|
||||
|
||||
case E_IRExtKind_SetSpace:
|
||||
{
|
||||
e_oplist_push_set_space(arena, out, root->u64);
|
||||
e_oplist_push_set_space(arena, out, root->value.u128);
|
||||
for(E_IRNode *child = root->first;
|
||||
child != &e_irnode_nil;
|
||||
child = child->next)
|
||||
@@ -1292,11 +1319,11 @@ e_append_oplist_from_irtree(Arena *arena, E_IRNode *root, E_OpList *out)
|
||||
// 3. <ptr_left>
|
||||
|
||||
// rjf: modify prt_right in place to create step 2
|
||||
e_oplist_push_op(arena, &prt_right, RDI_EvalOp_Skip, prt_left.encoded_size);
|
||||
e_oplist_push_op(arena, &prt_right, RDI_EvalOp_Skip, e_value_u64(prt_left.encoded_size));
|
||||
|
||||
// rjf: merge 1 into out
|
||||
e_oplist_concat_in_place(out, &prt_cond);
|
||||
e_oplist_push_op(arena, out, RDI_EvalOp_Cond, prt_right.encoded_size);
|
||||
e_oplist_push_op(arena, out, RDI_EvalOp_Cond, e_value_u64(prt_right.encoded_size));
|
||||
|
||||
// rjf: merge 2 into out
|
||||
e_oplist_concat_in_place(out, &prt_right);
|
||||
@@ -1330,7 +1357,7 @@ e_append_oplist_from_irtree(Arena *arena, E_IRNode *root, E_OpList *out)
|
||||
}
|
||||
|
||||
// rjf: emit op to compute this node
|
||||
e_oplist_push_op(arena, out, (RDI_EvalOp)root->op, root->u64);
|
||||
e_oplist_push_op(arena, out, (RDI_EvalOp)root->op, root->value);
|
||||
}
|
||||
}break;
|
||||
}
|
||||
@@ -1371,7 +1398,7 @@ e_bytecode_from_oplist(Arena *arena, E_OpList *oplist)
|
||||
|
||||
// rjf: fill bytecode
|
||||
ptr[0] = opcode;
|
||||
MemoryCopy(ptr + 1, &op->u64, extra_byte_count);
|
||||
MemoryCopy(ptr + 1, &op->value.u64, extra_byte_count);
|
||||
|
||||
// rjf: advance
|
||||
ptr = next_ptr;
|
||||
@@ -1380,13 +1407,13 @@ e_bytecode_from_oplist(Arena *arena, E_OpList *oplist)
|
||||
case RDI_EvalOp_ConstString:
|
||||
{
|
||||
// rjf: compute bytecode advance
|
||||
U8 *next_ptr = ptr + 2 + op->u64;
|
||||
U8 *next_ptr = ptr + 2 + op->value.u64;
|
||||
Assert(next_ptr <= opl);
|
||||
|
||||
// rjf: fill
|
||||
ptr[0] = opcode;
|
||||
ptr[1] = (U8)op->u64;
|
||||
MemoryCopy(ptr+2, op->string.str, op->u64);
|
||||
ptr[1] = (U8)op->value.u64;
|
||||
MemoryCopy(ptr+2, op->string.str, op->value.u64);
|
||||
|
||||
// rjf: advance
|
||||
ptr = next_ptr;
|
||||
@@ -1415,7 +1442,7 @@ e_bytecode_from_oplist(Arena *arena, E_OpList *oplist)
|
||||
|
||||
// rjf: fill bytecode
|
||||
ptr[0] = opcode;
|
||||
MemoryCopy(ptr + 1, &op->u64, extra_byte_count);
|
||||
MemoryCopy(ptr + 1, &op->value.u64, extra_byte_count);
|
||||
|
||||
// rjf: advance
|
||||
ptr = next_ptr;
|
||||
|
||||
+3
-3
@@ -19,7 +19,7 @@ struct E_Op
|
||||
{
|
||||
E_Op *next;
|
||||
RDI_EvalOp opcode;
|
||||
U64 u64;
|
||||
E_Value value;
|
||||
String8 string;
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ struct E_IRNode
|
||||
E_IRNode *next;
|
||||
RDI_EvalOp op;
|
||||
String8 string;
|
||||
U64 u64;
|
||||
E_Value value;
|
||||
};
|
||||
|
||||
typedef struct E_IRTreeAndType E_IRTreeAndType;
|
||||
@@ -87,7 +87,7 @@ internal void e_select_ir_ctx(E_IRCtx *ctx);
|
||||
//~ rjf: IR-ization Functions
|
||||
|
||||
//- rjf: op list functions
|
||||
internal void e_oplist_push_op(Arena *arena, E_OpList *list, RDI_EvalOp opcode, U64 p);
|
||||
internal void e_oplist_push_op(Arena *arena, E_OpList *list, RDI_EvalOp opcode, E_Value value);
|
||||
internal void e_oplist_push_uconst(Arena *arena, E_OpList *list, U64 x);
|
||||
internal void e_oplist_push_sconst(Arena *arena, E_OpList *list, S64 x);
|
||||
internal void e_oplist_push_bytecode(Arena *arena, E_OpList *list, String8 bytecode);
|
||||
|
||||
+13
-13
@@ -1257,7 +1257,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
REGS_AliasCode alias_code = 0;
|
||||
E_TypeKey type_key = zero_struct;
|
||||
String8 local_lookup_string = token_string;
|
||||
E_Space space = E_Space_Null;
|
||||
E_Space space = {0};
|
||||
Architecture arch = Architecture_Null;
|
||||
|
||||
//- rjf: identifiers surrounded by ``s should have those `s stripped
|
||||
@@ -1430,7 +1430,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
U32 match_idx = matches[matches_count-1];
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_name_idx(rdi, GlobalVariables, match_idx);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, global_var->voff);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, e_value_u64(global_var->voff));
|
||||
loc_kind = RDI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = global_var->type_idx;
|
||||
@@ -1470,7 +1470,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
U32 match_idx = matches[0];
|
||||
RDI_ThreadVariable *thread_var = rdi_element_from_name_idx(rdi, ThreadVariables, match_idx);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, thread_var->tls_off);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, e_value_u64(thread_var->tls_off));
|
||||
loc_kind = RDI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = thread_var->type_idx;
|
||||
@@ -1512,7 +1512,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, procedure->root_scope_idx);
|
||||
U64 voff = *rdi_element_from_name_idx(rdi, ScopeVOffData, scope->voff_range_first);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, voff);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, e_value_u64(voff));
|
||||
loc_kind = RDI_LocationKind_ValBytecodeStream;
|
||||
loc_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = procedure->type_idx;
|
||||
@@ -1534,7 +1534,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
{
|
||||
mapped_identifier = 1;
|
||||
identifier_looks_like_type_expr = 1;
|
||||
space = E_Space_Null;
|
||||
MemoryZeroStruct(&space);
|
||||
arch = e_parse_ctx->primary_module->arch;
|
||||
}
|
||||
}
|
||||
@@ -1611,9 +1611,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
E_OpList oplist = {0};
|
||||
U64 byte_size = bit_size_from_arch(arch)/8;
|
||||
U64 regread_param = RDI_EncodeRegReadParam(loc_reg_u16.reg_code, byte_size, 0);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_RegRead, regread_param);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU16, loc_reg_u16.offset);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_Add, 0);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_RegRead, e_value_u64(regread_param));
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU16, e_value_u64(loc_reg_u16.offset));
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_Add, e_value_u64(0));
|
||||
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
||||
atom->mode = E_Mode_Offset;
|
||||
atom->space = space;
|
||||
@@ -1626,10 +1626,10 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
E_OpList oplist = {0};
|
||||
U64 byte_size = bit_size_from_arch(arch)/8;
|
||||
U64 regread_param = RDI_EncodeRegReadParam(loc_reg_u16.reg_code, byte_size, 0);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_RegRead, regread_param);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU16, loc_reg_u16.offset);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_Add, 0);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_MemRead, bit_size_from_arch(arch)/8);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_RegRead, e_value_u64(regread_param));
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU16, e_value_u64(loc_reg_u16.offset));
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_Add, e_value_u64(0));
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_MemRead, e_value_u64(bit_size_from_arch(arch)/8));
|
||||
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
||||
atom->mode = E_Mode_Offset;
|
||||
atom->space = space;
|
||||
@@ -1645,7 +1645,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
U64 byte_size = (U64)reg_rng.byte_size;
|
||||
U64 byte_pos = 0;
|
||||
U64 regread_param = RDI_EncodeRegReadParam(loc_reg.reg_code, byte_size, byte_pos);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_RegRead, regread_param);
|
||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_RegRead, e_value_u64(regread_param));
|
||||
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
||||
atom->mode = E_Mode_Value;
|
||||
atom->space = space;
|
||||
|
||||
@@ -138,6 +138,32 @@ fs_timestamp_from_path(String8 path)
|
||||
return result;
|
||||
}
|
||||
|
||||
internal U64
|
||||
fs_size_from_path(String8 path)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
U64 result = 0;
|
||||
path = path_normalized_from_string(scratch.arena, path);
|
||||
U128 path_key = hs_hash_from_data(path);
|
||||
U64 slot_idx = path_key.u64[0]%fs_shared->slots_count;
|
||||
U64 stripe_idx = slot_idx%fs_shared->stripes_count;
|
||||
FS_Slot *slot = &fs_shared->slots[slot_idx];
|
||||
FS_Stripe *stripe = &fs_shared->stripes[stripe_idx];
|
||||
OS_MutexScopeR(stripe->rw_mutex)
|
||||
{
|
||||
for(FS_Node *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
if(str8_match(path, n->path, 0))
|
||||
{
|
||||
result = n->size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Streamer Threads
|
||||
|
||||
@@ -263,6 +289,7 @@ fs_streamer_thread__entry_point(void *p)
|
||||
if(post_props.modified == pre_props.modified)
|
||||
{
|
||||
node->timestamp = post_props.modified;
|
||||
node->size = post_props.size;
|
||||
}
|
||||
ins_atomic_u32_eval_assign(&node->is_working, 0);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ struct FS_Node
|
||||
FS_Node *next;
|
||||
String8 path;
|
||||
U64 timestamp;
|
||||
U64 size;
|
||||
B32 is_working;
|
||||
};
|
||||
|
||||
@@ -83,6 +84,7 @@ internal U64 fs_change_gen(void);
|
||||
internal U128 fs_hash_from_path(String8 path, U64 endt_us);
|
||||
internal U128 fs_key_from_path(String8 path);
|
||||
internal U64 fs_timestamp_from_path(String8 path);
|
||||
internal U64 fs_size_from_path(String8 path);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Streamer Threads
|
||||
|
||||
@@ -92,7 +92,7 @@ RDI_U8 rdi_section_is_required_table[37] =
|
||||
0,
|
||||
};
|
||||
|
||||
RDI_U8 rdi_eval_op_ctrlbits_table[47] =
|
||||
RDI_U8 rdi_eval_op_ctrlbits_table[48] =
|
||||
{
|
||||
RDI_EVAL_CTRLBITS(0, 0, 0),
|
||||
RDI_EVAL_CTRLBITS(0, 0, 0),
|
||||
@@ -110,6 +110,7 @@ RDI_EVAL_CTRLBITS(1, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(2, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(4, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(8, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(16, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(1, 0, 1),
|
||||
RDI_EVAL_CTRLBITS(1, 1, 1),
|
||||
RDI_EVAL_CTRLBITS(1, 1, 1),
|
||||
|
||||
@@ -52,7 +52,7 @@ typedef int64_t RDI_S64;
|
||||
|
||||
// \"raddbg\0\0\"
|
||||
#define RDI_MAGIC_CONSTANT 0x0000676264646172
|
||||
#define RDI_ENCODING_VERSION 9
|
||||
#define RDI_ENCODING_VERSION 10
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
//~ Format Types & Functions
|
||||
@@ -453,37 +453,38 @@ RDI_EvalOp_ConstU8 = 12,
|
||||
RDI_EvalOp_ConstU16 = 13,
|
||||
RDI_EvalOp_ConstU32 = 14,
|
||||
RDI_EvalOp_ConstU64 = 15,
|
||||
RDI_EvalOp_ConstString = 16,
|
||||
RDI_EvalOp_Abs = 17,
|
||||
RDI_EvalOp_Neg = 18,
|
||||
RDI_EvalOp_Add = 19,
|
||||
RDI_EvalOp_Sub = 20,
|
||||
RDI_EvalOp_Mul = 21,
|
||||
RDI_EvalOp_Div = 22,
|
||||
RDI_EvalOp_Mod = 23,
|
||||
RDI_EvalOp_LShift = 24,
|
||||
RDI_EvalOp_RShift = 25,
|
||||
RDI_EvalOp_BitAnd = 26,
|
||||
RDI_EvalOp_BitOr = 27,
|
||||
RDI_EvalOp_BitXor = 28,
|
||||
RDI_EvalOp_BitNot = 29,
|
||||
RDI_EvalOp_LogAnd = 30,
|
||||
RDI_EvalOp_LogOr = 31,
|
||||
RDI_EvalOp_LogNot = 32,
|
||||
RDI_EvalOp_EqEq = 33,
|
||||
RDI_EvalOp_NtEq = 34,
|
||||
RDI_EvalOp_LsEq = 35,
|
||||
RDI_EvalOp_GrEq = 36,
|
||||
RDI_EvalOp_Less = 37,
|
||||
RDI_EvalOp_Grtr = 38,
|
||||
RDI_EvalOp_Trunc = 39,
|
||||
RDI_EvalOp_TruncSigned = 40,
|
||||
RDI_EvalOp_Convert = 41,
|
||||
RDI_EvalOp_Pick = 42,
|
||||
RDI_EvalOp_Pop = 43,
|
||||
RDI_EvalOp_Insert = 44,
|
||||
RDI_EvalOp_ValueRead = 45,
|
||||
RDI_EvalOp_COUNT = 46,
|
||||
RDI_EvalOp_ConstU128 = 16,
|
||||
RDI_EvalOp_ConstString = 17,
|
||||
RDI_EvalOp_Abs = 18,
|
||||
RDI_EvalOp_Neg = 19,
|
||||
RDI_EvalOp_Add = 20,
|
||||
RDI_EvalOp_Sub = 21,
|
||||
RDI_EvalOp_Mul = 22,
|
||||
RDI_EvalOp_Div = 23,
|
||||
RDI_EvalOp_Mod = 24,
|
||||
RDI_EvalOp_LShift = 25,
|
||||
RDI_EvalOp_RShift = 26,
|
||||
RDI_EvalOp_BitAnd = 27,
|
||||
RDI_EvalOp_BitOr = 28,
|
||||
RDI_EvalOp_BitXor = 29,
|
||||
RDI_EvalOp_BitNot = 30,
|
||||
RDI_EvalOp_LogAnd = 31,
|
||||
RDI_EvalOp_LogOr = 32,
|
||||
RDI_EvalOp_LogNot = 33,
|
||||
RDI_EvalOp_EqEq = 34,
|
||||
RDI_EvalOp_NtEq = 35,
|
||||
RDI_EvalOp_LsEq = 36,
|
||||
RDI_EvalOp_GrEq = 37,
|
||||
RDI_EvalOp_Less = 38,
|
||||
RDI_EvalOp_Grtr = 39,
|
||||
RDI_EvalOp_Trunc = 40,
|
||||
RDI_EvalOp_TruncSigned = 41,
|
||||
RDI_EvalOp_Convert = 42,
|
||||
RDI_EvalOp_Pick = 43,
|
||||
RDI_EvalOp_Pop = 44,
|
||||
RDI_EvalOp_Insert = 45,
|
||||
RDI_EvalOp_ValueRead = 46,
|
||||
RDI_EvalOp_COUNT = 47,
|
||||
} RDI_EvalOpEnum;
|
||||
|
||||
typedef RDI_U8 RDI_EvalTypeGroup;
|
||||
@@ -858,6 +859,7 @@ X(ConstU8)\
|
||||
X(ConstU16)\
|
||||
X(ConstU32)\
|
||||
X(ConstU64)\
|
||||
X(ConstU128)\
|
||||
X(ConstString)\
|
||||
X(Abs)\
|
||||
X(Neg)\
|
||||
@@ -993,10 +995,10 @@ typedef RDI_U32_Table RDI_U32_NameMapBuckets;
|
||||
typedef RDI_U32_Table RDI_U32_NameMapNodes;
|
||||
#endif
|
||||
|
||||
#define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) ((decodeN) | ((popN) << 4) | ((pushN) << 6))
|
||||
#define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) ((ctrlbits) & 0xf)
|
||||
#define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 4) & 0x3)
|
||||
#define RDI_PUSHN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 6) & 0x3)
|
||||
#define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) ((decodeN) | ((popN) << 5) | ((pushN) << 7))
|
||||
#define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) ((ctrlbits) & 0x1f)
|
||||
#define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 5) & 0x3)
|
||||
#define RDI_PUSHN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 7) & 0x1)
|
||||
#define RDI_EncodeRegReadParam(reg,bytesize,bytepos) ((reg)|((bytesize)<<8)|((bytepos)<<16))
|
||||
|
||||
typedef struct RDI_Header RDI_Header;
|
||||
@@ -1357,6 +1359,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_U8 rdi_section_is_required_table[37];
|
||||
extern RDI_U8 rdi_eval_op_ctrlbits_table[47];
|
||||
extern RDI_U8 rdi_eval_op_ctrlbits_table[48];
|
||||
|
||||
#endif // RDI_FORMAT_H
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
"";
|
||||
"// \"raddbg\0\0\"";
|
||||
"#define RDI_MAGIC_CONSTANT 0x0000676264646172";
|
||||
"#define RDI_ENCODING_VERSION 9";
|
||||
"#define RDI_ENCODING_VERSION 10";
|
||||
"";
|
||||
"////////////////////////////////////////////////////////////////";
|
||||
"//~ Format Types & Functions";
|
||||
@@ -1246,37 +1246,38 @@ RDI_EvalOpTable:
|
||||
{ConstU16 13 2 0 1}
|
||||
{ConstU32 14 4 0 1}
|
||||
{ConstU64 15 8 0 1}
|
||||
{ConstString 16 1 0 1}
|
||||
{Abs 17 1 1 1}
|
||||
{Neg 18 1 1 1}
|
||||
{Add 19 1 2 1}
|
||||
{Sub 20 1 2 1}
|
||||
{Mul 21 1 2 1}
|
||||
{Div 22 1 2 1}
|
||||
{Mod 23 1 2 1}
|
||||
{LShift 24 1 2 1}
|
||||
{RShift 25 1 2 1}
|
||||
{BitAnd 26 1 2 1}
|
||||
{BitOr 27 1 2 1}
|
||||
{BitXor 28 1 2 1}
|
||||
{BitNot 29 1 1 1}
|
||||
{LogAnd 30 1 2 1}
|
||||
{LogOr 31 1 2 1}
|
||||
{LogNot 32 1 1 1}
|
||||
{EqEq 33 1 2 1}
|
||||
{NtEq 34 1 2 1}
|
||||
{LsEq 35 1 2 1}
|
||||
{GrEq 36 1 2 1}
|
||||
{Less 37 1 2 1}
|
||||
{Grtr 38 1 2 1}
|
||||
{Trunc 39 1 1 1}
|
||||
{TruncSigned 40 1 1 1}
|
||||
{Convert 41 2 1 1}
|
||||
{Pick 42 1 0 1}
|
||||
{Pop 43 0 1 0}
|
||||
{Insert 44 1 0 0}
|
||||
{ValueRead 45 1 2 1}
|
||||
{COUNT 46 0 0 0}
|
||||
{ConstU128 16 16 0 1}
|
||||
{ConstString 17 1 0 1}
|
||||
{Abs 18 1 1 1}
|
||||
{Neg 19 1 1 1}
|
||||
{Add 20 1 2 1}
|
||||
{Sub 21 1 2 1}
|
||||
{Mul 22 1 2 1}
|
||||
{Div 23 1 2 1}
|
||||
{Mod 24 1 2 1}
|
||||
{LShift 25 1 2 1}
|
||||
{RShift 26 1 2 1}
|
||||
{BitAnd 27 1 2 1}
|
||||
{BitOr 28 1 2 1}
|
||||
{BitXor 29 1 2 1}
|
||||
{BitNot 30 1 1 1}
|
||||
{LogAnd 31 1 2 1}
|
||||
{LogOr 32 1 2 1}
|
||||
{LogNot 33 1 1 1}
|
||||
{EqEq 34 1 2 1}
|
||||
{NtEq 35 1 2 1}
|
||||
{LsEq 36 1 2 1}
|
||||
{GrEq 37 1 2 1}
|
||||
{Less 38 1 2 1}
|
||||
{Grtr 39 1 2 1}
|
||||
{Trunc 40 1 1 1}
|
||||
{TruncSigned 41 1 1 1}
|
||||
{Convert 42 2 1 1}
|
||||
{Pick 43 1 0 1}
|
||||
{Pop 44 0 1 0}
|
||||
{Insert 45 1 0 0}
|
||||
{ValueRead 46 1 2 1}
|
||||
{COUNT 47 0 0 0}
|
||||
}
|
||||
|
||||
// NOTE(rjf): "ck" -> "conversion kind, when converted to type group", used in square matrix form
|
||||
@@ -1335,10 +1336,10 @@ RDI_EvalConversionKindTable:
|
||||
|
||||
@gen(enums)
|
||||
```
|
||||
#define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) ((decodeN) | ((popN) << 4) | ((pushN) << 6))
|
||||
#define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) ((ctrlbits) & 0xf)
|
||||
#define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 4) & 0x3)
|
||||
#define RDI_PUSHN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 6) & 0x3)
|
||||
#define RDI_EVAL_CTRLBITS(decodeN,popN,pushN) ((decodeN) | ((popN) << 5) | ((pushN) << 7))
|
||||
#define RDI_DECODEN_FROM_CTRLBITS(ctrlbits) ((ctrlbits) & 0x1f)
|
||||
#define RDI_POPN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 5) & 0x3)
|
||||
#define RDI_PUSHN_FROM_CTRLBITS(ctrlbits) (((ctrlbits) >> 7) & 0x1)
|
||||
#define RDI_EncodeRegReadParam(reg,bytesize,bytepos) ((reg)|((bytesize)<<8)|((bytepos)<<16))
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user