mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-30 09:54:45 +00:00
Add intrinsics.type_is_endian_platform
This commit is contained in:
@@ -1351,8 +1351,7 @@ bool is_type_union_maybe_pointer_original_alignment(Type *t) {
|
||||
|
||||
|
||||
|
||||
|
||||
bool is_type_integer_endian_big(Type *t) {
|
||||
bool is_type_endian_big(Type *t) {
|
||||
t = core_type(t);
|
||||
if (t->kind == Type_Basic) {
|
||||
if (t->Basic.flags & BasicFlag_EndianBig) {
|
||||
@@ -1362,15 +1361,13 @@ bool is_type_integer_endian_big(Type *t) {
|
||||
}
|
||||
return build_context.endian_kind == TargetEndian_Big;
|
||||
} else if (t->kind == Type_BitSet) {
|
||||
return is_type_integer_endian_big(bit_set_to_int(t));
|
||||
return is_type_endian_big(bit_set_to_int(t));
|
||||
} else if (t->kind == Type_Pointer) {
|
||||
return is_type_integer_endian_big(&basic_types[Basic_uintptr]);
|
||||
return is_type_endian_big(&basic_types[Basic_uintptr]);
|
||||
}
|
||||
return build_context.endian_kind == TargetEndian_Big;
|
||||
}
|
||||
|
||||
|
||||
bool is_type_integer_endian_little(Type *t) {
|
||||
bool is_type_endian_little(Type *t) {
|
||||
t = core_type(t);
|
||||
if (t->kind == Type_Basic) {
|
||||
if (t->Basic.flags & BasicFlag_EndianLittle) {
|
||||
@@ -1380,17 +1377,23 @@ bool is_type_integer_endian_little(Type *t) {
|
||||
}
|
||||
return build_context.endian_kind == TargetEndian_Little;
|
||||
} else if (t->kind == Type_BitSet) {
|
||||
return is_type_integer_endian_little(bit_set_to_int(t));
|
||||
return is_type_endian_little(bit_set_to_int(t));
|
||||
} else if (t->kind == Type_Pointer) {
|
||||
return is_type_integer_endian_little(&basic_types[Basic_uintptr]);
|
||||
return is_type_endian_little(&basic_types[Basic_uintptr]);
|
||||
}
|
||||
return build_context.endian_kind == TargetEndian_Little;
|
||||
}
|
||||
bool is_type_endian_big(Type *t) {
|
||||
return is_type_integer_endian_big(t);
|
||||
}
|
||||
bool is_type_endian_little(Type *t) {
|
||||
return is_type_integer_endian_little(t);
|
||||
|
||||
bool is_type_endian_platform(Type *t) {
|
||||
t = core_type(t);
|
||||
if (t->kind == Type_Basic) {
|
||||
return (t->Basic.flags & (BasicFlag_EndianLittle|BasicFlag_EndianBig)) == 0;
|
||||
} else if (t->kind == Type_BitSet) {
|
||||
return is_type_endian_platform(bit_set_to_int(t));
|
||||
} else if (t->kind == Type_Pointer) {
|
||||
return is_type_endian_platform(&basic_types[Basic_uintptr]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool types_have_same_internal_endian(Type *a, Type *b) {
|
||||
@@ -1446,9 +1449,9 @@ bool is_type_dereferenceable(Type *t) {
|
||||
bool is_type_different_to_arch_endianness(Type *t) {
|
||||
switch (build_context.endian_kind) {
|
||||
case TargetEndian_Little:
|
||||
return !is_type_integer_endian_little(t);
|
||||
return !is_type_endian_little(t);
|
||||
case TargetEndian_Big:
|
||||
return !is_type_integer_endian_big(t);
|
||||
return !is_type_endian_big(t);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user