mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 22:28:46 +00:00
Flesh out debug procedure type
This commit is contained in:
+1
-1
@@ -941,7 +941,7 @@ TB_API void tb_inst_memcpy(TB_Function* f, TB_Node* dst, TB_Node* src, TB_Node*
|
|||||||
// result = base + (index * stride)
|
// result = base + (index * stride)
|
||||||
TB_API TB_Node* tb_inst_array_access(TB_Function* f, TB_Node* base, TB_Node* index, int64_t stride);
|
TB_API TB_Node* tb_inst_array_access(TB_Function* f, TB_Node* base, TB_Node* index, int64_t stride);
|
||||||
|
|
||||||
// result = base +
|
// result = base + offset
|
||||||
// where base is a pointer
|
// where base is a pointer
|
||||||
TB_API TB_Node* tb_inst_member_access(TB_Function* f, TB_Node* base, int64_t offset);
|
TB_API TB_Node* tb_inst_member_access(TB_Function* f, TB_Node* base, int64_t offset);
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,8 @@ struct cgProcedure {
|
|||||||
bool is_entry_point;
|
bool is_entry_point;
|
||||||
bool is_startup;
|
bool is_startup;
|
||||||
|
|
||||||
|
TB_DebugType *debug_type;
|
||||||
|
|
||||||
cgValue value;
|
cgValue value;
|
||||||
|
|
||||||
Ast *curr_stmt;
|
Ast *curr_stmt;
|
||||||
|
|||||||
+23
-3
@@ -12,6 +12,20 @@ gb_internal TB_DebugType *cg_debug_type(cgModule *m, Type *type) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gb_internal TB_DebugType *cg_debug_type_for_proc(cgModule *m, Type *type) {
|
||||||
|
GB_ASSERT(is_type_proc(type));
|
||||||
|
TB_DebugType **func_found = nullptr;
|
||||||
|
TB_DebugType *func_ptr = cg_debug_type(m, type);
|
||||||
|
GB_ASSERT(func_ptr != nullptr);
|
||||||
|
|
||||||
|
mutex_lock(&m->debug_type_mutex);
|
||||||
|
func_found = map_get(&m->proc_debug_type_map, type);
|
||||||
|
mutex_unlock(&m->debug_type_mutex);
|
||||||
|
GB_ASSERT(func_found != nullptr);
|
||||||
|
return *func_found;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gb_internal TB_DebugType *cg_debug_type_internal_record(cgModule *m, Type *type, String const &record_name) {
|
gb_internal TB_DebugType *cg_debug_type_internal_record(cgModule *m, Type *type, String const &record_name) {
|
||||||
Type *bt = base_type(type);
|
Type *bt = base_type(type);
|
||||||
switch (bt->kind) {
|
switch (bt->kind) {
|
||||||
@@ -345,7 +359,7 @@ gb_internal TB_DebugType *cg_debug_type_internal(cgModule *m, Type *type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_odin_cc) {
|
if (pt->calling_convention == ProcCC_Odin) {
|
||||||
// `context` ptr
|
// `context` ptr
|
||||||
param_count += 1;
|
param_count += 1;
|
||||||
}
|
}
|
||||||
@@ -406,8 +420,14 @@ gb_internal TB_DebugType *cg_debug_type_internal(cgModule *m, Type *type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GB_ASSERT(param_index == param_count);
|
if (pt->calling_convention == ProcCC_Odin) {
|
||||||
GB_ASSERT(return_index == return_count);
|
Type *type = t_context_ptr;
|
||||||
|
String name = str_lit("__.context_ptr");
|
||||||
|
params[param_index++] = tb_debug_create_field(m->mod, cg_debug_type(m, type), name.len, cast(char const *)name.text, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
GB_ASSERT_MSG(param_index == param_count, "%td vs %td for %s", param_index, param_count, type_to_string(type));
|
||||||
|
GB_ASSERT_MSG(return_index == return_count, "%td vs %td for %s", return_index, return_count, type_to_string(type));
|
||||||
|
|
||||||
return func_ptr;
|
return func_ptr;
|
||||||
}
|
}
|
||||||
|
|||||||
+20
-4
@@ -326,8 +326,16 @@ gb_internal cgProcedure *cg_procedure_create(cgModule *m, Entity *entity, bool i
|
|||||||
if (p->symbol == nullptr) {
|
if (p->symbol == nullptr) {
|
||||||
TB_Arena *arena = tb_default_arena();
|
TB_Arena *arena = tb_default_arena();
|
||||||
p->func = tb_function_create(m->mod, link_name.len, cast(char const *)link_name.text, linkage, TB_COMDAT_NONE);
|
p->func = tb_function_create(m->mod, link_name.len, cast(char const *)link_name.text, linkage, TB_COMDAT_NONE);
|
||||||
p->proto = cg_procedure_type_as_prototype(m, p->type);
|
|
||||||
tb_function_set_prototype(p->func, p->proto, arena);
|
// p->proto = cg_procedure_type_as_prototype(m, p->type);
|
||||||
|
// tb_function_set_prototype(p->func, p->proto, arena);
|
||||||
|
|
||||||
|
size_t out_param_count = 0;
|
||||||
|
p->debug_type = cg_debug_type_for_proc(m, p->type);
|
||||||
|
TB_Node **params = tb_function_set_prototype_from_dbg(p->func, p->debug_type, arena, &out_param_count);
|
||||||
|
gb_unused(params);
|
||||||
|
p->proto = tb_function_get_prototype(p->func);
|
||||||
|
|
||||||
p->symbol = cast(TB_Symbol *)p->func;
|
p->symbol = cast(TB_Symbol *)p->func;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,8 +381,16 @@ gb_internal cgProcedure *cg_procedure_create_dummy(cgModule *m, String const &li
|
|||||||
|
|
||||||
TB_Arena *arena = tb_default_arena();
|
TB_Arena *arena = tb_default_arena();
|
||||||
p->func = tb_function_create(m->mod, link_name.len, cast(char const *)link_name.text, linkage, TB_COMDAT_NONE);
|
p->func = tb_function_create(m->mod, link_name.len, cast(char const *)link_name.text, linkage, TB_COMDAT_NONE);
|
||||||
p->proto = cg_procedure_type_as_prototype(m, p->type);
|
|
||||||
tb_function_set_prototype(p->func, p->proto, arena);
|
// p->proto = cg_procedure_type_as_prototype(m, p->type);
|
||||||
|
// tb_function_set_prototype(p->func, p->proto, arena);
|
||||||
|
size_t out_param_count = 0;
|
||||||
|
p->debug_type = cg_debug_type_for_proc(m, p->type);
|
||||||
|
TB_Node **params = tb_function_set_prototype_from_dbg(p->func, p->debug_type, arena, &out_param_count);
|
||||||
|
gb_unused(params);
|
||||||
|
p->proto = tb_function_get_prototype(p->func);
|
||||||
|
|
||||||
|
|
||||||
p->symbol = cast(TB_Symbol *)p->func;
|
p->symbol = cast(TB_Symbol *)p->func;
|
||||||
|
|
||||||
cgValue proc_value = cg_value(p->symbol, p->type);
|
cgValue proc_value = cg_value(p->symbol, p->type);
|
||||||
|
|||||||
Reference in New Issue
Block a user