mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
stage2: fix build on 32-bit ISAs
Fixes regression introduced in 93b854eb745ab3294054ae71150fe60f134f4d10.
This commit is contained in:
parent
9bf2bda683
commit
c5ee73f65b
@ -368,7 +368,7 @@ fn analyzeInst(
|
||||
.vector_init => {
|
||||
const ty_pl = inst_datas[inst].ty_pl;
|
||||
const vector_ty = a.air.getRefType(ty_pl.ty);
|
||||
const len = @intCast(u32, vector_ty.arrayLen());
|
||||
const len = vector_ty.vectorLen();
|
||||
const elements = @bitCast([]const Air.Inst.Ref, a.air.extra[ty_pl.payload..][0..len]);
|
||||
|
||||
if (elements.len <= bpi - 1) {
|
||||
|
||||
@ -11010,7 +11010,7 @@ fn zirClzCtz(
|
||||
const result_scalar_ty = try Type.smallestUnsignedInt(sema.arena, bits);
|
||||
switch (operand_ty.zigTypeTag()) {
|
||||
.Vector => {
|
||||
const vec_len = operand_ty.arrayLen();
|
||||
const vec_len = operand_ty.vectorLen();
|
||||
const result_ty = try Type.vector(sema.arena, vec_len, result_scalar_ty);
|
||||
if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| {
|
||||
if (val.isUndef()) return sema.addConstUndef(result_ty);
|
||||
@ -14578,7 +14578,7 @@ fn coerceVectors(
|
||||
) !Air.Inst.Ref {
|
||||
const inst_ty = sema.typeOf(inst);
|
||||
const inst_len = inst_ty.arrayLen();
|
||||
const dest_len = dest_ty.arrayLen();
|
||||
const dest_len = try sema.usizeCast(block, dest_ty_src, dest_ty.arrayLen());
|
||||
|
||||
if (dest_len != inst_len) {
|
||||
const msg = msg: {
|
||||
|
||||
@ -2577,7 +2577,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const vector_ty = self.air.typeOfIndex(inst);
|
||||
const len = @intCast(u32, vector_ty.arrayLen());
|
||||
const len = vector_ty.vectorLen();
|
||||
const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
|
||||
const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
|
||||
const result: MCValue = res: {
|
||||
|
||||
@ -3675,7 +3675,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const vector_ty = self.air.typeOfIndex(inst);
|
||||
const len = @intCast(u32, vector_ty.arrayLen());
|
||||
const len = vector_ty.vectorLen();
|
||||
const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
|
||||
const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
|
||||
const result: MCValue = res: {
|
||||
|
||||
@ -2076,7 +2076,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const vector_ty = self.air.typeOfIndex(inst);
|
||||
const len = @intCast(u32, vector_ty.arrayLen());
|
||||
const len = vector_ty.vectorLen();
|
||||
const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
|
||||
const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
|
||||
const result: MCValue = res: {
|
||||
|
||||
@ -3239,7 +3239,7 @@ fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
if (self.liveness.isUnused(inst)) return WValue{ .none = {} };
|
||||
|
||||
const vector_ty = self.air.typeOfIndex(inst);
|
||||
const len = @intCast(u32, vector_ty.arrayLen());
|
||||
const len = vector_ty.vectorLen();
|
||||
const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
|
||||
const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
|
||||
|
||||
|
||||
@ -3669,7 +3669,7 @@ fn airSplat(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
fn airVectorInit(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const vector_ty = self.air.typeOfIndex(inst);
|
||||
const len = @intCast(u32, vector_ty.arrayLen());
|
||||
const len = vector_ty.vectorLen();
|
||||
const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
|
||||
const elements = @bitCast([]const Air.Inst.Ref, self.air.extra[ty_pl.payload..][0..len]);
|
||||
const result: MCValue = res: {
|
||||
|
||||
@ -3038,7 +3038,7 @@ fn airVectorInit(f: *Function, inst: Air.Inst.Index) !CValue {
|
||||
const inst_ty = f.air.typeOfIndex(inst);
|
||||
const ty_pl = f.air.instructions.items(.data)[inst].ty_pl;
|
||||
const vector_ty = f.air.getRefType(ty_pl.ty);
|
||||
const len = @intCast(u32, vector_ty.arrayLen());
|
||||
const len = vector_ty.vectorLen();
|
||||
const elements = @bitCast([]const Air.Inst.Ref, f.air.extra[ty_pl.payload..][0..len]);
|
||||
|
||||
const writer = f.object.writer();
|
||||
|
||||
@ -873,7 +873,7 @@ pub const DeclGen = struct {
|
||||
},
|
||||
.Vector => {
|
||||
const elem_type = try dg.llvmType(t.childType());
|
||||
return elem_type.vectorType(@intCast(c_uint, t.arrayLen()));
|
||||
return elem_type.vectorType(t.vectorLen());
|
||||
},
|
||||
.Optional => {
|
||||
var buf: Type.Payload.ElemType = undefined;
|
||||
@ -4170,7 +4170,7 @@ pub const FuncGen = struct {
|
||||
const target = self.dg.module.getTarget();
|
||||
const bits = operand_ty.intInfo(target).bits;
|
||||
const vec_len: ?u32 = switch (operand_ty.zigTypeTag()) {
|
||||
.Vector => @intCast(u32, operand_ty.arrayLen()),
|
||||
.Vector => operand_ty.vectorLen(),
|
||||
else => null,
|
||||
};
|
||||
|
||||
@ -4372,7 +4372,7 @@ pub const FuncGen = struct {
|
||||
const scalar = try self.resolveInst(ty_op.operand);
|
||||
const scalar_ty = self.air.typeOf(ty_op.operand);
|
||||
const vector_ty = self.air.typeOfIndex(inst);
|
||||
const len = @intCast(u32, vector_ty.arrayLen());
|
||||
const len = vector_ty.vectorLen();
|
||||
const scalar_llvm_ty = try self.dg.llvmType(scalar_ty);
|
||||
const op_llvm_ty = scalar_llvm_ty.vectorType(1);
|
||||
const u32_llvm_ty = self.context.intType(32);
|
||||
|
||||
@ -295,7 +295,7 @@ const Writer = struct {
|
||||
fn writeVectorInit(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void {
|
||||
const ty_pl = w.air.instructions.items(.data)[inst].ty_pl;
|
||||
const vector_ty = w.air.getRefType(ty_pl.ty);
|
||||
const len = @intCast(u32, vector_ty.arrayLen());
|
||||
const len = vector_ty.vectorLen();
|
||||
const elements = @bitCast([]const Air.Inst.Ref, w.air.extra[ty_pl.payload..][0..len]);
|
||||
|
||||
try s.print("{}, [", .{vector_ty});
|
||||
|
||||
@ -3005,6 +3005,13 @@ pub const Type = extern union {
|
||||
return ty.arrayLen() + @boolToInt(ty.sentinel() != null);
|
||||
}
|
||||
|
||||
pub fn vectorLen(ty: Type) u32 {
|
||||
return switch (ty.tag()) {
|
||||
.vector => @intCast(u32, ty.castTag(.vector).?.data.len),
|
||||
else => unreachable,
|
||||
};
|
||||
}
|
||||
|
||||
/// Asserts the type is an array, pointer or vector.
|
||||
pub fn sentinel(self: Type) ?Value {
|
||||
return switch (self.tag()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user