aboutsummaryrefslogtreecommitdiff
path: root/src/types.cpp
diff options
context:
space:
mode:
authorAndreas T Jonsson <mail@andreasjonsson.se>2024-05-10 09:04:52 +0200
committerAndreas T Jonsson <mail@andreasjonsson.se>2024-05-10 09:04:52 +0200
commitb72c2edabbc9087b07a30b781de1925d6570dd62 (patch)
tree0e96f43038901ec8c6f6b015071c1803a2166d41 /src/types.cpp
parent273e4c6b4ce6f1060870782c8e780fe2b371ede4 (diff)
parent41bd8cf7143902db59c02c56fc5318a7e749d7a5 (diff)
Merge branch 'master' into netbsd
Diffstat (limited to 'src/types.cpp')
-rw-r--r--src/types.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp
index 18cb12ea1..30e009086 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -184,6 +184,8 @@ struct TypeProc {
isize specialization_count;
ProcCallingConvention calling_convention;
i32 variadic_index;
+ String require_target_feature;
+ String enable_target_feature;
// TODO(bill): Make this a flag set rather than bools
bool variadic;
bool require_results;
@@ -2991,7 +2993,22 @@ gb_internal Type *union_tag_type(Type *u) {
return t_uint;
}
+gb_internal int matched_target_features(TypeProc *t) {
+ if (t->require_target_feature.len == 0) {
+ return 0;
+ }
+ int matches = 0;
+ String_Iterator it = {t->require_target_feature, 0};
+ for (;;) {
+ String str = string_split_iterator(&it, ',');
+ if (str == "") break;
+ if (check_target_feature_is_valid_for_target_arch(str, nullptr)) {
+ matches += 1;
+ }
+ }
+ return matches;
+}
enum ProcTypeOverloadKind {
ProcOverload_Identical, // The types are identical
@@ -3003,6 +3020,7 @@ enum ProcTypeOverloadKind {
ProcOverload_ResultCount,
ProcOverload_ResultTypes,
ProcOverload_Polymorphic,
+ ProcOverload_TargetFeatures,
ProcOverload_NotProcedure,
@@ -3060,6 +3078,10 @@ gb_internal ProcTypeOverloadKind are_proc_types_overload_safe(Type *x, Type *y)
}
}
+ if (matched_target_features(&px) != matched_target_features(&py)) {
+ return ProcOverload_TargetFeatures;
+ }
+
if (px.params != nullptr && py.params != nullptr) {
Entity *ex = px.params->Tuple.variables[0];
Entity *ey = py.params->Tuple.variables[0];
@@ -3245,6 +3267,10 @@ gb_internal Selection lookup_field_with_selection(Type *type_, String field_name
}
}
+ if (is_type_polymorphic(type)) {
+ // NOTE(bill): A polymorphic struct has no fields, this only hits in the case of an error
+ return sel;
+ }
wait_signal_until_available(&type->Struct.fields_wait_signal);
isize field_count = type->Struct.fields.count;
if (field_count != 0) for_array(i, type->Struct.fields) {