Skip to content

Remove @Vector #6209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/stage1/all_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,7 +1783,6 @@ enum BuiltinFnId {
BuiltinFnIdIntToErr,
BuiltinFnIdEnumToInt,
BuiltinFnIdIntToEnum,
BuiltinFnIdVectorType,
BuiltinFnIdShuffle,
BuiltinFnIdSplat,
BuiltinFnIdSetCold,
Expand Down Expand Up @@ -2565,7 +2564,6 @@ enum IrInstSrcId {
IrInstSrcIdIntToFloat,
IrInstSrcIdFloatToInt,
IrInstSrcIdBoolToInt,
IrInstSrcIdVectorType,
IrInstSrcIdShuffleVector,
IrInstSrcIdSplat,
IrInstSrcIdBoolNot,
Expand Down Expand Up @@ -3599,13 +3597,6 @@ struct IrInstSrcBoolToInt {
IrInstSrc *target;
};

struct IrInstSrcVectorType {
IrInstSrc base;

IrInstSrc *len;
IrInstSrc *elem_type;
};

struct IrInstSrcBoolNot {
IrInstSrc base;

Expand Down
1 change: 0 additions & 1 deletion src/stage1/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8601,7 +8601,6 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdIntToEnum, "intToEnum", 2);
create_builtin_fn(g, BuiltinFnIdCompileErr, "compileError", 1);
create_builtin_fn(g, BuiltinFnIdCompileLog, "compileLog", SIZE_MAX);
create_builtin_fn(g, BuiltinFnIdVectorType, "Vector", 2);
create_builtin_fn(g, BuiltinFnIdShuffle, "shuffle", 4);
create_builtin_fn(g, BuiltinFnIdSplat, "splat", 2);
create_builtin_fn(g, BuiltinFnIdSetCold, "setCold", 1);
Expand Down
51 changes: 0 additions & 51 deletions src/stage1/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ static void destroy_instruction_src(IrInstSrc *inst) {
return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcFloatToInt *>(inst));
case IrInstSrcIdBoolToInt:
return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcBoolToInt *>(inst));
case IrInstSrcIdVectorType:
return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcVectorType *>(inst));
case IrInstSrcIdShuffleVector:
return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcShuffleVector *>(inst));
case IrInstSrcIdSplat:
Expand Down Expand Up @@ -1344,10 +1342,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcBoolToInt *) {
return IrInstSrcIdBoolToInt;
}

static constexpr IrInstSrcId ir_inst_id(IrInstSrcVectorType *) {
return IrInstSrcIdVectorType;
}

static constexpr IrInstSrcId ir_inst_id(IrInstSrcShuffleVector *) {
return IrInstSrcIdShuffleVector;
}
Expand Down Expand Up @@ -3638,19 +3632,6 @@ static IrInstSrc *ir_build_bool_to_int(IrBuilderSrc *irb, Scope *scope, AstNode
return &instruction->base;
}

static IrInstSrc *ir_build_vector_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *len,
IrInstSrc *elem_type)
{
IrInstSrcVectorType *instruction = ir_build_instruction<IrInstSrcVectorType>(irb, scope, source_node);
instruction->len = len;
instruction->elem_type = elem_type;

ir_ref_instruction(len, irb->current_basic_block);
ir_ref_instruction(elem_type, irb->current_basic_block);

return &instruction->base;
}

static IrInstSrc *ir_build_shuffle_vector(IrBuilderSrc *irb, Scope *scope, AstNode *source_node,
IrInstSrc *scalar_type, IrInstSrc *a, IrInstSrc *b, IrInstSrc *mask)
{
Expand Down Expand Up @@ -6849,21 +6830,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod
IrInstSrc *result = ir_build_bool_to_int(irb, scope, node, arg0_value);
return ir_lval_wrap(irb, scope, result, lval, result_loc);
}
case BuiltinFnIdVectorType:
{
AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
if (arg0_value == irb->codegen->invalid_inst_src)
return arg0_value;

AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope);
if (arg1_value == irb->codegen->invalid_inst_src)
return arg1_value;

IrInstSrc *vector_type = ir_build_vector_type(irb, scope, node, arg0_value, arg1_value);
return ir_lval_wrap(irb, scope, vector_type, lval, result_loc);
}
case BuiltinFnIdShuffle:
{
AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
Expand Down Expand Up @@ -27375,20 +27341,6 @@ static IrInstGen *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstSrcBo
return ir_resolve_cast(ira, &instruction->base.base, target, u1_type, CastOpBoolToInt);
}

static IrInstGen *ir_analyze_instruction_vector_type(IrAnalyze *ira, IrInstSrcVectorType *instruction) {
uint64_t len;
if (!ir_resolve_unsigned(ira, instruction->len->child, ira->codegen->builtin_types.entry_u32, &len))
return ira->codegen->invalid_inst_gen;

ZigType *elem_type = ir_resolve_vector_elem_type(ira, instruction->elem_type->child);
if (type_is_invalid(elem_type))
return ira->codegen->invalid_inst_gen;

ZigType *vector_type = get_vector_type(ira->codegen, len, elem_type);

return ir_const_type(ira, &instruction->base.base, vector_type);
}

static IrInstGen *ir_analyze_shuffle_vector(IrAnalyze *ira, IrInst* source_instr,
ZigType *scalar_type, IrInstGen *a, IrInstGen *b, IrInstGen *mask)
{
Expand Down Expand Up @@ -31838,8 +31790,6 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
return ir_analyze_instruction_float_to_int(ira, (IrInstSrcFloatToInt *)instruction);
case IrInstSrcIdBoolToInt:
return ir_analyze_instruction_bool_to_int(ira, (IrInstSrcBoolToInt *)instruction);
case IrInstSrcIdVectorType:
return ir_analyze_instruction_vector_type(ira, (IrInstSrcVectorType *)instruction);
case IrInstSrcIdShuffleVector:
return ir_analyze_instruction_shuffle_vector(ira, (IrInstSrcShuffleVector *)instruction);
case IrInstSrcIdSplat:
Expand Down Expand Up @@ -32328,7 +32278,6 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) {
case IrInstSrcIdRef:
case IrInstSrcIdEmbedFile:
case IrInstSrcIdTruncate:
case IrInstSrcIdVectorType:
case IrInstSrcIdShuffleVector:
case IrInstSrcIdSplat:
case IrInstSrcIdBoolNot:
Expand Down
13 changes: 0 additions & 13 deletions src/stage1/ir_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
return "SrcFloatToInt";
case IrInstSrcIdBoolToInt:
return "SrcBoolToInt";
case IrInstSrcIdVectorType:
return "SrcVectorType";
case IrInstSrcIdBoolNot:
return "SrcBoolNot";
case IrInstSrcIdMemset:
Expand Down Expand Up @@ -1689,14 +1687,6 @@ static void ir_print_bool_to_int(IrPrintSrc *irp, IrInstSrcBoolToInt *instructio
fprintf(irp->f, ")");
}

static void ir_print_vector_type(IrPrintSrc *irp, IrInstSrcVectorType *instruction) {
fprintf(irp->f, "@Vector(");
ir_print_other_inst_src(irp, instruction->len);
fprintf(irp->f, ", ");
ir_print_other_inst_src(irp, instruction->elem_type);
fprintf(irp->f, ")");
}

static void ir_print_shuffle_vector(IrPrintSrc *irp, IrInstSrcShuffleVector *instruction) {
fprintf(irp->f, "@shuffle(");
ir_print_other_inst_src(irp, instruction->scalar_type);
Expand Down Expand Up @@ -2802,9 +2792,6 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
case IrInstSrcIdBoolToInt:
ir_print_bool_to_int(irp, (IrInstSrcBoolToInt *)instruction);
break;
case IrInstSrcIdVectorType:
ir_print_vector_type(irp, (IrInstSrcVectorType *)instruction);
break;
case IrInstSrcIdShuffleVector:
ir_print_shuffle_vector(irp, (IrInstSrcShuffleVector *)instruction);
break;
Expand Down
19 changes: 10 additions & 9 deletions test/compile_errors.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8104,6 +8104,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
});

cases.add("compare optional to non-optional with invalid types",
\\const Vector = @import("std").meta.Vector;
\\export fn inconsistentChildType() void {
\\ var x: ?i32 = undefined;
\\ const y: comptime_int = 10;
Expand All @@ -8117,8 +8118,8 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\}
\\
\\export fn optionalVector() void {
\\ var x: ?@Vector(10, i32) = undefined;
\\ var y: @Vector(10, i32) = undefined;
\\ var x: ?Vector(10, i32) = undefined;
\\ var y: Vector(10, i32) = undefined;
\\ _ = (x == y);
\\}
\\
Expand All @@ -8128,13 +8129,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ _ = (x == y);
\\}
, &[_][]const u8{
":4:12: error: cannot compare types '?i32' and 'comptime_int'",
":4:12: note: optional child type 'i32' must be the same as non-optional type 'comptime_int'",
":10:12: error: cannot compare types '?i32' and '?i32'",
":10:12: note: optional to optional comparison is only supported for optional pointer types",
":16:12: error: TODO add comparison of optional vector",
":22:12: error: cannot compare types '?[3]i32' and '[3]i32'",
":22:12: note: operator not supported for type '[3]i32'",
"tmp.zig:5:12: error: cannot compare types '?i32' and 'comptime_int'",
"tmp.zig:5:12: note: optional child type 'i32' must be the same as non-optional type 'comptime_int'",
"tmp.zig:11:12: error: cannot compare types '?i32' and '?i32'",
"tmp.zig:11:12: note: optional to optional comparison is only supported for optional pointer types",
"tmp.zig:17:12: error: TODO add comparison of optional vector",
"tmp.zig:23:12: error: cannot compare types '?[3]i32' and '[3]i32'",
"tmp.zig:23:12: note: operator not supported for type '[3]i32'",
});

cases.add("slice cannot have its bytes reinterpreted",
Expand Down
3 changes: 0 additions & 3 deletions test/stage1/behavior/type.zig
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,6 @@ test "Type.Opaque" {

test "Type.Vector" {
testTypes(&[_]type{
@Vector(0, u8),
@Vector(4, u8),
@Vector(8, *u8),
std.meta.Vector(0, u8),
std.meta.Vector(4, u8),
std.meta.Vector(8, *u8),
Expand Down