mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Simplify procedure parameters callee logic
This commit is contained in:
@@ -267,7 +267,6 @@ struct lbProcedure {
|
|||||||
bool is_done;
|
bool is_done;
|
||||||
|
|
||||||
lbAddr return_ptr;
|
lbAddr return_ptr;
|
||||||
Array<lbValue> params;
|
|
||||||
Array<lbDefer> defer_stmts;
|
Array<lbDefer> defer_stmts;
|
||||||
Array<lbBlock *> blocks;
|
Array<lbBlock *> blocks;
|
||||||
Array<lbBranchBlocks> branch_blocks;
|
Array<lbBranchBlocks> branch_blocks;
|
||||||
|
|||||||
+19
-34
@@ -107,7 +107,6 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body)
|
|||||||
|
|
||||||
gbAllocator a = heap_allocator();
|
gbAllocator a = heap_allocator();
|
||||||
p->children.allocator = a;
|
p->children.allocator = a;
|
||||||
p->params.allocator = a;
|
|
||||||
p->defer_stmts.allocator = a;
|
p->defer_stmts.allocator = a;
|
||||||
p->blocks.allocator = a;
|
p->blocks.allocator = a;
|
||||||
p->branch_blocks.allocator = a;
|
p->branch_blocks.allocator = a;
|
||||||
@@ -323,7 +322,6 @@ lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name, Type *type
|
|||||||
|
|
||||||
gbAllocator a = permanent_allocator();
|
gbAllocator a = permanent_allocator();
|
||||||
p->children.allocator = a;
|
p->children.allocator = a;
|
||||||
p->params.allocator = a;
|
|
||||||
p->defer_stmts.allocator = a;
|
p->defer_stmts.allocator = a;
|
||||||
p->blocks.allocator = a;
|
p->blocks.allocator = a;
|
||||||
p->branch_blocks.allocator = a;
|
p->branch_blocks.allocator = a;
|
||||||
@@ -478,42 +476,29 @@ void lb_begin_procedure_body(lbProcedure *p) {
|
|||||||
if (arg_type->kind == lbArg_Ignore) {
|
if (arg_type->kind == lbArg_Ignore) {
|
||||||
continue;
|
continue;
|
||||||
} else if (arg_type->kind == lbArg_Direct) {
|
} else if (arg_type->kind == lbArg_Direct) {
|
||||||
lbParamPasskind kind = lbParamPass_Value;
|
if (e->token.string.len != 0 && !is_blank_ident(e->token.string)) {
|
||||||
LLVMTypeRef param_type = lb_type(p->module, e->type);
|
LLVMTypeRef param_type = lb_type(p->module, e->type);
|
||||||
if (param_type != arg_type->type) {
|
LLVMValueRef value = LLVMGetParam(p->value, param_offset+param_index);
|
||||||
kind = lbParamPass_BitCast;
|
|
||||||
|
value = OdinLLVMBuildTransmute(p, value, param_type);
|
||||||
|
|
||||||
|
lbValue param = {};
|
||||||
|
param.value = value;
|
||||||
|
param.type = e->type;
|
||||||
|
|
||||||
|
lbValue ptr = lb_address_from_load_or_generate_local(p, param);
|
||||||
|
lb_add_entity(p->module, e, ptr);
|
||||||
}
|
}
|
||||||
LLVMValueRef value = LLVMGetParam(p->value, param_offset+param_index);
|
|
||||||
|
|
||||||
value = OdinLLVMBuildTransmute(p, value, param_type);
|
|
||||||
|
|
||||||
lbValue param = {};
|
|
||||||
param.value = value;
|
|
||||||
param.type = e->type;
|
|
||||||
array_add(&p->params, param);
|
|
||||||
|
|
||||||
if (e->token.string.len != 0) {
|
|
||||||
lbAddr l = lb_add_local(p, e->type, e, false, param_index);
|
|
||||||
lb_addr_store(p, l, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
param_index += 1;
|
|
||||||
} else if (arg_type->kind == lbArg_Indirect) {
|
} else if (arg_type->kind == lbArg_Indirect) {
|
||||||
LLVMValueRef value_ptr = LLVMGetParam(p->value, param_offset+param_index);
|
if (e->token.string.len != 0 && !is_blank_ident(e->token.string)) {
|
||||||
LLVMValueRef value = LLVMBuildLoad(p->builder, value_ptr, "");
|
lbValue ptr = {};
|
||||||
|
ptr.value = LLVMGetParam(p->value, param_offset+param_index);
|
||||||
|
ptr.type = alloc_type_pointer(e->type);
|
||||||
|
|
||||||
lbValue param = {};
|
lb_add_entity(p->module, e, ptr);
|
||||||
param.value = value;
|
}
|
||||||
param.type = e->type;
|
|
||||||
array_add(&p->params, param);
|
|
||||||
|
|
||||||
lbValue ptr = {};
|
|
||||||
ptr.value = value_ptr;
|
|
||||||
ptr.type = alloc_type_pointer(e->type);
|
|
||||||
|
|
||||||
lb_add_entity(p->module, e, ptr);
|
|
||||||
param_index += 1;
|
|
||||||
}
|
}
|
||||||
|
param_index += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user