Remove u128 and i128

This commit is contained in:
gingerBill
2018-01-13 22:26:37 +00:00
parent 37790c13a0
commit 6b3c4cc379
16 changed files with 249 additions and 252 deletions
+29 -28
View File
@@ -793,7 +793,7 @@ bool is_polymorphic_type_assignable(Checker *c, Type *poly, Type *source, bool c
if (e->Constant.value.kind != ExactValue_Integer) {
return false;
}
i64 count = i128_to_i64(e->Constant.value.value_integer);
i64 count = e->Constant.value.value_integer;
if (count != source->Array.count) {
return false;
}
@@ -1211,37 +1211,39 @@ bool check_representable_as_constant(Checker *c, ExactValue in_value, Type *type
return true;
}
i128 i = v.value_integer;
u128 u = *cast(u128 *)&i;
i64 i = v.value_integer;
u64 u = *cast(u64 *)&i;
i64 s = 8*type_size_of(c->allocator, type);
u128 umax = U128_NEG_ONE;
if (s < 128) {
umax = u128_sub(u128_shl(U128_ONE, cast(u32)s), U128_ONE);
u64 umax = ~cast(u64)0ull;
if (s < 64) {
umax = (1ull << cast(u64)s) - 1ull;
} else {
// IMPORTANT TODO(bill): I NEED A PROPER BIG NUMBER LIBRARY THAT CAN SUPPORT 128 bit floats
s = 128;
s = 64;
}
i128 imax = i128_shl(I128_ONE, cast(u32)s-1);
i64 imin = -1ll << (s-1ll);
i64 imax = (1ll << (s-1ll))-1ll;
switch (type->Basic.kind) {
case Basic_rune:
case Basic_i8:
case Basic_i16:
case Basic_i32:
case Basic_i64:
case Basic_i128:
case Basic_int:
return i128_le(i128_neg(imax), i) && i128_le(i, i128_sub(imax, I128_ONE));
return imin <= i && i <= imax;
case Basic_u8:
case Basic_u16:
case Basic_u32:
case Basic_u64:
case Basic_u128:
case Basic_uint:
case Basic_uintptr:
return !(u128_lt(u, U128_ZERO) || u128_gt(u, umax));
return !(u < 0ull || u > umax);
case Basic_u64:
return 0ull <= i;
case Basic_i64:
return true;
case Basic_UntypedInteger:
return true;
@@ -1317,11 +1319,11 @@ void check_is_expressible(Checker *c, Operand *o, Type *type) {
} else {
char buf[127] = {};
String str = {};
i128 i = o->value.value_integer;
i64 i = o->value.value_integer;
if (is_type_unsigned(o->type)) {
str = u128_to_string(*cast(u128 *)&i, buf, gb_size_of(buf));
str = u64_to_string(*cast(u64 *)&i, buf, gb_size_of(buf));
} else {
str = i128_to_string(i, buf, gb_size_of(buf));
str = i64_to_string(i, buf, gb_size_of(buf));
}
error(o->expr, "'%s = %.*s' overflows '%s'", a, LIT(str), b);
}
@@ -1569,7 +1571,7 @@ void check_shift(Checker *c, Operand *x, Operand *y, AstNode *node) {
return;
}
i64 amount = i128_to_i64(y_val.value_integer);
i64 amount = y_val.value_integer;
if (amount > 128) {
gbString err_str = expr_to_string(y->expr);
error(node, "Shift amount too large: '%s'", err_str);
@@ -1604,7 +1606,7 @@ void check_shift(Checker *c, Operand *x, Operand *y, AstNode *node) {
}
}
if (y->mode == Addressing_Constant && i128_lt(y->value.value_integer, I128_ZERO)) {
if (y->mode == Addressing_Constant && y->value.value_integer < 0) {
gbString err_str = expr_to_string(y->expr);
error(node, "Shift amount cannot be negative: '%s'", err_str);
gb_string_free(err_str);
@@ -1656,7 +1658,7 @@ Operand check_ptr_addition(Checker *c, TokenKind op, Operand *ptr, Operand *offs
if (ptr->mode == Addressing_Constant && offset->mode == Addressing_Constant) {
i64 ptr_val = ptr->value.value_pointer;
i64 offset_val = i128_to_i64(exact_value_to_integer(offset->value).value_integer);
i64 offset_val = exact_value_to_integer(offset->value).value_integer;
i64 new_ptr_val = ptr_val;
if (op == Token_Add) {
new_ptr_val += elem_size*offset_val;
@@ -2010,7 +2012,7 @@ void check_binary_expr(Checker *c, Operand *x, AstNode *node) {
bool fail = false;
switch (y->value.kind) {
case ExactValue_Integer:
if (i128_eq(y->value.value_integer, I128_ZERO)) {
if (y->value.value_integer == 0 ) {
fail = true;
}
break;
@@ -2148,7 +2150,7 @@ void convert_untyped_error(Checker *c, Operand *operand, Type *target_type) {
char *extra_text = "";
if (operand->mode == Addressing_Constant) {
if (i128_eq(operand->value.value_integer, I128_ZERO)) {
if (operand->value.value_integer == 0) {
if (make_string_c(expr_str) != "nil") { // HACK NOTE(bill): Just in case
// NOTE(bill): Doesn't matter what the type is as it's still zero in the union
extra_text = " - Did you want 'nil'?";
@@ -2396,7 +2398,7 @@ bool check_index_value(Checker *c, bool open_range, AstNode *index_value, i64 ma
if (operand.mode == Addressing_Constant &&
(c->context.stmt_state_flags & StmtStateFlag_no_bounds_check) == 0) {
i64 i = i128_to_i64(exact_value_to_integer(operand.value).value_integer);
i64 i = exact_value_to_integer(operand.value).value_integer;
if (i < 0) {
gbString expr_str = expr_to_string(operand.expr);
error(operand.expr, "Index '%s' cannot be a negative value", expr_str);
@@ -2605,7 +2607,7 @@ Entity *check_selector(Checker *c, Operand *operand, AstNode *node, Type *type_h
operand->expr = node;
return nullptr;
}
i64 index = i128_to_i64(o.value.value_integer);
i64 index = o.value.value_integer;
if (index < 0) {
error(o.expr, "Index %lld cannot be a negative value", index);
operand->mode = Addressing_Invalid;
@@ -3307,7 +3309,6 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
i64 max_count = type->Array.count;
Type *elem_type = type->Array.elem;
i128 max_count128 = i128_from_i64(max_count);
i64 arg_count = 0;
for_array(i, ce->args) {
if (i == 0) {
@@ -3325,12 +3326,12 @@ bool check_builtin_procedure(Checker *c, Operand *operand, AstNode *call, i32 id
return false;
}
if (op.value.value_integer < I128_ZERO) {
if (op.value.value_integer < 0) {
error(op.expr, "Negative 'swizzle' index");
return false;
}
if (max_count128 <= op.value.value_integer) {
if (max_count <= op.value.value_integer) {
error(op.expr, "'swizzle' index exceeds length");
return false;
}
@@ -3717,7 +3718,7 @@ break;
if (operand->mode == Addressing_Constant) {
switch (operand->value.kind) {
case ExactValue_Integer:
operand->value.value_integer = i128_abs(operand->value.value_integer);
operand->value.value_integer = gb_abs(operand->value.value_integer);
break;
case ExactValue_Float:
operand->value.value_float = gb_abs(operand->value.value_float);
+7 -7
View File
@@ -260,16 +260,16 @@ Type *check_assignment_variable(Checker *c, Operand *lhs, Operand *rhs) {
if (rhs->mode == Addressing_Constant) {
ExactValue v = exact_value_to_integer(rhs->value);
if (v.kind == ExactValue_Integer) {
i128 i = v.value_integer;
u128 u = *cast(u128 *)&i;
u128 umax = U128_NEG_ONE;
if (lhs_bits < 128) {
umax = u128_sub(u128_shl(U128_ONE, cast(u32)lhs_bits), U128_ONE);
i64 i = v.value_integer;
u64 u = *cast(u64 *)&i;
u64 umax = ~cast(u64)0ull;
if (lhs_bits < 64) {
umax = (1ull << cast(u64)lhs_bits) - 1ull;
}
i128 imax = i128_shl(I128_ONE, cast(u32)lhs_bits-1);
i64 imax = 1ll << (cast(i64)lhs_bits-1ll);
bool ok = false;
ok = !(u128_lt(u, U128_ZERO) || u128_gt(u, umax));
ok = !(u < 0 || u > umax);
if (ok) {
return rhs->type;
+5 -5
View File
@@ -271,7 +271,7 @@ bool check_custom_align(Checker *c, AstNode *node, i64 *align_) {
Type *type = base_type(o.type);
if (is_type_untyped(type) || is_type_integer(type)) {
if (o.value.kind == ExactValue_Integer) {
i64 align = i128_to_i64(o.value.value_integer);
i64 align = o.value.value_integer;
if (align < 1 || !gb_is_power_of_two(align)) {
error(node, "#align must be a power of 2, got %lld", align);
return false;
@@ -847,9 +847,9 @@ void check_bit_field_type(Checker *c, Type *bit_field_type, AstNode *node) {
error(value, "Bit field bit size must be a constant integer");
continue;
}
i64 bits = i128_to_i64(v.value_integer);
if (bits < 0 || bits > 128) {
error(value, "Bit field's bit size must be within the range 1..<128, got %lld", cast(long long)bits);
i64 bits = v.value_integer;
if (bits < 0 || bits > 64) {
error(value, "Bit field's bit size must be within the range 1..<64, got %lld", cast(long long)bits);
continue;
}
@@ -1767,7 +1767,7 @@ i64 check_array_count(Checker *c, Operand *o, AstNode *e) {
Type *type = base_type(o->type);
if (is_type_untyped(type) || is_type_integer(type)) {
if (o->value.kind == ExactValue_Integer) {
i64 count = i128_to_i64(o->value.value_integer);
i64 count = o->value.value_integer;
if (count >= 0) {
return count;
}
-1
View File
@@ -913,7 +913,6 @@ void init_universal_scope(void) {
t_u8_ptr = make_type_pointer(a, t_u8);
t_int_ptr = make_type_pointer(a, t_int);
t_i64_ptr = make_type_pointer(a, t_i64);
t_i128_ptr = make_type_pointer(a, t_i128);
t_f64_ptr = make_type_pointer(a, t_f64);
t_u8_slice = make_type_slice(a, t_u8);
t_string_slice = make_type_slice(a, t_string);
+96 -6
View File
@@ -95,23 +95,113 @@ GB_ALLOCATOR_PROC(heap_allocator_proc) {
#include "unicode.cpp"
#include "string.cpp"
#include "array.cpp"
#include "integer128.cpp"
// #include "integer128.cpp"
#include "murmurhash3.cpp"
#define for_array(index_, array_) for (isize index_ = 0; index_ < (array_).count; index_++)
u128 fnv128a(void const *data, isize len) {
u128 o = u128_lo_hi(0x13bull, 0x1000000ull);
u128 h = u128_lo_hi(0x62b821756295c58dull, 0x6c62272e07bb0142ull);
u64 fnv64a(void const *data, isize len) {
u8 const *bytes = cast(u8 const *)data;
u64 h = 0xcbf29ce484222325ull;
for (isize i = 0; i < len; i++) {
h.lo ^= bytes[i];
h = h * o;
u64 b = cast(u64)bytes[i];
h = (h ^ b) * 0x100000001b3ull;
}
return h;
}
u64 u64_digit_value(Rune r) {
if ('0' <= r && r <= '9') {
return r - '0';
} else if ('a' <= r && r <= 'f') {
return r - 'a' + 10;
} else if ('A' <= r && r <= 'F') {
return r - 'A' + 10;
}
return 16; // NOTE(bill): Larger than highest possible
}
u64 u64_from_string(String string) {
u64 base = 10;
bool has_prefix = false;
if (string.len > 2 && string[0] == '0') {
switch (string[1]) {
case 'b': base = 2; has_prefix = true; break;
case 'o': base = 8; has_prefix = true; break;
case 'd': base = 10; has_prefix = true; break;
case 'z': base = 12; has_prefix = true; break;
case 'x': base = 16; has_prefix = true; break;
}
}
u8 *text = string.text;
isize len = string.len;
if (has_prefix) {
text += 2;
len -= 2;
}
u64 result = 0ull;
for (isize i = 0; i < len; i++) {
Rune r = cast(Rune)text[i];
if (r == '_') {
continue;
}
u64 v = u64_digit_value(r);
if (v >= base) {
break;
}
result *= base;
result += v;
}
return result;
}
String u64_to_string(u64 v, char *out_buf, isize out_buf_len) {
char buf[200] = {0};
isize i = gb_size_of(buf);
u64 b = 10;
while (v >= b) {
buf[--i] = gb__num_to_char_table[v%b];
v /= b;
}
buf[--i] = gb__num_to_char_table[v%b];
isize len = gb_min(gb_size_of(buf)-i, out_buf_len);
gb_memcopy(out_buf, &buf[i], len);
return make_string(cast(u8 *)out_buf, len);
}
String i64_to_string(i64 a, char *out_buf, isize out_buf_len) {
char buf[200] = {0};
isize i = gb_size_of(buf);
bool negative = false;
if (a < 0) {
negative = true;
a = -a;
}
u64 v = cast(u64)a;
u64 b = 10;
while (v >= b) {
buf[--i] = gb__num_to_char_table[v%b];
v /= b;
}
buf[--i] = gb__num_to_char_table[v%b];
if (negative) {
buf[--i] = '-';
}
isize len = gb_min(gb_size_of(buf)-i, out_buf_len);
gb_memcopy(out_buf, &buf[i], len);
return make_string(cast(u8 *)out_buf, len);
}
#include "map.cpp"
+27 -32
View File
@@ -33,7 +33,7 @@ struct ExactValue {
union {
bool value_bool;
String value_string;
i128 value_integer; // NOTE(bill): This must be an integer and not a pointer
i64 value_integer; // NOTE(bill): This must be an integer and not a pointer
f64 value_float;
i64 value_pointer;
Complex128 value_complex;
@@ -70,19 +70,14 @@ ExactValue exact_value_string(String string) {
}
ExactValue exact_value_i64(i64 i) {
ExactValue result = {ExactValue_Integer};
result.value_integer = i128_from_i64(i);
return result;
}
ExactValue exact_value_i128(i128 i) {
ExactValue result = {ExactValue_Integer};
result.value_integer = i;
return result;
}
ExactValue exact_value_u128(u128 i) {
ExactValue exact_value_u64(u64 i) {
ExactValue result = {ExactValue_Integer};
result.value_integer = u128_to_i128(i);
result.value_integer = i64(i);
return result;
}
@@ -119,7 +114,8 @@ ExactValue exact_value_procedure(AstNode *node) {
ExactValue exact_value_integer_from_string(String string) {
return exact_value_u128(u128_from_string(string));
u64 u = u64_from_string(string);
return exact_value_u64(u);
}
f64 float_from_string(String string) {
@@ -273,10 +269,10 @@ ExactValue exact_value_to_integer(ExactValue v) {
case ExactValue_Integer:
return v;
case ExactValue_Float: {
i128 i = i128_from_f64(v.value_float);
f64 f = i128_to_f64(i);
i64 i = cast(i64)v.value_float;
f64 f = cast(f64)i;
if (f == v.value_float) {
return exact_value_i128(i);
return exact_value_i64(i);
}
break;
}
@@ -291,7 +287,7 @@ ExactValue exact_value_to_integer(ExactValue v) {
ExactValue exact_value_to_float(ExactValue v) {
switch (v.kind) {
case ExactValue_Integer:
return exact_value_float(i128_to_f64(v.value_integer));
return exact_value_float(cast(f64)v.value_integer);
case ExactValue_Float:
return v;
}
@@ -302,7 +298,7 @@ ExactValue exact_value_to_float(ExactValue v) {
ExactValue exact_value_to_complex(ExactValue v) {
switch (v.kind) {
case ExactValue_Integer:
return exact_value_complex(i128_to_f64(v.value_integer), 0);
return exact_value_complex(cast(f64)v.value_integer, 0);
case ExactValue_Float:
return exact_value_complex(v.value_float, 0);
case ExactValue_Complex:
@@ -388,7 +384,7 @@ ExactValue exact_unary_operator_value(TokenKind op, ExactValue v, i32 precision)
}
case Token_Xor: {
i128 i = I128_ZERO;
i64 i = 0;
switch (v.kind) {
case ExactValue_Invalid:
return v;
@@ -402,12 +398,11 @@ ExactValue exact_unary_operator_value(TokenKind op, ExactValue v, i32 precision)
// NOTE(bill): unsigned integers will be negative and will need to be
// limited to the types precision
// IMPORTANT NOTE(bill): Max precision is 64 bits as that's how integers are stored
if (0 < precision && precision < 128) {
i = i & ~(I128_NEG_ONE << precision);
if (0 < precision && precision < 64) {
i = i & ~(-1ll << precision);
}
return exact_value_i128(i);
break;
return exact_value_i64(i);
}
case Token_Not: {
@@ -472,10 +467,10 @@ void match_exact_values(ExactValue *x, ExactValue *y) {
return;
case ExactValue_Float:
// TODO(bill): Is this good enough?
*x = exact_value_float(i128_to_f64(x->value_integer));
*x = exact_value_float(cast(f64)x->value_integer);
return;
case ExactValue_Complex:
*x = exact_value_complex(i128_to_f64(x->value_integer), 0);
*x = exact_value_complex(cast(f64)x->value_integer, 0);
return;
}
break;
@@ -513,27 +508,27 @@ ExactValue exact_binary_operator_value(TokenKind op, ExactValue x, ExactValue y)
break;
case ExactValue_Integer: {
i128 a = x.value_integer;
i128 b = y.value_integer;
i128 c = I128_ZERO;
i64 a = x.value_integer;
i64 b = y.value_integer;
i64 c = 0ll;
switch (op) {
case Token_Add: c = a + b; break;
case Token_Sub: c = a - b; break;
case Token_Mul: c = a * b; break;
case Token_Quo: return exact_value_float(fmod(i128_to_f64(a), i128_to_f64(b)));
case Token_Quo: return exact_value_float(fmod(cast(f64)a, cast(f64)b));
case Token_QuoEq: c = a / b; break; // NOTE(bill): Integer division
case Token_Mod: c = a % b; break;
case Token_ModMod: c = ((a % b) + b) % b; break;
case Token_And: c = a & b; break;
case Token_Or: c = a | b; break;
case Token_Xor: c = a ^ b; break;
case Token_AndNot: c = i128_and_not(a, b); break;
case Token_Shl: c = a << cast(u32)i128_to_u64(b); break;
case Token_Shr: c = a >> cast(u32)i128_to_u64(b); break;
case Token_AndNot: c = a & (~b); break;
case Token_Shl: c = a << b; break;
case Token_Shr: c = a >> b; break;
default: goto error;
}
return exact_value_i128(c);
return exact_value_i64(c);
break;
}
@@ -628,8 +623,8 @@ bool compare_exact_values(TokenKind op, ExactValue x, ExactValue y) {
break;
case ExactValue_Integer: {
i128 a = x.value_integer;
i128 b = y.value_integer;
i64 a = x.value_integer;
i64 b = y.value_integer;
switch (op) {
case Token_CmpEq: return a == b;
case Token_NotEq: return a != b;
+5 -26
View File
@@ -1808,7 +1808,7 @@ irValue *ir_gen_map_header(irProcedure *proc, irValue *map_val_ptr, Type *map_ty
}
irValue *ir_gen_map_key(irProcedure *proc, irValue *key, Type *key_type) {
Type *hash_type = t_u128;
Type *hash_type = t_u64;
irValue *v = ir_add_local_generated(proc, t_map_key);
Type *t = base_type(ir_type(key));
key = ir_emit_conv(proc, key, key_type);
@@ -1834,8 +1834,8 @@ irValue *ir_gen_map_key(irProcedure *proc, irValue *key, Type *key_type) {
if (str->kind == irValue_Constant) {
ExactValue ev = str->Constant.value;
GB_ASSERT(ev.kind == ExactValue_String);
u128 hs = fnv128a(ev.value_string.text, ev.value_string.len);
hashed_str = ir_value_constant(proc->module->allocator, t_u128, exact_value_u128(hs));
u64 hs = fnv64a(ev.value_string.text, ev.value_string.len);
hashed_str = ir_value_constant(proc->module->allocator, t_u64, exact_value_u64(hs));
} else {
irValue **args = gb_alloc_array(proc->module->allocator, irValue *, 1);
args[0] = str;
@@ -1936,7 +1936,6 @@ irValue *ir_addr_store(irProcedure *proc, irAddr addr, irValue *value) {
case 2: int_type = t_u16; break;
case 4: int_type = t_u32; break;
case 8: int_type = t_u64; break;
case 16: int_type = t_u128; break;
}
GB_ASSERT(int_type != nullptr);
@@ -2051,7 +2050,6 @@ irValue *ir_addr_load(irProcedure *proc, irAddr addr) {
case 2: int_type = t_u16; break;
case 4: int_type = t_u32; break;
case 8: int_type = t_u64; break;
case 16: int_type = t_u128; break;
}
GB_ASSERT(int_type != nullptr);
@@ -2355,23 +2353,6 @@ irValue *ir_emit_arith(irProcedure *proc, TokenKind op, irValue *left, irValue *
return ir_emit_arith(proc, Token_Mod, b, m, type);
}
if (is_type_i128_or_u128(type)) {
// IMPORTANT NOTE(bill): LLVM is goddamn buggy!
bool is_unsigned = is_type_unsigned(type);
char *name = nullptr;
if (op == Token_Quo) {
name = cast(char *)(is_unsigned ? "__udivti3" : "__divti3");
} else if (op == Token_Mod) {
name = cast(char *)(is_unsigned ? "__umodti3" : "__modti3");
}
if (name != nullptr) {
irValue **args = gb_alloc_array(proc->module->allocator, irValue *, 2);
args[0] = left;
args[1] = right;
return ir_emit_global_call(proc, name, args, 2);
}
}
return ir_emit(proc, ir_instr_binary_op(proc, op, left, right, type));
}
@@ -4587,7 +4568,7 @@ irValue *ir_build_builtin_proc(irProcedure *proc, AstNode *expr, TypeAndValue tv
GB_ASSERT(is_type_integer(tv.type));
GB_ASSERT(tv.value.kind == ExactValue_Integer);
i32 src_index = cast(i32)i128_to_i64(tv.value.value_integer);
i32 src_index = cast(i32)tv.value.value_integer;
i32 dst_index = i-1;
irValue *src_elem = ir_emit_array_epi(proc, src, src_index);
@@ -5484,7 +5465,7 @@ irAddr ir_build_addr(irProcedure *proc, AstNode *expr) {
Type *selector_type = base_type(type_of_expr(proc->module->info, se->selector));
GB_ASSERT_MSG(is_type_integer(selector_type), "%s", type_to_string(selector_type));
ExactValue val = type_and_value_of_expr(proc->module->info, sel).value;
i64 index = i128_to_i64(val.value_integer);
i64 index = val.value_integer;
Selection sel = lookup_field_from_index(proc->module->allocator, type, index);
GB_ASSERT(sel.entity != nullptr);
@@ -7900,8 +7881,6 @@ void ir_setup_type_info_data(irProcedure *proc) { // NOTE(bill): Setup type_info
case Basic_u32:
case Basic_i64:
case Basic_u64:
case Basic_i128:
case Basic_u128:
case Basic_int:
case Basic_uint:
case Basic_uintptr: {
+5 -7
View File
@@ -54,9 +54,9 @@ void ir_write_string(irFileBuffer *f, char const *s) {
void ir_write_byte(irFileBuffer *f, u8 c) {
ir_file_buffer_write(f, &c, 1);
}
void ir_write_i128(irFileBuffer *f, i128 i) {
void ir_write_i64(irFileBuffer *f, i64 i) {
char buf[200] = {};
String str = i128_to_string(i, buf, gb_size_of(buf)-1);
String str = i64_to_string(i, buf, gb_size_of(buf)-1);
ir_write_string(f, str);
}
@@ -280,8 +280,6 @@ void ir_print_type(irFileBuffer *f, irModule *m, Type *t, bool in_struct) {
case Basic_u32: ir_write_string(f, "i32"); return;
case Basic_i64: ir_write_string(f, "i64"); return;
case Basic_u64: ir_write_string(f, "i64"); return;
case Basic_i128: ir_write_string(f, "i128"); return;
case Basic_u128: ir_write_string(f, "i128"); return;
case Basic_rune: ir_write_string(f, "i32"); return;
@@ -525,19 +523,19 @@ void ir_print_exact_value(irFileBuffer *f, irModule *m, ExactValue value, Type *
}
case ExactValue_Integer: {
if (is_type_pointer(type)) {
if (i128_eq(value.value_integer, I128_ZERO)) {
if (value.value_integer == 0) {
ir_write_string(f, "null");
} else {
ir_write_string(f, "inttoptr (");
ir_print_type(f, m, t_int);
ir_write_byte(f, ' ');
ir_write_i128(f, value.value_integer);
ir_write_i64(f, value.value_integer);
ir_write_string(f, " to ");
ir_print_type(f, m, t_rawptr);
ir_write_string(f, ")");
}
} else {
ir_write_i128(f, value.value_integer);
ir_write_i64(f, value.value_integer);
}
break;
}
+2 -2
View File
@@ -361,7 +361,7 @@ bool parse_build_flags(Array<String> args) {
if (ok) switch (bf.kind) {
case BuildFlag_OptimizationLevel:
GB_ASSERT(value.kind == ExactValue_Integer);
build_context.optimization_level = cast(i32)i128_to_i64(value.value_integer);
build_context.optimization_level = cast(i32)value.value_integer;
break;
case BuildFlag_ShowTimings:
GB_ASSERT(value.kind == ExactValue_Invalid);
@@ -369,7 +369,7 @@ bool parse_build_flags(Array<String> args) {
break;
case BuildFlag_ThreadCount: {
GB_ASSERT(value.kind == ExactValue_Integer);
isize count = cast(isize)i128_to_i64(value.value_integer);
isize count = cast(isize)value.value_integer;
if (count <= 0) {
gb_printf_err("%.*s expected a positive non-zero number, got %.*s", LIT(name), LIT(param));
build_context.thread_count = 0;
+9 -9
View File
@@ -212,14 +212,14 @@ void MurmurHash3_x86_128(void const *key, isize len, u32 seed, void *out) {
((u32 *)out)[3] = h4;
}
gb_inline u128 MurmurHash3_128(void const *key, isize len, u32 seed) {
u128 res;
#if defined(GB_ARCH_64_BIT)
MurmurHash3_x64_128(key, len, seed, &res);
#else
MurmurHash3_x86_128(key, len, seed, &res);
#endif
return res;
}
// gb_inline u128 MurmurHash3_128(void const *key, isize len, u32 seed) {
// u128 res;
// #if defined(GB_ARCH_64_BIT)
// MurmurHash3_x64_128(key, len, seed, &res);
// #else
// MurmurHash3_x86_128(key, len, seed, &res);
// #endif
// return res;
// }
-15
View File
@@ -14,8 +14,6 @@ enum BasicKind {
Basic_u32,
Basic_i64,
Basic_u64,
Basic_i128,
Basic_u128,
Basic_rune,
@@ -249,8 +247,6 @@ gb_global Type basic_types[] = {
{Type_Basic, {Basic_u32, BasicFlag_Integer | BasicFlag_Unsigned, 4, STR_LIT("u32")}},
{Type_Basic, {Basic_i64, BasicFlag_Integer, 8, STR_LIT("i64")}},
{Type_Basic, {Basic_u64, BasicFlag_Integer | BasicFlag_Unsigned, 8, STR_LIT("u64")}},
{Type_Basic, {Basic_i128, BasicFlag_Integer, 16, STR_LIT("i128")}},
{Type_Basic, {Basic_u128, BasicFlag_Integer | BasicFlag_Unsigned, 16, STR_LIT("u128")}},
{Type_Basic, {Basic_rune, BasicFlag_Integer | BasicFlag_Rune, 4, STR_LIT("rune")}},
@@ -296,8 +292,6 @@ gb_global Type *t_i32 = &basic_types[Basic_i32];
gb_global Type *t_u32 = &basic_types[Basic_u32];
gb_global Type *t_i64 = &basic_types[Basic_i64];
gb_global Type *t_u64 = &basic_types[Basic_u64];
gb_global Type *t_i128 = &basic_types[Basic_i128];
gb_global Type *t_u128 = &basic_types[Basic_u128];
gb_global Type *t_rune = &basic_types[Basic_rune];
@@ -331,7 +325,6 @@ gb_global Type *t_untyped_undef = &basic_types[Basic_UntypedUndef];
gb_global Type *t_u8_ptr = nullptr;
gb_global Type *t_int_ptr = nullptr;
gb_global Type *t_i64_ptr = nullptr;
gb_global Type *t_i128_ptr = nullptr;
gb_global Type *t_f64_ptr = nullptr;
gb_global Type *t_u8_slice = nullptr;
gb_global Type *t_string_slice = nullptr;
@@ -756,12 +749,6 @@ bool is_type_uintptr(Type *t) {
}
return false;
}
bool is_type_i128_or_u128(Type *t) {
if (t->kind == Type_Basic) {
return (t->Basic.kind == Basic_i128) || (t->Basic.kind == Basic_u128);
}
return false;
}
bool is_type_rawptr(Type *t) {
if (t->kind == Type_Basic) {
return t->Basic.kind == Basic_rawptr;
@@ -1264,7 +1251,6 @@ Type *default_bit_field_value_type(Type *type) {
case 16: return t_u16;
case 32: return t_u32;
case 64: return t_u64;
case 128: return t_u128;
default: GB_PANIC("Too big of a bit size!"); break;
}
}
@@ -1385,7 +1371,6 @@ Type *union_tag_type(gbAllocator a, Type *u) {
case 2: return t_u16;
case 4: return t_u32;
case 8: return t_u64;
case 16: return t_u128;
}
GB_PANIC("Invalid union_tag_size");
return t_uint;