mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Fix lb_add_proc_attribute_at_index
This commit is contained in:
+17
-7
@@ -1082,10 +1082,21 @@ void lb_add_procedure_value(lbModule *m, lbProcedure *p) {
|
|||||||
|
|
||||||
|
|
||||||
lbValue lb_emit_string(lbProcedure *p, lbValue str_elem, lbValue str_len) {
|
lbValue lb_emit_string(lbProcedure *p, lbValue str_elem, lbValue str_len) {
|
||||||
lbAddr res = lb_add_local_generated(p, t_string, false);
|
if (lb_is_const(str_elem) && lb_is_const(str_len)) {
|
||||||
lb_emit_store(p, lb_emit_struct_ep(p, res.addr, 0), str_elem);
|
LLVMValueRef values[2] = {
|
||||||
lb_emit_store(p, lb_emit_struct_ep(p, res.addr, 1), str_len);
|
str_elem.value,
|
||||||
return lb_addr_load(p, res);
|
str_len.value,
|
||||||
|
};
|
||||||
|
lbValue res = {};
|
||||||
|
res.type = t_string;
|
||||||
|
res.value = LLVMConstNamedStruct(lb_type(p->module, t_string), values, gb_count_of(values));
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
|
lbAddr res = lb_add_local_generated(p, t_string, false);
|
||||||
|
lb_emit_store(p, lb_emit_struct_ep(p, res.addr, 0), str_elem);
|
||||||
|
lb_emit_store(p, lb_emit_struct_ep(p, res.addr, 1), str_len);
|
||||||
|
return lb_addr_load(p, res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, u64 value) {
|
LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, u64 value) {
|
||||||
@@ -1094,12 +1105,11 @@ LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name, u64 value) {
|
void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name, u64 value) {
|
||||||
LLVMContextRef ctx = LLVMGetModuleContext(p->module->mod);
|
LLVMAddAttributeAtIndex(p->value, cast(unsigned)index, lb_create_enum_attribute(p->module->ctx, name, value));
|
||||||
// LLVMAddAttributeAtIndex(p->value, cast(unsigned)index, lb_create_enum_attribute(ctx, name, value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name) {
|
void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, char const *name) {
|
||||||
lb_add_proc_attribute_at_index(p, index, name, true);
|
lb_add_proc_attribute_at_index(p, index, name, cast(u64)true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user