mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-07 16:35:41 +00:00
eliminate os_core, move into base; eliminate regs, move into arch abstraction layer, define x64 regs in x64 layer; move win32 backend for os core (now base) functionality to top-level win32 layer
This commit is contained in:
@@ -707,11 +707,12 @@ e_oplist_from_location(Arena *arena, RDI_Parsed *rdi, RDI_Location loc)
|
||||
{
|
||||
RDI_TopLevelInfo *tli = rdi_element_from_name_idx(rdi, TopLevelInfo, 0);
|
||||
Arch arch = arch_from_rdi_arch(tli->arch);
|
||||
ARCH_Info *arch_info = arch_info_from_arch(arch);
|
||||
RDI_RegCode rdi_regcode = rdi_regcode_from_location(loc);
|
||||
REGS_RegCode regs_reg_code = regs_reg_code_from_arch_rdi_code(arch, rdi_regcode);
|
||||
REGS_Rng reg_rng = regs_reg_code_rng_table_from_arch(arch)[regs_reg_code];
|
||||
U64 byte_size = (U64)reg_rng.byte_size;
|
||||
U64 byte_pos = 0;
|
||||
ARCH_RegCode reg_code = arch_reg_code_from_rdi(arch, rdi_regcode);
|
||||
Rng1U16 reg_rng = arch_info->reg_code_rng_table[reg_code];
|
||||
U64 byte_size = (U64)dim_1u16(reg_rng);
|
||||
U64 byte_pos = reg_rng.min;
|
||||
e_oplist_push_op(arena, &result, RDI_EvalOp_RegRead, e_value_u64(RDI_EncodeRegReadParam(rdi_regcode, byte_size, byte_pos)));
|
||||
}break;
|
||||
|
||||
@@ -830,7 +831,6 @@ internal void
|
||||
e_select_ir_ctx(E_IRCtx *ctx)
|
||||
{
|
||||
if(ctx->regs_map == 0) { ctx->regs_map = &e_string2num_map_nil; }
|
||||
if(ctx->reg_alias_map == 0) { ctx->reg_alias_map = &e_string2num_map_nil; }
|
||||
if(ctx->locals_map == 0) { ctx->locals_map = &e_string2num_map_nil; }
|
||||
if(ctx->member_map == 0) { ctx->member_map = &e_string2num_map_nil; }
|
||||
if(ctx->macro_map == 0) { ctx->macro_map = push_array(e_cache->arena, E_String2ExprMap, 1); ctx->macro_map[0] = e_string2expr_map_make(e_cache->arena, 512); }
|
||||
|
||||
@@ -165,7 +165,6 @@ typedef enum E_TypeKeyKind
|
||||
E_TypeKeyKind_Ext,
|
||||
E_TypeKeyKind_Cons,
|
||||
E_TypeKeyKind_Reg,
|
||||
E_TypeKeyKind_RegAlias,
|
||||
}
|
||||
E_TypeKeyKind;
|
||||
|
||||
@@ -795,7 +794,6 @@ typedef struct E_IRCtx E_IRCtx;
|
||||
struct E_IRCtx
|
||||
{
|
||||
E_String2NumMap *regs_map;
|
||||
E_String2NumMap *reg_alias_map;
|
||||
E_String2NumMap *locals_map; // (within `primary_module`)
|
||||
E_String2NumMap *member_map; // (within `primary_module`)
|
||||
E_String2ExprMap *macro_map;
|
||||
|
||||
@@ -280,13 +280,14 @@ e_interpret(String8 bytecode)
|
||||
U8 rdi_reg_code = (imm.u64&0x0000FF)>>0;
|
||||
U8 byte_size = (imm.u64&0x00FF00)>>8;
|
||||
U8 byte_off = (imm.u64&0xFF0000)>>16;
|
||||
REGS_RegCode base_reg_code = regs_reg_code_from_arch_rdi_code(e_interpret_ctx->reg_arch, rdi_reg_code);
|
||||
REGS_Rng *rng_table = regs_reg_code_rng_table_from_arch(e_interpret_ctx->reg_arch);
|
||||
Arch arch = e_interpret_ctx->reg_arch;
|
||||
ARCH_Info *arch_info = arch_info_from_arch(arch);
|
||||
ARCH_RegCode base_reg_code = arch_reg_code_from_rdi(arch, rdi_reg_code);
|
||||
B32 good_read = 0;
|
||||
if(0 <= rdi_reg_code && rdi_reg_code < regs_reg_code_count_from_arch(e_interpret_ctx->reg_arch))
|
||||
if(0 <= base_reg_code && base_reg_code < arch_info->reg_code_count)
|
||||
{
|
||||
REGS_Rng rng = rng_table[base_reg_code];
|
||||
U64 off = (U64)rng.byte_off + byte_off;
|
||||
Rng1U16 rng = arch_info->reg_code_rng_table[base_reg_code];
|
||||
U64 off = (U64)rng.min + byte_off;
|
||||
U64 size = (U64)byte_size;
|
||||
good_read = e_space_read(e_interpret_ctx->reg_space, &nval, r1u64(off, off+size));
|
||||
}
|
||||
|
||||
+14
-38
@@ -2016,49 +2016,25 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
|
||||
if(reg_num != 0)
|
||||
{
|
||||
string_mapped = 1;
|
||||
REGS_Rng reg_rng = regs_reg_code_rng_table_from_arch(e_base_ctx->primary_module->arch)[reg_num];
|
||||
Arch arch = e_base_ctx->primary_module->arch;
|
||||
ARCH_Info *arch_info = arch_info_from_arch(arch);
|
||||
ARCH_RegCode reg_code = reg_num;
|
||||
Rng1U16 reg_rng = arch_info->reg_code_rng_table[reg_code];
|
||||
U64 reg_size = dim_1u16(reg_rng);
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_uconst(arena, &oplist, reg_rng.byte_off);
|
||||
e_oplist_push_uconst(arena, &oplist, reg_rng.min);
|
||||
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
mapped_bytecode_mode = E_Mode_Offset;
|
||||
mapped_bytecode_space = e_base_ctx->thread_reg_space;
|
||||
REGS_UsageKind reg_usage_kind = regs_reg_code_usage_kind_table_from_arch(e_base_ctx->primary_module->arch)[reg_num];
|
||||
B32 is_vector = arch_info->reg_code_is_vector_table[reg_code];
|
||||
if(0){}
|
||||
else if(reg_usage_kind == REGS_UsageKind_Normal && reg_rng.byte_size == 1) {mapped_type_key = e_type_key_basic(E_TypeKind_U8);}
|
||||
else if(reg_usage_kind == REGS_UsageKind_Normal && reg_rng.byte_size == 2) {mapped_type_key = e_type_key_basic(E_TypeKind_U16);}
|
||||
else if(reg_usage_kind == REGS_UsageKind_Normal && reg_rng.byte_size == 4) {mapped_type_key = e_type_key_basic(E_TypeKind_U32);}
|
||||
else if(reg_usage_kind == REGS_UsageKind_Normal && reg_rng.byte_size == 8) {mapped_type_key = e_type_key_basic(E_TypeKind_U64);}
|
||||
else if(!is_vector && reg_size == 1) {mapped_type_key = e_type_key_basic(E_TypeKind_U8);}
|
||||
else if(!is_vector && reg_size == 2) {mapped_type_key = e_type_key_basic(E_TypeKind_U16);}
|
||||
else if(!is_vector && reg_size == 4) {mapped_type_key = e_type_key_basic(E_TypeKind_U32);}
|
||||
else if(!is_vector && reg_size == 8) {mapped_type_key = e_type_key_basic(E_TypeKind_U64);}
|
||||
else
|
||||
{
|
||||
mapped_type_key = e_type_key_reg(e_base_ctx->primary_module->arch, reg_num);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
//- rjf: try register aliases
|
||||
case E_IdentifierResolutionPath_RegisterAliases:
|
||||
if(!string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("reg"), 0)))
|
||||
{
|
||||
U64 alias_num = e_num_from_string(e_ir_ctx->reg_alias_map, string);
|
||||
if(alias_num != 0)
|
||||
{
|
||||
string_mapped = 1;
|
||||
REGS_Slice alias_slice = regs_alias_code_slice_table_from_arch(e_base_ctx->primary_module->arch)[alias_num];
|
||||
REGS_Rng alias_reg_rng = regs_reg_code_rng_table_from_arch(e_base_ctx->primary_module->arch)[alias_slice.code];
|
||||
E_OpList oplist = {0};
|
||||
e_oplist_push_uconst(arena, &oplist, alias_reg_rng.byte_off + alias_slice.byte_off);
|
||||
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
mapped_bytecode_mode = E_Mode_Offset;
|
||||
mapped_bytecode_space = e_base_ctx->thread_reg_space;
|
||||
REGS_UsageKind reg_usage_kind = regs_alias_code_usage_kind_table_from_arch(e_base_ctx->primary_module->arch)[alias_num];
|
||||
if(0){}
|
||||
else if(reg_usage_kind == REGS_UsageKind_Normal && alias_slice.byte_size == 1) {mapped_type_key = e_type_key_basic(E_TypeKind_U8);}
|
||||
else if(reg_usage_kind == REGS_UsageKind_Normal && alias_slice.byte_size == 2) {mapped_type_key = e_type_key_basic(E_TypeKind_U16);}
|
||||
else if(reg_usage_kind == REGS_UsageKind_Normal && alias_slice.byte_size == 4) {mapped_type_key = e_type_key_basic(E_TypeKind_U32);}
|
||||
else if(reg_usage_kind == REGS_UsageKind_Normal && alias_slice.byte_size == 8) {mapped_type_key = e_type_key_basic(E_TypeKind_U64);}
|
||||
else
|
||||
{
|
||||
mapped_type_key = e_type_key_reg_alias(e_base_ctx->primary_module->arch, alias_num);
|
||||
mapped_type_key = e_type_key_reg(arch, reg_code);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
@@ -2185,7 +2161,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
String8 file_path = expr->string;
|
||||
FileProperties props = os_properties_from_file_path(file_path);
|
||||
FileProperties props = properties_from_file_path(file_path);
|
||||
if(!str8_match(expr->qualifier, str8_lit("folder"), 0) && !(props.flags & FilePropertyFlag_IsFolder) && file_path.size != 0)
|
||||
{
|
||||
E_Space space = e_space_make(E_SpaceKind_FileSystem);
|
||||
@@ -2196,7 +2172,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
|
||||
else
|
||||
{
|
||||
String8 folder_path = str8_chop_last_slash(file_path);
|
||||
props = os_properties_from_file_path(folder_path);
|
||||
props = properties_from_file_path(folder_path);
|
||||
if(props.flags & FilePropertyFlag_IsFolder || folder_path.size == 0 || str8_match(folder_path, str8_lit("/"), StringMatchFlag_SlashInsensitive))
|
||||
{
|
||||
E_Space space = e_space_make(E_SpaceKind_FileSystem);
|
||||
|
||||
@@ -18,7 +18,6 @@ typedef enum E_IdentifierResolutionPath
|
||||
E_IdentifierResolutionPath_BuiltInConstants,
|
||||
E_IdentifierResolutionPath_BuiltInTypes,
|
||||
E_IdentifierResolutionPath_Registers,
|
||||
E_IdentifierResolutionPath_RegisterAliases,
|
||||
E_IdentifierResolutionPath_Macros,
|
||||
}
|
||||
E_IdentifierResolutionPath;
|
||||
@@ -89,7 +88,6 @@ E_IdentifierResolutionPath e_default_identifier_resolution_paths[] =
|
||||
E_IdentifierResolutionPath_BuiltInTypes,
|
||||
E_IdentifierResolutionPath_DebugInfoMatch,
|
||||
E_IdentifierResolutionPath_Registers,
|
||||
E_IdentifierResolutionPath_RegisterAliases,
|
||||
E_IdentifierResolutionPath_Macros,
|
||||
};
|
||||
E_IdentifierResolutionRule e_default_identifier_resolution_rule =
|
||||
@@ -110,7 +108,6 @@ E_IdentifierResolutionPath e_callable_identifier_resolution_paths[] =
|
||||
E_IdentifierResolutionPath_BuiltInTypes,
|
||||
E_IdentifierResolutionPath_DebugInfoMatch,
|
||||
E_IdentifierResolutionPath_Registers,
|
||||
E_IdentifierResolutionPath_RegisterAliases,
|
||||
};
|
||||
E_IdentifierResolutionRule e_callable_identifier_resolution_rule =
|
||||
{
|
||||
|
||||
+11
-27
@@ -288,7 +288,7 @@ e_type_key_ext(E_TypeKind kind, U32 type_idx, U32 rdi_num)
|
||||
}
|
||||
|
||||
internal E_TypeKey
|
||||
e_type_key_reg(Arch arch, REGS_RegCode code)
|
||||
e_type_key_reg(Arch arch, ARCH_RegCode code)
|
||||
{
|
||||
E_TypeKey key = {E_TypeKeyKind_Reg};
|
||||
key.u32[0] = (U32)arch;
|
||||
@@ -296,15 +296,6 @@ e_type_key_reg(Arch arch, REGS_RegCode code)
|
||||
return key;
|
||||
}
|
||||
|
||||
internal E_TypeKey
|
||||
e_type_key_reg_alias(Arch arch, REGS_AliasCode code)
|
||||
{
|
||||
E_TypeKey key = {E_TypeKeyKind_RegAlias};
|
||||
key.u32[0] = (U32)arch;
|
||||
key.u32[1] = (U32)code;
|
||||
return key;
|
||||
}
|
||||
|
||||
//- rjf: constructed type construction
|
||||
|
||||
internal U64
|
||||
@@ -625,7 +616,6 @@ e_type_kind_from_key(E_TypeKey key)
|
||||
case E_TypeKeyKind_Ext: {kind = (E_TypeKind)key.u32[0];}break;
|
||||
case E_TypeKeyKind_Cons: {kind = (E_TypeKind)key.u32[0];}break;
|
||||
case E_TypeKeyKind_Reg: {kind = E_TypeKind_Union;}break;
|
||||
case E_TypeKeyKind_RegAlias:{kind = E_TypeKind_Union;}break;
|
||||
}
|
||||
return kind;
|
||||
}
|
||||
@@ -1100,16 +1090,10 @@ e_push_type_from_key(Arena *arena, E_TypeKey key)
|
||||
case E_TypeKeyKind_Reg:
|
||||
{
|
||||
Arch arch = (Arch)key.u32[0];
|
||||
REGS_RegCode code = (REGS_RegCode)key.u32[1];
|
||||
REGS_Rng rng = regs_reg_code_rng_table_from_arch(arch)[code];
|
||||
reg_byte_count = (U64)rng.byte_size;
|
||||
}goto build_reg_type;
|
||||
case E_TypeKeyKind_RegAlias:
|
||||
{
|
||||
Arch arch = (Arch)key.u32[0];
|
||||
REGS_AliasCode code = (REGS_AliasCode)key.u32[1];
|
||||
REGS_Slice slice = regs_alias_code_slice_table_from_arch(arch)[code];
|
||||
reg_byte_count = (U64)slice.byte_size;
|
||||
ARCH_Info *arch_info = arch_info_from_arch(arch);
|
||||
ARCH_RegCode code = (ARCH_RegCode)key.u32[1];
|
||||
Rng1U16 rng = arch_info->reg_code_rng_table[code];
|
||||
reg_byte_count = (U64)dim_1u16(rng);
|
||||
}goto build_reg_type;
|
||||
build_reg_type:
|
||||
{
|
||||
@@ -3117,23 +3101,23 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(folder)
|
||||
String8List folder_paths = {0};
|
||||
String8List file_paths = {0};
|
||||
{
|
||||
OS_FileIter *iter = os_file_iter_begin(scratch.arena, folder_path, 0);
|
||||
for(OS_FileInfo info = {0}; os_file_iter_next(scratch.arena, iter, &info);)
|
||||
FileIter *iter = file_iter_begin(scratch.arena, folder_path, 0);
|
||||
for(FileInfo info = {0}; file_iter_next(scratch.arena, iter, &info);)
|
||||
{
|
||||
FuzzyMatchRangeList matches = fuzzy_match_find(scratch.arena, local_filter, info.name);
|
||||
if(matches.count == matches.needle_part_count)
|
||||
{
|
||||
if(info.props.flags & FilePropertyFlag_IsFolder)
|
||||
{
|
||||
str8_list_push(scratch.arena, &folder_paths, push_str8_copy(arena, info.name));
|
||||
str8_list_push(scratch.arena, &folder_paths, str8_copy(arena, info.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
str8_list_push(scratch.arena, &file_paths, push_str8_copy(arena, info.name));
|
||||
str8_list_push(scratch.arena, &file_paths, str8_copy(arena, info.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
os_file_iter_end(iter);
|
||||
file_iter_end(iter);
|
||||
}
|
||||
|
||||
//- rjf: build accelerator
|
||||
@@ -3252,7 +3236,7 @@ E_TYPE_IREXT_FUNCTION_DEF(file)
|
||||
|
||||
//- rjf: fill accel
|
||||
accel->file_path = push_str8_copy(arena, file_path);
|
||||
accel->props = os_properties_from_file_path(file_path);
|
||||
accel->props = properties_from_file_path(file_path);
|
||||
accel->fields = str8_array_from_list(arena, &fields);
|
||||
|
||||
scratch_end(scratch);
|
||||
|
||||
@@ -71,8 +71,7 @@ internal E_EnumValArray e_enum_val_array_from_list(Arena *arena, E_EnumValList *
|
||||
internal E_TypeKey e_type_key_zero(void);
|
||||
internal E_TypeKey e_type_key_basic(E_TypeKind kind);
|
||||
internal E_TypeKey e_type_key_ext(E_TypeKind kind, U32 type_idx, U32 rdi_num);
|
||||
internal E_TypeKey e_type_key_reg(Arch arch, REGS_RegCode code);
|
||||
internal E_TypeKey e_type_key_reg_alias(Arch arch, REGS_AliasCode code);
|
||||
internal E_TypeKey e_type_key_reg(Arch arch, ARCH_RegCode code);
|
||||
|
||||
//- rjf: constructed type construction
|
||||
internal U64 e_hash_from_cons_type_params(E_ConsTypeParams *params);
|
||||
|
||||
Reference in New Issue
Block a user