export CodeView types as aliases to its builtin counter-parts,

This commit is contained in:
Nikita Smith
2025-03-27 13:47:47 -07:00
parent 53c889e5d3
commit 49ba163077
7 changed files with 175 additions and 54 deletions
+4 -6
View File
@@ -38,8 +38,8 @@ d2r_rdi_reg_from_dw_reg_code(Arch arch, U64 reg_code)
case Arch_Null: return 0;
case Arch_x64: return d2r_rdi_reg_from_dw_reg_code_x64(reg_code);
case Arch_x86: return d2r_rdi_reg_from_dw_reg_code_x86(reg_code);
default: InvalidPath;
}
InvalidPath;
return 0;
}
@@ -89,7 +89,7 @@ d2r_type_from_attrib(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, D
Assert(!"unexpected attrib class");
}
} else if (attrib->attrib_kind == DW_Attrib_Null) {
type = type_table->void_type;
type = rdim_builtin_type_from_kind(*type_table->types, RDI_TypeKind_NULL);
}
return type;
@@ -1154,7 +1154,7 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
RDIM_UnitChunkList units = {0};
RDIM_UDTChunkList udts = {0};
RDIM_TypeChunkList types = {0};
RDIM_TypeChunkList types = rdim_init_type_chunk_list(arena, arch);
RDIM_SymbolChunkList gvars = {0};
RDIM_SymbolChunkList tvars = {0};
RDIM_SymbolChunkList procs = {0};
@@ -1356,8 +1356,6 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
type_table->ht = hash_table_init(comp_temp.arena, 0x4000);
type_table->types = &types;
type_table->type_chunk_cap = TYPE_CHUNK_CAP;
type_table->void_type = d2r_create_type(arena, type_table);
type_table->void_type->kind = RDI_TypeKind_Void;
type_table->varg_type = d2r_create_type(arena, type_table);
type_table->varg_type->kind = RDI_TypeKind_Variadic;
@@ -1597,7 +1595,7 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
default: AssertAlways(!"unexpected base type encoding"); break; // TODO: error handling
}
RDIM_Type *base_type = d2r_create_type(arena, type_table);
RDIM_Type *base_type = rdim_builtin_type_from_kind(types, kind);
base_type->kind = kind;
base_type->byte_size = byte_size;
-1
View File
@@ -9,7 +9,6 @@ typedef struct D2R_TypeTable
HashTable *ht;
RDIM_TypeChunkList *types;
U64 type_chunk_cap;
RDIM_Type *void_type;
RDIM_Type *varg_type;
} D2R_TypeTable;
+21 -38
View File
@@ -2445,27 +2445,24 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
// from regular type info.
//
RDIM_Type **itype_type_ptrs = 0;
RDIM_TypeChunkList all_types = {0};
RDIM_TypeChunkList all_types = rdim_init_type_chunk_list(arena, arch);
#define p2r_type_ptr_from_itype(itype) (((itype) < tpi_leaf->itype_opl) ? itype_type_ptrs[itype] : 0)
if(in->flags & RC_Flag_Types) ProfScope("types pass 1: construct all root/stub types from TPI")
{
itype_type_ptrs = push_array(arena, RDIM_Type *, tpi_leaf->itype_opl);
//////////////////////////
//- build basic type
//- build basic types
//
{
RDIM_DataModel data_model = rdim_infer_data_model(OperatingSystem_Windows, top_level_info.arch);
RDI_TypeKind short_type = rdim_short_type_from_data_model(data_model);
RDI_TypeKind ushort_type = rdim_unsigned_short_type_from_data_model(data_model);
RDI_TypeKind int_type = rdim_int_type_from_data_model(data_model);
RDI_TypeKind uint_type = rdim_unsigned_int_type_from_data_model(data_model);
RDI_TypeKind long_type = rdim_long_type_from_data_model(data_model);
RDI_TypeKind ulong_type = rdim_unsigned_long_type_from_data_model(data_model);
RDI_TypeKind long_long_type = rdim_long_long_type_from_data_model(data_model);
RDI_TypeKind ulong_long_type = rdim_unsigned_long_long_type_from_data_model(data_model);
RDI_TypeKind ptr_type = rdim_pointer_size_t_type_from_data_model(data_model);
RDIM_DataModel data_model = rdim_infer_data_model(OperatingSystem_Windows, top_level_info.arch);
RDI_TypeKind short_type = rdim_short_type_from_data_model(data_model);
RDI_TypeKind long_type = rdim_long_type_from_data_model(data_model);
RDI_TypeKind long_long_type = rdim_long_long_type_from_data_model(data_model);
RDI_TypeKind ushort_type = rdim_unsigned_short_type_from_data_model(data_model);
RDI_TypeKind ulong_type = rdim_unsigned_long_type_from_data_model(data_model);
RDI_TypeKind ulong_long_type = rdim_unsigned_long_long_type_from_data_model(data_model);
RDI_TypeKind ptr_type = rdim_pointer_size_t_type_from_data_model(data_model);
struct
{
@@ -2508,8 +2505,8 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
{ "__uint8" , RDI_TypeKind_U8 , CV_BasicType_UINT8 , 1, 1, 1 },
{ "__int16" , RDI_TypeKind_S16 , CV_BasicType_INT16 , 1, 1, 1 },
{ "__uint16" , RDI_TypeKind_U16 , CV_BasicType_UINT16 , 1, 1, 1 },
{ "int" , int_type , CV_BasicType_INT32 , 1, 1, 1 },
{ "unsigned int" , uint_type , CV_BasicType_UINT32 , 1, 1, 1 },
{ "int" , RDI_TypeKind_S32 , CV_BasicType_INT32 , 1, 1, 1 },
{ "unsigned int" , RDI_TypeKind_U32 , CV_BasicType_UINT32 , 1, 1, 1 },
{ "__int64" , RDI_TypeKind_S64 , CV_BasicType_INT64 , 1, 1, 1 },
{ "__uint64" , RDI_TypeKind_U64 , CV_BasicType_UINT64 , 1, 1, 1 },
{ "__int128" , RDI_TypeKind_S128 , CV_BasicType_INT128 , 1, 1, 1 },
@@ -2524,22 +2521,11 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
for(U64 i = 0; i < ArrayCount(table); i += 1)
{
U64 builtin_size;
if(table[i].kind_rdi == RDI_TypeKind_Void || table[i].kind_rdi == RDI_TypeKind_Handle)
{
builtin_size = arch_addr_size;
}
else
{
builtin_size = rdi_size_from_basic_type_kind(table[i].kind_rdi);
}
RDIM_Type *builtin = rdim_type_chunk_list_push(arena, &all_types, tpi_leaf->itype_opl);
builtin->kind = table[i].kind_rdi;
builtin->name = str8_cstring(table[i].name);
builtin->byte_size = builtin_size;
itype_type_ptrs[table[i].kind_cv] = builtin;
RDIM_Type *type = rdim_type_chunk_list_push(arena, &all_types, tpi_leaf->itype_opl);
type->kind = RDI_TypeKind_Alias;
type->name = str8_cstring(table[i].name);
type->direct_type = rdim_builtin_type_from_kind(all_types, table[i].kind_rdi);
itype_type_ptrs[table[i].kind_cv] = type;
if(table[i].make_pointer_near)
{
@@ -2547,8 +2533,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
RDIM_Type *ptr_near = rdim_type_chunk_list_push(arena, &all_types, tpi_leaf->itype_opl);
ptr_near->kind = RDI_TypeKind_Ptr;
ptr_near->byte_size = 2;
ptr_near->direct_type = builtin;
ptr_near->direct_type = type;
itype_type_ptrs[near_ptr_itype] = ptr_near;
}
if(table[i].make_pointer_32)
@@ -2557,8 +2542,7 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
RDIM_Type *ptr_32 = rdim_type_chunk_list_push(arena, &all_types, tpi_leaf->itype_opl);
ptr_32->kind = RDI_TypeKind_Ptr;
ptr_32->byte_size = 4;
ptr_32->direct_type = builtin;
ptr_32->direct_type = type;
itype_type_ptrs[ptr_32_itype] = ptr_32;
}
if(table[i].make_pointer_64)
@@ -2567,15 +2551,14 @@ p2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
RDIM_Type *ptr_64 = rdim_type_chunk_list_push(arena, &all_types, tpi_leaf->itype_opl);
ptr_64->kind = RDI_TypeKind_Ptr;
ptr_64->byte_size = 8;
ptr_64->direct_type = builtin;
ptr_64->direct_type = type;
itype_type_ptrs[ptr_64_itype] = ptr_64;
}
}
}
//////////////////////////
//- rjf: build non-basic type
//- rjf: build complex type
//
for(CV_TypeId itype = tpi_leaf->itype_first; itype < tpi_leaf->itype_opl; itype += 1)
{