mirror of
https://github.com/odin-lang/Odin.git
synced 2026-10-09 14:22:18 -04:00
Support enable_target_feature and require_target_feature for asm templates
This commit is contained in:
1 parent
df3b988db8
commit
07b5c2ee0f
11 files changed
+162
-58
No files matched your search
+12
-8
@@ -9150,25 +9150,29 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
if (pt->kind == Type_Proc) {
|
||||
char const *kind = "procedure";
|
||||
if (pt->Proc.calling_convention == ProcCC_InlineAsm) {
|
||||
kind = "inline 'asm' template";
|
||||
}
|
||||
String invalid;
|
||||
if (pt->kind == Type_Proc && pt->Proc.require_target_feature.len != 0) {
|
||||
if (pt->Proc.require_target_feature.len != 0) {
|
||||
if (!check_target_feature_is_valid_for_target_arch(pt->Proc.require_target_feature, &invalid)) {
|
||||
error(call, "Called procedure requires target feature '%.*s' which is invalid for the build target", LIT(invalid));
|
||||
error(call, "Called %s requires target feature '%.*s' which is invalid for the build target", kind, LIT(invalid));
|
||||
} else if (!check_target_feature_is_enabled(pt->Proc.require_target_feature, &invalid)) {
|
||||
error(call, "Calling this procedure requires target feature '%.*s' to be enabled", LIT(invalid));
|
||||
error(call, "Calling this %s requires target feature '%.*s' to be enabled", kind, LIT(invalid));
|
||||
}
|
||||
}
|
||||
|
||||
if (pt->kind == Type_Proc && pt->Proc.enable_target_feature.len != 0) {
|
||||
if (pt->Proc.enable_target_feature.len != 0) {
|
||||
if (!check_target_feature_is_valid_for_target_arch(pt->Proc.enable_target_feature, &invalid)) {
|
||||
error(call, "Called procedure enables target feature '%.*s' which is invalid for the build target", LIT(invalid));
|
||||
error(call, "Called %s enables target feature '%.*s' which is invalid for the build target", kind, LIT(invalid));
|
||||
}
|
||||
|
||||
// NOTE: Due to restrictions in LLVM you can not inline calls with a superset of features.
|
||||
if (is_call_inlined) {
|
||||
if (c->curr_proc_decl == nullptr) {
|
||||
error(call, "Calling a '#force_inline' procedure that enables target features is not allowed at file scope");
|
||||
error(call, "Calling a '#force_inline' %s that enables target features is not allowed at file scope", kind);
|
||||
} else {
|
||||
Entity *e = c->curr_proc_decl->entity.load();
|
||||
GB_ASSERT(e);
|
||||
@@ -9176,7 +9180,7 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c
|
||||
String scope_features = e->type->Proc.enable_target_feature;
|
||||
if (!check_target_feature_is_superset_of(scope_features, pt->Proc.enable_target_feature, &invalid)) {
|
||||
ERROR_BLOCK();
|
||||
error(call, "Inlined procedure enables target feature '%.*s', this requires the calling procedure to at least enable the same feature", LIT(invalid));
|
||||
error(call, "Inlined %s enables target feature '%.*s', this requires the calling %s to at least enable the same feature", kind, LIT(invalid), kind);
|
||||
|
||||
error_line("\tSuggested Example: @(enable_target_feature=\"%.*s\")\n", LIT(invalid));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user