From f065ca33a2d1de40e0feb61e6ec447b346302852 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Thu, 28 Aug 2025 14:53:43 -0700 Subject: [PATCH] location block baking --- src/lib_rdi_make/rdi_make.h | 7 +++++++ src/rdi_make/rdi_make_local_2.c | 34 +++++++++++++++++++++++++++------ src/rdi_make/rdi_make_local_2.h | 1 + 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/lib_rdi_make/rdi_make.h b/src/lib_rdi_make/rdi_make.h index 105060fd..f5a0fe5c 100644 --- a/src/lib_rdi_make/rdi_make.h +++ b/src/lib_rdi_make/rdi_make.h @@ -1467,6 +1467,13 @@ struct RDIM_LocationBakeResult RDI_U64 location_data_size; }; +typedef struct RDIM_LocationBlockBakeResult RDIM_LocationBlockBakeResult; +struct RDIM_LocationBlockBakeResult +{ + RDI_LocationBlock *location_blocks; + RDI_U64 location_blocks_count; +}; + typedef struct RDIM_GlobalVariableBakeResult RDIM_GlobalVariableBakeResult; struct RDIM_GlobalVariableBakeResult { diff --git a/src/rdi_make/rdi_make_local_2.c b/src/rdi_make/rdi_make_local_2.c index efbb8569..b06b6bdd 100644 --- a/src/rdi_make/rdi_make_local_2.c +++ b/src/rdi_make/rdi_make_local_2.c @@ -820,36 +820,41 @@ rdim2_bake(Arena *arena, RDIM_BakeParams *params) rdim2_shared->baked_locations.location_data = push_array(arena, RDI_U8, rdim2_shared->baked_locations.location_data_size); } if(lane_idx() == lane_from_task_idx(8)) + { + rdim2_shared->baked_location_blocks.location_blocks_count = params->location_cases.total_count+1; + rdim2_shared->baked_location_blocks.location_blocks = push_array(arena, RDI_LocationBlock, rdim2_shared->baked_location_blocks.location_blocks_count); + } + if(lane_idx() == lane_from_task_idx(9)) { rdim2_shared->baked_global_variables.global_variables_count = params->global_variables.total_count+1; rdim2_shared->baked_global_variables.global_variables = push_array(arena, RDI_GlobalVariable, rdim2_shared->baked_global_variables.global_variables_count); } - if(lane_idx() == lane_from_task_idx(9)) + if(lane_idx() == lane_from_task_idx(10)) { rdim2_shared->baked_thread_variables.thread_variables_count = params->thread_variables.total_count+1; rdim2_shared->baked_thread_variables.thread_variables = push_array(arena, RDI_ThreadVariable, rdim2_shared->baked_thread_variables.thread_variables_count); } - if(lane_idx() == lane_from_task_idx(10)) + if(lane_idx() == lane_from_task_idx(11)) { rdim2_shared->baked_constants.constants_count = params->constants.total_count+1; rdim2_shared->baked_constants.constants = push_array(arena, RDI_Constant, rdim2_shared->baked_constants.constants_count); } - if(lane_idx() == lane_from_task_idx(11)) + if(lane_idx() == lane_from_task_idx(12)) { rdim2_shared->baked_constants.constant_values_count = params->constants.total_count+1; rdim2_shared->baked_constants.constant_values = push_array(arena, RDI_U32, rdim2_shared->baked_constants.constant_values_count); } - if(lane_idx() == lane_from_task_idx(12)) + if(lane_idx() == lane_from_task_idx(13)) { rdim2_shared->baked_constants.constant_value_data_size = params->constants.total_value_data_size; rdim2_shared->baked_constants.constant_value_data = push_array(arena, RDI_U8, rdim2_shared->baked_constants.constant_value_data_size); } - if(lane_idx() == lane_from_task_idx(13)) + if(lane_idx() == lane_from_task_idx(14)) { rdim2_shared->baked_procedures.procedures_count = params->procedures.total_count+1; rdim2_shared->baked_procedures.procedures = push_array(arena, RDI_Procedure, rdim2_shared->baked_procedures.procedures_count); } - if(lane_idx() == lane_from_task_idx(14)) + if(lane_idx() == lane_from_task_idx(15)) { rdim2_shared->baked_inline_sites.inline_sites_count = params->inline_sites.total_count+1; rdim2_shared->baked_inline_sites.inline_sites = push_array(arena, RDI_InlineSite, rdim2_shared->baked_inline_sites.inline_sites_count); @@ -1064,6 +1069,23 @@ rdim2_bake(Arena *arena, RDIM_BakeParams *params) } } + //- rjf: bake location blocks + ProfScope("bake location blocks") + { + for EachNode(n, RDIM_LocationCaseChunkNode, params->location_cases.first) + { + Rng1U64 range = lane_range(n->count); + for EachInRange(n_idx, range) + { + RDIM_LocationCase2 *src = &n->v[n_idx]; + RDI_LocationBlock *dst = &rdim2_shared->baked_location_blocks.location_blocks[n->base_idx + n_idx + 1]; + dst->scope_off_first = (RDI_U32)src->voff_range.min; // TODO(rjf): @u64_to_u32 + dst->scope_off_opl = (RDI_U32)src->voff_range.max; // TODO(rjf): @u64_to_u32 + dst->location_data_off = rdim_off_from_location(src->location); + } + } + } + //- rjf: bake global variables ProfScope("bake global variables") { diff --git a/src/rdi_make/rdi_make_local_2.h b/src/rdi_make/rdi_make_local_2.h index 9e679f6a..be4a09a4 100644 --- a/src/rdi_make/rdi_make_local_2.h +++ b/src/rdi_make/rdi_make_local_2.h @@ -54,6 +54,7 @@ struct RDIM2_Shared RDIM_TypeNodeBakeResult baked_type_nodes; RDIM_UDTBakeResult baked_udts; RDIM_LocationBakeResult baked_locations; + RDIM_LocationBlockBakeResult baked_location_blocks; RDIM_GlobalVariableBakeResult baked_global_variables; RDIM_ThreadVariableBakeResult baked_thread_variables; RDIM_ConstantsBakeResult baked_constants;