diff options
| author | gingerBill <bill@gingerbill.org> | 2022-05-30 14:53:12 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-05-30 14:53:12 +0100 |
| commit | f3aefbc4434b92fc3fda74c942c953b08dd18a62 (patch) | |
| tree | d13281680a7cd14ce92630cb9d3a49c984b2a888 /src/llvm_backend_proc.cpp | |
| parent | cef022539ebd41a4a80707f1a702e09e6748ade0 (diff) | |
`@(require_target_feature=<string>)` `@(enable_target_feature=<string>)`
require_target_feature - required by the target micro-architecture
enable_target_feature - will be enabled for the specified procedure only
Diffstat (limited to 'src/llvm_backend_proc.cpp')
| -rw-r--r-- | src/llvm_backend_proc.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 1e3591bf1..296a7fa6b 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -169,6 +169,19 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) } } + 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 (entity->flags & EntityFlag_Cold) { lb_add_attribute_to_proc(m, p->value, "cold"); } |