authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-06-05 10:16:51-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2018-06-05 10:16:51-04:00
log677eaf29b10df9b1dc461b37e7be78734b11ef19
tree3046287688eeb219464fcb2c2ba1fd34185b1a0c
parente53b683bd3958a7b1c517e2391edce42b9d4e48b
parenta8146ade2a57bea12ea2d16bd273f03578e5d559
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #1057 from ziglang/comptime-int

Rename integer literal type and float literal type

13 files changed, 355 insertions(+), 341 deletions(-)

doc/langref.html.in+16-16
...@@ -4893,10 +4893,10 @@ pub const TypeId = enum {...@@ -4893,10 +4893,10 @@ pub const TypeId = enum {
4893 Pointer,4893 Pointer,
4894 Array,4894 Array,
4895 Struct,4895 Struct,
4896 FloatLiteral,4896 ComptimeFloat,
4897 IntLiteral,4897 ComptimeInt,
4898 UndefinedLiteral,4898 Undefined,
4899 NullLiteral,4899 Null,
4900 Nullable,4900 Nullable,
4901 ErrorUnion,4901 ErrorUnion,
4902 Error,4902 Error,
...@@ -4927,10 +4927,10 @@ pub const TypeInfo = union(TypeId) {...@@ -4927,10 +4927,10 @@ pub const TypeInfo = union(TypeId) {
4927 Pointer: Pointer,4927 Pointer: Pointer,
4928 Array: Array,4928 Array: Array,
4929 Struct: Struct,4929 Struct: Struct,
4930 FloatLiteral: void,4930 ComptimeFloat: void,
4931 IntLiteral: void,4931 ComptimeInt: void,
4932 UndefinedLiteral: void,4932 Undefined: void,
4933 NullLiteral: void,4933 Null: void,
4934 Nullable: Nullable,4934 Nullable: Nullable,
4935 ErrorUnion: ErrorUnion,4935 ErrorUnion: ErrorUnion,
4936 ErrorSet: ErrorSet,4936 ErrorSet: ErrorSet,
...@@ -5685,10 +5685,10 @@ pub const TypeId = enum {...@@ -5685,10 +5685,10 @@ pub const TypeId = enum {
5685 Pointer,5685 Pointer,
5686 Array,5686 Array,
5687 Struct,5687 Struct,
5688 FloatLiteral,5688 ComptimeFloat,
5689 IntLiteral,5689 ComptimeInt,
5690 UndefinedLiteral,5690 Undefined,
5691 NullLiteral,5691 Null,
5692 Nullable,5692 Nullable,
5693 ErrorUnion,5693 ErrorUnion,
5694 ErrorSet,5694 ErrorSet,
...@@ -5713,10 +5713,10 @@ pub const TypeInfo = union(TypeId) {...@@ -5713,10 +5713,10 @@ pub const TypeInfo = union(TypeId) {
5713 Pointer: Pointer,5713 Pointer: Pointer,
5714 Array: Array,5714 Array: Array,
5715 Struct: Struct,5715 Struct: Struct,
5716 FloatLiteral: void,5716 ComptimeFloat: void,
5717 IntLiteral: void,5717 ComptimeInt: void,
5718 UndefinedLiteral: void,5718 Undefined: void,
5719 NullLiteral: void,5719 Null: void,
5720 Nullable: Nullable,5720 Nullable: Nullable,
5721 ErrorUnion: ErrorUnion,5721 ErrorUnion: ErrorUnion,
5722 ErrorSet: ErrorSet,5722 ErrorSet: ErrorSet,
src/all_types.hpp+4-4
...@@ -1159,10 +1159,10 @@ enum TypeTableEntryId {...@@ -1159,10 +1159,10 @@ enum TypeTableEntryId {
1159 TypeTableEntryIdPointer,1159 TypeTableEntryIdPointer,
1160 TypeTableEntryIdArray,1160 TypeTableEntryIdArray,
1161 TypeTableEntryIdStruct,1161 TypeTableEntryIdStruct,
1162 TypeTableEntryIdNumLitFloat,1162 TypeTableEntryIdComptimeFloat,
1163 TypeTableEntryIdNumLitInt,1163 TypeTableEntryIdComptimeInt,
1164 TypeTableEntryIdUndefLit,1164 TypeTableEntryIdUndefined,
1165 TypeTableEntryIdNullLit,1165 TypeTableEntryIdNull,
1166 TypeTableEntryIdMaybe,1166 TypeTableEntryIdMaybe,
1167 TypeTableEntryIdErrorUnion,1167 TypeTableEntryIdErrorUnion,
1168 TypeTableEntryIdErrorSet,1168 TypeTableEntryIdErrorSet,
src/analyze.cpp+92-92
...@@ -232,10 +232,10 @@ bool type_is_complete(TypeTableEntry *type_entry) {...@@ -232,10 +232,10 @@ bool type_is_complete(TypeTableEntry *type_entry) {
232 case TypeTableEntryIdFloat:232 case TypeTableEntryIdFloat:
233 case TypeTableEntryIdPointer:233 case TypeTableEntryIdPointer:
234 case TypeTableEntryIdArray:234 case TypeTableEntryIdArray:
235 case TypeTableEntryIdNumLitFloat:235 case TypeTableEntryIdComptimeFloat:
236 case TypeTableEntryIdNumLitInt:236 case TypeTableEntryIdComptimeInt:
237 case TypeTableEntryIdUndefLit:237 case TypeTableEntryIdUndefined:
238 case TypeTableEntryIdNullLit:238 case TypeTableEntryIdNull:
239 case TypeTableEntryIdMaybe:239 case TypeTableEntryIdMaybe:
240 case TypeTableEntryIdErrorUnion:240 case TypeTableEntryIdErrorUnion:
241 case TypeTableEntryIdErrorSet:241 case TypeTableEntryIdErrorSet:
...@@ -268,10 +268,10 @@ bool type_has_zero_bits_known(TypeTableEntry *type_entry) {...@@ -268,10 +268,10 @@ bool type_has_zero_bits_known(TypeTableEntry *type_entry) {
268 case TypeTableEntryIdFloat:268 case TypeTableEntryIdFloat:
269 case TypeTableEntryIdPointer:269 case TypeTableEntryIdPointer:
270 case TypeTableEntryIdArray:270 case TypeTableEntryIdArray:
271 case TypeTableEntryIdNumLitFloat:271 case TypeTableEntryIdComptimeFloat:
272 case TypeTableEntryIdNumLitInt:272 case TypeTableEntryIdComptimeInt:
273 case TypeTableEntryIdUndefLit:273 case TypeTableEntryIdUndefined:
274 case TypeTableEntryIdNullLit:274 case TypeTableEntryIdNull:
275 case TypeTableEntryIdMaybe:275 case TypeTableEntryIdMaybe:
276 case TypeTableEntryIdErrorUnion:276 case TypeTableEntryIdErrorUnion:
277 case TypeTableEntryIdErrorSet:277 case TypeTableEntryIdErrorSet:
...@@ -1333,10 +1333,10 @@ static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {...@@ -1333,10 +1333,10 @@ static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {
1333 zig_unreachable();1333 zig_unreachable();
1334 case TypeTableEntryIdMetaType:1334 case TypeTableEntryIdMetaType:
1335 case TypeTableEntryIdUnreachable:1335 case TypeTableEntryIdUnreachable:
1336 case TypeTableEntryIdNumLitFloat:1336 case TypeTableEntryIdComptimeFloat:
1337 case TypeTableEntryIdNumLitInt:1337 case TypeTableEntryIdComptimeInt:
1338 case TypeTableEntryIdUndefLit:1338 case TypeTableEntryIdUndefined:
1339 case TypeTableEntryIdNullLit:1339 case TypeTableEntryIdNull:
1340 case TypeTableEntryIdErrorUnion:1340 case TypeTableEntryIdErrorUnion:
1341 case TypeTableEntryIdErrorSet:1341 case TypeTableEntryIdErrorSet:
1342 case TypeTableEntryIdNamespace:1342 case TypeTableEntryIdNamespace:
...@@ -1374,10 +1374,10 @@ static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {...@@ -1374,10 +1374,10 @@ static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {
1374 case TypeTableEntryIdInvalid:1374 case TypeTableEntryIdInvalid:
1375 zig_unreachable();1375 zig_unreachable();
1376 case TypeTableEntryIdMetaType:1376 case TypeTableEntryIdMetaType:
1377 case TypeTableEntryIdNumLitFloat:1377 case TypeTableEntryIdComptimeFloat:
1378 case TypeTableEntryIdNumLitInt:1378 case TypeTableEntryIdComptimeInt:
1379 case TypeTableEntryIdUndefLit:1379 case TypeTableEntryIdUndefined:
1380 case TypeTableEntryIdNullLit:1380 case TypeTableEntryIdNull:
1381 case TypeTableEntryIdErrorUnion:1381 case TypeTableEntryIdErrorUnion:
1382 case TypeTableEntryIdErrorSet:1382 case TypeTableEntryIdErrorSet:
1383 case TypeTableEntryIdNamespace:1383 case TypeTableEntryIdNamespace:
...@@ -1511,15 +1511,15 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c...@@ -1511,15 +1511,15 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
1511 case TypeTableEntryIdInvalid:1511 case TypeTableEntryIdInvalid:
1512 return g->builtin_types.entry_invalid;1512 return g->builtin_types.entry_invalid;
1513 case TypeTableEntryIdUnreachable:1513 case TypeTableEntryIdUnreachable:
1514 case TypeTableEntryIdUndefLit:1514 case TypeTableEntryIdUndefined:
1515 case TypeTableEntryIdNullLit:1515 case TypeTableEntryIdNull:
1516 case TypeTableEntryIdArgTuple:1516 case TypeTableEntryIdArgTuple:
1517 case TypeTableEntryIdOpaque:1517 case TypeTableEntryIdOpaque:
1518 add_node_error(g, param_node->data.param_decl.type,1518 add_node_error(g, param_node->data.param_decl.type,
1519 buf_sprintf("parameter of type '%s' not allowed", buf_ptr(&type_entry->name)));1519 buf_sprintf("parameter of type '%s' not allowed", buf_ptr(&type_entry->name)));
1520 return g->builtin_types.entry_invalid;1520 return g->builtin_types.entry_invalid;
1521 case TypeTableEntryIdNumLitFloat:1521 case TypeTableEntryIdComptimeFloat:
1522 case TypeTableEntryIdNumLitInt:1522 case TypeTableEntryIdComptimeInt:
1523 case TypeTableEntryIdNamespace:1523 case TypeTableEntryIdNamespace:
1524 case TypeTableEntryIdBlock:1524 case TypeTableEntryIdBlock:
1525 case TypeTableEntryIdBoundFn:1525 case TypeTableEntryIdBoundFn:
...@@ -1599,16 +1599,16 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c...@@ -1599,16 +1599,16 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
1599 case TypeTableEntryIdInvalid:1599 case TypeTableEntryIdInvalid:
1600 zig_unreachable();1600 zig_unreachable();
16011601
1602 case TypeTableEntryIdUndefLit:1602 case TypeTableEntryIdUndefined:
1603 case TypeTableEntryIdNullLit:1603 case TypeTableEntryIdNull:
1604 case TypeTableEntryIdArgTuple:1604 case TypeTableEntryIdArgTuple:
1605 case TypeTableEntryIdOpaque:1605 case TypeTableEntryIdOpaque:
1606 add_node_error(g, fn_proto->return_type,1606 add_node_error(g, fn_proto->return_type,
1607 buf_sprintf("return type '%s' not allowed", buf_ptr(&fn_type_id.return_type->name)));1607 buf_sprintf("return type '%s' not allowed", buf_ptr(&fn_type_id.return_type->name)));
1608 return g->builtin_types.entry_invalid;1608 return g->builtin_types.entry_invalid;
16091609
1610 case TypeTableEntryIdNumLitFloat:1610 case TypeTableEntryIdComptimeFloat:
1611 case TypeTableEntryIdNumLitInt:1611 case TypeTableEntryIdComptimeInt:
1612 case TypeTableEntryIdNamespace:1612 case TypeTableEntryIdNamespace:
1613 case TypeTableEntryIdBlock:1613 case TypeTableEntryIdBlock:
1614 case TypeTableEntryIdBoundFn:1614 case TypeTableEntryIdBoundFn:
...@@ -3337,16 +3337,16 @@ TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEnt...@@ -3337,16 +3337,16 @@ TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEnt
3337 case TypeTableEntryIdInvalid:3337 case TypeTableEntryIdInvalid:
3338 return g->builtin_types.entry_invalid;3338 return g->builtin_types.entry_invalid;
3339 case TypeTableEntryIdUnreachable:3339 case TypeTableEntryIdUnreachable:
3340 case TypeTableEntryIdNumLitFloat:3340 case TypeTableEntryIdUndefined:
3341 case TypeTableEntryIdNumLitInt:3341 case TypeTableEntryIdNull:
3342 case TypeTableEntryIdUndefLit:
3343 case TypeTableEntryIdNullLit:
3344 case TypeTableEntryIdBlock:3342 case TypeTableEntryIdBlock:
3345 case TypeTableEntryIdArgTuple:3343 case TypeTableEntryIdArgTuple:
3346 case TypeTableEntryIdOpaque:3344 case TypeTableEntryIdOpaque:
3347 add_node_error(g, source_node, buf_sprintf("variable of type '%s' not allowed",3345 add_node_error(g, source_node, buf_sprintf("variable of type '%s' not allowed",
3348 buf_ptr(&type_entry->name)));3346 buf_ptr(&type_entry->name)));
3349 return g->builtin_types.entry_invalid;3347 return g->builtin_types.entry_invalid;
3348 case TypeTableEntryIdComptimeFloat:
3349 case TypeTableEntryIdComptimeInt:
3350 case TypeTableEntryIdNamespace:3350 case TypeTableEntryIdNamespace:
3351 case TypeTableEntryIdMetaType:3351 case TypeTableEntryIdMetaType:
3352 case TypeTableEntryIdVoid:3352 case TypeTableEntryIdVoid:
...@@ -3480,12 +3480,12 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {...@@ -3480,12 +3480,12 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {
3480 add_node_error(g, source_node, buf_sprintf("variable initialization is unreachable"));3480 add_node_error(g, source_node, buf_sprintf("variable initialization is unreachable"));
3481 implicit_type = g->builtin_types.entry_invalid;3481 implicit_type = g->builtin_types.entry_invalid;
3482 } else if ((!is_const || linkage == VarLinkageExternal) &&3482 } else if ((!is_const || linkage == VarLinkageExternal) &&
3483 (implicit_type->id == TypeTableEntryIdNumLitFloat ||3483 (implicit_type->id == TypeTableEntryIdComptimeFloat ||
3484 implicit_type->id == TypeTableEntryIdNumLitInt))3484 implicit_type->id == TypeTableEntryIdComptimeInt))
3485 {3485 {
3486 add_node_error(g, source_node, buf_sprintf("unable to infer variable type"));3486 add_node_error(g, source_node, buf_sprintf("unable to infer variable type"));
3487 implicit_type = g->builtin_types.entry_invalid;3487 implicit_type = g->builtin_types.entry_invalid;
3488 } else if (implicit_type->id == TypeTableEntryIdNullLit) {3488 } else if (implicit_type->id == TypeTableEntryIdNull) {
3489 add_node_error(g, source_node, buf_sprintf("unable to infer variable type"));3489 add_node_error(g, source_node, buf_sprintf("unable to infer variable type"));
3490 implicit_type = g->builtin_types.entry_invalid;3490 implicit_type = g->builtin_types.entry_invalid;
3491 } else if (implicit_type->id == TypeTableEntryIdMetaType && !is_const) {3491 } else if (implicit_type->id == TypeTableEntryIdMetaType && !is_const) {
...@@ -3730,10 +3730,10 @@ static bool is_container(TypeTableEntry *type_entry) {...@@ -3730,10 +3730,10 @@ static bool is_container(TypeTableEntry *type_entry) {
3730 case TypeTableEntryIdInt:3730 case TypeTableEntryIdInt:
3731 case TypeTableEntryIdFloat:3731 case TypeTableEntryIdFloat:
3732 case TypeTableEntryIdArray:3732 case TypeTableEntryIdArray:
3733 case TypeTableEntryIdNumLitFloat:3733 case TypeTableEntryIdComptimeFloat:
3734 case TypeTableEntryIdNumLitInt:3734 case TypeTableEntryIdComptimeInt:
3735 case TypeTableEntryIdUndefLit:3735 case TypeTableEntryIdUndefined:
3736 case TypeTableEntryIdNullLit:3736 case TypeTableEntryIdNull:
3737 case TypeTableEntryIdMaybe:3737 case TypeTableEntryIdMaybe:
3738 case TypeTableEntryIdErrorUnion:3738 case TypeTableEntryIdErrorUnion:
3739 case TypeTableEntryIdErrorSet:3739 case TypeTableEntryIdErrorSet:
...@@ -3779,10 +3779,10 @@ void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry) {...@@ -3779,10 +3779,10 @@ void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry) {
3779 case TypeTableEntryIdInt:3779 case TypeTableEntryIdInt:
3780 case TypeTableEntryIdFloat:3780 case TypeTableEntryIdFloat:
3781 case TypeTableEntryIdArray:3781 case TypeTableEntryIdArray:
3782 case TypeTableEntryIdNumLitFloat:3782 case TypeTableEntryIdComptimeFloat:
3783 case TypeTableEntryIdNumLitInt:3783 case TypeTableEntryIdComptimeInt:
3784 case TypeTableEntryIdUndefLit:3784 case TypeTableEntryIdUndefined:
3785 case TypeTableEntryIdNullLit:3785 case TypeTableEntryIdNull:
3786 case TypeTableEntryIdMaybe:3786 case TypeTableEntryIdMaybe:
3787 case TypeTableEntryIdErrorUnion:3787 case TypeTableEntryIdErrorUnion:
3788 case TypeTableEntryIdErrorSet:3788 case TypeTableEntryIdErrorSet:
...@@ -4283,10 +4283,10 @@ bool handle_is_ptr(TypeTableEntry *type_entry) {...@@ -4283,10 +4283,10 @@ bool handle_is_ptr(TypeTableEntry *type_entry) {
4283 switch (type_entry->id) {4283 switch (type_entry->id) {
4284 case TypeTableEntryIdInvalid:4284 case TypeTableEntryIdInvalid:
4285 case TypeTableEntryIdMetaType:4285 case TypeTableEntryIdMetaType:
4286 case TypeTableEntryIdNumLitFloat:4286 case TypeTableEntryIdComptimeFloat:
4287 case TypeTableEntryIdNumLitInt:4287 case TypeTableEntryIdComptimeInt:
4288 case TypeTableEntryIdUndefLit:4288 case TypeTableEntryIdUndefined:
4289 case TypeTableEntryIdNullLit:4289 case TypeTableEntryIdNull:
4290 case TypeTableEntryIdNamespace:4290 case TypeTableEntryIdNamespace:
4291 case TypeTableEntryIdBlock:4291 case TypeTableEntryIdBlock:
4292 case TypeTableEntryIdBoundFn:4292 case TypeTableEntryIdBoundFn:
...@@ -4568,7 +4568,7 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {...@@ -4568,7 +4568,7 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {
4568 case TypeTableEntryIdVoid:4568 case TypeTableEntryIdVoid:
4569 return (uint32_t)4149439618;4569 return (uint32_t)4149439618;
4570 case TypeTableEntryIdInt:4570 case TypeTableEntryIdInt:
4571 case TypeTableEntryIdNumLitInt:4571 case TypeTableEntryIdComptimeInt:
4572 {4572 {
4573 uint32_t result = 1331471175;4573 uint32_t result = 1331471175;
4574 for (size_t i = 0; i < const_val->data.x_bigint.digit_count; i += 1) {4574 for (size_t i = 0; i < const_val->data.x_bigint.digit_count; i += 1) {
...@@ -4609,7 +4609,7 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {...@@ -4609,7 +4609,7 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {
4609 default:4609 default:
4610 zig_unreachable();4610 zig_unreachable();
4611 }4611 }
4612 case TypeTableEntryIdNumLitFloat:4612 case TypeTableEntryIdComptimeFloat:
4613 {4613 {
4614 float128_t f128 = bigfloat_to_f128(&const_val->data.x_bigfloat);4614 float128_t f128 = bigfloat_to_f128(&const_val->data.x_bigfloat);
4615 uint32_t ints[4];4615 uint32_t ints[4];
...@@ -4672,9 +4672,9 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {...@@ -4672,9 +4672,9 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {
4672 case TypeTableEntryIdPromise:4672 case TypeTableEntryIdPromise:
4673 // TODO better hashing algorithm4673 // TODO better hashing algorithm
4674 return 223048345;4674 return 223048345;
4675 case TypeTableEntryIdUndefLit:4675 case TypeTableEntryIdUndefined:
4676 return 162837799;4676 return 162837799;
4677 case TypeTableEntryIdNullLit:4677 case TypeTableEntryIdNull:
4678 return 844854567;4678 return 844854567;
4679 case TypeTableEntryIdArray:4679 case TypeTableEntryIdArray:
4680 // TODO better hashing algorithm4680 // TODO better hashing algorithm
...@@ -4754,10 +4754,10 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) {...@@ -4754,10 +4754,10 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) {
4754 case TypeTableEntryIdUnreachable:4754 case TypeTableEntryIdUnreachable:
4755 case TypeTableEntryIdInt:4755 case TypeTableEntryIdInt:
4756 case TypeTableEntryIdFloat:4756 case TypeTableEntryIdFloat:
4757 case TypeTableEntryIdNumLitFloat:4757 case TypeTableEntryIdComptimeFloat:
4758 case TypeTableEntryIdNumLitInt:4758 case TypeTableEntryIdComptimeInt:
4759 case TypeTableEntryIdUndefLit:4759 case TypeTableEntryIdUndefined:
4760 case TypeTableEntryIdNullLit:4760 case TypeTableEntryIdNull:
4761 case TypeTableEntryIdNamespace:4761 case TypeTableEntryIdNamespace:
4762 case TypeTableEntryIdBoundFn:4762 case TypeTableEntryIdBoundFn:
4763 case TypeTableEntryIdFn:4763 case TypeTableEntryIdFn:
...@@ -4819,10 +4819,10 @@ static bool return_type_is_cacheable(TypeTableEntry *return_type) {...@@ -4819,10 +4819,10 @@ static bool return_type_is_cacheable(TypeTableEntry *return_type) {
4819 case TypeTableEntryIdUnreachable:4819 case TypeTableEntryIdUnreachable:
4820 case TypeTableEntryIdInt:4820 case TypeTableEntryIdInt:
4821 case TypeTableEntryIdFloat:4821 case TypeTableEntryIdFloat:
4822 case TypeTableEntryIdNumLitFloat:4822 case TypeTableEntryIdComptimeFloat:
4823 case TypeTableEntryIdNumLitInt:4823 case TypeTableEntryIdComptimeInt:
4824 case TypeTableEntryIdUndefLit:4824 case TypeTableEntryIdUndefined:
4825 case TypeTableEntryIdNullLit:4825 case TypeTableEntryIdNull:
4826 case TypeTableEntryIdNamespace:4826 case TypeTableEntryIdNamespace:
4827 case TypeTableEntryIdBoundFn:4827 case TypeTableEntryIdBoundFn:
4828 case TypeTableEntryIdFn:4828 case TypeTableEntryIdFn:
...@@ -4930,10 +4930,10 @@ bool type_requires_comptime(TypeTableEntry *type_entry) {...@@ -4930,10 +4930,10 @@ bool type_requires_comptime(TypeTableEntry *type_entry) {
4930 case TypeTableEntryIdInvalid:4930 case TypeTableEntryIdInvalid:
4931 case TypeTableEntryIdOpaque:4931 case TypeTableEntryIdOpaque:
4932 zig_unreachable();4932 zig_unreachable();
4933 case TypeTableEntryIdNumLitFloat:4933 case TypeTableEntryIdComptimeFloat:
4934 case TypeTableEntryIdNumLitInt:4934 case TypeTableEntryIdComptimeInt:
4935 case TypeTableEntryIdUndefLit:4935 case TypeTableEntryIdUndefined:
4936 case TypeTableEntryIdNullLit:4936 case TypeTableEntryIdNull:
4937 case TypeTableEntryIdMetaType:4937 case TypeTableEntryIdMetaType:
4938 case TypeTableEntryIdNamespace:4938 case TypeTableEntryIdNamespace:
4939 case TypeTableEntryIdBlock:4939 case TypeTableEntryIdBlock:
...@@ -5070,7 +5070,7 @@ ConstExprValue *create_const_signed(TypeTableEntry *type, int64_t x) {...@@ -5070,7 +5070,7 @@ ConstExprValue *create_const_signed(TypeTableEntry *type, int64_t x) {
5070void init_const_float(ConstExprValue *const_val, TypeTableEntry *type, double value) {5070void init_const_float(ConstExprValue *const_val, TypeTableEntry *type, double value) {
5071 const_val->special = ConstValSpecialStatic;5071 const_val->special = ConstValSpecialStatic;
5072 const_val->type = type;5072 const_val->type = type;
5073 if (type->id == TypeTableEntryIdNumLitFloat) {5073 if (type->id == TypeTableEntryIdComptimeFloat) {
5074 bigfloat_init_64(&const_val->data.x_bigfloat, value);5074 bigfloat_init_64(&const_val->data.x_bigfloat, value);
5075 } else if (type->id == TypeTableEntryIdFloat) {5075 } else if (type->id == TypeTableEntryIdFloat) {
5076 switch (type->data.floating.bit_count) {5076 switch (type->data.floating.bit_count) {
...@@ -5350,10 +5350,10 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {...@@ -5350,10 +5350,10 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {
5350 default:5350 default:
5351 zig_unreachable();5351 zig_unreachable();
5352 }5352 }
5353 case TypeTableEntryIdNumLitFloat:5353 case TypeTableEntryIdComptimeFloat:
5354 return bigfloat_cmp(&a->data.x_bigfloat, &b->data.x_bigfloat) == CmpEQ;5354 return bigfloat_cmp(&a->data.x_bigfloat, &b->data.x_bigfloat) == CmpEQ;
5355 case TypeTableEntryIdInt:5355 case TypeTableEntryIdInt:
5356 case TypeTableEntryIdNumLitInt:5356 case TypeTableEntryIdComptimeInt:
5357 return bigint_cmp(&a->data.x_bigint, &b->data.x_bigint) == CmpEQ;5357 return bigint_cmp(&a->data.x_bigint, &b->data.x_bigint) == CmpEQ;
5358 case TypeTableEntryIdPointer:5358 case TypeTableEntryIdPointer:
5359 case TypeTableEntryIdFn:5359 case TypeTableEntryIdFn:
...@@ -5410,9 +5410,9 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {...@@ -5410,9 +5410,9 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {
5410 return false;5410 return false;
5411 }5411 }
5412 return true;5412 return true;
5413 case TypeTableEntryIdUndefLit:5413 case TypeTableEntryIdUndefined:
5414 zig_panic("TODO");5414 zig_panic("TODO");
5415 case TypeTableEntryIdNullLit:5415 case TypeTableEntryIdNull:
5416 zig_panic("TODO");5416 zig_panic("TODO");
5417 case TypeTableEntryIdMaybe:5417 case TypeTableEntryIdMaybe:
5418 if (a->data.x_maybe == nullptr || b->data.x_maybe == nullptr) {5418 if (a->data.x_maybe == nullptr || b->data.x_maybe == nullptr) {
...@@ -5514,7 +5514,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {...@@ -5514,7 +5514,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
5514 case TypeTableEntryIdVoid:5514 case TypeTableEntryIdVoid:
5515 buf_appendf(buf, "{}");5515 buf_appendf(buf, "{}");
5516 return;5516 return;
5517 case TypeTableEntryIdNumLitFloat:5517 case TypeTableEntryIdComptimeFloat:
5518 bigfloat_append_buf(buf, &const_val->data.x_bigfloat);5518 bigfloat_append_buf(buf, &const_val->data.x_bigfloat);
5519 return;5519 return;
5520 case TypeTableEntryIdFloat:5520 case TypeTableEntryIdFloat:
...@@ -5542,7 +5542,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {...@@ -5542,7 +5542,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
5542 default:5542 default:
5543 zig_unreachable();5543 zig_unreachable();
5544 }5544 }
5545 case TypeTableEntryIdNumLitInt:5545 case TypeTableEntryIdComptimeInt:
5546 case TypeTableEntryIdInt:5546 case TypeTableEntryIdInt:
5547 bigint_append_buf(buf, &const_val->data.x_bigint, 10);5547 bigint_append_buf(buf, &const_val->data.x_bigint, 10);
5548 return;5548 return;
...@@ -5646,12 +5646,12 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {...@@ -5646,12 +5646,12 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
5646 buf_appendf(buf, "}");5646 buf_appendf(buf, "}");
5647 return;5647 return;
5648 }5648 }
5649 case TypeTableEntryIdNullLit:5649 case TypeTableEntryIdNull:
5650 {5650 {
5651 buf_appendf(buf, "null");5651 buf_appendf(buf, "null");
5652 return;5652 return;
5653 }5653 }
5654 case TypeTableEntryIdUndefLit:5654 case TypeTableEntryIdUndefined:
5655 {5655 {
5656 buf_appendf(buf, "undefined");5656 buf_appendf(buf, "undefined");
5657 return;5657 return;
...@@ -5761,10 +5761,10 @@ uint32_t type_id_hash(TypeId x) {...@@ -5761,10 +5761,10 @@ uint32_t type_id_hash(TypeId x) {
5761 case TypeTableEntryIdUnreachable:5761 case TypeTableEntryIdUnreachable:
5762 case TypeTableEntryIdFloat:5762 case TypeTableEntryIdFloat:
5763 case TypeTableEntryIdStruct:5763 case TypeTableEntryIdStruct:
5764 case TypeTableEntryIdNumLitFloat:5764 case TypeTableEntryIdComptimeFloat:
5765 case TypeTableEntryIdNumLitInt:5765 case TypeTableEntryIdComptimeInt:
5766 case TypeTableEntryIdUndefLit:5766 case TypeTableEntryIdUndefined:
5767 case TypeTableEntryIdNullLit:5767 case TypeTableEntryIdNull:
5768 case TypeTableEntryIdMaybe:5768 case TypeTableEntryIdMaybe:
5769 case TypeTableEntryIdErrorSet:5769 case TypeTableEntryIdErrorSet:
5770 case TypeTableEntryIdEnum:5770 case TypeTableEntryIdEnum:
...@@ -5807,10 +5807,10 @@ bool type_id_eql(TypeId a, TypeId b) {...@@ -5807,10 +5807,10 @@ bool type_id_eql(TypeId a, TypeId b) {
5807 case TypeTableEntryIdUnreachable:5807 case TypeTableEntryIdUnreachable:
5808 case TypeTableEntryIdFloat:5808 case TypeTableEntryIdFloat:
5809 case TypeTableEntryIdStruct:5809 case TypeTableEntryIdStruct:
5810 case TypeTableEntryIdNumLitFloat:5810 case TypeTableEntryIdComptimeFloat:
5811 case TypeTableEntryIdNumLitInt:5811 case TypeTableEntryIdComptimeInt:
5812 case TypeTableEntryIdUndefLit:5812 case TypeTableEntryIdUndefined:
5813 case TypeTableEntryIdNullLit:5813 case TypeTableEntryIdNull:
5814 case TypeTableEntryIdMaybe:5814 case TypeTableEntryIdMaybe:
5815 case TypeTableEntryIdPromise:5815 case TypeTableEntryIdPromise:
5816 case TypeTableEntryIdErrorSet:5816 case TypeTableEntryIdErrorSet:
...@@ -5929,10 +5929,10 @@ static const TypeTableEntryId all_type_ids[] = {...@@ -5929,10 +5929,10 @@ static const TypeTableEntryId all_type_ids[] = {
5929 TypeTableEntryIdPointer,5929 TypeTableEntryIdPointer,
5930 TypeTableEntryIdArray,5930 TypeTableEntryIdArray,
5931 TypeTableEntryIdStruct,5931 TypeTableEntryIdStruct,
5932 TypeTableEntryIdNumLitFloat,5932 TypeTableEntryIdComptimeFloat,
5933 TypeTableEntryIdNumLitInt,5933 TypeTableEntryIdComptimeInt,
5934 TypeTableEntryIdUndefLit,5934 TypeTableEntryIdUndefined,
5935 TypeTableEntryIdNullLit,5935 TypeTableEntryIdNull,
5936 TypeTableEntryIdMaybe,5936 TypeTableEntryIdMaybe,
5937 TypeTableEntryIdErrorUnion,5937 TypeTableEntryIdErrorUnion,
5938 TypeTableEntryIdErrorSet,5938 TypeTableEntryIdErrorSet,
...@@ -5980,13 +5980,13 @@ size_t type_id_index(TypeTableEntry *entry) {...@@ -5980,13 +5980,13 @@ size_t type_id_index(TypeTableEntry *entry) {
5980 if (entry->data.structure.is_slice)5980 if (entry->data.structure.is_slice)
5981 return 25;5981 return 25;
5982 return 8;5982 return 8;
5983 case TypeTableEntryIdNumLitFloat:5983 case TypeTableEntryIdComptimeFloat:
5984 return 9;5984 return 9;
5985 case TypeTableEntryIdNumLitInt:5985 case TypeTableEntryIdComptimeInt:
5986 return 10;5986 return 10;
5987 case TypeTableEntryIdUndefLit:5987 case TypeTableEntryIdUndefined:
5988 return 11;5988 return 11;
5989 case TypeTableEntryIdNullLit:5989 case TypeTableEntryIdNull:
5990 return 12;5990 return 12;
5991 case TypeTableEntryIdMaybe:5991 case TypeTableEntryIdMaybe:
5992 return 13;5992 return 13;
...@@ -6038,14 +6038,14 @@ const char *type_id_name(TypeTableEntryId id) {...@@ -6038,14 +6038,14 @@ const char *type_id_name(TypeTableEntryId id) {
6038 return "Array";6038 return "Array";
6039 case TypeTableEntryIdStruct:6039 case TypeTableEntryIdStruct:
6040 return "Struct";6040 return "Struct";
6041 case TypeTableEntryIdNumLitFloat:6041 case TypeTableEntryIdComptimeFloat:
6042 return "FloatLiteral";6042 return "ComptimeFloat";
6043 case TypeTableEntryIdNumLitInt:6043 case TypeTableEntryIdComptimeInt:
6044 return "IntLiteral";6044 return "ComptimeInt";
6045 case TypeTableEntryIdUndefLit:6045 case TypeTableEntryIdUndefined:
6046 return "UndefinedLiteral";6046 return "Undefined";
6047 case TypeTableEntryIdNullLit:6047 case TypeTableEntryIdNull:
6048 return "NullLiteral";6048 return "Null";
6049 case TypeTableEntryIdMaybe:6049 case TypeTableEntryIdMaybe:
6050 return "Nullable";6050 return "Nullable";
6051 case TypeTableEntryIdErrorUnion:6051 case TypeTableEntryIdErrorUnion:
src/codegen.cpp+34-32
...@@ -4916,10 +4916,10 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con...@@ -4916,10 +4916,10 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
4916 case TypeTableEntryIdInvalid:4916 case TypeTableEntryIdInvalid:
4917 case TypeTableEntryIdMetaType:4917 case TypeTableEntryIdMetaType:
4918 case TypeTableEntryIdUnreachable:4918 case TypeTableEntryIdUnreachable:
4919 case TypeTableEntryIdNumLitFloat:4919 case TypeTableEntryIdComptimeFloat:
4920 case TypeTableEntryIdNumLitInt:4920 case TypeTableEntryIdComptimeInt:
4921 case TypeTableEntryIdUndefLit:4921 case TypeTableEntryIdUndefined:
4922 case TypeTableEntryIdNullLit:4922 case TypeTableEntryIdNull:
4923 case TypeTableEntryIdErrorUnion:4923 case TypeTableEntryIdErrorUnion:
4924 case TypeTableEntryIdErrorSet:4924 case TypeTableEntryIdErrorSet:
4925 case TypeTableEntryIdNamespace:4925 case TypeTableEntryIdNamespace:
...@@ -5362,10 +5362,10 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c...@@ -5362,10 +5362,10 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c
5362 case TypeTableEntryIdInvalid:5362 case TypeTableEntryIdInvalid:
5363 case TypeTableEntryIdMetaType:5363 case TypeTableEntryIdMetaType:
5364 case TypeTableEntryIdUnreachable:5364 case TypeTableEntryIdUnreachable:
5365 case TypeTableEntryIdNumLitFloat:5365 case TypeTableEntryIdComptimeFloat:
5366 case TypeTableEntryIdNumLitInt:5366 case TypeTableEntryIdComptimeInt:
5367 case TypeTableEntryIdUndefLit:5367 case TypeTableEntryIdUndefined:
5368 case TypeTableEntryIdNullLit:5368 case TypeTableEntryIdNull:
5369 case TypeTableEntryIdNamespace:5369 case TypeTableEntryIdNamespace:
5370 case TypeTableEntryIdBlock:5370 case TypeTableEntryIdBlock:
5371 case TypeTableEntryIdBoundFn:5371 case TypeTableEntryIdBoundFn:
...@@ -5604,7 +5604,7 @@ static void do_code_gen(CodeGen *g) {...@@ -5604,7 +5604,7 @@ static void do_code_gen(CodeGen *g) {
5604 TldVar *tld_var = g->global_vars.at(i);5604 TldVar *tld_var = g->global_vars.at(i);
5605 VariableTableEntry *var = tld_var->var;5605 VariableTableEntry *var = tld_var->var;
56065606
5607 if (var->value->type->id == TypeTableEntryIdNumLitFloat) {5607 if (var->value->type->id == TypeTableEntryIdComptimeFloat) {
5608 // Generate debug info for it but that's it.5608 // Generate debug info for it but that's it.
5609 ConstExprValue *const_val = var->value;5609 ConstExprValue *const_val = var->value;
5610 assert(const_val->special != ConstValSpecialRuntime);5610 assert(const_val->special != ConstValSpecialRuntime);
...@@ -5618,7 +5618,7 @@ static void do_code_gen(CodeGen *g) {...@@ -5618,7 +5618,7 @@ static void do_code_gen(CodeGen *g) {
5618 continue;5618 continue;
5619 }5619 }
56205620
5621 if (var->value->type->id == TypeTableEntryIdNumLitInt) {5621 if (var->value->type->id == TypeTableEntryIdComptimeInt) {
5622 // Generate debug info for it but that's it.5622 // Generate debug info for it but that's it.
5623 ConstExprValue *const_val = var->value;5623 ConstExprValue *const_val = var->value;
5624 assert(const_val->special != ConstValSpecialRuntime);5624 assert(const_val->special != ConstValSpecialRuntime);
...@@ -6012,25 +6012,27 @@ static void define_builtin_types(CodeGen *g) {...@@ -6012,25 +6012,27 @@ static void define_builtin_types(CodeGen *g) {
6012 g->builtin_types.entry_block = entry;6012 g->builtin_types.entry_block = entry;
6013 }6013 }
6014 {6014 {
6015 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNumLitFloat);6015 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdComptimeFloat);
6016 buf_init_from_str(&entry->name, "(float literal)");6016 buf_init_from_str(&entry->name, "comptime_float");
6017 entry->zero_bits = true;6017 entry->zero_bits = true;
6018 g->builtin_types.entry_num_lit_float = entry;6018 g->builtin_types.entry_num_lit_float = entry;
6019 g->primitive_type_table.put(&entry->name, entry);
6019 }6020 }
6020 {6021 {
6021 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNumLitInt);6022 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdComptimeInt);
6022 buf_init_from_str(&entry->name, "(integer literal)");6023 buf_init_from_str(&entry->name, "comptime_int");
6023 entry->zero_bits = true;6024 entry->zero_bits = true;
6024 g->builtin_types.entry_num_lit_int = entry;6025 g->builtin_types.entry_num_lit_int = entry;
6026 g->primitive_type_table.put(&entry->name, entry);
6025 }6027 }
6026 {6028 {
6027 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUndefLit);6029 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUndefined);
6028 buf_init_from_str(&entry->name, "(undefined)");6030 buf_init_from_str(&entry->name, "(undefined)");
6029 entry->zero_bits = true;6031 entry->zero_bits = true;
6030 g->builtin_types.entry_undef = entry;6032 g->builtin_types.entry_undef = entry;
6031 }6033 }
6032 {6034 {
6033 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNullLit);6035 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNull);
6034 buf_init_from_str(&entry->name, "(null)");6036 buf_init_from_str(&entry->name, "(null)");
6035 entry->zero_bits = true;6037 entry->zero_bits = true;
6036 g->builtin_types.entry_null = entry;6038 g->builtin_types.entry_null = entry;
...@@ -6495,10 +6497,10 @@ static void define_builtin_compile_vars(CodeGen *g) {...@@ -6495,10 +6497,10 @@ static void define_builtin_compile_vars(CodeGen *g) {
6495 " Slice: Slice,\n"6497 " Slice: Slice,\n"
6496 " Array: Array,\n"6498 " Array: Array,\n"
6497 " Struct: Struct,\n"6499 " Struct: Struct,\n"
6498 " FloatLiteral: void,\n"6500 " ComptimeFloat: void,\n"
6499 " IntLiteral: void,\n"6501 " ComptimeInt: void,\n"
6500 " UndefinedLiteral: void,\n"6502 " Undefined: void,\n"
6501 " NullLiteral: void,\n"6503 " Null: void,\n"
6502 " Nullable: Nullable,\n"6504 " Nullable: Nullable,\n"
6503 " ErrorUnion: ErrorUnion,\n"6505 " ErrorUnion: ErrorUnion,\n"
6504 " ErrorSet: ErrorSet,\n"6506 " ErrorSet: ErrorSet,\n"
...@@ -7070,10 +7072,10 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, TypeTableEntry...@@ -7070,10 +7072,10 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, TypeTableEntry
7070 switch (type_entry->id) {7072 switch (type_entry->id) {
7071 case TypeTableEntryIdInvalid:7073 case TypeTableEntryIdInvalid:
7072 case TypeTableEntryIdMetaType:7074 case TypeTableEntryIdMetaType:
7073 case TypeTableEntryIdNumLitFloat:7075 case TypeTableEntryIdComptimeFloat:
7074 case TypeTableEntryIdNumLitInt:7076 case TypeTableEntryIdComptimeInt:
7075 case TypeTableEntryIdUndefLit:7077 case TypeTableEntryIdUndefined:
7076 case TypeTableEntryIdNullLit:7078 case TypeTableEntryIdNull:
7077 case TypeTableEntryIdNamespace:7079 case TypeTableEntryIdNamespace:
7078 case TypeTableEntryIdBlock:7080 case TypeTableEntryIdBlock:
7079 case TypeTableEntryIdBoundFn:7081 case TypeTableEntryIdBoundFn:
...@@ -7255,10 +7257,10 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf...@@ -7255,10 +7257,10 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf
7255 case TypeTableEntryIdBoundFn:7257 case TypeTableEntryIdBoundFn:
7256 case TypeTableEntryIdNamespace:7258 case TypeTableEntryIdNamespace:
7257 case TypeTableEntryIdBlock:7259 case TypeTableEntryIdBlock:
7258 case TypeTableEntryIdNumLitFloat:7260 case TypeTableEntryIdComptimeFloat:
7259 case TypeTableEntryIdNumLitInt:7261 case TypeTableEntryIdComptimeInt:
7260 case TypeTableEntryIdUndefLit:7262 case TypeTableEntryIdUndefined:
7261 case TypeTableEntryIdNullLit:7263 case TypeTableEntryIdNull:
7262 case TypeTableEntryIdArgTuple:7264 case TypeTableEntryIdArgTuple:
7263 case TypeTableEntryIdPromise:7265 case TypeTableEntryIdPromise:
7264 zig_unreachable();7266 zig_unreachable();
...@@ -7407,11 +7409,11 @@ static void gen_h_file(CodeGen *g) {...@@ -7407,11 +7409,11 @@ static void gen_h_file(CodeGen *g) {
7407 case TypeTableEntryIdInt:7409 case TypeTableEntryIdInt:
7408 case TypeTableEntryIdFloat:7410 case TypeTableEntryIdFloat:
7409 case TypeTableEntryIdPointer:7411 case TypeTableEntryIdPointer:
7410 case TypeTableEntryIdNumLitFloat:7412 case TypeTableEntryIdComptimeFloat:
7411 case TypeTableEntryIdNumLitInt:7413 case TypeTableEntryIdComptimeInt:
7412 case TypeTableEntryIdArray:7414 case TypeTableEntryIdArray:
7413 case TypeTableEntryIdUndefLit:7415 case TypeTableEntryIdUndefined:
7414 case TypeTableEntryIdNullLit:7416 case TypeTableEntryIdNull:
7415 case TypeTableEntryIdErrorUnion:7417 case TypeTableEntryIdErrorUnion:
7416 case TypeTableEntryIdErrorSet:7418 case TypeTableEntryIdErrorSet:
7417 case TypeTableEntryIdNamespace:7419 case TypeTableEntryIdNamespace:
src/ir.cpp+170-170
...@@ -6945,14 +6945,14 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so...@@ -6945,14 +6945,14 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so
6945}6945}
69466946
6947static bool const_val_fits_in_num_lit(ConstExprValue *const_val, TypeTableEntry *num_lit_type) {6947static bool const_val_fits_in_num_lit(ConstExprValue *const_val, TypeTableEntry *num_lit_type) {
6948 return ((num_lit_type->id == TypeTableEntryIdNumLitFloat &&6948 return ((num_lit_type->id == TypeTableEntryIdComptimeFloat &&
6949 (const_val->type->id == TypeTableEntryIdFloat || const_val->type->id == TypeTableEntryIdNumLitFloat)) ||6949 (const_val->type->id == TypeTableEntryIdFloat || const_val->type->id == TypeTableEntryIdComptimeFloat)) ||
6950 (num_lit_type->id == TypeTableEntryIdNumLitInt &&6950 (num_lit_type->id == TypeTableEntryIdComptimeInt &&
6951 (const_val->type->id == TypeTableEntryIdInt || const_val->type->id == TypeTableEntryIdNumLitInt)));6951 (const_val->type->id == TypeTableEntryIdInt || const_val->type->id == TypeTableEntryIdComptimeInt)));
6952}6952}
69536953
6954static bool float_has_fraction(ConstExprValue *const_val) {6954static bool float_has_fraction(ConstExprValue *const_val) {
6955 if (const_val->type->id == TypeTableEntryIdNumLitFloat) {6955 if (const_val->type->id == TypeTableEntryIdComptimeFloat) {
6956 return bigfloat_has_fraction(&const_val->data.x_bigfloat);6956 return bigfloat_has_fraction(&const_val->data.x_bigfloat);
6957 } else if (const_val->type->id == TypeTableEntryIdFloat) {6957 } else if (const_val->type->id == TypeTableEntryIdFloat) {
6958 switch (const_val->type->data.floating.bit_count) {6958 switch (const_val->type->data.floating.bit_count) {
...@@ -6975,7 +6975,7 @@ static bool float_has_fraction(ConstExprValue *const_val) {...@@ -6975,7 +6975,7 @@ static bool float_has_fraction(ConstExprValue *const_val) {
6975}6975}
69766976
6977static void float_append_buf(Buf *buf, ConstExprValue *const_val) {6977static void float_append_buf(Buf *buf, ConstExprValue *const_val) {
6978 if (const_val->type->id == TypeTableEntryIdNumLitFloat) {6978 if (const_val->type->id == TypeTableEntryIdComptimeFloat) {
6979 bigfloat_append_buf(buf, &const_val->data.x_bigfloat);6979 bigfloat_append_buf(buf, &const_val->data.x_bigfloat);
6980 } else if (const_val->type->id == TypeTableEntryIdFloat) {6980 } else if (const_val->type->id == TypeTableEntryIdFloat) {
6981 switch (const_val->type->data.floating.bit_count) {6981 switch (const_val->type->data.floating.bit_count) {
...@@ -7010,7 +7010,7 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) {...@@ -7010,7 +7010,7 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) {
7010}7010}
70117011
7012static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) {7012static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) {
7013 if (const_val->type->id == TypeTableEntryIdNumLitFloat) {7013 if (const_val->type->id == TypeTableEntryIdComptimeFloat) {
7014 bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat);7014 bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat);
7015 } else if (const_val->type->id == TypeTableEntryIdFloat) {7015 } else if (const_val->type->id == TypeTableEntryIdFloat) {
7016 switch (const_val->type->data.floating.bit_count) {7016 switch (const_val->type->data.floating.bit_count) {
...@@ -7046,7 +7046,7 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) {...@@ -7046,7 +7046,7 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) {
7046}7046}
70477047
7048static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) {7048static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) {
7049 if (dest_val->type->id == TypeTableEntryIdNumLitFloat) {7049 if (dest_val->type->id == TypeTableEntryIdComptimeFloat) {
7050 bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat);7050 bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat);
7051 } else if (dest_val->type->id == TypeTableEntryIdFloat) {7051 } else if (dest_val->type->id == TypeTableEntryIdFloat) {
7052 switch (dest_val->type->data.floating.bit_count) {7052 switch (dest_val->type->data.floating.bit_count) {
...@@ -7068,7 +7068,7 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) {...@@ -7068,7 +7068,7 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) {
7068}7068}
70697069
7070static void float_init_f32(ConstExprValue *dest_val, float x) {7070static void float_init_f32(ConstExprValue *dest_val, float x) {
7071 if (dest_val->type->id == TypeTableEntryIdNumLitFloat) {7071 if (dest_val->type->id == TypeTableEntryIdComptimeFloat) {
7072 bigfloat_init_32(&dest_val->data.x_bigfloat, x);7072 bigfloat_init_32(&dest_val->data.x_bigfloat, x);
7073 } else if (dest_val->type->id == TypeTableEntryIdFloat) {7073 } else if (dest_val->type->id == TypeTableEntryIdFloat) {
7074 switch (dest_val->type->data.floating.bit_count) {7074 switch (dest_val->type->data.floating.bit_count) {
...@@ -7094,7 +7094,7 @@ static void float_init_f32(ConstExprValue *dest_val, float x) {...@@ -7094,7 +7094,7 @@ static void float_init_f32(ConstExprValue *dest_val, float x) {
7094}7094}
70957095
7096static void float_init_f64(ConstExprValue *dest_val, double x) {7096static void float_init_f64(ConstExprValue *dest_val, double x) {
7097 if (dest_val->type->id == TypeTableEntryIdNumLitFloat) {7097 if (dest_val->type->id == TypeTableEntryIdComptimeFloat) {
7098 bigfloat_init_64(&dest_val->data.x_bigfloat, x);7098 bigfloat_init_64(&dest_val->data.x_bigfloat, x);
7099 } else if (dest_val->type->id == TypeTableEntryIdFloat) {7099 } else if (dest_val->type->id == TypeTableEntryIdFloat) {
7100 switch (dest_val->type->data.floating.bit_count) {7100 switch (dest_val->type->data.floating.bit_count) {
...@@ -7120,7 +7120,7 @@ static void float_init_f64(ConstExprValue *dest_val, double x) {...@@ -7120,7 +7120,7 @@ static void float_init_f64(ConstExprValue *dest_val, double x) {
7120}7120}
71217121
7122static void float_init_f128(ConstExprValue *dest_val, float128_t x) {7122static 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 bigfloat_init_128(&dest_val->data.x_bigfloat, x);7124 bigfloat_init_128(&dest_val->data.x_bigfloat, x);
7125 } else if (dest_val->type->id == TypeTableEntryIdFloat) {7125 } else if (dest_val->type->id == TypeTableEntryIdFloat) {
7126 switch (dest_val->type->data.floating.bit_count) {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,7 +7150,7 @@ static void float_init_f128(ConstExprValue *dest_val, float128_t x) {
7150}7150}
71517151
7152static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) {7152static 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 float_init_bigfloat(dest_val, &src_val->data.x_bigfloat);7154 float_init_bigfloat(dest_val, &src_val->data.x_bigfloat);
7155 } else if (src_val->type->id == TypeTableEntryIdFloat) {7155 } else if (src_val->type->id == TypeTableEntryIdFloat) {
7156 switch (src_val->type->data.floating.bit_count) {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,7 +7173,7 @@ static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val)
71737173
7174static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) {7174static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) {
7175 assert(op1->type == op2->type);7175 assert(op1->type == op2->type);
7176 if (op1->type->id == TypeTableEntryIdNumLitFloat) {7176 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
7177 return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat);7177 return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat);
7178 } else if (op1->type->id == TypeTableEntryIdFloat) {7178 } else if (op1->type->id == TypeTableEntryIdFloat) {
7179 switch (op1->type->data.floating.bit_count) {7179 switch (op1->type->data.floating.bit_count) {
...@@ -7210,7 +7210,7 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) {...@@ -7210,7 +7210,7 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) {
7210}7210}
72117211
7212static Cmp float_cmp_zero(ConstExprValue *op) {7212static Cmp float_cmp_zero(ConstExprValue *op) {
7213 if (op->type->id == TypeTableEntryIdNumLitFloat) {7213 if (op->type->id == TypeTableEntryIdComptimeFloat) {
7214 return bigfloat_cmp_zero(&op->data.x_bigfloat);7214 return bigfloat_cmp_zero(&op->data.x_bigfloat);
7215 } else if (op->type->id == TypeTableEntryIdFloat) {7215 } else if (op->type->id == TypeTableEntryIdFloat) {
7216 switch (op->type->data.floating.bit_count) {7216 switch (op->type->data.floating.bit_count) {
...@@ -7251,7 +7251,7 @@ static Cmp float_cmp_zero(ConstExprValue *op) {...@@ -7251,7 +7251,7 @@ static Cmp float_cmp_zero(ConstExprValue *op) {
7251static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {7251static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
7252 assert(op1->type == op2->type);7252 assert(op1->type == op2->type);
7253 out_val->type = op1->type;7253 out_val->type = op1->type;
7254 if (op1->type->id == TypeTableEntryIdNumLitFloat) {7254 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
7255 bigfloat_add(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);7255 bigfloat_add(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
7256 } else if (op1->type->id == TypeTableEntryIdFloat) {7256 } else if (op1->type->id == TypeTableEntryIdFloat) {
7257 switch (op1->type->data.floating.bit_count) {7257 switch (op1->type->data.floating.bit_count) {
...@@ -7275,7 +7275,7 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal...@@ -7275,7 +7275,7 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
7275static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {7275static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
7276 assert(op1->type == op2->type);7276 assert(op1->type == op2->type);
7277 out_val->type = op1->type;7277 out_val->type = op1->type;
7278 if (op1->type->id == TypeTableEntryIdNumLitFloat) {7278 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
7279 bigfloat_sub(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);7279 bigfloat_sub(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
7280 } else if (op1->type->id == TypeTableEntryIdFloat) {7280 } else if (op1->type->id == TypeTableEntryIdFloat) {
7281 switch (op1->type->data.floating.bit_count) {7281 switch (op1->type->data.floating.bit_count) {
...@@ -7299,7 +7299,7 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal...@@ -7299,7 +7299,7 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
7299static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {7299static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
7300 assert(op1->type == op2->type);7300 assert(op1->type == op2->type);
7301 out_val->type = op1->type;7301 out_val->type = op1->type;
7302 if (op1->type->id == TypeTableEntryIdNumLitFloat) {7302 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
7303 bigfloat_mul(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);7303 bigfloat_mul(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
7304 } else if (op1->type->id == TypeTableEntryIdFloat) {7304 } else if (op1->type->id == TypeTableEntryIdFloat) {
7305 switch (op1->type->data.floating.bit_count) {7305 switch (op1->type->data.floating.bit_count) {
...@@ -7323,7 +7323,7 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal...@@ -7323,7 +7323,7 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
7323static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {7323static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
7324 assert(op1->type == op2->type);7324 assert(op1->type == op2->type);
7325 out_val->type = op1->type;7325 out_val->type = op1->type;
7326 if (op1->type->id == TypeTableEntryIdNumLitFloat) {7326 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
7327 bigfloat_div(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);7327 bigfloat_div(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
7328 } else if (op1->type->id == TypeTableEntryIdFloat) {7328 } else if (op1->type->id == TypeTableEntryIdFloat) {
7329 switch (op1->type->data.floating.bit_count) {7329 switch (op1->type->data.floating.bit_count) {
...@@ -7347,7 +7347,7 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal...@@ -7347,7 +7347,7 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
7347static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {7347static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
7348 assert(op1->type == op2->type);7348 assert(op1->type == op2->type);
7349 out_val->type = op1->type;7349 out_val->type = op1->type;
7350 if (op1->type->id == TypeTableEntryIdNumLitFloat) {7350 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
7351 bigfloat_div_trunc(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);7351 bigfloat_div_trunc(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
7352 } else if (op1->type->id == TypeTableEntryIdFloat) {7352 } else if (op1->type->id == TypeTableEntryIdFloat) {
7353 switch (op1->type->data.floating.bit_count) {7353 switch (op1->type->data.floating.bit_count) {
...@@ -7382,7 +7382,7 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE...@@ -7382,7 +7382,7 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE
7382static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {7382static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
7383 assert(op1->type == op2->type);7383 assert(op1->type == op2->type);
7384 out_val->type = op1->type;7384 out_val->type = op1->type;
7385 if (op1->type->id == TypeTableEntryIdNumLitFloat) {7385 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
7386 bigfloat_div_floor(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);7386 bigfloat_div_floor(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
7387 } else if (op1->type->id == TypeTableEntryIdFloat) {7387 } else if (op1->type->id == TypeTableEntryIdFloat) {
7388 switch (op1->type->data.floating.bit_count) {7388 switch (op1->type->data.floating.bit_count) {
...@@ -7407,7 +7407,7 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE...@@ -7407,7 +7407,7 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE
7407static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {7407static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
7408 assert(op1->type == op2->type);7408 assert(op1->type == op2->type);
7409 out_val->type = op1->type;7409 out_val->type = op1->type;
7410 if (op1->type->id == TypeTableEntryIdNumLitFloat) {7410 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
7411 bigfloat_rem(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);7411 bigfloat_rem(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
7412 } else if (op1->type->id == TypeTableEntryIdFloat) {7412 } else if (op1->type->id == TypeTableEntryIdFloat) {
7413 switch (op1->type->data.floating.bit_count) {7413 switch (op1->type->data.floating.bit_count) {
...@@ -7431,7 +7431,7 @@ static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal...@@ -7431,7 +7431,7 @@ static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
7431static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {7431static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
7432 assert(op1->type == op2->type);7432 assert(op1->type == op2->type);
7433 out_val->type = op1->type;7433 out_val->type = op1->type;
7434 if (op1->type->id == TypeTableEntryIdNumLitFloat) {7434 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
7435 bigfloat_mod(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);7435 bigfloat_mod(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
7436 } else if (op1->type->id == TypeTableEntryIdFloat) {7436 } else if (op1->type->id == TypeTableEntryIdFloat) {
7437 switch (op1->type->data.floating.bit_count) {7437 switch (op1->type->data.floating.bit_count) {
...@@ -7456,7 +7456,7 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal...@@ -7456,7 +7456,7 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
74567456
7457static void float_negate(ConstExprValue *out_val, ConstExprValue *op) {7457static void float_negate(ConstExprValue *out_val, ConstExprValue *op) {
7458 out_val->type = op->type;7458 out_val->type = op->type;
7459 if (op->type->id == TypeTableEntryIdNumLitFloat) {7459 if (op->type->id == TypeTableEntryIdComptimeFloat) {
7460 bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat);7460 bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat);
7461 } else if (op->type->id == TypeTableEntryIdFloat) {7461 } else if (op->type->id == TypeTableEntryIdFloat) {
7462 switch (op->type->data.floating.bit_count) {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,9 +7530,9 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
7530 assert(const_val->special != ConstValSpecialRuntime);7530 assert(const_val->special != ConstValSpecialRuntime);
75317531
7532 bool const_val_is_int = (const_val->type->id == TypeTableEntryIdInt ||7532 bool const_val_is_int = (const_val->type->id == TypeTableEntryIdInt ||
7533 const_val->type->id == TypeTableEntryIdNumLitInt);7533 const_val->type->id == TypeTableEntryIdComptimeInt);
7534 bool const_val_is_float = (const_val->type->id == TypeTableEntryIdFloat ||7534 bool const_val_is_float = (const_val->type->id == TypeTableEntryIdFloat ||
7535 const_val->type->id == TypeTableEntryIdNumLitFloat);7535 const_val->type->id == TypeTableEntryIdComptimeFloat);
7536 if (other_type->id == TypeTableEntryIdFloat) {7536 if (other_type->id == TypeTableEntryIdFloat) {
7537 return true;7537 return true;
7538 } else if (other_type->id == TypeTableEntryIdInt && const_val_is_int) {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,7 +7576,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
7576 return true;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 const_val_is_float)7580 const_val_is_float)
7581 {7581 {
7582 if (float_has_fraction(const_val)) {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,7 +7589,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
7589 buf_ptr(&other_type->name)));7589 buf_ptr(&other_type->name)));
7590 return false;7590 return false;
7591 } else {7591 } else {
7592 if (other_type->id == TypeTableEntryIdNumLitInt) {7592 if (other_type->id == TypeTableEntryIdComptimeInt) {
7593 return true;7593 return true;
7594 } else {7594 } else {
7595 BigInt bigint;7595 BigInt bigint;
...@@ -7960,7 +7960,7 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,...@@ -7960,7 +7960,7 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
79607960
7961 // implicit conversion from null literal to maybe type7961 // implicit conversion from null literal to maybe type
7962 if (expected_type->id == TypeTableEntryIdMaybe &&7962 if (expected_type->id == TypeTableEntryIdMaybe &&
7963 actual_type->id == TypeTableEntryIdNullLit)7963 actual_type->id == TypeTableEntryIdNull)
7964 {7964 {
7965 return ImplicitCastMatchResultYes;7965 return ImplicitCastMatchResultYes;
7966 }7966 }
...@@ -8078,8 +8078,8 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,...@@ -8078,8 +8078,8 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
80788078
8079 // implicit number literal to typed number8079 // implicit number literal to typed number
8080 // implicit number literal to &const integer8080 // implicit number literal to &const integer
8081 if (actual_type->id == TypeTableEntryIdNumLitFloat ||8081 if (actual_type->id == TypeTableEntryIdComptimeFloat ||
8082 actual_type->id == TypeTableEntryIdNumLitInt)8082 actual_type->id == TypeTableEntryIdComptimeInt)
8083 {8083 {
8084 if (expected_type->id == TypeTableEntryIdPointer &&8084 if (expected_type->id == TypeTableEntryIdPointer &&
8085 expected_type->data.pointer.is_const)8085 expected_type->data.pointer.is_const)
...@@ -8099,9 +8099,9 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,...@@ -8099,9 +8099,9 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
8099 // implicit typed number to integer or float literal.8099 // implicit typed number to integer or float literal.
8100 // works when the number is known8100 // works when the number is known
8101 if (value->value.special == ConstValSpecialStatic) {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 return ImplicitCastMatchResultYes;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 return ImplicitCastMatchResultYes;8105 return ImplicitCastMatchResultYes;
8106 }8106 }
8107 }8107 }
...@@ -8142,7 +8142,7 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,...@@ -8142,7 +8142,7 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
8142 }8142 }
81438143
8144 // implicit undefined literal to anything8144 // implicit undefined literal to anything
8145 if (actual_type->id == TypeTableEntryIdUndefLit) {8145 if (actual_type->id == TypeTableEntryIdUndefined) {
8146 return ImplicitCastMatchResultYes;8146 return ImplicitCastMatchResultYes;
8147 }8147 }
81488148
...@@ -8190,7 +8190,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -8190,7 +8190,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
8190 }8190 }
8191 }8191 }
81928192
8193 bool any_are_null = (prev_inst->value.type->id == TypeTableEntryIdNullLit);8193 bool any_are_null = (prev_inst->value.type->id == TypeTableEntryIdNull);
8194 bool convert_to_const_slice = false;8194 bool convert_to_const_slice = false;
8195 for (size_t i = 1; i < instruction_count; i += 1) {8195 for (size_t i = 1; i < instruction_count; i += 1) {
8196 IrInstruction *cur_inst = instructions[i];8196 IrInstruction *cur_inst = instructions[i];
...@@ -8469,12 +8469,12 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -8469,12 +8469,12 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
8469 }8469 }
8470 }8470 }
84718471
8472 if (prev_type->id == TypeTableEntryIdNullLit) {8472 if (prev_type->id == TypeTableEntryIdNull) {
8473 prev_inst = cur_inst;8473 prev_inst = cur_inst;
8474 continue;8474 continue;
8475 }8475 }
84768476
8477 if (cur_type->id == TypeTableEntryIdNullLit) {8477 if (cur_type->id == TypeTableEntryIdNull) {
8478 any_are_null = true;8478 any_are_null = true;
8479 continue;8479 continue;
8480 }8480 }
...@@ -8546,17 +8546,17 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -8546,17 +8546,17 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
8546 continue;8546 continue;
8547 }8547 }
85488548
8549 if (cur_type->id == TypeTableEntryIdUndefLit) {8549 if (cur_type->id == TypeTableEntryIdUndefined) {
8550 continue;8550 continue;
8551 }8551 }
85528552
8553 if (prev_type->id == TypeTableEntryIdUndefLit) {8553 if (prev_type->id == TypeTableEntryIdUndefined) {
8554 prev_inst = cur_inst;8554 prev_inst = cur_inst;
8555 continue;8555 continue;
8556 }8556 }
85578557
8558 if (prev_type->id == TypeTableEntryIdNumLitInt ||8558 if (prev_type->id == TypeTableEntryIdComptimeInt ||
8559 prev_type->id == TypeTableEntryIdNumLitFloat)8559 prev_type->id == TypeTableEntryIdComptimeFloat)
8560 {8560 {
8561 if (ir_num_lit_fits_in_other_type(ira, prev_inst, cur_type, false)) {8561 if (ir_num_lit_fits_in_other_type(ira, prev_inst, cur_type, false)) {
8562 prev_inst = cur_inst;8562 prev_inst = cur_inst;
...@@ -8566,8 +8566,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -8566,8 +8566,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
8566 }8566 }
8567 }8567 }
85688568
8569 if (cur_type->id == TypeTableEntryIdNumLitInt ||8569 if (cur_type->id == TypeTableEntryIdComptimeInt ||
8570 cur_type->id == TypeTableEntryIdNumLitFloat)8570 cur_type->id == TypeTableEntryIdComptimeFloat)
8571 {8571 {
8572 if (ir_num_lit_fits_in_other_type(ira, cur_inst, prev_type, false)) {8572 if (ir_num_lit_fits_in_other_type(ira, cur_inst, prev_type, false)) {
8573 continue;8573 continue;
...@@ -8671,13 +8671,13 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -8671,13 +8671,13 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
8671 } else if (expected_type != nullptr && expected_type->id == TypeTableEntryIdErrorUnion) {8671 } else if (expected_type != nullptr && expected_type->id == TypeTableEntryIdErrorUnion) {
8672 return get_error_union_type(ira->codegen, err_set_type, expected_type->data.error_union.payload_type);8672 return get_error_union_type(ira->codegen, err_set_type, expected_type->data.error_union.payload_type);
8673 } else {8673 } else {
8674 if (prev_inst->value.type->id == TypeTableEntryIdNumLitInt ||8674 if (prev_inst->value.type->id == TypeTableEntryIdComptimeInt ||
8675 prev_inst->value.type->id == TypeTableEntryIdNumLitFloat)8675 prev_inst->value.type->id == TypeTableEntryIdComptimeFloat)
8676 {8676 {
8677 ir_add_error_node(ira, source_node,8677 ir_add_error_node(ira, source_node,
8678 buf_sprintf("unable to make error union out of number literal"));8678 buf_sprintf("unable to make error union out of number literal"));
8679 return ira->codegen->builtin_types.entry_invalid;8679 return ira->codegen->builtin_types.entry_invalid;
8680 } else if (prev_inst->value.type->id == TypeTableEntryIdNullLit) {8680 } else if (prev_inst->value.type->id == TypeTableEntryIdNull) {
8681 ir_add_error_node(ira, source_node,8681 ir_add_error_node(ira, source_node,
8682 buf_sprintf("unable to make error union out of null literal"));8682 buf_sprintf("unable to make error union out of null literal"));
8683 return ira->codegen->builtin_types.entry_invalid;8683 return ira->codegen->builtin_types.entry_invalid;
...@@ -8685,9 +8685,9 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod...@@ -8685,9 +8685,9 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
8685 return get_error_union_type(ira->codegen, err_set_type, prev_inst->value.type);8685 return get_error_union_type(ira->codegen, err_set_type, prev_inst->value.type);
8686 }8686 }
8687 }8687 }
8688 } else if (any_are_null && prev_inst->value.type->id != TypeTableEntryIdNullLit) {8688 } else if (any_are_null && prev_inst->value.type->id != TypeTableEntryIdNull) {
8689 if (prev_inst->value.type->id == TypeTableEntryIdNumLitInt ||8689 if (prev_inst->value.type->id == TypeTableEntryIdComptimeInt ||
8690 prev_inst->value.type->id == TypeTableEntryIdNumLitFloat)8690 prev_inst->value.type->id == TypeTableEntryIdComptimeFloat)
8691 {8691 {
8692 ir_add_error_node(ira, source_node,8692 ir_add_error_node(ira, source_node,
8693 buf_sprintf("unable to make maybe out of number literal"));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,7 +8743,7 @@ static void eval_const_expr_implicit_cast(CastOp cast_op,
8743 break;8743 break;
8744 }8744 }
8745 case CastOpNumLitToConcrete:8745 case CastOpNumLitToConcrete:
8746 if (other_val->type->id == TypeTableEntryIdNumLitFloat) {8746 if (other_val->type->id == TypeTableEntryIdComptimeFloat) {
8747 assert(new_type->id == TypeTableEntryIdFloat);8747 assert(new_type->id == TypeTableEntryIdFloat);
8748 switch (new_type->data.floating.bit_count) {8748 switch (new_type->data.floating.bit_count) {
8749 case 32:8749 case 32:
...@@ -8758,7 +8758,7 @@ static void eval_const_expr_implicit_cast(CastOp cast_op,...@@ -8758,7 +8758,7 @@ static void eval_const_expr_implicit_cast(CastOp cast_op,
8758 default:8758 default:
8759 zig_unreachable();8759 zig_unreachable();
8760 }8760 }
8761 } else if (other_val->type->id == TypeTableEntryIdNumLitInt) {8761 } else if (other_val->type->id == TypeTableEntryIdComptimeInt) {
8762 bigint_init_bigint(&const_val->data.x_bigint, &other_val->data.x_bigint);8762 bigint_init_bigint(&const_val->data.x_bigint, &other_val->data.x_bigint);
8763 } else {8763 } else {
8764 zig_unreachable();8764 zig_unreachable();
...@@ -9601,9 +9601,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction...@@ -9601,9 +9601,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction
96019601
9602 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,9602 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
9603 source_instr->source_node, wanted_type);9603 source_instr->source_node, wanted_type);
9604 if (wanted_type->id == TypeTableEntryIdNumLitFloat) {9604 if (wanted_type->id == TypeTableEntryIdComptimeFloat) {
9605 float_init_float(&result->value, val);9605 float_init_float(&result->value, val);
9606 } else if (wanted_type->id == TypeTableEntryIdNumLitInt) {9606 } else if (wanted_type->id == TypeTableEntryIdComptimeInt) {
9607 bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint);9607 bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint);
9608 } else {9608 } else {
9609 zig_unreachable();9609 zig_unreachable();
...@@ -9978,8 +9978,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -9978,8 +9978,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
9978 TypeTableEntry *wanted_child_type = wanted_type->data.maybe.child_type;9978 TypeTableEntry *wanted_child_type = wanted_type->data.maybe.child_type;
9979 if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node).id == ConstCastResultIdOk) {9979 if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node).id == ConstCastResultIdOk) {
9980 return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type);9980 return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type);
9981 } else if (actual_type->id == TypeTableEntryIdNumLitInt ||9981 } else if (actual_type->id == TypeTableEntryIdComptimeInt ||
9982 actual_type->id == TypeTableEntryIdNumLitFloat)9982 actual_type->id == TypeTableEntryIdComptimeFloat)
9983 {9983 {
9984 if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) {9984 if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) {
9985 return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type);9985 return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type);
...@@ -10004,7 +10004,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10004,7 +10004,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1000410004
10005 // explicit cast from null literal to maybe type10005 // explicit cast from null literal to maybe type
10006 if (wanted_type->id == TypeTableEntryIdMaybe &&10006 if (wanted_type->id == TypeTableEntryIdMaybe &&
10007 actual_type->id == TypeTableEntryIdNullLit)10007 actual_type->id == TypeTableEntryIdNull)
10008 {10008 {
10009 return ir_analyze_null_to_maybe(ira, source_instr, value, wanted_type);10009 return ir_analyze_null_to_maybe(ira, source_instr, value, wanted_type);
10010 }10010 }
...@@ -10013,8 +10013,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10013,8 +10013,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10013 if (wanted_type->id == TypeTableEntryIdErrorUnion) {10013 if (wanted_type->id == TypeTableEntryIdErrorUnion) {
10014 if (types_match_const_cast_only(ira, wanted_type->data.error_union.payload_type, actual_type, source_node).id == ConstCastResultIdOk) {10014 if (types_match_const_cast_only(ira, wanted_type->data.error_union.payload_type, actual_type, source_node).id == ConstCastResultIdOk) {
10015 return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type);10015 return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type);
10016 } else if (actual_type->id == TypeTableEntryIdNumLitInt ||10016 } else if (actual_type->id == TypeTableEntryIdComptimeInt ||
10017 actual_type->id == TypeTableEntryIdNumLitFloat)10017 actual_type->id == TypeTableEntryIdComptimeFloat)
10018 {10018 {
10019 if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) {10019 if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) {
10020 return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type);10020 return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type);
...@@ -10061,9 +10061,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10061,9 +10061,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10061 {10061 {
10062 TypeTableEntry *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type;10062 TypeTableEntry *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type;
10063 if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node).id == ConstCastResultIdOk ||10063 if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node).id == ConstCastResultIdOk ||
10064 actual_type->id == TypeTableEntryIdNullLit ||10064 actual_type->id == TypeTableEntryIdNull ||
10065 actual_type->id == TypeTableEntryIdNumLitInt ||10065 actual_type->id == TypeTableEntryIdComptimeInt ||
10066 actual_type->id == TypeTableEntryIdNumLitFloat)10066 actual_type->id == TypeTableEntryIdComptimeFloat)
10067 {10067 {
10068 IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value);10068 IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value);
10069 if (type_is_invalid(cast1->value.type))10069 if (type_is_invalid(cast1->value.type))
...@@ -10079,8 +10079,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10079,8 +10079,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1007910079
10080 // explicit cast from number literal to another type10080 // explicit cast from number literal to another type
10081 // explicit cast from number literal to &const integer10081 // explicit cast from number literal to &const integer
10082 if (actual_type->id == TypeTableEntryIdNumLitFloat ||10082 if (actual_type->id == TypeTableEntryIdComptimeFloat ||
10083 actual_type->id == TypeTableEntryIdNumLitInt)10083 actual_type->id == TypeTableEntryIdComptimeInt)
10084 {10084 {
10085 ensure_complete_type(ira->codegen, wanted_type);10085 ensure_complete_type(ira->codegen, wanted_type);
10086 if (type_is_invalid(wanted_type))10086 if (type_is_invalid(wanted_type))
...@@ -10109,9 +10109,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10109,9 +10109,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10109 return cast2;10109 return cast2;
10110 } else if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) {10110 } else if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) {
10111 CastOp op;10111 CastOp op;
10112 if ((actual_type->id == TypeTableEntryIdNumLitFloat &&10112 if ((actual_type->id == TypeTableEntryIdComptimeFloat &&
10113 wanted_type->id == TypeTableEntryIdFloat) ||10113 wanted_type->id == TypeTableEntryIdFloat) ||
10114 (actual_type->id == TypeTableEntryIdNumLitInt &&10114 (actual_type->id == TypeTableEntryIdComptimeInt &&
10115 wanted_type->id == TypeTableEntryIdInt))10115 wanted_type->id == TypeTableEntryIdInt))
10116 {10116 {
10117 op = CastOpNumLitToConcrete;10117 op = CastOpNumLitToConcrete;
...@@ -10131,8 +10131,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10131,8 +10131,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
10131 // explicit cast from typed number to integer or float literal.10131 // explicit cast from typed number to integer or float literal.
10132 // works when the number is known at compile time10132 // works when the number is known at compile time
10133 if (instr_is_comptime(value) &&10133 if (instr_is_comptime(value) &&
10134 ((actual_type->id == TypeTableEntryIdInt && wanted_type->id == TypeTableEntryIdNumLitInt) ||10134 ((actual_type->id == TypeTableEntryIdInt && wanted_type->id == TypeTableEntryIdComptimeInt) ||
10135 (actual_type->id == TypeTableEntryIdFloat && wanted_type->id == TypeTableEntryIdNumLitFloat)))10135 (actual_type->id == TypeTableEntryIdFloat && wanted_type->id == TypeTableEntryIdComptimeFloat)))
10136 {10136 {
10137 return ir_analyze_number_to_literal(ira, source_instr, value, wanted_type);10137 return ir_analyze_number_to_literal(ira, source_instr, value, wanted_type);
10138 }10138 }
...@@ -10230,7 +10230,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst...@@ -10230,7 +10230,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1023010230
1023110231
10232 // explicit cast from undefined to anything10232 // explicit cast from undefined to anything
10233 if (actual_type->id == TypeTableEntryIdUndefLit) {10233 if (actual_type->id == TypeTableEntryIdUndefined) {
10234 return ir_analyze_undefined_to_anything(ira, source_instr, value, wanted_type);10234 return ir_analyze_undefined_to_anything(ira, source_instr, value, wanted_type);
10235 }10235 }
1023610236
...@@ -10627,19 +10627,19 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp...@@ -10627,19 +10627,19 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
10627 IrBinOp op_id = bin_op_instruction->op_id;10627 IrBinOp op_id = bin_op_instruction->op_id;
10628 bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq);10628 bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq);
10629 if (is_equality_cmp &&10629 if (is_equality_cmp &&
10630 ((op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdMaybe) ||10630 ((op1->value.type->id == TypeTableEntryIdNull && op2->value.type->id == TypeTableEntryIdMaybe) ||
10631 (op2->value.type->id == TypeTableEntryIdNullLit && op1->value.type->id == TypeTableEntryIdMaybe) ||10631 (op2->value.type->id == TypeTableEntryIdNull && op1->value.type->id == TypeTableEntryIdMaybe) ||
10632 (op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdNullLit)))10632 (op1->value.type->id == TypeTableEntryIdNull && op2->value.type->id == TypeTableEntryIdNull)))
10633 {10633 {
10634 if (op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdNullLit) {10634 if (op1->value.type->id == TypeTableEntryIdNull && op2->value.type->id == TypeTableEntryIdNull) {
10635 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base);10635 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base);
10636 out_val->data.x_bool = (op_id == IrBinOpCmpEq);10636 out_val->data.x_bool = (op_id == IrBinOpCmpEq);
10637 return ira->codegen->builtin_types.entry_bool;10637 return ira->codegen->builtin_types.entry_bool;
10638 }10638 }
10639 IrInstruction *maybe_op;10639 IrInstruction *maybe_op;
10640 if (op1->value.type->id == TypeTableEntryIdNullLit) {10640 if (op1->value.type->id == TypeTableEntryIdNull) {
10641 maybe_op = op2;10641 maybe_op = op2;
10642 } else if (op2->value.type->id == TypeTableEntryIdNullLit) {10642 } else if (op2->value.type->id == TypeTableEntryIdNull) {
10643 maybe_op = op1;10643 maybe_op = op1;
10644 } else {10644 } else {
10645 zig_unreachable();10645 zig_unreachable();
...@@ -10759,8 +10759,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp...@@ -10759,8 +10759,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
10759 case TypeTableEntryIdInvalid:10759 case TypeTableEntryIdInvalid:
10760 zig_unreachable(); // handled above10760 zig_unreachable(); // handled above
1076110761
10762 case TypeTableEntryIdNumLitFloat:10762 case TypeTableEntryIdComptimeFloat:
10763 case TypeTableEntryIdNumLitInt:10763 case TypeTableEntryIdComptimeInt:
10764 case TypeTableEntryIdInt:10764 case TypeTableEntryIdInt:
10765 case TypeTableEntryIdFloat:10765 case TypeTableEntryIdFloat:
10766 break;10766 break;
...@@ -10795,8 +10795,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp...@@ -10795,8 +10795,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
10795 case TypeTableEntryIdUnreachable:10795 case TypeTableEntryIdUnreachable:
10796 case TypeTableEntryIdArray:10796 case TypeTableEntryIdArray:
10797 case TypeTableEntryIdStruct:10797 case TypeTableEntryIdStruct:
10798 case TypeTableEntryIdUndefLit:10798 case TypeTableEntryIdUndefined:
10799 case TypeTableEntryIdNullLit:10799 case TypeTableEntryIdNull:
10800 case TypeTableEntryIdMaybe:10800 case TypeTableEntryIdMaybe:
10801 case TypeTableEntryIdErrorUnion:10801 case TypeTableEntryIdErrorUnion:
10802 case TypeTableEntryIdUnion:10802 case TypeTableEntryIdUnion:
...@@ -10818,10 +10818,10 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp...@@ -10818,10 +10818,10 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
10818 bool one_possible_value = !type_requires_comptime(resolved_type) && !type_has_bits(resolved_type);10818 bool one_possible_value = !type_requires_comptime(resolved_type) && !type_has_bits(resolved_type);
10819 if (one_possible_value || (value_is_comptime(op1_val) && value_is_comptime(op2_val))) {10819 if (one_possible_value || (value_is_comptime(op1_val) && value_is_comptime(op2_val))) {
10820 bool answer;10820 bool answer;
10821 if (resolved_type->id == TypeTableEntryIdNumLitFloat || resolved_type->id == TypeTableEntryIdFloat) {10821 if (resolved_type->id == TypeTableEntryIdComptimeFloat || resolved_type->id == TypeTableEntryIdFloat) {
10822 Cmp cmp_result = float_cmp(op1_val, op2_val);10822 Cmp cmp_result = float_cmp(op1_val, op2_val);
10823 answer = resolve_cmp_op_id(op_id, cmp_result);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 Cmp cmp_result = bigint_cmp(&op1_val->data.x_bigint, &op2_val->data.x_bigint);10825 Cmp cmp_result = bigint_cmp(&op1_val->data.x_bigint, &op2_val->data.x_bigint);
10826 answer = resolve_cmp_op_id(op_id, cmp_result);10826 answer = resolve_cmp_op_id(op_id, cmp_result);
10827 } else {10827 } else {
...@@ -10885,12 +10885,12 @@ static int ir_eval_math_op(TypeTableEntry *type_entry, ConstExprValue *op1_val,...@@ -10885,12 +10885,12 @@ static int ir_eval_math_op(TypeTableEntry *type_entry, ConstExprValue *op1_val,
10885 bool is_int;10885 bool is_int;
10886 bool is_float;10886 bool is_float;
10887 Cmp op2_zcmp;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 is_int = true;10889 is_int = true;
10890 is_float = false;10890 is_float = false;
10891 op2_zcmp = bigint_cmp_zero(&op2_val->data.x_bigint);10891 op2_zcmp = bigint_cmp_zero(&op2_val->data.x_bigint);
10892 } else if (type_entry->id == TypeTableEntryIdFloat ||10892 } else if (type_entry->id == TypeTableEntryIdFloat ||
10893 type_entry->id == TypeTableEntryIdNumLitFloat)10893 type_entry->id == TypeTableEntryIdComptimeFloat)
10894 {10894 {
10895 is_int = false;10895 is_int = false;
10896 is_float = true;10896 is_float = true;
...@@ -11064,7 +11064,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *...@@ -11064,7 +11064,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
11064 if (type_is_invalid(op1->value.type))11064 if (type_is_invalid(op1->value.type))
11065 return ira->codegen->builtin_types.entry_invalid;11065 return ira->codegen->builtin_types.entry_invalid;
1106611066
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 ir_add_error(ira, &bin_op_instruction->base,11068 ir_add_error(ira, &bin_op_instruction->base,
11069 buf_sprintf("bit shifting operation expected integer type, found '%s'",11069 buf_sprintf("bit shifting operation expected integer type, found '%s'",
11070 buf_ptr(&op1->value.type->name)));11070 buf_ptr(&op1->value.type->name)));
...@@ -11077,7 +11077,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *...@@ -11077,7 +11077,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
1107711077
11078 IrInstruction *casted_op2;11078 IrInstruction *casted_op2;
11079 IrBinOp op_id = bin_op_instruction->op_id;11079 IrBinOp op_id = bin_op_instruction->op_id;
11080 if (op1->value.type->id == TypeTableEntryIdNumLitInt) {11080 if (op1->value.type->id == TypeTableEntryIdComptimeInt) {
11081 casted_op2 = op2;11081 casted_op2 = op2;
1108211082
11083 if (op_id == IrBinOpBitShiftLeftLossy) {11083 if (op_id == IrBinOpBitShiftLeftLossy) {
...@@ -11122,7 +11122,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *...@@ -11122,7 +11122,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
1112211122
11123 ir_num_lit_fits_in_other_type(ira, result_instruction, op1->value.type, false);11123 ir_num_lit_fits_in_other_type(ira, result_instruction, op1->value.type, false);
11124 return op1->value.type;11124 return op1->value.type;
11125 } else if (op1->value.type->id == TypeTableEntryIdNumLitInt) {11125 } else if (op1->value.type->id == TypeTableEntryIdComptimeInt) {
11126 ir_add_error(ira, &bin_op_instruction->base,11126 ir_add_error(ira, &bin_op_instruction->base,
11127 buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known"));11127 buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known"));
11128 return ira->codegen->builtin_types.entry_invalid;11128 return ira->codegen->builtin_types.entry_invalid;
...@@ -11158,15 +11158,15 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -11158,15 +11158,15 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
11158 if (type_is_invalid(resolved_type))11158 if (type_is_invalid(resolved_type))
11159 return resolved_type;11159 return resolved_type;
1116011160
11161 bool is_int = resolved_type->id == TypeTableEntryIdInt || resolved_type->id == TypeTableEntryIdNumLitInt;11161 bool is_int = resolved_type->id == TypeTableEntryIdInt || resolved_type->id == TypeTableEntryIdComptimeInt;
11162 bool is_float = resolved_type->id == TypeTableEntryIdFloat || resolved_type->id == TypeTableEntryIdNumLitFloat;11162 bool is_float = resolved_type->id == TypeTableEntryIdFloat || resolved_type->id == TypeTableEntryIdComptimeFloat;
11163 bool is_signed_div = (11163 bool is_signed_div = (
11164 (resolved_type->id == TypeTableEntryIdInt && resolved_type->data.integral.is_signed) ||11164 (resolved_type->id == TypeTableEntryIdInt && resolved_type->data.integral.is_signed) ||
11165 resolved_type->id == TypeTableEntryIdFloat ||11165 resolved_type->id == TypeTableEntryIdFloat ||
11166 (resolved_type->id == TypeTableEntryIdNumLitFloat &&11166 (resolved_type->id == TypeTableEntryIdComptimeFloat &&
11167 ((bigfloat_cmp_zero(&op1->value.data.x_bigfloat) != CmpGT) !=11167 ((bigfloat_cmp_zero(&op1->value.data.x_bigfloat) != CmpGT) !=
11168 (bigfloat_cmp_zero(&op2->value.data.x_bigfloat) != CmpGT))) ||11168 (bigfloat_cmp_zero(&op2->value.data.x_bigfloat) != CmpGT))) ||
11169 (resolved_type->id == TypeTableEntryIdNumLitInt &&11169 (resolved_type->id == TypeTableEntryIdComptimeInt &&
11170 ((bigint_cmp_zero(&op1->value.data.x_bigint) != CmpGT) !=11170 ((bigint_cmp_zero(&op1->value.data.x_bigint) != CmpGT) !=
11171 (bigint_cmp_zero(&op2->value.data.x_bigint) != CmpGT)))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,7 +11267,7 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
11267 return ira->codegen->builtin_types.entry_invalid;11267 return ira->codegen->builtin_types.entry_invalid;
11268 }11268 }
1126911269
11270 if (resolved_type->id == TypeTableEntryIdNumLitInt) {11270 if (resolved_type->id == TypeTableEntryIdComptimeInt) {
11271 if (op_id == IrBinOpAddWrap) {11271 if (op_id == IrBinOpAddWrap) {
11272 op_id = IrBinOpAdd;11272 op_id = IrBinOpAdd;
11273 } else if (op_id == IrBinOpSubWrap) {11273 } else if (op_id == IrBinOpSubWrap) {
...@@ -11641,11 +11641,11 @@ static VarClassRequired get_var_class_required(TypeTableEntry *type_entry) {...@@ -11641,11 +11641,11 @@ static VarClassRequired get_var_class_required(TypeTableEntry *type_entry) {
11641 case TypeTableEntryIdFn:11641 case TypeTableEntryIdFn:
11642 case TypeTableEntryIdPromise:11642 case TypeTableEntryIdPromise:
11643 return VarClassRequiredAny;11643 return VarClassRequiredAny;
11644 case TypeTableEntryIdNumLitFloat:11644 case TypeTableEntryIdComptimeFloat:
11645 case TypeTableEntryIdNumLitInt:11645 case TypeTableEntryIdComptimeInt:
11646 case TypeTableEntryIdUndefLit:11646 case TypeTableEntryIdUndefined:
11647 case TypeTableEntryIdBlock:11647 case TypeTableEntryIdBlock:
11648 case TypeTableEntryIdNullLit:11648 case TypeTableEntryIdNull:
11649 case TypeTableEntryIdOpaque:11649 case TypeTableEntryIdOpaque:
11650 case TypeTableEntryIdMetaType:11650 case TypeTableEntryIdMetaType:
11651 case TypeTableEntryIdNamespace:11651 case TypeTableEntryIdNamespace:
...@@ -11910,10 +11910,10 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi...@@ -11910,10 +11910,10 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi
11910 case TypeTableEntryIdMetaType:11910 case TypeTableEntryIdMetaType:
11911 case TypeTableEntryIdVoid:11911 case TypeTableEntryIdVoid:
11912 case TypeTableEntryIdUnreachable:11912 case TypeTableEntryIdUnreachable:
11913 case TypeTableEntryIdNumLitFloat:11913 case TypeTableEntryIdComptimeFloat:
11914 case TypeTableEntryIdNumLitInt:11914 case TypeTableEntryIdComptimeInt:
11915 case TypeTableEntryIdUndefLit:11915 case TypeTableEntryIdUndefined:
11916 case TypeTableEntryIdNullLit:11916 case TypeTableEntryIdNull:
11917 case TypeTableEntryIdMaybe:11917 case TypeTableEntryIdMaybe:
11918 case TypeTableEntryIdErrorUnion:11918 case TypeTableEntryIdErrorUnion:
11919 case TypeTableEntryIdErrorSet:11919 case TypeTableEntryIdErrorSet:
...@@ -11934,10 +11934,10 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi...@@ -11934,10 +11934,10 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi
11934 case TypeTableEntryIdFloat:11934 case TypeTableEntryIdFloat:
11935 case TypeTableEntryIdPointer:11935 case TypeTableEntryIdPointer:
11936 case TypeTableEntryIdArray:11936 case TypeTableEntryIdArray:
11937 case TypeTableEntryIdNumLitFloat:11937 case TypeTableEntryIdComptimeFloat:
11938 case TypeTableEntryIdNumLitInt:11938 case TypeTableEntryIdComptimeInt:
11939 case TypeTableEntryIdUndefLit:11939 case TypeTableEntryIdUndefined:
11940 case TypeTableEntryIdNullLit:11940 case TypeTableEntryIdNull:
11941 case TypeTableEntryIdMaybe:11941 case TypeTableEntryIdMaybe:
11942 case TypeTableEntryIdErrorUnion:11942 case TypeTableEntryIdErrorUnion:
11943 case TypeTableEntryIdErrorSet:11943 case TypeTableEntryIdErrorSet:
...@@ -12149,7 +12149,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod...@@ -12149,7 +12149,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
12149 }12149 }
1215012150
12151 bool comptime_arg = param_decl_node->data.param_decl.is_inline ||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;
1215312153
12154 ConstExprValue *arg_val;12154 ConstExprValue *arg_val;
1215512155
...@@ -12174,8 +12174,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod...@@ -12174,8 +12174,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
12174 var->shadowable = !comptime_arg;12174 var->shadowable = !comptime_arg;
1217512175
12176 *next_proto_i += 1;12176 *next_proto_i += 1;
12177 } else if (casted_arg->value.type->id == TypeTableEntryIdNumLitInt ||12177 } else if (casted_arg->value.type->id == TypeTableEntryIdComptimeInt ||
12178 casted_arg->value.type->id == TypeTableEntryIdNumLitFloat)12178 casted_arg->value.type->id == TypeTableEntryIdComptimeFloat)
12179 {12179 {
12180 ir_add_error(ira, casted_arg,12180 ir_add_error(ira, casted_arg,
12181 buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557"));12181 buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557"));
...@@ -12898,10 +12898,10 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op...@@ -12898,10 +12898,10 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op
12898 case TypeTableEntryIdPointer:12898 case TypeTableEntryIdPointer:
12899 case TypeTableEntryIdArray:12899 case TypeTableEntryIdArray:
12900 case TypeTableEntryIdStruct:12900 case TypeTableEntryIdStruct:
12901 case TypeTableEntryIdNumLitFloat:12901 case TypeTableEntryIdComptimeFloat:
12902 case TypeTableEntryIdNumLitInt:12902 case TypeTableEntryIdComptimeInt:
12903 case TypeTableEntryIdUndefLit:12903 case TypeTableEntryIdUndefined:
12904 case TypeTableEntryIdNullLit:12904 case TypeTableEntryIdNull:
12905 case TypeTableEntryIdMaybe:12905 case TypeTableEntryIdMaybe:
12906 case TypeTableEntryIdErrorUnion:12906 case TypeTableEntryIdErrorUnion:
12907 case TypeTableEntryIdErrorSet:12907 case TypeTableEntryIdErrorSet:
...@@ -12935,10 +12935,10 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un...@@ -12935,10 +12935,10 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un
1293512935
12936 bool is_wrap_op = (un_op_instruction->op_id == IrUnOpNegationWrap);12936 bool is_wrap_op = (un_op_instruction->op_id == IrUnOpNegationWrap);
1293712937
12938 bool is_float = (expr_type->id == TypeTableEntryIdFloat || expr_type->id == TypeTableEntryIdNumLitFloat);12938 bool is_float = (expr_type->id == TypeTableEntryIdFloat || expr_type->id == TypeTableEntryIdComptimeFloat);
1293912939
12940 if ((expr_type->id == TypeTableEntryIdInt && expr_type->data.integral.is_signed) ||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 if (instr_is_comptime(value)) {12943 if (instr_is_comptime(value)) {
12944 ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad);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,7 +12954,7 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un
12954 } else {12954 } else {
12955 bigint_negate(&out_val->data.x_bigint, &target_const_val->data.x_bigint);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 return expr_type;12958 return expr_type;
12959 }12959 }
1296012960
...@@ -13150,10 +13150,10 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP...@@ -13150,10 +13150,10 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
13150 if (type_is_invalid(resolved_type))13150 if (type_is_invalid(resolved_type))
13151 return resolved_type;13151 return resolved_type;
1315213152
13153 if (resolved_type->id == TypeTableEntryIdNumLitFloat ||13153 if (resolved_type->id == TypeTableEntryIdComptimeFloat ||
13154 resolved_type->id == TypeTableEntryIdNumLitInt ||13154 resolved_type->id == TypeTableEntryIdComptimeInt ||
13155 resolved_type->id == TypeTableEntryIdNullLit ||13155 resolved_type->id == TypeTableEntryIdNull ||
13156 resolved_type->id == TypeTableEntryIdUndefLit)13156 resolved_type->id == TypeTableEntryIdUndefined)
13157 {13157 {
13158 ir_add_error_node(ira, phi_instruction->base.source_node,13158 ir_add_error_node(ira, phi_instruction->base.source_node,
13159 buf_sprintf("unable to infer expression type"));13159 buf_sprintf("unable to infer expression type"));
...@@ -14213,10 +14213,10 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi...@@ -14213,10 +14213,10 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi
14213 switch (type_entry->id) {14213 switch (type_entry->id) {
14214 case TypeTableEntryIdInvalid:14214 case TypeTableEntryIdInvalid:
14215 zig_unreachable(); // handled above14215 zig_unreachable(); // handled above
14216 case TypeTableEntryIdNumLitFloat:14216 case TypeTableEntryIdComptimeFloat:
14217 case TypeTableEntryIdNumLitInt:14217 case TypeTableEntryIdComptimeInt:
14218 case TypeTableEntryIdUndefLit:14218 case TypeTableEntryIdUndefined:
14219 case TypeTableEntryIdNullLit:14219 case TypeTableEntryIdNull:
14220 case TypeTableEntryIdNamespace:14220 case TypeTableEntryIdNamespace:
14221 case TypeTableEntryIdBlock:14221 case TypeTableEntryIdBlock:
14222 case TypeTableEntryIdBoundFn:14222 case TypeTableEntryIdBoundFn:
...@@ -14479,8 +14479,8 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,...@@ -14479,8 +14479,8 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
14479 case TypeTableEntryIdInvalid: // handled above14479 case TypeTableEntryIdInvalid: // handled above
14480 zig_unreachable();14480 zig_unreachable();
14481 case TypeTableEntryIdUnreachable:14481 case TypeTableEntryIdUnreachable:
14482 case TypeTableEntryIdUndefLit:14482 case TypeTableEntryIdUndefined:
14483 case TypeTableEntryIdNullLit:14483 case TypeTableEntryIdNull:
14484 case TypeTableEntryIdBlock:14484 case TypeTableEntryIdBlock:
14485 case TypeTableEntryIdArgTuple:14485 case TypeTableEntryIdArgTuple:
14486 case TypeTableEntryIdOpaque:14486 case TypeTableEntryIdOpaque:
...@@ -14495,8 +14495,8 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,...@@ -14495,8 +14495,8 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
14495 case TypeTableEntryIdPointer:14495 case TypeTableEntryIdPointer:
14496 case TypeTableEntryIdArray:14496 case TypeTableEntryIdArray:
14497 case TypeTableEntryIdStruct:14497 case TypeTableEntryIdStruct:
14498 case TypeTableEntryIdNumLitFloat:14498 case TypeTableEntryIdComptimeFloat:
14499 case TypeTableEntryIdNumLitInt:14499 case TypeTableEntryIdComptimeInt:
14500 case TypeTableEntryIdMaybe:14500 case TypeTableEntryIdMaybe:
14501 case TypeTableEntryIdErrorUnion:14501 case TypeTableEntryIdErrorUnion:
14502 case TypeTableEntryIdErrorSet:14502 case TypeTableEntryIdErrorSet:
...@@ -14587,8 +14587,8 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,...@@ -14587,8 +14587,8 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
14587 case TypeTableEntryIdInvalid: // handled above14587 case TypeTableEntryIdInvalid: // handled above
14588 zig_unreachable();14588 zig_unreachable();
14589 case TypeTableEntryIdUnreachable:14589 case TypeTableEntryIdUnreachable:
14590 case TypeTableEntryIdUndefLit:14590 case TypeTableEntryIdUndefined:
14591 case TypeTableEntryIdNullLit:14591 case TypeTableEntryIdNull:
14592 case TypeTableEntryIdBlock:14592 case TypeTableEntryIdBlock:
14593 case TypeTableEntryIdArgTuple:14593 case TypeTableEntryIdArgTuple:
14594 case TypeTableEntryIdOpaque:14594 case TypeTableEntryIdOpaque:
...@@ -14603,8 +14603,8 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,...@@ -14603,8 +14603,8 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
14603 case TypeTableEntryIdPointer:14603 case TypeTableEntryIdPointer:
14604 case TypeTableEntryIdArray:14604 case TypeTableEntryIdArray:
14605 case TypeTableEntryIdStruct:14605 case TypeTableEntryIdStruct:
14606 case TypeTableEntryIdNumLitFloat:14606 case TypeTableEntryIdComptimeFloat:
14607 case TypeTableEntryIdNumLitInt:14607 case TypeTableEntryIdComptimeInt:
14608 case TypeTableEntryIdMaybe:14608 case TypeTableEntryIdMaybe:
14609 case TypeTableEntryIdErrorUnion:14609 case TypeTableEntryIdErrorUnion:
14610 case TypeTableEntryIdErrorSet:14610 case TypeTableEntryIdErrorSet:
...@@ -14656,11 +14656,11 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira,...@@ -14656,11 +14656,11 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira,
14656 case TypeTableEntryIdInvalid: // handled above14656 case TypeTableEntryIdInvalid: // handled above
14657 zig_unreachable();14657 zig_unreachable();
14658 case TypeTableEntryIdUnreachable:14658 case TypeTableEntryIdUnreachable:
14659 case TypeTableEntryIdUndefLit:14659 case TypeTableEntryIdUndefined:
14660 case TypeTableEntryIdNullLit:14660 case TypeTableEntryIdNull:
14661 case TypeTableEntryIdBlock:14661 case TypeTableEntryIdBlock:
14662 case TypeTableEntryIdNumLitFloat:14662 case TypeTableEntryIdComptimeFloat:
14663 case TypeTableEntryIdNumLitInt:14663 case TypeTableEntryIdComptimeInt:
14664 case TypeTableEntryIdBoundFn:14664 case TypeTableEntryIdBoundFn:
14665 case TypeTableEntryIdMetaType:14665 case TypeTableEntryIdMetaType:
14666 case TypeTableEntryIdNamespace:14666 case TypeTableEntryIdNamespace:
...@@ -14713,7 +14713,7 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn...@@ -14713,7 +14713,7 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn
1471314713
14714 ir_build_test_nonnull_from(&ira->new_irb, &instruction->base, value);14714 ir_build_test_nonnull_from(&ira->new_irb, &instruction->base, value);
14715 return ira->codegen->builtin_types.entry_bool;14715 return ira->codegen->builtin_types.entry_bool;
14716 } else if (type_entry->id == TypeTableEntryIdNullLit) {14716 } else if (type_entry->id == TypeTableEntryIdNull) {
14717 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);14717 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
14718 out_val->data.x_bool = false;14718 out_val->data.x_bool = false;
14719 return ira->codegen->builtin_types.entry_bool;14719 return ira->codegen->builtin_types.entry_bool;
...@@ -15020,8 +15020,8 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,...@@ -15020,8 +15020,8 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
15020 case TypeTableEntryIdBool:15020 case TypeTableEntryIdBool:
15021 case TypeTableEntryIdInt:15021 case TypeTableEntryIdInt:
15022 case TypeTableEntryIdFloat:15022 case TypeTableEntryIdFloat:
15023 case TypeTableEntryIdNumLitFloat:15023 case TypeTableEntryIdComptimeFloat:
15024 case TypeTableEntryIdNumLitInt:15024 case TypeTableEntryIdComptimeInt:
15025 case TypeTableEntryIdPointer:15025 case TypeTableEntryIdPointer:
15026 case TypeTableEntryIdPromise:15026 case TypeTableEntryIdPromise:
15027 case TypeTableEntryIdFn:15027 case TypeTableEntryIdFn:
...@@ -15099,8 +15099,8 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,...@@ -15099,8 +15099,8 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
15099 case TypeTableEntryIdUnreachable:15099 case TypeTableEntryIdUnreachable:
15100 case TypeTableEntryIdArray:15100 case TypeTableEntryIdArray:
15101 case TypeTableEntryIdStruct:15101 case TypeTableEntryIdStruct:
15102 case TypeTableEntryIdUndefLit:15102 case TypeTableEntryIdUndefined:
15103 case TypeTableEntryIdNullLit:15103 case TypeTableEntryIdNull:
15104 case TypeTableEntryIdMaybe:15104 case TypeTableEntryIdMaybe:
15105 case TypeTableEntryIdBlock:15105 case TypeTableEntryIdBlock:
15106 case TypeTableEntryIdBoundFn:15106 case TypeTableEntryIdBoundFn:
...@@ -15618,10 +15618,10 @@ static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_...@@ -15618,10 +15618,10 @@ static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_
15618 case TypeTableEntryIdPromise:15618 case TypeTableEntryIdPromise:
15619 case TypeTableEntryIdArray:15619 case TypeTableEntryIdArray:
15620 case TypeTableEntryIdStruct:15620 case TypeTableEntryIdStruct:
15621 case TypeTableEntryIdNumLitFloat:15621 case TypeTableEntryIdComptimeFloat:
15622 case TypeTableEntryIdNumLitInt:15622 case TypeTableEntryIdComptimeInt:
15623 case TypeTableEntryIdUndefLit:15623 case TypeTableEntryIdUndefined:
15624 case TypeTableEntryIdNullLit:15624 case TypeTableEntryIdNull:
15625 case TypeTableEntryIdMaybe:15625 case TypeTableEntryIdMaybe:
15626 case TypeTableEntryIdErrorUnion:15626 case TypeTableEntryIdErrorUnion:
15627 case TypeTableEntryIdErrorSet:15627 case TypeTableEntryIdErrorSet:
...@@ -16280,10 +16280,10 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t...@@ -16280,10 +16280,10 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
16280 case TypeTableEntryIdVoid:16280 case TypeTableEntryIdVoid:
16281 case TypeTableEntryIdBool:16281 case TypeTableEntryIdBool:
16282 case TypeTableEntryIdUnreachable:16282 case TypeTableEntryIdUnreachable:
16283 case TypeTableEntryIdNumLitFloat:16283 case TypeTableEntryIdComptimeFloat:
16284 case TypeTableEntryIdNumLitInt:16284 case TypeTableEntryIdComptimeInt:
16285 case TypeTableEntryIdUndefLit:16285 case TypeTableEntryIdUndefined:
16286 case TypeTableEntryIdNullLit:16286 case TypeTableEntryIdNull:
16287 case TypeTableEntryIdNamespace:16287 case TypeTableEntryIdNamespace:
16288 case TypeTableEntryIdBlock:16288 case TypeTableEntryIdBlock:
16289 case TypeTableEntryIdArgTuple:16289 case TypeTableEntryIdArgTuple:
...@@ -17143,7 +17143,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc...@@ -17143,7 +17143,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc
17143 return ira->codegen->builtin_types.entry_invalid;17143 return ira->codegen->builtin_types.entry_invalid;
1714417144
17145 if (dest_type->id != TypeTableEntryIdInt &&17145 if (dest_type->id != TypeTableEntryIdInt &&
17146 dest_type->id != TypeTableEntryIdNumLitInt)17146 dest_type->id != TypeTableEntryIdComptimeInt)
17147 {17147 {
17148 ir_add_error(ira, dest_type_value, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name)));17148 ir_add_error(ira, dest_type_value, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name)));
17149 return ira->codegen->builtin_types.entry_invalid;17149 return ira->codegen->builtin_types.entry_invalid;
...@@ -17155,7 +17155,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc...@@ -17155,7 +17155,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc
17155 return ira->codegen->builtin_types.entry_invalid;17155 return ira->codegen->builtin_types.entry_invalid;
1715617156
17157 if (src_type->id != TypeTableEntryIdInt &&17157 if (src_type->id != TypeTableEntryIdInt &&
17158 src_type->id != TypeTableEntryIdNumLitInt)17158 src_type->id != TypeTableEntryIdComptimeInt)
17159 {17159 {
17160 ir_add_error(ira, target, buf_sprintf("expected integer type, found '%s'", buf_ptr(&src_type->name)));17160 ir_add_error(ira, target, buf_sprintf("expected integer type, found '%s'", buf_ptr(&src_type->name)));
17161 return ira->codegen->builtin_types.entry_invalid;17161 return ira->codegen->builtin_types.entry_invalid;
...@@ -17876,10 +17876,10 @@ static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruc...@@ -17876,10 +17876,10 @@ static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruc
17876 zig_unreachable();17876 zig_unreachable();
17877 case TypeTableEntryIdMetaType:17877 case TypeTableEntryIdMetaType:
17878 case TypeTableEntryIdUnreachable:17878 case TypeTableEntryIdUnreachable:
17879 case TypeTableEntryIdNumLitFloat:17879 case TypeTableEntryIdComptimeFloat:
17880 case TypeTableEntryIdNumLitInt:17880 case TypeTableEntryIdComptimeInt:
17881 case TypeTableEntryIdUndefLit:17881 case TypeTableEntryIdUndefined:
17882 case TypeTableEntryIdNullLit:17882 case TypeTableEntryIdNull:
17883 case TypeTableEntryIdNamespace:17883 case TypeTableEntryIdNamespace:
17884 case TypeTableEntryIdBlock:17884 case TypeTableEntryIdBlock:
17885 case TypeTableEntryIdBoundFn:17885 case TypeTableEntryIdBoundFn:
...@@ -18377,8 +18377,8 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira...@@ -18377,8 +18377,8 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira
18377 if (!end_val)18377 if (!end_val)
18378 return ira->codegen->builtin_types.entry_invalid;18378 return ira->codegen->builtin_types.entry_invalid;
1837918379
18380 assert(start_val->type->id == TypeTableEntryIdInt || start_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 == TypeTableEntryIdNumLitInt);18381 assert(end_val->type->id == TypeTableEntryIdInt || end_val->type->id == TypeTableEntryIdComptimeInt);
18382 AstNode *prev_node = rangeset_add_range(&rs, &start_val->data.x_bigint, &end_val->data.x_bigint,18382 AstNode *prev_node = rangeset_add_range(&rs, &start_val->data.x_bigint, &end_val->data.x_bigint,
18383 start_value->source_node);18383 start_value->source_node);
18384 if (prev_node != nullptr) {18384 if (prev_node != nullptr) {
...@@ -18610,10 +18610,10 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue...@@ -18610,10 +18610,10 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
18610 case TypeTableEntryIdNamespace:18610 case TypeTableEntryIdNamespace:
18611 case TypeTableEntryIdBlock:18611 case TypeTableEntryIdBlock:
18612 case TypeTableEntryIdUnreachable:18612 case TypeTableEntryIdUnreachable:
18613 case TypeTableEntryIdNumLitFloat:18613 case TypeTableEntryIdComptimeFloat:
18614 case TypeTableEntryIdNumLitInt:18614 case TypeTableEntryIdComptimeInt:
18615 case TypeTableEntryIdUndefLit:18615 case TypeTableEntryIdUndefined:
18616 case TypeTableEntryIdNullLit:18616 case TypeTableEntryIdNull:
18617 case TypeTableEntryIdPromise:18617 case TypeTableEntryIdPromise:
18618 zig_unreachable();18618 zig_unreachable();
18619 case TypeTableEntryIdVoid:18619 case TypeTableEntryIdVoid:
...@@ -18677,10 +18677,10 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue...@@ -18677,10 +18677,10 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
18677 case TypeTableEntryIdNamespace:18677 case TypeTableEntryIdNamespace:
18678 case TypeTableEntryIdBlock:18678 case TypeTableEntryIdBlock:
18679 case TypeTableEntryIdUnreachable:18679 case TypeTableEntryIdUnreachable:
18680 case TypeTableEntryIdNumLitFloat:18680 case TypeTableEntryIdComptimeFloat:
18681 case TypeTableEntryIdNumLitInt:18681 case TypeTableEntryIdComptimeInt:
18682 case TypeTableEntryIdUndefLit:18682 case TypeTableEntryIdUndefined:
18683 case TypeTableEntryIdNullLit:18683 case TypeTableEntryIdNull:
18684 case TypeTableEntryIdPromise:18684 case TypeTableEntryIdPromise:
18685 zig_unreachable();18685 zig_unreachable();
18686 case TypeTableEntryIdVoid:18686 case TypeTableEntryIdVoid:
...@@ -18758,10 +18758,10 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc...@@ -18758,10 +18758,10 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc
18758 case TypeTableEntryIdNamespace:18758 case TypeTableEntryIdNamespace:
18759 case TypeTableEntryIdBlock:18759 case TypeTableEntryIdBlock:
18760 case TypeTableEntryIdUnreachable:18760 case TypeTableEntryIdUnreachable:
18761 case TypeTableEntryIdNumLitFloat:18761 case TypeTableEntryIdComptimeFloat:
18762 case TypeTableEntryIdNumLitInt:18762 case TypeTableEntryIdComptimeInt:
18763 case TypeTableEntryIdUndefLit:18763 case TypeTableEntryIdUndefined:
18764 case TypeTableEntryIdNullLit:18764 case TypeTableEntryIdNull:
18765 ir_add_error(ira, dest_type_value,18765 ir_add_error(ira, dest_type_value,
18766 buf_sprintf("unable to @bitCast from type '%s'", buf_ptr(&src_type->name)));18766 buf_sprintf("unable to @bitCast from type '%s'", buf_ptr(&src_type->name)));
18767 return ira->codegen->builtin_types.entry_invalid;18767 return ira->codegen->builtin_types.entry_invalid;
...@@ -18784,10 +18784,10 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc...@@ -18784,10 +18784,10 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc
18784 case TypeTableEntryIdNamespace:18784 case TypeTableEntryIdNamespace:
18785 case TypeTableEntryIdBlock:18785 case TypeTableEntryIdBlock:
18786 case TypeTableEntryIdUnreachable:18786 case TypeTableEntryIdUnreachable:
18787 case TypeTableEntryIdNumLitFloat:18787 case TypeTableEntryIdComptimeFloat:
18788 case TypeTableEntryIdNumLitInt:18788 case TypeTableEntryIdComptimeInt:
18789 case TypeTableEntryIdUndefLit:18789 case TypeTableEntryIdUndefined:
18790 case TypeTableEntryIdNullLit:18790 case TypeTableEntryIdNull:
18791 ir_add_error(ira, dest_type_value,18791 ir_add_error(ira, dest_type_value,
18792 buf_sprintf("unable to @bitCast to type '%s'", buf_ptr(&dest_type->name)));18792 buf_sprintf("unable to @bitCast to type '%s'", buf_ptr(&dest_type->name)));
18793 return ira->codegen->builtin_types.entry_invalid;18793 return ira->codegen->builtin_types.entry_invalid;
...@@ -19560,7 +19560,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction...@@ -19560,7 +19560,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction
19560 if (type_is_invalid(op->value.type))19560 if (type_is_invalid(op->value.type))
19561 return ira->codegen->builtin_types.entry_invalid;19561 return ira->codegen->builtin_types.entry_invalid;
1956219562
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 if (!ok_type) {19564 if (!ok_type) {
19565 ir_add_error(ira, instruction->type, buf_sprintf("@sqrt does not support type '%s'", buf_ptr(&float_type->name)));19565 ir_add_error(ira, instruction->type, buf_sprintf("@sqrt does not support type '%s'", buf_ptr(&float_type->name)));
19566 return ira->codegen->builtin_types.entry_invalid;19566 return ira->codegen->builtin_types.entry_invalid;
...@@ -19577,7 +19577,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction...@@ -19577,7 +19577,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction
1957719577
19578 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);19578 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1957919579
19580 if (float_type->id == TypeTableEntryIdNumLitFloat) {19580 if (float_type->id == TypeTableEntryIdComptimeFloat) {
19581 bigfloat_sqrt(&out_val->data.x_bigfloat, &val->data.x_bigfloat);19581 bigfloat_sqrt(&out_val->data.x_bigfloat, &val->data.x_bigfloat);
19582 } else if (float_type->id == TypeTableEntryIdFloat) {19582 } else if (float_type->id == TypeTableEntryIdFloat) {
19583 switch (float_type->data.floating.bit_count) {19583 switch (float_type->data.floating.bit_count) {
std/math/ln.zig+2-2
...@@ -14,7 +14,7 @@ const TypeId = builtin.TypeId;...@@ -14,7 +14,7 @@ const TypeId = builtin.TypeId;
14pub fn ln(x: var) @typeOf(x) {14pub fn ln(x: var) @typeOf(x) {
15 const T = @typeOf(x);15 const T = @typeOf(x);
16 switch (@typeId(T)) {16 switch (@typeId(T)) {
17 TypeId.FloatLiteral => {17 TypeId.ComptimeFloat => {
18 return @typeOf(1.0)(ln_64(x));18 return @typeOf(1.0)(ln_64(x));
19 },19 },
20 TypeId.Float => {20 TypeId.Float => {
...@@ -24,7 +24,7 @@ pub fn ln(x: var) @typeOf(x) {...@@ -24,7 +24,7 @@ pub fn ln(x: var) @typeOf(x) {
24 else => @compileError("ln not implemented for " ++ @typeName(T)),24 else => @compileError("ln not implemented for " ++ @typeName(T)),
25 };25 };
26 },26 },
27 TypeId.IntLiteral => {27 TypeId.ComptimeInt => {
28 return @typeOf(1)(math.floor(ln_64(f64(x))));28 return @typeOf(1)(math.floor(ln_64(f64(x))));
29 },29 },
30 TypeId.Int => {30 TypeId.Int => {
std/math/log.zig+3-3
...@@ -9,15 +9,15 @@ pub fn log(comptime T: type, base: T, x: T) T {...@@ -9,15 +9,15 @@ pub fn log(comptime T: type, base: T, x: T) T {
9 return math.log2(x);9 return math.log2(x);
10 } else if (base == 10) {10 } else if (base == 10) {
11 return math.log10(x);11 return math.log10(x);
12 } else if ((@typeId(T) == TypeId.Float or @typeId(T) == TypeId.FloatLiteral) and base == math.e) {12 } else if ((@typeId(T) == TypeId.Float or @typeId(T) == TypeId.ComptimeFloat) and base == math.e) {
13 return math.ln(x);13 return math.ln(x);
14 }14 }
1515
16 switch (@typeId(T)) {16 switch (@typeId(T)) {
17 TypeId.FloatLiteral => {17 TypeId.ComptimeFloat => {
18 return @typeOf(1.0)(math.ln(f64(x)) / math.ln(f64(base)));18 return @typeOf(1.0)(math.ln(f64(x)) / math.ln(f64(base)));
19 },19 },
20 TypeId.IntLiteral => {20 TypeId.ComptimeInt => {
21 return @typeOf(1)(math.floor(math.ln(f64(x)) / math.ln(f64(base))));21 return @typeOf(1)(math.floor(math.ln(f64(x)) / math.ln(f64(base))));
22 },22 },
23 builtin.TypeId.Int => {23 builtin.TypeId.Int => {
std/math/log10.zig+2-2
...@@ -14,7 +14,7 @@ const TypeId = builtin.TypeId;...@@ -14,7 +14,7 @@ const TypeId = builtin.TypeId;
14pub fn log10(x: var) @typeOf(x) {14pub fn log10(x: var) @typeOf(x) {
15 const T = @typeOf(x);15 const T = @typeOf(x);
16 switch (@typeId(T)) {16 switch (@typeId(T)) {
17 TypeId.FloatLiteral => {17 TypeId.ComptimeFloat => {
18 return @typeOf(1.0)(log10_64(x));18 return @typeOf(1.0)(log10_64(x));
19 },19 },
20 TypeId.Float => {20 TypeId.Float => {
...@@ -24,7 +24,7 @@ pub fn log10(x: var) @typeOf(x) {...@@ -24,7 +24,7 @@ pub fn log10(x: var) @typeOf(x) {
24 else => @compileError("log10 not implemented for " ++ @typeName(T)),24 else => @compileError("log10 not implemented for " ++ @typeName(T)),
25 };25 };
26 },26 },
27 TypeId.IntLiteral => {27 TypeId.ComptimeInt => {
28 return @typeOf(1)(math.floor(log10_64(f64(x))));28 return @typeOf(1)(math.floor(log10_64(f64(x))));
29 },29 },
30 TypeId.Int => {30 TypeId.Int => {
std/math/log2.zig+2-2
...@@ -14,7 +14,7 @@ const TypeId = builtin.TypeId;...@@ -14,7 +14,7 @@ const TypeId = builtin.TypeId;
14pub fn log2(x: var) @typeOf(x) {14pub fn log2(x: var) @typeOf(x) {
15 const T = @typeOf(x);15 const T = @typeOf(x);
16 switch (@typeId(T)) {16 switch (@typeId(T)) {
17 TypeId.FloatLiteral => {17 TypeId.ComptimeFloat => {
18 return @typeOf(1.0)(log2_64(x));18 return @typeOf(1.0)(log2_64(x));
19 },19 },
20 TypeId.Float => {20 TypeId.Float => {
...@@ -24,7 +24,7 @@ pub fn log2(x: var) @typeOf(x) {...@@ -24,7 +24,7 @@ pub fn log2(x: var) @typeOf(x) {
24 else => @compileError("log2 not implemented for " ++ @typeName(T)),24 else => @compileError("log2 not implemented for " ++ @typeName(T)),
25 };25 };
26 },26 },
27 TypeId.IntLiteral => comptime {27 TypeId.ComptimeInt => comptime {
28 var result = 0;28 var result = 0;
29 var x_shifted = x;29 var x_shifted = x;
30 while (b: {30 while (b: {
std/math/sqrt.zig+2-2
...@@ -14,9 +14,9 @@ const TypeId = builtin.TypeId;...@@ -14,9 +14,9 @@ const TypeId = builtin.TypeId;
14pub fn sqrt(x: var) (if (@typeId(@typeOf(x)) == TypeId.Int) @IntType(false, @typeOf(x).bit_count / 2) else @typeOf(x)) {14pub fn sqrt(x: var) (if (@typeId(@typeOf(x)) == TypeId.Int) @IntType(false, @typeOf(x).bit_count / 2) else @typeOf(x)) {
15 const T = @typeOf(x);15 const T = @typeOf(x);
16 switch (@typeId(T)) {16 switch (@typeId(T)) {
17 TypeId.FloatLiteral => return T(@sqrt(f64, x)), // TODO upgrade to f12817 TypeId.ComptimeFloat => return T(@sqrt(f64, x)), // TODO upgrade to f128
18 TypeId.Float => return @sqrt(T, x),18 TypeId.Float => return @sqrt(T, x),
19 TypeId.IntLiteral => comptime {19 TypeId.ComptimeInt => comptime {
20 if (x > @maxValue(u128)) {20 if (x > @maxValue(u128)) {
21 @compileError("sqrt not implemented for comptime_int greater than 128 bits");21 @compileError("sqrt not implemented for comptime_int greater than 128 bits");
22 }22 }
test/cases/math.zig+18-6
...@@ -329,14 +329,14 @@ fn testShrExact(x: u8) void {...@@ -329,14 +329,14 @@ fn testShrExact(x: u8) void {
329 assert(shifted == 0b00101101);329 assert(shifted == 0b00101101);
330}330}
331331
332test "big number addition" {332test "comptime_int addition" {
333 comptime {333 comptime {
334 assert(35361831660712422535336160538497375248 + 101752735581729509668353361206450473702 == 137114567242441932203689521744947848950);334 assert(35361831660712422535336160538497375248 + 101752735581729509668353361206450473702 == 137114567242441932203689521744947848950);
335 assert(594491908217841670578297176641415611445982232488944558774612 + 390603545391089362063884922208143568023166603618446395589768 == 985095453608931032642182098849559179469148836107390954364380);335 assert(594491908217841670578297176641415611445982232488944558774612 + 390603545391089362063884922208143568023166603618446395589768 == 985095453608931032642182098849559179469148836107390954364380);
336 }336 }
337}337}
338338
339test "big number multiplication" {339test "comptime_int multiplication" {
340 comptime {340 comptime {
341 assert(341 assert(
342 45960427431263824329884196484953148229 * 128339149605334697009938835852565949723 == 5898522172026096622534201617172456926982464453350084962781392314016180490567,342 45960427431263824329884196484953148229 * 128339149605334697009938835852565949723 == 5898522172026096622534201617172456926982464453350084962781392314016180490567,
...@@ -347,13 +347,13 @@ test "big number multiplication" {...@@ -347,13 +347,13 @@ test "big number multiplication" {
347 }347 }
348}348}
349349
350test "big number shifting" {350test "comptime_int shifting" {
351 comptime {351 comptime {
352 assert((u128(1) << 127) == 0x80000000000000000000000000000000);352 assert((u128(1) << 127) == 0x80000000000000000000000000000000);
353 }353 }
354}354}
355355
356test "big number multi-limb shift and mask" {356test "comptime_int multi-limb shift and mask" {
357 comptime {357 comptime {
358 var a = 0xefffffffa0000001eeeeeeefaaaaaaab;358 var a = 0xefffffffa0000001eeeeeeefaaaaaaab;
359359
...@@ -370,7 +370,7 @@ test "big number multi-limb shift and mask" {...@@ -370,7 +370,7 @@ test "big number multi-limb shift and mask" {
370 }370 }
371}371}
372372
373test "big number multi-limb partial shift right" {373test "comptime_int multi-limb partial shift right" {
374 comptime {374 comptime {
375 var a = 0x1ffffffffeeeeeeee;375 var a = 0x1ffffffffeeeeeeee;
376 a >>= 16;376 a >>= 16;
...@@ -391,7 +391,7 @@ fn test_xor() void {...@@ -391,7 +391,7 @@ fn test_xor() void {
391 assert(0xFF ^ 0xFF == 0x00);391 assert(0xFF ^ 0xFF == 0x00);
392}392}
393393
394test "big number xor" {394test "comptime_int xor" {
395 comptime {395 comptime {
396 assert(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ^ 0x00000000000000000000000000000000 == 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);396 assert(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ^ 0x00000000000000000000000000000000 == 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
397 assert(0xFFFFFFFFFFFFFFFF0000000000000000 ^ 0x0000000000000000FFFFFFFFFFFFFFFF == 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);397 assert(0xFFFFFFFFFFFFFFFF0000000000000000 ^ 0x0000000000000000FFFFFFFFFFFFFFFF == 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
...@@ -449,3 +449,15 @@ test "@sqrt" {...@@ -449,3 +449,15 @@ test "@sqrt" {
449fn testSqrt(comptime T: type, x: T) void {449fn testSqrt(comptime T: type, x: T) void {
450 assert(@sqrt(T, x * x) == x);450 assert(@sqrt(T, x * x) == x);
451}451}
452
453test "comptime_int param and return" {
454 const a = comptimeAdd(35361831660712422535336160538497375248, 101752735581729509668353361206450473702);
455 assert(a == 137114567242441932203689521744947848950);
456
457 const b = comptimeAdd(594491908217841670578297176641415611445982232488944558774612, 390603545391089362063884922208143568023166603618446395589768);
458 assert(b == 985095453608931032642182098849559179469148836107390954364380);
459}
460
461fn comptimeAdd(comptime a: comptime_int, comptime b: comptime_int) comptime_int {
462 return a + b;
463}
test/cases/misc.zig+4-4
...@@ -501,10 +501,10 @@ test "@typeId" {...@@ -501,10 +501,10 @@ test "@typeId" {
501 assert(@typeId(*f32) == Tid.Pointer);501 assert(@typeId(*f32) == Tid.Pointer);
502 assert(@typeId([2]u8) == Tid.Array);502 assert(@typeId([2]u8) == Tid.Array);
503 assert(@typeId(AStruct) == Tid.Struct);503 assert(@typeId(AStruct) == Tid.Struct);
504 assert(@typeId(@typeOf(1)) == Tid.IntLiteral);504 assert(@typeId(@typeOf(1)) == Tid.ComptimeInt);
505 assert(@typeId(@typeOf(1.0)) == Tid.FloatLiteral);505 assert(@typeId(@typeOf(1.0)) == Tid.ComptimeFloat);
506 assert(@typeId(@typeOf(undefined)) == Tid.UndefinedLiteral);506 assert(@typeId(@typeOf(undefined)) == Tid.Undefined);
507 assert(@typeId(@typeOf(null)) == Tid.NullLiteral);507 assert(@typeId(@typeOf(null)) == Tid.Null);
508 assert(@typeId(?i32) == Tid.Nullable);508 assert(@typeId(?i32) == Tid.Nullable);
509 assert(@typeId(error!i32) == Tid.ErrorUnion);509 assert(@typeId(error!i32) == Tid.ErrorUnion);
510 assert(@typeId(error) == Tid.ErrorSet);510 assert(@typeId(error) == Tid.ErrorSet);
test/compile_errors.zig+6-6
...@@ -1539,7 +1539,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1539,7 +1539,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1539 \\fn foo() *const i32 { return y; }1539 \\fn foo() *const i32 { return y; }
1540 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }1540 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
1541 ,1541 ,
1542 ".tmp_source.zig:3:30: error: expected type '*const i32', found '*const (integer literal)'",1542 ".tmp_source.zig:3:30: error: expected type '*const i32', found '*const comptime_int'",
1543 );1543 );
15441544
1545 cases.add(1545 cases.add(
...@@ -1555,7 +1555,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1555,7 +1555,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1555 \\const x = 2 == 2.0;1555 \\const x = 2 == 2.0;
1556 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }1556 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
1557 ,1557 ,
1558 ".tmp_source.zig:1:11: error: integer value 2 cannot be implicitly casted to type '(float literal)'",1558 ".tmp_source.zig:1:11: error: integer value 2 cannot be implicitly casted to type 'comptime_float'",
1559 );1559 );
15601560
1561 cases.add(1561 cases.add(
...@@ -2189,7 +2189,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -2189,7 +2189,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
2189 \\2189 \\
2190 \\export fn entry() usize { return @sizeOf(@typeOf(block_aligned_stuff)); }2190 \\export fn entry() usize { return @sizeOf(@typeOf(block_aligned_stuff)); }
2191 ,2191 ,
2192 ".tmp_source.zig:3:60: error: unable to perform binary not operation on type '(integer literal)'",2192 ".tmp_source.zig:3:60: error: unable to perform binary not operation on type 'comptime_int'",
2193 );2193 );
21942194
2195 cases.addCase(x: {2195 cases.addCase(x: {
...@@ -3269,10 +3269,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3269,10 +3269,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
3269 \\ fn bar(self: *const Foo) void {}3269 \\ fn bar(self: *const Foo) void {}
3270 \\};3270 \\};
3271 ,3271 ,
3272 ".tmp_source.zig:4:4: error: variable of type '*(integer literal)' must be const or comptime",3272 ".tmp_source.zig:4:4: error: variable of type '*comptime_int' must be const or comptime",
3273 ".tmp_source.zig:7:4: error: variable of type '(undefined)' must be const or comptime",3273 ".tmp_source.zig:7:4: error: variable of type '(undefined)' must be const or comptime",
3274 ".tmp_source.zig:8:4: error: variable of type '(integer literal)' must be const or comptime",3274 ".tmp_source.zig:8:4: error: variable of type 'comptime_int' must be const or comptime",
3275 ".tmp_source.zig:9:4: error: variable of type '(float literal)' must be const or comptime",3275 ".tmp_source.zig:9:4: error: variable of type 'comptime_float' must be const or comptime",
3276 ".tmp_source.zig:10:4: error: variable of type '(block)' must be const or comptime",3276 ".tmp_source.zig:10:4: error: variable of type '(block)' must be const or comptime",
3277 ".tmp_source.zig:11:4: error: variable of type '(null)' must be const or comptime",3277 ".tmp_source.zig:11:4: error: variable of type '(null)' must be const or comptime",
3278 ".tmp_source.zig:12:4: error: variable of type 'Opaque' must be const or comptime",3278 ".tmp_source.zig:12:4: error: variable of type 'Opaque' must be const or comptime",