authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-02-24 23:50:02+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-02-25 01:27:34+02:00
logd56115ef4189a7716d9371ef87df9124a61f5ab1
tree2fef1af7bb3e97aeb15bcb3ce7dc134fd86d3a43
parent538d9a5dd8e0eca02d363bbd5f749405e003f1c6
signaturelock-open Commit is signed but in an unrecognized format.

remove `@IntType` and `@ArgType` (mostly) from the compiler


6 files changed, 2 insertions(+), 94 deletions(-)

doc/langref.html.in+2-2
...@@ -2810,10 +2810,10 @@ test "@TagType" {...@@ -2810,10 +2810,10 @@ test "@TagType" {
2810 assert(@TagType(Small) == u2);2810 assert(@TagType(Small) == u2);
2811}2811}
28122812
2813// @typeInfo tells us the field count and the fields name:2813// @typeInfo tells us the field count and the fields names:
2814test "@typeInfo" {2814test "@typeInfo" {
2815 assert(@typeInfo(Small).Enum.fields.len == 4);2815 assert(@typeInfo(Small).Enum.fields.len == 4);
2816 assert(mem.eql(u8, @typeInfo(Small).Enum.fields[0].name, "Two"));2816 assert(mem.eql(u8, @typeInfo(Small).Enum.fields[1].name, "Two"));
2817}2817}
28182818
2819// @tagName gives a []const u8 representation of an enum value:2819// @tagName gives a []const u8 representation of an enum value:
src/all_types.hpp-10
...@@ -1754,7 +1754,6 @@ enum BuiltinFnId {...@@ -1754,7 +1754,6 @@ enum BuiltinFnId {
1754 BuiltinFnIdIntToErr,1754 BuiltinFnIdIntToErr,
1755 BuiltinFnIdEnumToInt,1755 BuiltinFnIdEnumToInt,
1756 BuiltinFnIdIntToEnum,1756 BuiltinFnIdIntToEnum,
1757 BuiltinFnIdIntType,
1758 BuiltinFnIdVectorType,1757 BuiltinFnIdVectorType,
1759 BuiltinFnIdShuffle,1758 BuiltinFnIdShuffle,
1760 BuiltinFnIdSplat,1759 BuiltinFnIdSplat,
...@@ -1781,7 +1780,6 @@ enum BuiltinFnId {...@@ -1781,7 +1780,6 @@ enum BuiltinFnId {
1781 BuiltinFnIdOpaqueType,1780 BuiltinFnIdOpaqueType,
1782 BuiltinFnIdThis,1781 BuiltinFnIdThis,
1783 BuiltinFnIdSetAlignStack,1782 BuiltinFnIdSetAlignStack,
1784 BuiltinFnIdArgType,
1785 BuiltinFnIdExport,1783 BuiltinFnIdExport,
1786 BuiltinFnIdErrorReturnTrace,1784 BuiltinFnIdErrorReturnTrace,
1787 BuiltinFnIdAtomicRmw,1785 BuiltinFnIdAtomicRmw,
...@@ -2626,7 +2624,6 @@ enum IrInstSrcId {...@@ -2626,7 +2624,6 @@ enum IrInstSrcId {
2626 IrInstSrcIdIntToFloat,2624 IrInstSrcIdIntToFloat,
2627 IrInstSrcIdFloatToInt,2625 IrInstSrcIdFloatToInt,
2628 IrInstSrcIdBoolToInt,2626 IrInstSrcIdBoolToInt,
2629 IrInstSrcIdIntType,
2630 IrInstSrcIdVectorType,2627 IrInstSrcIdVectorType,
2631 IrInstSrcIdShuffleVector,2628 IrInstSrcIdShuffleVector,
2632 IrInstSrcIdSplat,2629 IrInstSrcIdSplat,
...@@ -3628,13 +3625,6 @@ struct IrInstSrcBoolToInt {...@@ -3628,13 +3625,6 @@ struct IrInstSrcBoolToInt {
3628 IrInstSrc *target;3625 IrInstSrc *target;
3629};3626};
36303627
3631struct IrInstSrcIntType {
3632 IrInstSrc base;
3633
3634 IrInstSrc *is_signed;
3635 IrInstSrc *bit_count;
3636};
3637
3638struct IrInstSrcVectorType {3628struct IrInstSrcVectorType {
3639 IrInstSrc base;3629 IrInstSrc base;
36403630
src/codegen.cpp-2
...@@ -8189,7 +8189,6 @@ static void define_builtin_fns(CodeGen *g) {...@@ -8189,7 +8189,6 @@ static void define_builtin_fns(CodeGen *g) {
8189 create_builtin_fn(g, BuiltinFnIdIntToEnum, "intToEnum", 2);8189 create_builtin_fn(g, BuiltinFnIdIntToEnum, "intToEnum", 2);
8190 create_builtin_fn(g, BuiltinFnIdCompileErr, "compileError", 1);8190 create_builtin_fn(g, BuiltinFnIdCompileErr, "compileError", 1);
8191 create_builtin_fn(g, BuiltinFnIdCompileLog, "compileLog", SIZE_MAX);8191 create_builtin_fn(g, BuiltinFnIdCompileLog, "compileLog", SIZE_MAX);
8192 create_builtin_fn(g, BuiltinFnIdIntType, "IntType", 2); // TODO rename to Int
8193 create_builtin_fn(g, BuiltinFnIdVectorType, "Vector", 2);8192 create_builtin_fn(g, BuiltinFnIdVectorType, "Vector", 2);
8194 create_builtin_fn(g, BuiltinFnIdShuffle, "shuffle", 4);8193 create_builtin_fn(g, BuiltinFnIdShuffle, "shuffle", 4);
8195 create_builtin_fn(g, BuiltinFnIdSplat, "splat", 2);8194 create_builtin_fn(g, BuiltinFnIdSplat, "splat", 2);
...@@ -8234,7 +8233,6 @@ static void define_builtin_fns(CodeGen *g) {...@@ -8234,7 +8233,6 @@ static void define_builtin_fns(CodeGen *g) {
8234 create_builtin_fn(g, BuiltinFnIdAlignCast, "alignCast", 2);8233 create_builtin_fn(g, BuiltinFnIdAlignCast, "alignCast", 2);
8235 create_builtin_fn(g, BuiltinFnIdOpaqueType, "OpaqueType", 0);8234 create_builtin_fn(g, BuiltinFnIdOpaqueType, "OpaqueType", 0);
8236 create_builtin_fn(g, BuiltinFnIdSetAlignStack, "setAlignStack", 1);8235 create_builtin_fn(g, BuiltinFnIdSetAlignStack, "setAlignStack", 1);
8237 create_builtin_fn(g, BuiltinFnIdArgType, "ArgType", 2);
8238 create_builtin_fn(g, BuiltinFnIdExport, "export", 2);8236 create_builtin_fn(g, BuiltinFnIdExport, "export", 2);
8239 create_builtin_fn(g, BuiltinFnIdErrorReturnTrace, "errorReturnTrace", 0);8237 create_builtin_fn(g, BuiltinFnIdErrorReturnTrace, "errorReturnTrace", 0);
8240 create_builtin_fn(g, BuiltinFnIdAtomicRmw, "atomicRmw", 5);8238 create_builtin_fn(g, BuiltinFnIdAtomicRmw, "atomicRmw", 5);
src/ir.cpp-66
...@@ -389,8 +389,6 @@ static void destroy_instruction_src(IrInstSrc *inst) {...@@ -389,8 +389,6 @@ static void destroy_instruction_src(IrInstSrc *inst) {
389 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFloatToInt *>(inst));389 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFloatToInt *>(inst));
390 case IrInstSrcIdBoolToInt:390 case IrInstSrcIdBoolToInt:
391 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBoolToInt *>(inst));391 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBoolToInt *>(inst));
392 case IrInstSrcIdIntType:
393 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntType *>(inst));
394 case IrInstSrcIdVectorType:392 case IrInstSrcIdVectorType:
395 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcVectorType *>(inst));393 return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcVectorType *>(inst));
396 case IrInstSrcIdShuffleVector:394 case IrInstSrcIdShuffleVector:
...@@ -1285,10 +1283,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcBoolToInt *) {...@@ -1285,10 +1283,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcBoolToInt *) {
1285 return IrInstSrcIdBoolToInt;1283 return IrInstSrcIdBoolToInt;
1286}1284}
12871285
1288static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntType *) {
1289 return IrInstSrcIdIntType;
1290}
1291
1292static constexpr IrInstSrcId ir_inst_id(IrInstSrcVectorType *) {1286static constexpr IrInstSrcId ir_inst_id(IrInstSrcVectorType *) {
1293 return IrInstSrcIdVectorType;1287 return IrInstSrcIdVectorType;
1294}1288}
...@@ -3518,19 +3512,6 @@ static IrInstSrc *ir_build_bool_to_int(IrBuilderSrc *irb, Scope *scope, AstNode...@@ -3518,19 +3512,6 @@ static IrInstSrc *ir_build_bool_to_int(IrBuilderSrc *irb, Scope *scope, AstNode
3518 return &instruction->base;3512 return &instruction->base;
3519}3513}
35203514
3521static IrInstSrc *ir_build_int_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *is_signed,
3522 IrInstSrc *bit_count)
3523{
3524 IrInstSrcIntType *instruction = ir_build_instruction<IrInstSrcIntType>(irb, scope, source_node);
3525 instruction->is_signed = is_signed;
3526 instruction->bit_count = bit_count;
3527
3528 ir_ref_instruction(is_signed, irb->current_basic_block);
3529 ir_ref_instruction(bit_count, irb->current_basic_block);
3530
3531 return &instruction->base;
3532}
3533
3534static IrInstSrc *ir_build_vector_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *len,3515static IrInstSrc *ir_build_vector_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *len,
3535 IrInstSrc *elem_type)3516 IrInstSrc *elem_type)
3536{3517{
...@@ -6530,21 +6511,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod...@@ -6530,21 +6511,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod
6530 IrInstSrc *result = ir_build_bool_to_int(irb, scope, node, arg0_value);6511 IrInstSrc *result = ir_build_bool_to_int(irb, scope, node, arg0_value);
6531 return ir_lval_wrap(irb, scope, result, lval, result_loc);6512 return ir_lval_wrap(irb, scope, result, lval, result_loc);
6532 }6513 }
6533 case BuiltinFnIdIntType:
6534 {
6535 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
6536 IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
6537 if (arg0_value == irb->codegen->invalid_inst_src)
6538 return arg0_value;
6539
6540 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
6541 IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope);
6542 if (arg1_value == irb->codegen->invalid_inst_src)
6543 return arg1_value;
6544
6545 IrInstSrc *int_type = ir_build_int_type(irb, scope, node, arg0_value, arg1_value);
6546 return ir_lval_wrap(irb, scope, int_type, lval, result_loc);
6547 }
6548 case BuiltinFnIdVectorType:6514 case BuiltinFnIdVectorType:
6549 {6515 {
6550 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);6516 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
...@@ -7074,21 +7040,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod...@@ -7074,21 +7040,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod
7074 IrInstSrc *set_align_stack = ir_build_set_align_stack(irb, scope, node, arg0_value);7040 IrInstSrc *set_align_stack = ir_build_set_align_stack(irb, scope, node, arg0_value);
7075 return ir_lval_wrap(irb, scope, set_align_stack, lval, result_loc);7041 return ir_lval_wrap(irb, scope, set_align_stack, lval, result_loc);
7076 }7042 }
7077 case BuiltinFnIdArgType:
7078 {
7079 AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
7080 IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
7081 if (arg0_value == irb->codegen->invalid_inst_src)
7082 return arg0_value;
7083
7084 AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
7085 IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope);
7086 if (arg1_value == irb->codegen->invalid_inst_src)
7087 return arg1_value;
7088
7089 IrInstSrc *arg_type = ir_build_arg_type(irb, scope, node, arg0_value, arg1_value, false);
7090 return ir_lval_wrap(irb, scope, arg_type, lval, result_loc);
7091 }
7092 case BuiltinFnIdExport:7043 case BuiltinFnIdExport:
7093 {7044 {
7094 // Cast the options parameter to the options type7045 // Cast the options parameter to the options type
...@@ -25385,20 +25336,6 @@ static IrInstGen *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstSrcBo...@@ -25385,20 +25336,6 @@ static IrInstGen *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstSrcBo
25385 return ir_resolve_cast(ira, &instruction->base.base, target, u1_type, CastOpBoolToInt);25336 return ir_resolve_cast(ira, &instruction->base.base, target, u1_type, CastOpBoolToInt);
25386}25337}
2538725338
25388static IrInstGen *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstSrcIntType *instruction) {
25389 IrInstGen *is_signed_value = instruction->is_signed->child;
25390 bool is_signed;
25391 if (!ir_resolve_bool(ira, is_signed_value, &is_signed))
25392 return ira->codegen->invalid_inst_gen;
25393
25394 IrInstGen *bit_count_value = instruction->bit_count->child;
25395 uint64_t bit_count;
25396 if (!ir_resolve_unsigned(ira, bit_count_value, ira->codegen->builtin_types.entry_u16, &bit_count))
25397 return ira->codegen->invalid_inst_gen;
25398
25399 return ir_const_type(ira, &instruction->base.base, get_int_type(ira->codegen, is_signed, (uint32_t)bit_count));
25400}
25401
25402static IrInstGen *ir_analyze_instruction_vector_type(IrAnalyze *ira, IrInstSrcVectorType *instruction) {25339static IrInstGen *ir_analyze_instruction_vector_type(IrAnalyze *ira, IrInstSrcVectorType *instruction) {
25403 uint64_t len;25340 uint64_t len;
25404 if (!ir_resolve_unsigned(ira, instruction->len->child, ira->codegen->builtin_types.entry_u32, &len))25341 if (!ir_resolve_unsigned(ira, instruction->len->child, ira->codegen->builtin_types.entry_u32, &len))
...@@ -29270,8 +29207,6 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc...@@ -29270,8 +29207,6 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
29270 return ir_analyze_instruction_float_to_int(ira, (IrInstSrcFloatToInt *)instruction);29207 return ir_analyze_instruction_float_to_int(ira, (IrInstSrcFloatToInt *)instruction);
29271 case IrInstSrcIdBoolToInt:29208 case IrInstSrcIdBoolToInt:
29272 return ir_analyze_instruction_bool_to_int(ira, (IrInstSrcBoolToInt *)instruction);29209 return ir_analyze_instruction_bool_to_int(ira, (IrInstSrcBoolToInt *)instruction);
29273 case IrInstSrcIdIntType:
29274 return ir_analyze_instruction_int_type(ira, (IrInstSrcIntType *)instruction);
29275 case IrInstSrcIdVectorType:29210 case IrInstSrcIdVectorType:
29276 return ir_analyze_instruction_vector_type(ira, (IrInstSrcVectorType *)instruction);29211 return ir_analyze_instruction_vector_type(ira, (IrInstSrcVectorType *)instruction);
29277 case IrInstSrcIdShuffleVector:29212 case IrInstSrcIdShuffleVector:
...@@ -29754,7 +29689,6 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) {...@@ -29754,7 +29689,6 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) {
29754 case IrInstSrcIdRef:29689 case IrInstSrcIdRef:
29755 case IrInstSrcIdEmbedFile:29690 case IrInstSrcIdEmbedFile:
29756 case IrInstSrcIdTruncate:29691 case IrInstSrcIdTruncate:
29757 case IrInstSrcIdIntType:
29758 case IrInstSrcIdVectorType:29692 case IrInstSrcIdVectorType:
29759 case IrInstSrcIdShuffleVector:29693 case IrInstSrcIdShuffleVector:
29760 case IrInstSrcIdSplat:29694 case IrInstSrcIdSplat:
src/ir_print.cpp-13
...@@ -179,8 +179,6 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {...@@ -179,8 +179,6 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
179 return "SrcFloatToInt";179 return "SrcFloatToInt";
180 case IrInstSrcIdBoolToInt:180 case IrInstSrcIdBoolToInt:
181 return "SrcBoolToInt";181 return "SrcBoolToInt";
182 case IrInstSrcIdIntType:
183 return "SrcIntType";
184 case IrInstSrcIdVectorType:182 case IrInstSrcIdVectorType:
185 return "SrcVectorType";183 return "SrcVectorType";
186 case IrInstSrcIdBoolNot:184 case IrInstSrcIdBoolNot:
...@@ -1652,14 +1650,6 @@ static void ir_print_bool_to_int(IrPrintSrc *irp, IrInstSrcBoolToInt *instructio...@@ -1652,14 +1650,6 @@ static void ir_print_bool_to_int(IrPrintSrc *irp, IrInstSrcBoolToInt *instructio
1652 fprintf(irp->f, ")");1650 fprintf(irp->f, ")");
1653}1651}
16541652
1655static void ir_print_int_type(IrPrintSrc *irp, IrInstSrcIntType *instruction) {
1656 fprintf(irp->f, "@IntType(");
1657 ir_print_other_inst_src(irp, instruction->is_signed);
1658 fprintf(irp->f, ", ");
1659 ir_print_other_inst_src(irp, instruction->bit_count);
1660 fprintf(irp->f, ")");
1661}
1662
1663static void ir_print_vector_type(IrPrintSrc *irp, IrInstSrcVectorType *instruction) {1653static void ir_print_vector_type(IrPrintSrc *irp, IrInstSrcVectorType *instruction) {
1664 fprintf(irp->f, "@Vector(");1654 fprintf(irp->f, "@Vector(");
1665 ir_print_other_inst_src(irp, instruction->len);1655 ir_print_other_inst_src(irp, instruction->len);
...@@ -2739,9 +2729,6 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai...@@ -2739,9 +2729,6 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
2739 case IrInstSrcIdBoolToInt:2729 case IrInstSrcIdBoolToInt:
2740 ir_print_bool_to_int(irp, (IrInstSrcBoolToInt *)instruction);2730 ir_print_bool_to_int(irp, (IrInstSrcBoolToInt *)instruction);
2741 break;2731 break;
2742 case IrInstSrcIdIntType:
2743 ir_print_int_type(irp, (IrInstSrcIntType *)instruction);
2744 break;
2745 case IrInstSrcIdVectorType:2732 case IrInstSrcIdVectorType:
2746 ir_print_vector_type(irp, (IrInstSrcVectorType *)instruction);2733 ir_print_vector_type(irp, (IrInstSrcVectorType *)instruction);
2747 break;2734 break;
test/compile_errors.zig-1
...@@ -1902,7 +1902,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1902,7 +1902,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1902 \\ var x: i65536 = 1;1902 \\ var x: i65536 = 1;
1903 \\}1903 \\}
1904 , &[_][]const u8{1904 , &[_][]const u8{
1905 "tmp.zig:2:31: error: integer value 65536 cannot be coerced to type 'u16'",
1906 "tmp.zig:5:12: error: primitive integer type 'i65536' exceeds maximum bit width of 65535",1905 "tmp.zig:5:12: error: primitive integer type 'i65536' exceeds maximum bit width of 65535",
1907 });1906 });
19081907