mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-26 23:11:32 +00:00
Merge branch 'master' of https://github.com/LeonardoTemperanza/Odin
This commit is contained in:
@@ -186,9 +186,32 @@ gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
|
||||
lb_init_module(pm, do_threading);
|
||||
}
|
||||
|
||||
if (pkg->kind == Package_Runtime) {
|
||||
// allow this to be per file
|
||||
} else if (!module_per_file) {
|
||||
bool allow_for_per_file = pkg->kind == Package_Runtime || module_per_file;
|
||||
|
||||
#if 0
|
||||
if (!allow_for_per_file) {
|
||||
if (pkg->files.count >= 20) {
|
||||
isize proc_count = 0;
|
||||
for (Entity *e : gen->info->entities) {
|
||||
if (e->kind != Entity_Procedure) {
|
||||
continue;
|
||||
}
|
||||
if (e->Procedure.is_foreign) {
|
||||
continue;
|
||||
}
|
||||
if (e->pkg == pkg) {
|
||||
proc_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (proc_count >= 300) {
|
||||
allow_for_per_file = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!allow_for_per_file) {
|
||||
continue;
|
||||
}
|
||||
// NOTE(bill): Probably per file is not a good idea, so leave this for later
|
||||
@@ -2524,29 +2547,9 @@ gb_internal LLVMAttributeRef lb_create_enum_attribute_with_type(LLVMContextRef c
|
||||
unsigned kind = 0;
|
||||
String s = make_string_c(name);
|
||||
|
||||
#if ODIN_LLVM_MINIMUM_VERSION_12
|
||||
kind = LLVMGetEnumAttributeKindForName(name, s.len);
|
||||
GB_ASSERT_MSG(kind != 0, "unknown attribute: %s", name);
|
||||
return LLVMCreateTypeAttribute(ctx, kind, type);
|
||||
#else
|
||||
// NOTE(2021-02-25, bill); All this attributes require a type associated with them
|
||||
// and the current LLVM C API does not expose this functionality yet.
|
||||
// It is better to ignore the attributes for the time being
|
||||
if (s == "byval") {
|
||||
// return nullptr;
|
||||
} else if (s == "byref") {
|
||||
return nullptr;
|
||||
} else if (s == "preallocated") {
|
||||
return nullptr;
|
||||
} else if (s == "sret") {
|
||||
// return nullptr;
|
||||
}
|
||||
|
||||
|
||||
kind = LLVMGetEnumAttributeKindForName(name, s.len);
|
||||
GB_ASSERT_MSG(kind != 0, "unknown attribute: %s", name);
|
||||
return LLVMCreateEnumAttribute(ctx, kind, 0);
|
||||
#endif
|
||||
kind = LLVMGetEnumAttributeKindForName(name, s.len);
|
||||
GB_ASSERT_MSG(kind != 0, "unknown attribute: %s", name);
|
||||
return LLVMCreateTypeAttribute(ctx, kind, type);
|
||||
}
|
||||
|
||||
gb_internal LLVMAttributeRef lb_create_enum_attribute(LLVMContextRef ctx, char const *name, u64 value) {
|
||||
@@ -2589,6 +2592,20 @@ gb_internal void lb_add_proc_attribute_at_index(lbProcedure *p, isize index, cha
|
||||
lb_add_proc_attribute_at_index(p, index, name, 0);
|
||||
}
|
||||
|
||||
gb_internal void lb_add_proc_attribute_at_index_with_string(lbProcedure *p, isize index, String const &name, String const &value) {
|
||||
LLVMAttributeRef attr = lb_create_string_attribute(p->module->ctx, name, value);
|
||||
GB_ASSERT(attr != nullptr);
|
||||
LLVMAddAttributeAtIndex(p->value, cast(unsigned)index, attr);
|
||||
}
|
||||
|
||||
gb_internal void lb_add_nocapture_proc_attribute_at_index(lbProcedure *p, isize index) {
|
||||
#if LLVM_VERSION_MAJOR >= 21
|
||||
lb_add_proc_attribute_at_index_with_string(p, index, make_string_c("captures"), make_string_c("none"));
|
||||
#else
|
||||
lb_add_proc_attribute_at_index(p, index, "nocapture");
|
||||
#endif
|
||||
}
|
||||
|
||||
gb_internal void lb_add_attribute_to_proc(lbModule *m, LLVMValueRef proc_value, char const *name, u64 value=0) {
|
||||
LLVMAddAttributeAtIndex(proc_value, LLVMAttributeIndex_FunctionIndex, lb_create_enum_attribute(m->ctx, name, value));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user