authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-13 10:42:38-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-01-13 10:42:38-07:00
logc5ee73f65b4c77fe08aa44b8611bf084ae700f24
treeaca72ec5f4fe45695bf7eea6bb288ee2f3ef27e9
parent9bf2bda68356212168a213141e0a21d9dab22655

stage2: fix build on 32-bit ISAs

Fixes regression introduced in 93b854eb745ab3294054ae71150fe60f134f4d10.

11 files changed, 20 insertions(+), 13 deletions(-)

src/Liveness.zig+1-1
...@@ -368,7 +368,7 @@ fn analyzeInst(...@@ -368,7 +368,7 @@ fn analyzeInst(
368 .vector_init => {368 .vector_init => {
369 const ty_pl = inst_datas[inst].ty_pl;369 const ty_pl = inst_datas[inst].ty_pl;
370 const vector_ty = a.air.getRefType(ty_pl.ty);370 const vector_ty = a.air.getRefType(ty_pl.ty);
371 const len = @intCast(u32, vector_ty.arrayLen());371 const len = vector_ty.vectorLen();
372 const elements = @bitCast([]const Air.Inst.Ref, a.air.extra[ty_pl.payload..][0..len]);372 const elements = @bitCast([]const Air.Inst.Ref, a.air.extra[ty_pl.payload..][0..len]);
373373
374 if (elements.len <= bpi - 1) {374 if (elements.len <= bpi - 1) {
src/Sema.zig+2-2
...@@ -11010,7 +11010,7 @@ fn zirClzCtz(...@@ -11010,7 +11010,7 @@ fn zirClzCtz(
11010 const result_scalar_ty = try Type.smallestUnsignedInt(sema.arena, bits);11010 const result_scalar_ty = try Type.smallestUnsignedInt(sema.arena, bits);
11011 switch (operand_ty.zigTypeTag()) {11011 switch (operand_ty.zigTypeTag()) {
11012 .Vector => {11012 .Vector => {
11013 const vec_len = operand_ty.arrayLen();11013 const vec_len = operand_ty.vectorLen();
11014 const result_ty = try Type.vector(sema.arena, vec_len, result_scalar_ty);11014 const result_ty = try Type.vector(sema.arena, vec_len, result_scalar_ty);
11015 if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| {11015 if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| {
11016 if (val.isUndef()) return sema.addConstUndef(result_ty);11016 if (val.isUndef()) return sema.addConstUndef(result_ty);
...@@ -14578,7 +14578,7 @@ fn coerceVectors(...@@ -14578,7 +14578,7 @@ fn coerceVectors(
14578) !Air.Inst.Ref {14578) !Air.Inst.Ref {
14579 const inst_ty = sema.typeOf(inst);14579 const inst_ty = sema.typeOf(inst);
14580 const inst_len = inst_ty.arrayLen();14580 const inst_len = inst_ty.arrayLen();
14581 const dest_len = dest_ty.arrayLen();14581 const dest_len = try sema.usizeCast(block, dest_ty_src, dest_ty.arrayLen());
1458214582
14583 if (dest_len != inst_len) {14583 if (dest_len != inst_len) {
14584 const msg = msg: {14584 const msg = msg: {
src/arch/aarch64/CodeGen.zig+1-1
...@@ -2577,7 +2577,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {...@@ -2577,7 +2577,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
25772577
2578fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {2578fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
2579 const vector_ty = self.air.typeOfIndex(inst);2579 const vector_ty = self.air.typeOfIndex(inst);
2580 const len = @intCast(u32, vector_ty.arrayLen());2580 const len = vector_ty.vectorLen();
2581 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;2581 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
2582 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);2582 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
2583 const result: MCValue = res: {2583 const result: MCValue = res: {
src/arch/arm/CodeGen.zig+1-1
...@@ -3675,7 +3675,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {...@@ -3675,7 +3675,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
36753675
3676fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {3676fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
3677 const vector_ty = self.air.typeOfIndex(inst);3677 const vector_ty = self.air.typeOfIndex(inst);
3678 const len = @intCast(u32, vector_ty.arrayLen());3678 const len = vector_ty.vectorLen();
3679 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;3679 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
3680 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);3680 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
3681 const result: MCValue = res: {3681 const result: MCValue = res: {
src/arch/riscv64/CodeGen.zig+1-1
...@@ -2076,7 +2076,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {...@@ -2076,7 +2076,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
20762076
2077fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {2077fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
2078 const vector_ty = self.air.typeOfIndex(inst);2078 const vector_ty = self.air.typeOfIndex(inst);
2079 const len = @intCast(u32, vector_ty.arrayLen());2079 const len = vector_ty.vectorLen();
2080 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;2080 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
2081 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);2081 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
2082 const result: MCValue = res: {2082 const result: MCValue = res: {
src/arch/wasm/CodeGen.zig+1-1
...@@ -3239,7 +3239,7 @@ fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {...@@ -3239,7 +3239,7 @@ fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
3239 if (self.liveness.isUnused(inst)) return WValue{ .none = {} };3239 if (self.liveness.isUnused(inst)) return WValue{ .none = {} };
32403240
3241 const vector_ty = self.air.typeOfIndex(inst);3241 const vector_ty = self.air.typeOfIndex(inst);
3242 const len = @intCast(u32, vector_ty.arrayLen());3242 const len = vector_ty.vectorLen();
3243 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;3243 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
3244 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);3244 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
32453245
src/arch/x86_64/CodeGen.zig+1-1
...@@ -3669,7 +3669,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {...@@ -3669,7 +3669,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
36693669
3670fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {3670fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
3671 const vector_ty = self.air.typeOfIndex(inst);3671 const vector_ty = self.air.typeOfIndex(inst);
3672 const len = @intCast(u32, vector_ty.arrayLen());3672 const len = vector_ty.vectorLen();
3673 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;3673 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
3674 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);3674 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
3675 const result: MCValue = res: {3675 const result: MCValue = res: {
src/codegen/c.zig+1-1
...@@ -3038,7 +3038,7 @@ fn airVectorInit(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -3038,7 +3038,7 @@ fn airVectorInit(f: *Function, inst: Air.Inst.Index) !CValue {
3038 const inst_ty = f.air.typeOfIndex(inst);3038 const inst_ty = f.air.typeOfIndex(inst);
3039 const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;3039 const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
3040 const vector_ty = f.air.getRefType(ty_pl.ty);3040 const vector_ty = f.air.getRefType(ty_pl.ty);
3041 const len = @intCast(u32, vector_ty.arrayLen());3041 const len = vector_ty.vectorLen();
3042 const elements = @bitCast([]const Air.Inst.Ref, f.air.extra[ty_pl.payload..][0..len]);3042 const elements = @bitCast([]const Air.Inst.Ref, f.air.extra[ty_pl.payload..][0..len]);
30433043
3044 const writer = f.object.writer();3044 const writer = f.object.writer();
src/codegen/llvm.zig+3-3
...@@ -873,7 +873,7 @@ pub const DeclGen = struct {...@@ -873,7 +873,7 @@ pub const DeclGen = struct {
873 },873 },
874 .Vector => {874 .Vector => {
875 const elem_type = try dg.llvmType(t.childType());875 const elem_type = try dg.llvmType(t.childType());
876 return elem_type.vectorType(@intCast(c_uint, t.arrayLen()));876 return elem_type.vectorType(t.vectorLen());
877 },877 },
878 .Optional => {878 .Optional => {
879 var buf: Type.Payload.ElemType = undefined;879 var buf: Type.Payload.ElemType = undefined;
...@@ -4170,7 +4170,7 @@ pub const FuncGen = struct {...@@ -4170,7 +4170,7 @@ pub const FuncGen = struct {
4170 const target = self.dg.module.getTarget();4170 const target = self.dg.module.getTarget();
4171 const bits = operand_ty.intInfo(target).bits;4171 const bits = operand_ty.intInfo(target).bits;
4172 const vec_len: ?u32 = switch (operand_ty.zigTypeTag()) {4172 const vec_len: ?u32 = switch (operand_ty.zigTypeTag()) {
4173 .Vector => @intCast(u32, operand_ty.arrayLen()),4173 .Vector => operand_ty.vectorLen(),
4174 else => null,4174 else => null,
4175 };4175 };
41764176
...@@ -4372,7 +4372,7 @@ pub const FuncGen = struct {...@@ -4372,7 +4372,7 @@ pub const FuncGen = struct {
4372 const scalar = try self.resolveInst(ty_op.operand);4372 const scalar = try self.resolveInst(ty_op.operand);
4373 const scalar_ty = self.air.typeOf(ty_op.operand);4373 const scalar_ty = self.air.typeOf(ty_op.operand);
4374 const vector_ty = self.air.typeOfIndex(inst);4374 const vector_ty = self.air.typeOfIndex(inst);
4375 const len = @intCast(u32, vector_ty.arrayLen());4375 const len = vector_ty.vectorLen();
4376 const scalar_llvm_ty = try self.dg.llvmType(scalar_ty);4376 const scalar_llvm_ty = try self.dg.llvmType(scalar_ty);
4377 const op_llvm_ty = scalar_llvm_ty.vectorType(1);4377 const op_llvm_ty = scalar_llvm_ty.vectorType(1);
4378 const u32_llvm_ty = self.context.intType(32);4378 const u32_llvm_ty = self.context.intType(32);
src/print_air.zig+1-1
...@@ -295,7 +295,7 @@ const Writer = struct {...@@ -295,7 +295,7 @@ const Writer = struct {
295 fn writeVectorInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {295 fn writeVectorInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
296 const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;296 const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
297 const vector_ty = w.air.getRefType(ty_pl.ty);297 const vector_ty = w.air.getRefType(ty_pl.ty);
298 const len = @intCast(u32, vector_ty.arrayLen());298 const len = vector_ty.vectorLen();
299 const elements = @bitCast([]const Air.Inst.Ref, w.air.extra[ty_pl.payload..][0..len]);299 const elements = @bitCast([]const Air.Inst.Ref, w.air.extra[ty_pl.payload..][0..len]);
300300
301 try s.print("{}, [", .{vector_ty});301 try s.print("{}, [", .{vector_ty});
src/type.zig+7
...@@ -3005,6 +3005,13 @@ pub const Type = extern union {...@@ -3005,6 +3005,13 @@ pub const Type = extern union {
3005 return ty.arrayLen() + @boolToInt(ty.sentinel() != null);3005 return ty.arrayLen() + @boolToInt(ty.sentinel() != null);
3006 }3006 }
30073007
3008 pub fn vectorLen(ty: Type) u32 {
3009 return switch (ty.tag()) {
3010 .vector => @intCast(u32, ty.castTag(.vector).?.data.len),
3011 else => unreachable,
3012 };
3013 }
3014
3008 /// Asserts the type is an array, pointer or vector.3015 /// Asserts the type is an array, pointer or vector.
3009 pub fn sentinel(self: Type) ?Value {3016 pub fn sentinel(self: Type) ?Value {
3010 return switch (self.tag()) {3017 return switch (self.tag()) {