aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_proc.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2024-05-05 21:50:57 +0100
committerGitHub <noreply@github.com>2024-05-05 21:50:57 +0100
commit15f7148eae89a36696916e15ed4c83fb7fed01c5 (patch)
tree1b743cb73db6ee1e5849820739c535e5a36f917f /src/llvm_backend_proc.cpp
parent1e5267c8e7ab1777e6691d28b4cf84f62c5e1871 (diff)
parent25f1d0906d2b5a8276c3832783970a798c12cc6c (diff)
Merge pull request #3526 from laytan/target-features
Improve target features support
Diffstat (limited to 'src/llvm_backend_proc.cpp')
-rw-r--r--src/llvm_backend_proc.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp
index f73698d34..898c9ac31 100644
--- a/src/llvm_backend_proc.cpp
+++ b/src/llvm_backend_proc.cpp
@@ -177,17 +177,24 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
break;
}
- if (!entity->Procedure.target_feature_disabled &&
- entity->Procedure.target_feature.len != 0) {
- auto features = split_by_comma(entity->Procedure.target_feature);
- for_array(i, features) {
- String feature = features[i];
- LLVMAttributeRef ref = LLVMCreateStringAttribute(
- m->ctx,
- cast(char const *)feature.text, cast(unsigned)feature.len,
- "", 0);
- LLVMAddAttributeAtIndex(p->value, LLVMAttributeIndex_FunctionIndex, ref);
+ if (pt->Proc.enable_target_feature.len != 0) {
+ gbString feature_str = gb_string_make(temporary_allocator(), "");
+
+ String_Iterator it = {pt->Proc.enable_target_feature, 0};
+ bool first = true;
+ for (;;) {
+ String str = string_split_iterator(&it, ',');
+ if (str == "") break;
+ if (!first) {
+ feature_str = gb_string_appendc(feature_str, ",");
+ }
+ first = false;
+
+ feature_str = gb_string_appendc(feature_str, "+");
+ feature_str = gb_string_append_length(feature_str, str.text, str.len);
}
+
+ lb_add_attribute_to_proc_with_string(m, p->value, make_string_c("target-features"), make_string_c(feature_str));
}
if (entity->flags & EntityFlag_Cold) {