Skip to content

Commit b43554c

Browse files
committed
loongarch64: fix build on 32-bit architectures
1 parent 14640ec commit b43554c

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/arch/loongarch64/CodeGen.zig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,15 @@ pub const MCValue = union(enum) {
355355

356356
/// Returns MCV of a limb.
357357
/// Caller does not own returned values.
358-
fn toLimbValue(mcv: MCValue, limb_index: usize) MCValue {
358+
fn toLimbValue(mcv: MCValue, limb_index: u64) MCValue {
359359
switch (mcv) {
360360
else => std.debug.panic("{s}: {}\n", .{ @src().fn_name, mcv }),
361361
.register, .immediate, .register_bias, .lea_frame, .lea_nav, .lea_uav, .lea_lazy_sym => {
362362
assert(limb_index == 0);
363363
return mcv;
364364
},
365365
inline .register_pair, .register_triple, .register_quadruple => |regs| {
366-
return .{ .register = regs[limb_index] };
366+
return .{ .register = regs[@intCast(limb_index)] };
367367
},
368368
.load_frame => |frame_addr| {
369369
return .{ .load_frame = .{
@@ -1381,12 +1381,12 @@ const Temp = struct {
13811381
},
13821382
inline .register_pair, .register_triple, .register_quadruple => |regs| {
13831383
if (reuse)
1384-
new_temp_index.tracking(cg).* = .init(.{ .register = regs[limb_index] })
1384+
new_temp_index.tracking(cg).* = .init(.{ .register = regs[@intCast(limb_index)] })
13851385
else {
13861386
const new_reg =
13871387
try cg.register_manager.allocReg(new_temp_index.toIndex(), abi.RegisterSets.gp);
13881388
new_temp_index.tracking(cg).* = .init(.{ .register = new_reg });
1389-
try cg.asmInst(.@"or"(new_reg, regs[limb_index], .zero));
1389+
try cg.asmInst(.@"or"(new_reg, regs[@intCast(limb_index)], .zero));
13901390
}
13911391
},
13921392
.register_bias, .register_offset => |_| {
@@ -1461,7 +1461,7 @@ const Temp = struct {
14611461

14621462
/// Returns MCV of a limb.
14631463
/// Caller does not own return values.
1464-
fn toLimbValue(temp: Temp, limb_index: usize, cg: *CodeGen) MCValue {
1464+
fn toLimbValue(temp: Temp, limb_index: u64, cg: *CodeGen) MCValue {
14651465
return temp.tracking(cg).short.toLimbValue(limb_index);
14661466
}
14671467

@@ -2550,7 +2550,7 @@ fn genCopyToMem(cg: *CodeGen, ty: Type, dst_mcv: MCValue, src_mcv: MCValue) !voi
25502550
.register_offset, .load_frame, .load_nav, .load_uav, .load_lazy_sym => {
25512551
const reg, const reg_lock = try cg.allocRegAndLock(.usize);
25522552
defer cg.register_manager.unlockReg(reg_lock);
2553-
for (0..cg.getLimbCount(ty)) |limb_i| {
2553+
for (0..@intCast(cg.getLimbCount(ty))) |limb_i| {
25542554
const size = cg.getLimbSize(ty, limb_i);
25552555
try cg.genCopyToReg(size, reg, src_mcv.toLimbValue(limb_i), .{});
25562556
try cg.genCopyRegToMem(dst_mcv.toLimbValue(limb_i), reg, size);
@@ -2954,7 +2954,7 @@ fn airLogicBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: LogicBinOpKind) !void {
29542954
})) {
29552955
const lhs, const rhs = sel.ops[0..2].*;
29562956
const dst, _ = try cg.tempReuseOrAlloc(inst, lhs, 0, ty, .{ .use_frame = false });
2957-
for (0..lhs.getLimbCount(cg)) |limb_i| {
2957+
for (0..@intCast(lhs.getLimbCount(cg))) |limb_i| {
29582958
const lhs_limb = lhs.toLimbValue(limb_i, cg);
29592959
const rhs_limb = rhs.toLimbValue(limb_i, cg);
29602960
const dst_limb = dst.toLimbValue(limb_i, cg);
@@ -2970,7 +2970,7 @@ fn airLogicBinOp(cg: *CodeGen, inst: Air.Inst.Index, op: LogicBinOpKind) !void {
29702970
const lhs, const rhs = sel.ops[0..2].*;
29712971
const tmp1, const tmp2 = sel.temps[0..2].*;
29722972
const dst, _ = try cg.tempReuseOrAlloc(inst, lhs, 0, ty, .{ .use_frame = false });
2973-
for (0..lhs.getLimbCount(cg)) |limb_i| {
2973+
for (0..@intCast(lhs.getLimbCount(cg))) |limb_i| {
29742974
const lhs_limb = try tmp1.ensureReg(cg, lhs.toLimbValue(limb_i, cg));
29752975
const rhs_limb = try tmp2.ensureReg(cg, rhs.toLimbValue(limb_i, cg));
29762976
const dst_limb = dst.toLimbValue(limb_i, cg);
@@ -3019,7 +3019,7 @@ fn airNot(cg: *CodeGen, inst: Air.Inst.Index) !void {
30193019
const op = sel.ops[0];
30203020
const tmp = sel.temps[0];
30213021
const dst, _ = try cg.tempReuseOrAlloc(inst, op, 0, ty, .{ .use_frame = false });
3022-
for (0..op.getLimbCount(cg)) |limb_i| {
3022+
for (0..@intCast(op.getLimbCount(cg))) |limb_i| {
30233023
const op_limb = try tmp.ensureReg(cg, op.toLimbValue(limb_i, cg));
30243024
const dst_limb = dst.toLimbValue(limb_i, cg);
30253025
try cg.asmInst(.nor(dst_limb.getReg().?, op_limb.getReg().?, .zero));

0 commit comments

Comments
 (0)