Fix bit set size with 128-bit integers

This commit is contained in:
gingerBill
2019-05-28 20:57:02 +01:00
parent c40acd008e
commit b894e2b378
2 changed files with 18 additions and 14 deletions
+2 -1
View File
@@ -948,7 +948,8 @@ void check_bit_set_type(CheckerContext *c, Type *type, Type *named_type, Ast *no
ast_node(bs, BitSetType, node); ast_node(bs, BitSetType, node);
GB_ASSERT(type->kind == Type_BitSet); GB_ASSERT(type->kind == Type_BitSet);
i64 const MAX_BITS = 64; i64 const DEFAULT_BITS = cast(i64)(8*build_context.word_size);
i64 const MAX_BITS = 128;
Ast *base = unparen_expr(bs->elem); Ast *base = unparen_expr(bs->elem);
if (is_ast_range(base)) { if (is_ast_range(base)) {
+3
View File
@@ -1243,6 +1243,7 @@ Type *bit_set_to_int(Type *t) {
case 2: return t_u16; case 2: return t_u16;
case 4: return t_u32; case 4: return t_u32;
case 8: return t_u64; case 8: return t_u64;
case 16: return t_u128;
} }
GB_PANIC("Unknown bit_set size"); GB_PANIC("Unknown bit_set size");
return nullptr; return nullptr;
@@ -2418,6 +2419,7 @@ i64 type_align_of_internal(Type *t, TypePath *path) {
if (bits <= 16) return 2; if (bits <= 16) return 2;
if (bits <= 32) return 4; if (bits <= 32) return 4;
if (bits <= 64) return 8; if (bits <= 64) return 8;
if (bits <= 128) return 16;
return 8; // NOTE(bill): Could be an invalid range so limit it for now return 8; // NOTE(bill): Could be an invalid range so limit it for now
} }
@@ -2669,6 +2671,7 @@ i64 type_size_of_internal(Type *t, TypePath *path) {
if (bits <= 16) return 2; if (bits <= 16) return 2;
if (bits <= 32) return 4; if (bits <= 32) return 4;
if (bits <= 64) return 8; if (bits <= 64) return 8;
if (bits <= 128) return 16;
return 8; // NOTE(bill): Could be an invalid range so limit it for now return 8; // NOTE(bill): Could be an invalid range so limit it for now
} }