| ... | ... | @@ -6945,14 +6945,14 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so |
| 6945 | 6945 | } |
| 6946 | 6946 | |
| 6947 | 6947 | static bool const_val_fits_in_num_lit(ConstExprValue *const_val, TypeTableEntry *num_lit_type) { |
| 6948 | | return ((num_lit_type->id == TypeTableEntryIdNumLitFloat && |
| 6949 | | (const_val->type->id == TypeTableEntryIdFloat || const_val->type->id == TypeTableEntryIdNumLitFloat)) || |
| 6950 | | (num_lit_type->id == TypeTableEntryIdNumLitInt && |
| 6951 | | (const_val->type->id == TypeTableEntryIdInt || const_val->type->id == TypeTableEntryIdNumLitInt))); |
| 6948 | return ((num_lit_type->id == TypeTableEntryIdComptimeFloat && |
| 6949 | (const_val->type->id == TypeTableEntryIdFloat || const_val->type->id == TypeTableEntryIdComptimeFloat)) || |
| 6950 | (num_lit_type->id == TypeTableEntryIdComptimeInt && |
| 6951 | (const_val->type->id == TypeTableEntryIdInt || const_val->type->id == TypeTableEntryIdComptimeInt))); |
| 6952 | 6952 | } |
| 6953 | 6953 | |
| 6954 | 6954 | static bool float_has_fraction(ConstExprValue *const_val) { |
| 6955 | | if (const_val->type->id == TypeTableEntryIdNumLitFloat) { |
| 6955 | if (const_val->type->id == TypeTableEntryIdComptimeFloat) { |
| 6956 | 6956 | return bigfloat_has_fraction(&const_val->data.x_bigfloat); |
| 6957 | 6957 | } else if (const_val->type->id == TypeTableEntryIdFloat) { |
| 6958 | 6958 | switch (const_val->type->data.floating.bit_count) { |
| ... | ... | @@ -6975,7 +6975,7 @@ static bool float_has_fraction(ConstExprValue *const_val) { |
| 6975 | 6975 | } |
| 6976 | 6976 | |
| 6977 | 6977 | static void float_append_buf(Buf *buf, ConstExprValue *const_val) { |
| 6978 | | if (const_val->type->id == TypeTableEntryIdNumLitFloat) { |
| 6978 | if (const_val->type->id == TypeTableEntryIdComptimeFloat) { |
| 6979 | 6979 | bigfloat_append_buf(buf, &const_val->data.x_bigfloat); |
| 6980 | 6980 | } else if (const_val->type->id == TypeTableEntryIdFloat) { |
| 6981 | 6981 | switch (const_val->type->data.floating.bit_count) { |
| ... | ... | @@ -7010,7 +7010,7 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) { |
| 7010 | 7010 | } |
| 7011 | 7011 | |
| 7012 | 7012 | static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { |
| 7013 | | if (const_val->type->id == TypeTableEntryIdNumLitFloat) { |
| 7013 | if (const_val->type->id == TypeTableEntryIdComptimeFloat) { |
| 7014 | 7014 | bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat); |
| 7015 | 7015 | } else if (const_val->type->id == TypeTableEntryIdFloat) { |
| 7016 | 7016 | switch (const_val->type->data.floating.bit_count) { |
| ... | ... | @@ -7046,7 +7046,7 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) { |
| 7046 | 7046 | } |
| 7047 | 7047 | |
| 7048 | 7048 | static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { |
| 7049 | | if (dest_val->type->id == TypeTableEntryIdNumLitFloat) { |
| 7049 | if (dest_val->type->id == TypeTableEntryIdComptimeFloat) { |
| 7050 | 7050 | bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat); |
| 7051 | 7051 | } else if (dest_val->type->id == TypeTableEntryIdFloat) { |
| 7052 | 7052 | switch (dest_val->type->data.floating.bit_count) { |
| ... | ... | @@ -7068,7 +7068,7 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) { |
| 7068 | 7068 | } |
| 7069 | 7069 | |
| 7070 | 7070 | static void float_init_f32(ConstExprValue *dest_val, float x) { |
| 7071 | | if (dest_val->type->id == TypeTableEntryIdNumLitFloat) { |
| 7071 | if (dest_val->type->id == TypeTableEntryIdComptimeFloat) { |
| 7072 | 7072 | bigfloat_init_32(&dest_val->data.x_bigfloat, x); |
| 7073 | 7073 | } else if (dest_val->type->id == TypeTableEntryIdFloat) { |
| 7074 | 7074 | switch (dest_val->type->data.floating.bit_count) { |
| ... | ... | @@ -7094,7 +7094,7 @@ static void float_init_f32(ConstExprValue *dest_val, float x) { |
| 7094 | 7094 | } |
| 7095 | 7095 | |
| 7096 | 7096 | static void float_init_f64(ConstExprValue *dest_val, double x) { |
| 7097 | | if (dest_val->type->id == TypeTableEntryIdNumLitFloat) { |
| 7097 | if (dest_val->type->id == TypeTableEntryIdComptimeFloat) { |
| 7098 | 7098 | bigfloat_init_64(&dest_val->data.x_bigfloat, x); |
| 7099 | 7099 | } else if (dest_val->type->id == TypeTableEntryIdFloat) { |
| 7100 | 7100 | switch (dest_val->type->data.floating.bit_count) { |
| ... | ... | @@ -7120,7 +7120,7 @@ static void float_init_f64(ConstExprValue *dest_val, double x) { |
| 7120 | 7120 | } |
| 7121 | 7121 | |
| 7122 | 7122 | static void float_init_f128(ConstExprValue *dest_val, float128_t x) { |
| 7123 | | if (dest_val->type->id == TypeTableEntryIdNumLitFloat) { |
| 7123 | if (dest_val->type->id == TypeTableEntryIdComptimeFloat) { |
| 7124 | 7124 | bigfloat_init_128(&dest_val->data.x_bigfloat, x); |
| 7125 | 7125 | } else if (dest_val->type->id == TypeTableEntryIdFloat) { |
| 7126 | 7126 | switch (dest_val->type->data.floating.bit_count) { |
| ... | ... | @@ -7150,7 +7150,7 @@ static void float_init_f128(ConstExprValue *dest_val, float128_t x) { |
| 7150 | 7150 | } |
| 7151 | 7151 | |
| 7152 | 7152 | static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) { |
| 7153 | | if (src_val->type->id == TypeTableEntryIdNumLitFloat) { |
| 7153 | if (src_val->type->id == TypeTableEntryIdComptimeFloat) { |
| 7154 | 7154 | float_init_bigfloat(dest_val, &src_val->data.x_bigfloat); |
| 7155 | 7155 | } else if (src_val->type->id == TypeTableEntryIdFloat) { |
| 7156 | 7156 | switch (src_val->type->data.floating.bit_count) { |
| ... | ... | @@ -7173,7 +7173,7 @@ static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) |
| 7173 | 7173 | |
| 7174 | 7174 | static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { |
| 7175 | 7175 | assert(op1->type == op2->type); |
| 7176 | | if (op1->type->id == TypeTableEntryIdNumLitFloat) { |
| 7176 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { |
| 7177 | 7177 | return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 7178 | 7178 | } else if (op1->type->id == TypeTableEntryIdFloat) { |
| 7179 | 7179 | switch (op1->type->data.floating.bit_count) { |
| ... | ... | @@ -7210,7 +7210,7 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) { |
| 7210 | 7210 | } |
| 7211 | 7211 | |
| 7212 | 7212 | static Cmp float_cmp_zero(ConstExprValue *op) { |
| 7213 | | if (op->type->id == TypeTableEntryIdNumLitFloat) { |
| 7213 | if (op->type->id == TypeTableEntryIdComptimeFloat) { |
| 7214 | 7214 | return bigfloat_cmp_zero(&op->data.x_bigfloat); |
| 7215 | 7215 | } else if (op->type->id == TypeTableEntryIdFloat) { |
| 7216 | 7216 | switch (op->type->data.floating.bit_count) { |
| ... | ... | @@ -7251,7 +7251,7 @@ static Cmp float_cmp_zero(ConstExprValue *op) { |
| 7251 | 7251 | static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 7252 | 7252 | assert(op1->type == op2->type); |
| 7253 | 7253 | out_val->type = op1->type; |
| 7254 | | if (op1->type->id == TypeTableEntryIdNumLitFloat) { |
| 7254 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { |
| 7255 | 7255 | bigfloat_add(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 7256 | 7256 | } else if (op1->type->id == TypeTableEntryIdFloat) { |
| 7257 | 7257 | switch (op1->type->data.floating.bit_count) { |
| ... | ... | @@ -7275,7 +7275,7 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 7275 | 7275 | static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 7276 | 7276 | assert(op1->type == op2->type); |
| 7277 | 7277 | out_val->type = op1->type; |
| 7278 | | if (op1->type->id == TypeTableEntryIdNumLitFloat) { |
| 7278 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { |
| 7279 | 7279 | bigfloat_sub(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 7280 | 7280 | } else if (op1->type->id == TypeTableEntryIdFloat) { |
| 7281 | 7281 | switch (op1->type->data.floating.bit_count) { |
| ... | ... | @@ -7299,7 +7299,7 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 7299 | 7299 | static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 7300 | 7300 | assert(op1->type == op2->type); |
| 7301 | 7301 | out_val->type = op1->type; |
| 7302 | | if (op1->type->id == TypeTableEntryIdNumLitFloat) { |
| 7302 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { |
| 7303 | 7303 | bigfloat_mul(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 7304 | 7304 | } else if (op1->type->id == TypeTableEntryIdFloat) { |
| 7305 | 7305 | switch (op1->type->data.floating.bit_count) { |
| ... | ... | @@ -7323,7 +7323,7 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 7323 | 7323 | static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 7324 | 7324 | assert(op1->type == op2->type); |
| 7325 | 7325 | out_val->type = op1->type; |
| 7326 | | if (op1->type->id == TypeTableEntryIdNumLitFloat) { |
| 7326 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { |
| 7327 | 7327 | bigfloat_div(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 7328 | 7328 | } else if (op1->type->id == TypeTableEntryIdFloat) { |
| 7329 | 7329 | switch (op1->type->data.floating.bit_count) { |
| ... | ... | @@ -7347,7 +7347,7 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 7347 | 7347 | static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 7348 | 7348 | assert(op1->type == op2->type); |
| 7349 | 7349 | out_val->type = op1->type; |
| 7350 | | if (op1->type->id == TypeTableEntryIdNumLitFloat) { |
| 7350 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { |
| 7351 | 7351 | bigfloat_div_trunc(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 7352 | 7352 | } else if (op1->type->id == TypeTableEntryIdFloat) { |
| 7353 | 7353 | switch (op1->type->data.floating.bit_count) { |
| ... | ... | @@ -7382,7 +7382,7 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE |
| 7382 | 7382 | static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 7383 | 7383 | assert(op1->type == op2->type); |
| 7384 | 7384 | out_val->type = op1->type; |
| 7385 | | if (op1->type->id == TypeTableEntryIdNumLitFloat) { |
| 7385 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { |
| 7386 | 7386 | bigfloat_div_floor(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 7387 | 7387 | } else if (op1->type->id == TypeTableEntryIdFloat) { |
| 7388 | 7388 | switch (op1->type->data.floating.bit_count) { |
| ... | ... | @@ -7407,7 +7407,7 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE |
| 7407 | 7407 | static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 7408 | 7408 | assert(op1->type == op2->type); |
| 7409 | 7409 | out_val->type = op1->type; |
| 7410 | | if (op1->type->id == TypeTableEntryIdNumLitFloat) { |
| 7410 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { |
| 7411 | 7411 | bigfloat_rem(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 7412 | 7412 | } else if (op1->type->id == TypeTableEntryIdFloat) { |
| 7413 | 7413 | switch (op1->type->data.floating.bit_count) { |
| ... | ... | @@ -7431,7 +7431,7 @@ static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 7431 | 7431 | static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) { |
| 7432 | 7432 | assert(op1->type == op2->type); |
| 7433 | 7433 | out_val->type = op1->type; |
| 7434 | | if (op1->type->id == TypeTableEntryIdNumLitFloat) { |
| 7434 | if (op1->type->id == TypeTableEntryIdComptimeFloat) { |
| 7435 | 7435 | bigfloat_mod(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat); |
| 7436 | 7436 | } else if (op1->type->id == TypeTableEntryIdFloat) { |
| 7437 | 7437 | switch (op1->type->data.floating.bit_count) { |
| ... | ... | @@ -7456,7 +7456,7 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal |
| 7456 | 7456 | |
| 7457 | 7457 | static void float_negate(ConstExprValue *out_val, ConstExprValue *op) { |
| 7458 | 7458 | out_val->type = op->type; |
| 7459 | | if (op->type->id == TypeTableEntryIdNumLitFloat) { |
| 7459 | if (op->type->id == TypeTableEntryIdComptimeFloat) { |
| 7460 | 7460 | bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat); |
| 7461 | 7461 | } else if (op->type->id == TypeTableEntryIdFloat) { |
| 7462 | 7462 | switch (op->type->data.floating.bit_count) { |
| ... | ... | @@ -7530,9 +7530,9 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 7530 | 7530 | assert(const_val->special != ConstValSpecialRuntime); |
| 7531 | 7531 | |
| 7532 | 7532 | bool const_val_is_int = (const_val->type->id == TypeTableEntryIdInt || |
| 7533 | | const_val->type->id == TypeTableEntryIdNumLitInt); |
| 7533 | const_val->type->id == TypeTableEntryIdComptimeInt); |
| 7534 | 7534 | bool const_val_is_float = (const_val->type->id == TypeTableEntryIdFloat || |
| 7535 | | const_val->type->id == TypeTableEntryIdNumLitFloat); |
| 7535 | const_val->type->id == TypeTableEntryIdComptimeFloat); |
| 7536 | 7536 | if (other_type->id == TypeTableEntryIdFloat) { |
| 7537 | 7537 | return true; |
| 7538 | 7538 | } else if (other_type->id == TypeTableEntryIdInt && const_val_is_int) { |
| ... | ... | @@ -7576,7 +7576,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 7576 | 7576 | return true; |
| 7577 | 7577 | } |
| 7578 | 7578 | } |
| 7579 | | if (explicit_cast && (other_type->id == TypeTableEntryIdInt || other_type->id == TypeTableEntryIdNumLitInt) && |
| 7579 | if (explicit_cast && (other_type->id == TypeTableEntryIdInt || other_type->id == TypeTableEntryIdComptimeInt) && |
| 7580 | 7580 | const_val_is_float) |
| 7581 | 7581 | { |
| 7582 | 7582 | if (float_has_fraction(const_val)) { |
| ... | ... | @@ -7589,7 +7589,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc |
| 7589 | 7589 | buf_ptr(&other_type->name))); |
| 7590 | 7590 | return false; |
| 7591 | 7591 | } else { |
| 7592 | | if (other_type->id == TypeTableEntryIdNumLitInt) { |
| 7592 | if (other_type->id == TypeTableEntryIdComptimeInt) { |
| 7593 | 7593 | return true; |
| 7594 | 7594 | } else { |
| 7595 | 7595 | BigInt bigint; |
| ... | ... | @@ -8078,8 +8078,8 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira, |
| 8078 | 8078 | |
| 8079 | 8079 | // implicit number literal to typed number |
| 8080 | 8080 | // implicit number literal to &const integer |
| 8081 | | if (actual_type->id == TypeTableEntryIdNumLitFloat || |
| 8082 | | actual_type->id == TypeTableEntryIdNumLitInt) |
| 8081 | if (actual_type->id == TypeTableEntryIdComptimeFloat || |
| 8082 | actual_type->id == TypeTableEntryIdComptimeInt) |
| 8083 | 8083 | { |
| 8084 | 8084 | if (expected_type->id == TypeTableEntryIdPointer && |
| 8085 | 8085 | expected_type->data.pointer.is_const) |
| ... | ... | @@ -8099,9 +8099,9 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira, |
| 8099 | 8099 | // implicit typed number to integer or float literal. |
| 8100 | 8100 | // works when the number is known |
| 8101 | 8101 | if (value->value.special == ConstValSpecialStatic) { |
| 8102 | | if (actual_type->id == TypeTableEntryIdInt && expected_type->id == TypeTableEntryIdNumLitInt) { |
| 8102 | if (actual_type->id == TypeTableEntryIdInt && expected_type->id == TypeTableEntryIdComptimeInt) { |
| 8103 | 8103 | return ImplicitCastMatchResultYes; |
| 8104 | | } else if (actual_type->id == TypeTableEntryIdFloat && expected_type->id == TypeTableEntryIdNumLitFloat) { |
| 8104 | } else if (actual_type->id == TypeTableEntryIdFloat && expected_type->id == TypeTableEntryIdComptimeFloat) { |
| 8105 | 8105 | return ImplicitCastMatchResultYes; |
| 8106 | 8106 | } |
| 8107 | 8107 | } |
| ... | ... | @@ -8555,8 +8555,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod |
| 8555 | 8555 | continue; |
| 8556 | 8556 | } |
| 8557 | 8557 | |
| 8558 | | if (prev_type->id == TypeTableEntryIdNumLitInt || |
| 8559 | | prev_type->id == TypeTableEntryIdNumLitFloat) |
| 8558 | if (prev_type->id == TypeTableEntryIdComptimeInt || |
| 8559 | prev_type->id == TypeTableEntryIdComptimeFloat) |
| 8560 | 8560 | { |
| 8561 | 8561 | if (ir_num_lit_fits_in_other_type(ira, prev_inst, cur_type, false)) { |
| 8562 | 8562 | prev_inst = cur_inst; |
| ... | ... | @@ -8566,8 +8566,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod |
| 8566 | 8566 | } |
| 8567 | 8567 | } |
| 8568 | 8568 | |
| 8569 | | if (cur_type->id == TypeTableEntryIdNumLitInt || |
| 8570 | | cur_type->id == TypeTableEntryIdNumLitFloat) |
| 8569 | if (cur_type->id == TypeTableEntryIdComptimeInt || |
| 8570 | cur_type->id == TypeTableEntryIdComptimeFloat) |
| 8571 | 8571 | { |
| 8572 | 8572 | if (ir_num_lit_fits_in_other_type(ira, cur_inst, prev_type, false)) { |
| 8573 | 8573 | continue; |
| ... | ... | @@ -8671,8 +8671,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod |
| 8671 | 8671 | } else if (expected_type != nullptr && expected_type->id == TypeTableEntryIdErrorUnion) { |
| 8672 | 8672 | return get_error_union_type(ira->codegen, err_set_type, expected_type->data.error_union.payload_type); |
| 8673 | 8673 | } else { |
| 8674 | | if (prev_inst->value.type->id == TypeTableEntryIdNumLitInt || |
| 8675 | | prev_inst->value.type->id == TypeTableEntryIdNumLitFloat) |
| 8674 | if (prev_inst->value.type->id == TypeTableEntryIdComptimeInt || |
| 8675 | prev_inst->value.type->id == TypeTableEntryIdComptimeFloat) |
| 8676 | 8676 | { |
| 8677 | 8677 | ir_add_error_node(ira, source_node, |
| 8678 | 8678 | buf_sprintf("unable to make error union out of number literal")); |
| ... | ... | @@ -8686,8 +8686,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod |
| 8686 | 8686 | } |
| 8687 | 8687 | } |
| 8688 | 8688 | } else if (any_are_null && prev_inst->value.type->id != TypeTableEntryIdNullLit) { |
| 8689 | | if (prev_inst->value.type->id == TypeTableEntryIdNumLitInt || |
| 8690 | | prev_inst->value.type->id == TypeTableEntryIdNumLitFloat) |
| 8689 | if (prev_inst->value.type->id == TypeTableEntryIdComptimeInt || |
| 8690 | prev_inst->value.type->id == TypeTableEntryIdComptimeFloat) |
| 8691 | 8691 | { |
| 8692 | 8692 | ir_add_error_node(ira, source_node, |
| 8693 | 8693 | buf_sprintf("unable to make maybe out of number literal")); |
| ... | ... | @@ -8743,7 +8743,7 @@ static void eval_const_expr_implicit_cast(CastOp cast_op, |
| 8743 | 8743 | break; |
| 8744 | 8744 | } |
| 8745 | 8745 | case CastOpNumLitToConcrete: |
| 8746 | | if (other_val->type->id == TypeTableEntryIdNumLitFloat) { |
| 8746 | if (other_val->type->id == TypeTableEntryIdComptimeFloat) { |
| 8747 | 8747 | assert(new_type->id == TypeTableEntryIdFloat); |
| 8748 | 8748 | switch (new_type->data.floating.bit_count) { |
| 8749 | 8749 | case 32: |
| ... | ... | @@ -8758,7 +8758,7 @@ static void eval_const_expr_implicit_cast(CastOp cast_op, |
| 8758 | 8758 | default: |
| 8759 | 8759 | zig_unreachable(); |
| 8760 | 8760 | } |
| 8761 | | } else if (other_val->type->id == TypeTableEntryIdNumLitInt) { |
| 8761 | } else if (other_val->type->id == TypeTableEntryIdComptimeInt) { |
| 8762 | 8762 | bigint_init_bigint(&const_val->data.x_bigint, &other_val->data.x_bigint); |
| 8763 | 8763 | } else { |
| 8764 | 8764 | zig_unreachable(); |
| ... | ... | @@ -9601,9 +9601,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction |
| 9601 | 9601 | |
| 9602 | 9602 | IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope, |
| 9603 | 9603 | source_instr->source_node, wanted_type); |
| 9604 | | if (wanted_type->id == TypeTableEntryIdNumLitFloat) { |
| 9604 | if (wanted_type->id == TypeTableEntryIdComptimeFloat) { |
| 9605 | 9605 | float_init_float(&result->value, val); |
| 9606 | | } else if (wanted_type->id == TypeTableEntryIdNumLitInt) { |
| 9606 | } else if (wanted_type->id == TypeTableEntryIdComptimeInt) { |
| 9607 | 9607 | bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint); |
| 9608 | 9608 | } else { |
| 9609 | 9609 | zig_unreachable(); |
| ... | ... | @@ -9978,8 +9978,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 9978 | 9978 | TypeTableEntry *wanted_child_type = wanted_type->data.maybe.child_type; |
| 9979 | 9979 | if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node).id == ConstCastResultIdOk) { |
| 9980 | 9980 | return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type); |
| 9981 | | } else if (actual_type->id == TypeTableEntryIdNumLitInt || |
| 9982 | | actual_type->id == TypeTableEntryIdNumLitFloat) |
| 9981 | } else if (actual_type->id == TypeTableEntryIdComptimeInt || |
| 9982 | actual_type->id == TypeTableEntryIdComptimeFloat) |
| 9983 | 9983 | { |
| 9984 | 9984 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) { |
| 9985 | 9985 | return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type); |
| ... | ... | @@ -10013,8 +10013,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10013 | 10013 | if (wanted_type->id == TypeTableEntryIdErrorUnion) { |
| 10014 | 10014 | if (types_match_const_cast_only(ira, wanted_type->data.error_union.payload_type, actual_type, source_node).id == ConstCastResultIdOk) { |
| 10015 | 10015 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type); |
| 10016 | | } else if (actual_type->id == TypeTableEntryIdNumLitInt || |
| 10017 | | actual_type->id == TypeTableEntryIdNumLitFloat) |
| 10016 | } else if (actual_type->id == TypeTableEntryIdComptimeInt || |
| 10017 | actual_type->id == TypeTableEntryIdComptimeFloat) |
| 10018 | 10018 | { |
| 10019 | 10019 | if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) { |
| 10020 | 10020 | return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type); |
| ... | ... | @@ -10062,8 +10062,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10062 | 10062 | TypeTableEntry *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type; |
| 10063 | 10063 | if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node).id == ConstCastResultIdOk || |
| 10064 | 10064 | actual_type->id == TypeTableEntryIdNullLit || |
| 10065 | | actual_type->id == TypeTableEntryIdNumLitInt || |
| 10066 | | actual_type->id == TypeTableEntryIdNumLitFloat) |
| 10065 | actual_type->id == TypeTableEntryIdComptimeInt || |
| 10066 | actual_type->id == TypeTableEntryIdComptimeFloat) |
| 10067 | 10067 | { |
| 10068 | 10068 | IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value); |
| 10069 | 10069 | if (type_is_invalid(cast1->value.type)) |
| ... | ... | @@ -10079,8 +10079,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10079 | 10079 | |
| 10080 | 10080 | // explicit cast from number literal to another type |
| 10081 | 10081 | // explicit cast from number literal to &const integer |
| 10082 | | if (actual_type->id == TypeTableEntryIdNumLitFloat || |
| 10083 | | actual_type->id == TypeTableEntryIdNumLitInt) |
| 10082 | if (actual_type->id == TypeTableEntryIdComptimeFloat || |
| 10083 | actual_type->id == TypeTableEntryIdComptimeInt) |
| 10084 | 10084 | { |
| 10085 | 10085 | ensure_complete_type(ira->codegen, wanted_type); |
| 10086 | 10086 | if (type_is_invalid(wanted_type)) |
| ... | ... | @@ -10109,9 +10109,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10109 | 10109 | return cast2; |
| 10110 | 10110 | } else if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) { |
| 10111 | 10111 | CastOp op; |
| 10112 | | if ((actual_type->id == TypeTableEntryIdNumLitFloat && |
| 10112 | if ((actual_type->id == TypeTableEntryIdComptimeFloat && |
| 10113 | 10113 | wanted_type->id == TypeTableEntryIdFloat) || |
| 10114 | | (actual_type->id == TypeTableEntryIdNumLitInt && |
| 10114 | (actual_type->id == TypeTableEntryIdComptimeInt && |
| 10115 | 10115 | wanted_type->id == TypeTableEntryIdInt)) |
| 10116 | 10116 | { |
| 10117 | 10117 | op = CastOpNumLitToConcrete; |
| ... | ... | @@ -10131,8 +10131,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst |
| 10131 | 10131 | // explicit cast from typed number to integer or float literal. |
| 10132 | 10132 | // works when the number is known at compile time |
| 10133 | 10133 | if (instr_is_comptime(value) && |
| 10134 | | ((actual_type->id == TypeTableEntryIdInt && wanted_type->id == TypeTableEntryIdNumLitInt) || |
| 10135 | | (actual_type->id == TypeTableEntryIdFloat && wanted_type->id == TypeTableEntryIdNumLitFloat))) |
| 10134 | ((actual_type->id == TypeTableEntryIdInt && wanted_type->id == TypeTableEntryIdComptimeInt) || |
| 10135 | (actual_type->id == TypeTableEntryIdFloat && wanted_type->id == TypeTableEntryIdComptimeFloat))) |
| 10136 | 10136 | { |
| 10137 | 10137 | return ir_analyze_number_to_literal(ira, source_instr, value, wanted_type); |
| 10138 | 10138 | } |
| ... | ... | @@ -10759,8 +10759,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 10759 | 10759 | case TypeTableEntryIdInvalid: |
| 10760 | 10760 | zig_unreachable(); // handled above |
| 10761 | 10761 | |
| 10762 | | case TypeTableEntryIdNumLitFloat: |
| 10763 | | case TypeTableEntryIdNumLitInt: |
| 10762 | case TypeTableEntryIdComptimeFloat: |
| 10763 | case TypeTableEntryIdComptimeInt: |
| 10764 | 10764 | case TypeTableEntryIdInt: |
| 10765 | 10765 | case TypeTableEntryIdFloat: |
| 10766 | 10766 | break; |
| ... | ... | @@ -10818,10 +10818,10 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp |
| 10818 | 10818 | bool one_possible_value = !type_requires_comptime(resolved_type) && !type_has_bits(resolved_type); |
| 10819 | 10819 | if (one_possible_value || (value_is_comptime(op1_val) && value_is_comptime(op2_val))) { |
| 10820 | 10820 | bool answer; |
| 10821 | | if (resolved_type->id == TypeTableEntryIdNumLitFloat || resolved_type->id == TypeTableEntryIdFloat) { |
| 10821 | if (resolved_type->id == TypeTableEntryIdComptimeFloat || resolved_type->id == TypeTableEntryIdFloat) { |
| 10822 | 10822 | Cmp cmp_result = float_cmp(op1_val, op2_val); |
| 10823 | 10823 | answer = resolve_cmp_op_id(op_id, cmp_result); |
| 10824 | | } else if (resolved_type->id == TypeTableEntryIdNumLitInt || resolved_type->id == TypeTableEntryIdInt) { |
| 10824 | } else if (resolved_type->id == TypeTableEntryIdComptimeInt || resolved_type->id == TypeTableEntryIdInt) { |
| 10825 | 10825 | Cmp cmp_result = bigint_cmp(&op1_val->data.x_bigint, &op2_val->data.x_bigint); |
| 10826 | 10826 | answer = resolve_cmp_op_id(op_id, cmp_result); |
| 10827 | 10827 | } else { |
| ... | ... | @@ -10885,12 +10885,12 @@ static int ir_eval_math_op(TypeTableEntry *type_entry, ConstExprValue *op1_val, |
| 10885 | 10885 | bool is_int; |
| 10886 | 10886 | bool is_float; |
| 10887 | 10887 | Cmp op2_zcmp; |
| 10888 | | if (type_entry->id == TypeTableEntryIdInt || type_entry->id == TypeTableEntryIdNumLitInt) { |
| 10888 | if (type_entry->id == TypeTableEntryIdInt || type_entry->id == TypeTableEntryIdComptimeInt) { |
| 10889 | 10889 | is_int = true; |
| 10890 | 10890 | is_float = false; |
| 10891 | 10891 | op2_zcmp = bigint_cmp_zero(&op2_val->data.x_bigint); |
| 10892 | 10892 | } else if (type_entry->id == TypeTableEntryIdFloat || |
| 10893 | | type_entry->id == TypeTableEntryIdNumLitFloat) |
| 10893 | type_entry->id == TypeTableEntryIdComptimeFloat) |
| 10894 | 10894 | { |
| 10895 | 10895 | is_int = false; |
| 10896 | 10896 | is_float = true; |
| ... | ... | @@ -11064,7 +11064,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp * |
| 11064 | 11064 | if (type_is_invalid(op1->value.type)) |
| 11065 | 11065 | return ira->codegen->builtin_types.entry_invalid; |
| 11066 | 11066 | |
| 11067 | | if (op1->value.type->id != TypeTableEntryIdInt && op1->value.type->id != TypeTableEntryIdNumLitInt) { |
| 11067 | if (op1->value.type->id != TypeTableEntryIdInt && op1->value.type->id != TypeTableEntryIdComptimeInt) { |
| 11068 | 11068 | ir_add_error(ira, &bin_op_instruction->base, |
| 11069 | 11069 | buf_sprintf("bit shifting operation expected integer type, found '%s'", |
| 11070 | 11070 | buf_ptr(&op1->value.type->name))); |
| ... | ... | @@ -11077,7 +11077,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp * |
| 11077 | 11077 | |
| 11078 | 11078 | IrInstruction *casted_op2; |
| 11079 | 11079 | IrBinOp op_id = bin_op_instruction->op_id; |
| 11080 | | if (op1->value.type->id == TypeTableEntryIdNumLitInt) { |
| 11080 | if (op1->value.type->id == TypeTableEntryIdComptimeInt) { |
| 11081 | 11081 | casted_op2 = op2; |
| 11082 | 11082 | |
| 11083 | 11083 | if (op_id == IrBinOpBitShiftLeftLossy) { |
| ... | ... | @@ -11122,7 +11122,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp * |
| 11122 | 11122 | |
| 11123 | 11123 | ir_num_lit_fits_in_other_type(ira, result_instruction, op1->value.type, false); |
| 11124 | 11124 | return op1->value.type; |
| 11125 | | } else if (op1->value.type->id == TypeTableEntryIdNumLitInt) { |
| 11125 | } else if (op1->value.type->id == TypeTableEntryIdComptimeInt) { |
| 11126 | 11126 | ir_add_error(ira, &bin_op_instruction->base, |
| 11127 | 11127 | buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); |
| 11128 | 11128 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -11158,15 +11158,15 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 11158 | 11158 | if (type_is_invalid(resolved_type)) |
| 11159 | 11159 | return resolved_type; |
| 11160 | 11160 | |
| 11161 | | bool is_int = resolved_type->id == TypeTableEntryIdInt || resolved_type->id == TypeTableEntryIdNumLitInt; |
| 11162 | | bool is_float = resolved_type->id == TypeTableEntryIdFloat || resolved_type->id == TypeTableEntryIdNumLitFloat; |
| 11161 | bool is_int = resolved_type->id == TypeTableEntryIdInt || resolved_type->id == TypeTableEntryIdComptimeInt; |
| 11162 | bool is_float = resolved_type->id == TypeTableEntryIdFloat || resolved_type->id == TypeTableEntryIdComptimeFloat; |
| 11163 | 11163 | bool is_signed_div = ( |
| 11164 | 11164 | (resolved_type->id == TypeTableEntryIdInt && resolved_type->data.integral.is_signed) || |
| 11165 | 11165 | resolved_type->id == TypeTableEntryIdFloat || |
| 11166 | | (resolved_type->id == TypeTableEntryIdNumLitFloat && |
| 11166 | (resolved_type->id == TypeTableEntryIdComptimeFloat && |
| 11167 | 11167 | ((bigfloat_cmp_zero(&op1->value.data.x_bigfloat) != CmpGT) != |
| 11168 | 11168 | (bigfloat_cmp_zero(&op2->value.data.x_bigfloat) != CmpGT))) || |
| 11169 | | (resolved_type->id == TypeTableEntryIdNumLitInt && |
| 11169 | (resolved_type->id == TypeTableEntryIdComptimeInt && |
| 11170 | 11170 | ((bigint_cmp_zero(&op1->value.data.x_bigint) != CmpGT) != |
| 11171 | 11171 | (bigint_cmp_zero(&op2->value.data.x_bigint) != CmpGT))) |
| 11172 | 11172 | ); |
| ... | ... | @@ -11267,7 +11267,7 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 11267 | 11267 | return ira->codegen->builtin_types.entry_invalid; |
| 11268 | 11268 | } |
| 11269 | 11269 | |
| 11270 | | if (resolved_type->id == TypeTableEntryIdNumLitInt) { |
| 11270 | if (resolved_type->id == TypeTableEntryIdComptimeInt) { |
| 11271 | 11271 | if (op_id == IrBinOpAddWrap) { |
| 11272 | 11272 | op_id = IrBinOpAdd; |
| 11273 | 11273 | } else if (op_id == IrBinOpSubWrap) { |
| ... | ... | @@ -11641,8 +11641,8 @@ static VarClassRequired get_var_class_required(TypeTableEntry *type_entry) { |
| 11641 | 11641 | case TypeTableEntryIdFn: |
| 11642 | 11642 | case TypeTableEntryIdPromise: |
| 11643 | 11643 | return VarClassRequiredAny; |
| 11644 | | case TypeTableEntryIdNumLitFloat: |
| 11645 | | case TypeTableEntryIdNumLitInt: |
| 11644 | case TypeTableEntryIdComptimeFloat: |
| 11645 | case TypeTableEntryIdComptimeInt: |
| 11646 | 11646 | case TypeTableEntryIdUndefLit: |
| 11647 | 11647 | case TypeTableEntryIdBlock: |
| 11648 | 11648 | case TypeTableEntryIdNullLit: |
| ... | ... | @@ -11910,8 +11910,8 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi |
| 11910 | 11910 | case TypeTableEntryIdMetaType: |
| 11911 | 11911 | case TypeTableEntryIdVoid: |
| 11912 | 11912 | case TypeTableEntryIdUnreachable: |
| 11913 | | case TypeTableEntryIdNumLitFloat: |
| 11914 | | case TypeTableEntryIdNumLitInt: |
| 11913 | case TypeTableEntryIdComptimeFloat: |
| 11914 | case TypeTableEntryIdComptimeInt: |
| 11915 | 11915 | case TypeTableEntryIdUndefLit: |
| 11916 | 11916 | case TypeTableEntryIdNullLit: |
| 11917 | 11917 | case TypeTableEntryIdMaybe: |
| ... | ... | @@ -11934,8 +11934,8 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi |
| 11934 | 11934 | case TypeTableEntryIdFloat: |
| 11935 | 11935 | case TypeTableEntryIdPointer: |
| 11936 | 11936 | case TypeTableEntryIdArray: |
| 11937 | | case TypeTableEntryIdNumLitFloat: |
| 11938 | | case TypeTableEntryIdNumLitInt: |
| 11937 | case TypeTableEntryIdComptimeFloat: |
| 11938 | case TypeTableEntryIdComptimeInt: |
| 11939 | 11939 | case TypeTableEntryIdUndefLit: |
| 11940 | 11940 | case TypeTableEntryIdNullLit: |
| 11941 | 11941 | case TypeTableEntryIdMaybe: |
| ... | ... | @@ -12149,7 +12149,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 12149 | 12149 | } |
| 12150 | 12150 | |
| 12151 | 12151 | bool comptime_arg = param_decl_node->data.param_decl.is_inline || |
| 12152 | | casted_arg->value.type->id == TypeTableEntryIdNumLitInt || casted_arg->value.type->id == TypeTableEntryIdNumLitFloat; |
| 12152 | casted_arg->value.type->id == TypeTableEntryIdComptimeInt || casted_arg->value.type->id == TypeTableEntryIdComptimeFloat; |
| 12153 | 12153 | |
| 12154 | 12154 | ConstExprValue *arg_val; |
| 12155 | 12155 | |
| ... | ... | @@ -12174,8 +12174,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 12174 | 12174 | var->shadowable = !comptime_arg; |
| 12175 | 12175 | |
| 12176 | 12176 | *next_proto_i += 1; |
| 12177 | | } else if (casted_arg->value.type->id == TypeTableEntryIdNumLitInt || |
| 12178 | | casted_arg->value.type->id == TypeTableEntryIdNumLitFloat) |
| 12177 | } else if (casted_arg->value.type->id == TypeTableEntryIdComptimeInt || |
| 12178 | casted_arg->value.type->id == TypeTableEntryIdComptimeFloat) |
| 12179 | 12179 | { |
| 12180 | 12180 | ir_add_error(ira, casted_arg, |
| 12181 | 12181 | buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557")); |
| ... | ... | @@ -12898,8 +12898,8 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op |
| 12898 | 12898 | case TypeTableEntryIdPointer: |
| 12899 | 12899 | case TypeTableEntryIdArray: |
| 12900 | 12900 | case TypeTableEntryIdStruct: |
| 12901 | | case TypeTableEntryIdNumLitFloat: |
| 12902 | | case TypeTableEntryIdNumLitInt: |
| 12901 | case TypeTableEntryIdComptimeFloat: |
| 12902 | case TypeTableEntryIdComptimeInt: |
| 12903 | 12903 | case TypeTableEntryIdUndefLit: |
| 12904 | 12904 | case TypeTableEntryIdNullLit: |
| 12905 | 12905 | case TypeTableEntryIdMaybe: |
| ... | ... | @@ -12935,10 +12935,10 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un |
| 12935 | 12935 | |
| 12936 | 12936 | bool is_wrap_op = (un_op_instruction->op_id == IrUnOpNegationWrap); |
| 12937 | 12937 | |
| 12938 | | bool is_float = (expr_type->id == TypeTableEntryIdFloat || expr_type->id == TypeTableEntryIdNumLitFloat); |
| 12938 | bool is_float = (expr_type->id == TypeTableEntryIdFloat || expr_type->id == TypeTableEntryIdComptimeFloat); |
| 12939 | 12939 | |
| 12940 | 12940 | if ((expr_type->id == TypeTableEntryIdInt && expr_type->data.integral.is_signed) || |
| 12941 | | expr_type->id == TypeTableEntryIdNumLitInt || (is_float && !is_wrap_op)) |
| 12941 | expr_type->id == TypeTableEntryIdComptimeInt || (is_float && !is_wrap_op)) |
| 12942 | 12942 | { |
| 12943 | 12943 | if (instr_is_comptime(value)) { |
| 12944 | 12944 | ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad); |
| ... | ... | @@ -12954,7 +12954,7 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un |
| 12954 | 12954 | } else { |
| 12955 | 12955 | bigint_negate(&out_val->data.x_bigint, &target_const_val->data.x_bigint); |
| 12956 | 12956 | } |
| 12957 | | if (is_wrap_op || is_float || expr_type->id == TypeTableEntryIdNumLitInt) { |
| 12957 | if (is_wrap_op || is_float || expr_type->id == TypeTableEntryIdComptimeInt) { |
| 12958 | 12958 | return expr_type; |
| 12959 | 12959 | } |
| 12960 | 12960 | |
| ... | ... | @@ -13150,8 +13150,8 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP |
| 13150 | 13150 | if (type_is_invalid(resolved_type)) |
| 13151 | 13151 | return resolved_type; |
| 13152 | 13152 | |
| 13153 | | if (resolved_type->id == TypeTableEntryIdNumLitFloat || |
| 13154 | | resolved_type->id == TypeTableEntryIdNumLitInt || |
| 13153 | if (resolved_type->id == TypeTableEntryIdComptimeFloat || |
| 13154 | resolved_type->id == TypeTableEntryIdComptimeInt || |
| 13155 | 13155 | resolved_type->id == TypeTableEntryIdNullLit || |
| 13156 | 13156 | resolved_type->id == TypeTableEntryIdUndefLit) |
| 13157 | 13157 | { |
| ... | ... | @@ -14213,8 +14213,8 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi |
| 14213 | 14213 | switch (type_entry->id) { |
| 14214 | 14214 | case TypeTableEntryIdInvalid: |
| 14215 | 14215 | zig_unreachable(); // handled above |
| 14216 | | case TypeTableEntryIdNumLitFloat: |
| 14217 | | case TypeTableEntryIdNumLitInt: |
| 14216 | case TypeTableEntryIdComptimeFloat: |
| 14217 | case TypeTableEntryIdComptimeInt: |
| 14218 | 14218 | case TypeTableEntryIdUndefLit: |
| 14219 | 14219 | case TypeTableEntryIdNullLit: |
| 14220 | 14220 | case TypeTableEntryIdNamespace: |
| ... | ... | @@ -14495,8 +14495,8 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 14495 | 14495 | case TypeTableEntryIdPointer: |
| 14496 | 14496 | case TypeTableEntryIdArray: |
| 14497 | 14497 | case TypeTableEntryIdStruct: |
| 14498 | | case TypeTableEntryIdNumLitFloat: |
| 14499 | | case TypeTableEntryIdNumLitInt: |
| 14498 | case TypeTableEntryIdComptimeFloat: |
| 14499 | case TypeTableEntryIdComptimeInt: |
| 14500 | 14500 | case TypeTableEntryIdMaybe: |
| 14501 | 14501 | case TypeTableEntryIdErrorUnion: |
| 14502 | 14502 | case TypeTableEntryIdErrorSet: |
| ... | ... | @@ -14603,8 +14603,8 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 14603 | 14603 | case TypeTableEntryIdPointer: |
| 14604 | 14604 | case TypeTableEntryIdArray: |
| 14605 | 14605 | case TypeTableEntryIdStruct: |
| 14606 | | case TypeTableEntryIdNumLitFloat: |
| 14607 | | case TypeTableEntryIdNumLitInt: |
| 14606 | case TypeTableEntryIdComptimeFloat: |
| 14607 | case TypeTableEntryIdComptimeInt: |
| 14608 | 14608 | case TypeTableEntryIdMaybe: |
| 14609 | 14609 | case TypeTableEntryIdErrorUnion: |
| 14610 | 14610 | case TypeTableEntryIdErrorSet: |
| ... | ... | @@ -14659,8 +14659,8 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira, |
| 14659 | 14659 | case TypeTableEntryIdUndefLit: |
| 14660 | 14660 | case TypeTableEntryIdNullLit: |
| 14661 | 14661 | case TypeTableEntryIdBlock: |
| 14662 | | case TypeTableEntryIdNumLitFloat: |
| 14663 | | case TypeTableEntryIdNumLitInt: |
| 14662 | case TypeTableEntryIdComptimeFloat: |
| 14663 | case TypeTableEntryIdComptimeInt: |
| 14664 | 14664 | case TypeTableEntryIdBoundFn: |
| 14665 | 14665 | case TypeTableEntryIdMetaType: |
| 14666 | 14666 | case TypeTableEntryIdNamespace: |
| ... | ... | @@ -15020,8 +15020,8 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 15020 | 15020 | case TypeTableEntryIdBool: |
| 15021 | 15021 | case TypeTableEntryIdInt: |
| 15022 | 15022 | case TypeTableEntryIdFloat: |
| 15023 | | case TypeTableEntryIdNumLitFloat: |
| 15024 | | case TypeTableEntryIdNumLitInt: |
| 15023 | case TypeTableEntryIdComptimeFloat: |
| 15024 | case TypeTableEntryIdComptimeInt: |
| 15025 | 15025 | case TypeTableEntryIdPointer: |
| 15026 | 15026 | case TypeTableEntryIdPromise: |
| 15027 | 15027 | case TypeTableEntryIdFn: |
| ... | ... | @@ -15618,8 +15618,8 @@ static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_ |
| 15618 | 15618 | case TypeTableEntryIdPromise: |
| 15619 | 15619 | case TypeTableEntryIdArray: |
| 15620 | 15620 | case TypeTableEntryIdStruct: |
| 15621 | | case TypeTableEntryIdNumLitFloat: |
| 15622 | | case TypeTableEntryIdNumLitInt: |
| 15621 | case TypeTableEntryIdComptimeFloat: |
| 15622 | case TypeTableEntryIdComptimeInt: |
| 15623 | 15623 | case TypeTableEntryIdUndefLit: |
| 15624 | 15624 | case TypeTableEntryIdNullLit: |
| 15625 | 15625 | case TypeTableEntryIdMaybe: |
| ... | ... | @@ -16280,8 +16280,8 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t |
| 16280 | 16280 | case TypeTableEntryIdVoid: |
| 16281 | 16281 | case TypeTableEntryIdBool: |
| 16282 | 16282 | case TypeTableEntryIdUnreachable: |
| 16283 | | case TypeTableEntryIdNumLitFloat: |
| 16284 | | case TypeTableEntryIdNumLitInt: |
| 16283 | case TypeTableEntryIdComptimeFloat: |
| 16284 | case TypeTableEntryIdComptimeInt: |
| 16285 | 16285 | case TypeTableEntryIdUndefLit: |
| 16286 | 16286 | case TypeTableEntryIdNullLit: |
| 16287 | 16287 | case TypeTableEntryIdNamespace: |
| ... | ... | @@ -17143,7 +17143,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc |
| 17143 | 17143 | return ira->codegen->builtin_types.entry_invalid; |
| 17144 | 17144 | |
| 17145 | 17145 | if (dest_type->id != TypeTableEntryIdInt && |
| 17146 | | dest_type->id != TypeTableEntryIdNumLitInt) |
| 17146 | dest_type->id != TypeTableEntryIdComptimeInt) |
| 17147 | 17147 | { |
| 17148 | 17148 | ir_add_error(ira, dest_type_value, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name))); |
| 17149 | 17149 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -17155,7 +17155,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc |
| 17155 | 17155 | return ira->codegen->builtin_types.entry_invalid; |
| 17156 | 17156 | |
| 17157 | 17157 | if (src_type->id != TypeTableEntryIdInt && |
| 17158 | | src_type->id != TypeTableEntryIdNumLitInt) |
| 17158 | src_type->id != TypeTableEntryIdComptimeInt) |
| 17159 | 17159 | { |
| 17160 | 17160 | ir_add_error(ira, target, buf_sprintf("expected integer type, found '%s'", buf_ptr(&src_type->name))); |
| 17161 | 17161 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -17876,8 +17876,8 @@ static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruc |
| 17876 | 17876 | zig_unreachable(); |
| 17877 | 17877 | case TypeTableEntryIdMetaType: |
| 17878 | 17878 | case TypeTableEntryIdUnreachable: |
| 17879 | | case TypeTableEntryIdNumLitFloat: |
| 17880 | | case TypeTableEntryIdNumLitInt: |
| 17879 | case TypeTableEntryIdComptimeFloat: |
| 17880 | case TypeTableEntryIdComptimeInt: |
| 17881 | 17881 | case TypeTableEntryIdUndefLit: |
| 17882 | 17882 | case TypeTableEntryIdNullLit: |
| 17883 | 17883 | case TypeTableEntryIdNamespace: |
| ... | ... | @@ -18377,8 +18377,8 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira |
| 18377 | 18377 | if (!end_val) |
| 18378 | 18378 | return ira->codegen->builtin_types.entry_invalid; |
| 18379 | 18379 | |
| 18380 | | assert(start_val->type->id == TypeTableEntryIdInt || start_val->type->id == TypeTableEntryIdNumLitInt); |
| 18381 | | assert(end_val->type->id == TypeTableEntryIdInt || end_val->type->id == TypeTableEntryIdNumLitInt); |
| 18380 | assert(start_val->type->id == TypeTableEntryIdInt || start_val->type->id == TypeTableEntryIdComptimeInt); |
| 18381 | assert(end_val->type->id == TypeTableEntryIdInt || end_val->type->id == TypeTableEntryIdComptimeInt); |
| 18382 | 18382 | AstNode *prev_node = rangeset_add_range(&rs, &start_val->data.x_bigint, &end_val->data.x_bigint, |
| 18383 | 18383 | start_value->source_node); |
| 18384 | 18384 | if (prev_node != nullptr) { |
| ... | ... | @@ -18610,8 +18610,8 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 18610 | 18610 | case TypeTableEntryIdNamespace: |
| 18611 | 18611 | case TypeTableEntryIdBlock: |
| 18612 | 18612 | case TypeTableEntryIdUnreachable: |
| 18613 | | case TypeTableEntryIdNumLitFloat: |
| 18614 | | case TypeTableEntryIdNumLitInt: |
| 18613 | case TypeTableEntryIdComptimeFloat: |
| 18614 | case TypeTableEntryIdComptimeInt: |
| 18615 | 18615 | case TypeTableEntryIdUndefLit: |
| 18616 | 18616 | case TypeTableEntryIdNullLit: |
| 18617 | 18617 | case TypeTableEntryIdPromise: |
| ... | ... | @@ -18677,8 +18677,8 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 18677 | 18677 | case TypeTableEntryIdNamespace: |
| 18678 | 18678 | case TypeTableEntryIdBlock: |
| 18679 | 18679 | case TypeTableEntryIdUnreachable: |
| 18680 | | case TypeTableEntryIdNumLitFloat: |
| 18681 | | case TypeTableEntryIdNumLitInt: |
| 18680 | case TypeTableEntryIdComptimeFloat: |
| 18681 | case TypeTableEntryIdComptimeInt: |
| 18682 | 18682 | case TypeTableEntryIdUndefLit: |
| 18683 | 18683 | case TypeTableEntryIdNullLit: |
| 18684 | 18684 | case TypeTableEntryIdPromise: |
| ... | ... | @@ -18758,8 +18758,8 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc |
| 18758 | 18758 | case TypeTableEntryIdNamespace: |
| 18759 | 18759 | case TypeTableEntryIdBlock: |
| 18760 | 18760 | case TypeTableEntryIdUnreachable: |
| 18761 | | case TypeTableEntryIdNumLitFloat: |
| 18762 | | case TypeTableEntryIdNumLitInt: |
| 18761 | case TypeTableEntryIdComptimeFloat: |
| 18762 | case TypeTableEntryIdComptimeInt: |
| 18763 | 18763 | case TypeTableEntryIdUndefLit: |
| 18764 | 18764 | case TypeTableEntryIdNullLit: |
| 18765 | 18765 | ir_add_error(ira, dest_type_value, |
| ... | ... | @@ -18784,8 +18784,8 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc |
| 18784 | 18784 | case TypeTableEntryIdNamespace: |
| 18785 | 18785 | case TypeTableEntryIdBlock: |
| 18786 | 18786 | case TypeTableEntryIdUnreachable: |
| 18787 | | case TypeTableEntryIdNumLitFloat: |
| 18788 | | case TypeTableEntryIdNumLitInt: |
| 18787 | case TypeTableEntryIdComptimeFloat: |
| 18788 | case TypeTableEntryIdComptimeInt: |
| 18789 | 18789 | case TypeTableEntryIdUndefLit: |
| 18790 | 18790 | case TypeTableEntryIdNullLit: |
| 18791 | 18791 | ir_add_error(ira, dest_type_value, |
| ... | ... | @@ -19560,7 +19560,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction |
| 19560 | 19560 | if (type_is_invalid(op->value.type)) |
| 19561 | 19561 | return ira->codegen->builtin_types.entry_invalid; |
| 19562 | 19562 | |
| 19563 | | bool ok_type = float_type->id == TypeTableEntryIdNumLitFloat || float_type->id == TypeTableEntryIdFloat; |
| 19563 | bool ok_type = float_type->id == TypeTableEntryIdComptimeFloat || float_type->id == TypeTableEntryIdFloat; |
| 19564 | 19564 | if (!ok_type) { |
| 19565 | 19565 | ir_add_error(ira, instruction->type, buf_sprintf("@sqrt does not support type '%s'", buf_ptr(&float_type->name))); |
| 19566 | 19566 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -19577,7 +19577,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction |
| 19577 | 19577 | |
| 19578 | 19578 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 19579 | 19579 | |
| 19580 | | if (float_type->id == TypeTableEntryIdNumLitFloat) { |
| 19580 | if (float_type->id == TypeTableEntryIdComptimeFloat) { |
| 19581 | 19581 | bigfloat_sqrt(&out_val->data.x_bigfloat, &val->data.x_bigfloat); |
| 19582 | 19582 | } else if (float_type->id == TypeTableEntryIdFloat) { |
| 19583 | 19583 | switch (float_type->data.floating.bit_count) { |