| author | |
| committer | |
| log | 2173e1f457f49990313e1ad038187af8a78205ab |
| tree | 187401e5d1294f234efd9f7747c5e0cc860cc141 |
| parent | e63d864c1ee343dff13b1e165079e092ee93e273 |
4 files changed, 23 insertions(+), 2 deletions(-)
src/bigint.cpp+1-1| ... | @@ -826,7 +826,7 @@ void bigint_shl(BigInt *dest, const BigInt *op1, const BigInt *op2) { | ... | @@ -826,7 +826,7 @@ void bigint_shl(BigInt *dest, const BigInt *op1, const BigInt *op2) { |
| 826 | const uint64_t *op1_digits = bigint_ptr(op1); | 826 | const uint64_t *op1_digits = bigint_ptr(op1); |
| 827 | uint64_t shift_amt = bigint_as_unsigned(op2); | 827 | uint64_t shift_amt = bigint_as_unsigned(op2); |
| 828 | 828 | ||
| 829 | if (op1->digit_count == 1) { | 829 | if (op1->digit_count == 1 && shift_amt < 64) { |
| 830 | dest->data.digit = op1_digits[0] << shift_amt; | 830 | dest->data.digit = op1_digits[0] << shift_amt; |
| 831 | if (dest->data.digit > op1_digits[0]) { | 831 | if (dest->data.digit > op1_digits[0]) { |
| 832 | dest->digit_count = 1; | 832 | dest->digit_count = 1; |
src/codegen.cpp+11| ... | @@ -3852,6 +3852,10 @@ static void build_all_basic_blocks(CodeGen *g, FnTableEntry *fn) { | ... | @@ -3852,6 +3852,10 @@ static void build_all_basic_blocks(CodeGen *g, FnTableEntry *fn) { |
| 3852 | static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef init_val, | 3852 | static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef init_val, |
| 3853 | TypeTableEntry *type_entry) | 3853 | TypeTableEntry *type_entry) |
| 3854 | { | 3854 | { |
| 3855 | if (g->strip_debug_symbols) { | ||
| 3856 | return; | ||
| 3857 | } | ||
| 3858 | |||
| 3855 | assert(var->gen_is_const); | 3859 | assert(var->gen_is_const); |
| 3856 | assert(type_entry); | 3860 | assert(type_entry); |
| 3857 | 3861 | ||
| ... | @@ -3863,6 +3867,7 @@ static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef ini | ... | @@ -3863,6 +3867,7 @@ static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef ini |
| 3863 | buf_ptr(&var->name), import->di_file, | 3867 | buf_ptr(&var->name), import->di_file, |
| 3864 | (unsigned)(var->decl_node->line + 1), | 3868 | (unsigned)(var->decl_node->line + 1), |
| 3865 | type_entry->di_type, is_local_to_unit); | 3869 | type_entry->di_type, is_local_to_unit); |
| 3870 | |||
| 3866 | // TODO ^^ make an actual global variable | 3871 | // TODO ^^ make an actual global variable |
| 3867 | } | 3872 | } |
| 3868 | 3873 | ||
| ... | @@ -5127,6 +5132,12 @@ static void get_c_type(CodeGen *g, TypeTableEntry *type_entry, Buf *out_buf) { | ... | @@ -5127,6 +5132,12 @@ static void get_c_type(CodeGen *g, TypeTableEntry *type_entry, Buf *out_buf) { |
| 5127 | case 64: | 5132 | case 64: |
| 5128 | buf_init_from_str(out_buf, "double"); | 5133 | buf_init_from_str(out_buf, "double"); |
| 5129 | break; | 5134 | break; |
| 5135 | case 80: | ||
| 5136 | buf_init_from_str(out_buf, "__float80"); | ||
| 5137 | break; | ||
| 5138 | case 128: | ||
| 5139 | buf_init_from_str(out_buf, "__float128"); | ||
| 5140 | break; | ||
| 5130 | default: | 5141 | default: |
| 5131 | zig_unreachable(); | 5142 | zig_unreachable(); |
| 5132 | } | 5143 | } |
std/special/compiler_rt/comparetf2.zig-1| ... | @@ -68,7 +68,6 @@ const GE_GREATER = c_int(1); | ... | @@ -68,7 +68,6 @@ const GE_GREATER = c_int(1); |
| 68 | const GE_UNORDERED = c_int(-1); // Note: different from LE_UNORDERED | 68 | const GE_UNORDERED = c_int(-1); // Note: different from LE_UNORDERED |
| 69 | 69 | ||
| 70 | export fn __getf2(a: f128, b: f128) -> c_int { | 70 | export fn __getf2(a: f128, b: f128) -> c_int { |
| 71 | |||
| 72 | const aInt = @bitCast(srep_t, a); | 71 | const aInt = @bitCast(srep_t, a); |
| 73 | const bInt = @bitCast(srep_t, b); | 72 | const bInt = @bitCast(srep_t, b); |
| 74 | const aAbs = @bitCast(rep_t, aInt) & absMask; | 73 | const aAbs = @bitCast(rep_t, aInt) & absMask; |
test/cases/math.zig+11| ... | @@ -313,6 +313,12 @@ test "big number multiplication" { | ... | @@ -313,6 +313,12 @@ test "big number multiplication" { |
| 313 | } | 313 | } |
| 314 | } | 314 | } |
| 315 | 315 | ||
| 316 | test "big number shifting" { | ||
| 317 | comptime { | ||
| 318 | assert((u128(1) << 127) == 0x80000000000000000000000000000000); | ||
| 319 | } | ||
| 320 | } | ||
| 321 | |||
| 316 | test "f128" { | 322 | test "f128" { |
| 317 | test_f128(); | 323 | test_f128(); |
| 318 | comptime test_f128(); | 324 | comptime test_f128(); |
| ... | @@ -327,4 +333,9 @@ fn test_f128() { | ... | @@ -327,4 +333,9 @@ fn test_f128() { |
| 327 | assert(make_f128(1.0) > 0.9); | 333 | assert(make_f128(1.0) > 0.9); |
| 328 | assert(make_f128(1.0) >= 0.9); | 334 | assert(make_f128(1.0) >= 0.9); |
| 329 | assert(make_f128(1.0) >= 1.0); | 335 | assert(make_f128(1.0) >= 1.0); |
| 336 | should_not_be_zero(1.0); | ||
| 337 | } | ||
| 338 | |||
| 339 | fn should_not_be_zero(x: f128) { | ||
| 340 | assert(x != 0.0); | ||
| 330 | } | 341 | } |