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(
368368 .vector_init => {
369369 const ty_pl = inst_datas[inst].ty_pl;
370370 const vector_ty = a.air.getRefType(ty_pl.ty);
371 const len = @intCast(u32, vector_ty.arrayLen());
371 const len = vector_ty.vectorLen();
372372 const elements = @bitCast([]const Air.Inst.Ref, a.air.extra[ty_pl.payload..][0..len]);
373373
374374 if (elements.len <= bpi - 1) {
src/Sema.zig+2-2
......@@ -11010,7 +11010,7 @@ fn zirClzCtz(
1101011010 const result_scalar_ty = try Type.smallestUnsignedInt(sema.arena, bits);
1101111011 switch (operand_ty.zigTypeTag()) {
1101211012 .Vector => {
11013 const vec_len = operand_ty.arrayLen();
11013 const vec_len = operand_ty.vectorLen();
1101411014 const result_ty = try Type.vector(sema.arena, vec_len, result_scalar_ty);
1101511015 if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| {
1101611016 if (val.isUndef()) return sema.addConstUndef(result_ty);
......@@ -14578,7 +14578,7 @@ fn coerceVectors(
1457814578) !Air.Inst.Ref {
1457914579 const inst_ty = sema.typeOf(inst);
1458014580 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
1458314583 if (dest_len != inst_len) {
1458414584 const msg = msg: {
src/arch/aarch64/CodeGen.zig+1-1
......@@ -2577,7 +2577,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
25772577
25782578fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
25792579 const vector_ty = self.air.typeOfIndex(inst);
2580 const len = @intCast(u32, vector_ty.arrayLen());
2580 const len = vector_ty.vectorLen();
25812581 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
25822582 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
25832583 const result: MCValue = res: {
src/arch/arm/CodeGen.zig+1-1
......@@ -3675,7 +3675,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
36753675
36763676fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
36773677 const vector_ty = self.air.typeOfIndex(inst);
3678 const len = @intCast(u32, vector_ty.arrayLen());
3678 const len = vector_ty.vectorLen();
36793679 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
36803680 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
36813681 const result: MCValue = res: {
src/arch/riscv64/CodeGen.zig+1-1
......@@ -2076,7 +2076,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
20762076
20772077fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
20782078 const vector_ty = self.air.typeOfIndex(inst);
2079 const len = @intCast(u32, vector_ty.arrayLen());
2079 const len = vector_ty.vectorLen();
20802080 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
20812081 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
20822082 const result: MCValue = res: {
src/arch/wasm/CodeGen.zig+1-1
......@@ -3239,7 +3239,7 @@ fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
32393239 if (self.liveness.isUnused(inst)) return WValue{ .none = {} };
32403240
32413241 const vector_ty = self.air.typeOfIndex(inst);
3242 const len = @intCast(u32, vector_ty.arrayLen());
3242 const len = vector_ty.vectorLen();
32433243 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
32443244 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 {
36693669
36703670fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
36713671 const vector_ty = self.air.typeOfIndex(inst);
3672 const len = @intCast(u32, vector_ty.arrayLen());
3672 const len = vector_ty.vectorLen();
36733673 const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
36743674 const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
36753675 const result: MCValue = res: {
src/codegen/c.zig+1-1
......@@ -3038,7 +3038,7 @@ fn airVectorInit(f: *Function, inst: Air.Inst.Index) !CValue {
30383038 const inst_ty = f.air.typeOfIndex(inst);
30393039 const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
30403040 const vector_ty = f.air.getRefType(ty_pl.ty);
3041 const len = @intCast(u32, vector_ty.arrayLen());
3041 const len = vector_ty.vectorLen();
30423042 const elements = @bitCast([]const Air.Inst.Ref, f.air.extra[ty_pl.payload..][0..len]);
30433043
30443044 const writer = f.object.writer();
src/codegen/llvm.zig+3-3
......@@ -873,7 +873,7 @@ pub const DeclGen = struct {
873873 },
874874 .Vector => {
875875 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());
877877 },
878878 .Optional => {
879879 var buf: Type.Payload.ElemType = undefined;
......@@ -4170,7 +4170,7 @@ pub const FuncGen = struct {
41704170 const target = self.dg.module.getTarget();
41714171 const bits = operand_ty.intInfo(target).bits;
41724172 const vec_len: ?u32 = switch (operand_ty.zigTypeTag()) {
4173 .Vector => @intCast(u32, operand_ty.arrayLen()),
4173 .Vector => operand_ty.vectorLen(),
41744174 else => null,
41754175 };
41764176
......@@ -4372,7 +4372,7 @@ pub const FuncGen = struct {
43724372 const scalar = try self.resolveInst(ty_op.operand);
43734373 const scalar_ty = self.air.typeOf(ty_op.operand);
43744374 const vector_ty = self.air.typeOfIndex(inst);
4375 const len = @intCast(u32, vector_ty.arrayLen());
4375 const len = vector_ty.vectorLen();
43764376 const scalar_llvm_ty = try self.dg.llvmType(scalar_ty);
43774377 const op_llvm_ty = scalar_llvm_ty.vectorType(1);
43784378 const u32_llvm_ty = self.context.intType(32);
src/print_air.zig+1-1
......@@ -295,7 +295,7 @@ const Writer = struct {
295295 fn writeVectorInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
296296 const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
297297 const vector_ty = w.air.getRefType(ty_pl.ty);
298 const len = @intCast(u32, vector_ty.arrayLen());
298 const len = vector_ty.vectorLen();
299299 const elements = @bitCast([]const Air.Inst.Ref, w.air.extra[ty_pl.payload..][0..len]);
300300
301301 try s.print("{}, [", .{vector_ty});
src/type.zig+7
......@@ -3005,6 +3005,13 @@ pub const Type = extern union {
30053005 return ty.arrayLen() + @boolToInt(ty.sentinel() != null);
30063006 }
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
30083015 /// Asserts the type is an array, pointer or vector.
30093016 pub fn sentinel(self: Type) ?Value {
30103017 return switch (self.tag()) {