mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Correct parapoly for #simd
This commit is contained in:
@@ -1328,6 +1328,19 @@ bool is_polymorphic_type_assignable(CheckerContext *c, Type *poly, Type *source,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
case Type_SimdVector:
|
||||||
|
if (source->kind == Type_SimdVector) {
|
||||||
|
if (poly->SimdVector.generic_count != nullptr) {
|
||||||
|
if (!polymorphic_assign_index(&poly->SimdVector.generic_count, &poly->SimdVector.count, source->SimdVector.count)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (poly->SimdVector.count == source->SimdVector.count) {
|
||||||
|
return is_polymorphic_type_assignable(c, poly->SimdVector.elem, source->SimdVector.elem, true, modify_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -2803,14 +2803,14 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t
|
|||||||
goto array_end;
|
goto array_end;
|
||||||
}
|
}
|
||||||
if (is_type_polymorphic(elem)) {
|
if (is_type_polymorphic(elem)) {
|
||||||
count = 1;
|
// Ignore
|
||||||
} else if (count < 1 || !is_power_of_two(count)) {
|
} else if (count < 1 || !is_power_of_two(count)) {
|
||||||
error(at->count, "Invalid length for 'intrinsics.simd_vector', expected a power of two length, got '%lld'", cast(long long)count);
|
error(at->count, "Invalid length for 'intrinsics.simd_vector', expected a power of two length, got '%lld'", cast(long long)count);
|
||||||
*type = alloc_type_array(elem, count, generic_type);
|
*type = alloc_type_array(elem, count, generic_type);
|
||||||
goto array_end;
|
goto array_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
*type = alloc_type_simd_vector(count, elem);
|
*type = alloc_type_simd_vector(count, elem, generic_type);
|
||||||
} else {
|
} else {
|
||||||
error(at->tag, "Invalid tag applied to array, got #%.*s", LIT(name));
|
error(at->tag, "Invalid tag applied to array, got #%.*s", LIT(name));
|
||||||
*type = alloc_type_array(elem, count, generic_type);
|
*type = alloc_type_array(elem, count, generic_type);
|
||||||
|
|||||||
+8
-1
@@ -261,6 +261,7 @@ struct TypeProc {
|
|||||||
TYPE_KIND(SimdVector, struct { \
|
TYPE_KIND(SimdVector, struct { \
|
||||||
i64 count; \
|
i64 count; \
|
||||||
Type *elem; \
|
Type *elem; \
|
||||||
|
Type *generic_count; \
|
||||||
}) \
|
}) \
|
||||||
TYPE_KIND(RelativePointer, struct { \
|
TYPE_KIND(RelativePointer, struct { \
|
||||||
Type *pointer_type; \
|
Type *pointer_type; \
|
||||||
@@ -1085,10 +1086,11 @@ Type *alloc_type_bit_set() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Type *alloc_type_simd_vector(i64 count, Type *elem) {
|
Type *alloc_type_simd_vector(i64 count, Type *elem, Type *generic_count=nullptr) {
|
||||||
Type *t = alloc_type(Type_SimdVector);
|
Type *t = alloc_type(Type_SimdVector);
|
||||||
t->SimdVector.count = count;
|
t->SimdVector.count = count;
|
||||||
t->SimdVector.elem = elem;
|
t->SimdVector.elem = elem;
|
||||||
|
t->SimdVector.generic_count = generic_count;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2078,6 +2080,11 @@ bool is_type_polymorphic(Type *t, bool or_specialized=false) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return is_type_polymorphic(t->Array.elem, or_specialized);
|
return is_type_polymorphic(t->Array.elem, or_specialized);
|
||||||
|
case Type_SimdVector:
|
||||||
|
if (t->SimdVector.generic_count != nullptr) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return is_type_polymorphic(t->SimdVector.elem, or_specialized);
|
||||||
case Type_DynamicArray:
|
case Type_DynamicArray:
|
||||||
return is_type_polymorphic(t->DynamicArray.elem, or_specialized);
|
return is_type_polymorphic(t->DynamicArray.elem, or_specialized);
|
||||||
case Type_Slice:
|
case Type_Slice:
|
||||||
|
|||||||
Reference in New Issue
Block a user