From 90a8817f558bb5c5b4292c666b2ed61b4a415f8d Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 5 May 2022 22:33:03 +0200 Subject: [PATCH] aarch64: ensure we set correct operand size at codegen stage --- src/arch/aarch64/CodeGen.zig | 9 +++++++-- src/arch/aarch64/Emit.zig | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/arch/aarch64/CodeGen.zig b/src/arch/aarch64/CodeGen.zig index d146724188531a78c6402e07a20e548515887a7d..825bf51b1f26d9ba617ff2e6322ea845b6ccbc48 100644 --- a/src/arch/aarch64/CodeGen.zig +++ b/src/arch/aarch64/CodeGen.zig @@ -1335,8 +1335,6 @@ fn binOpRegister( .shift = .lsl, } }, .mul, - .smull, - .umull, .lsl_register, .asr_register, .lsr_register, @@ -1345,6 +1343,13 @@ fn binOpRegister( .rn = lhs_reg, .rm = rhs_reg, } }, + .smull, + .umull, + => .{ .rrr = .{ + .rd = dest_reg.to64(), + .rn = lhs_reg, + .rm = rhs_reg, + } }, .and_shifted_register, .orr_shifted_register, .eor_shifted_register, diff --git a/src/arch/aarch64/Emit.zig b/src/arch/aarch64/Emit.zig index 959ca4037c8f47a84757640bbae7276cc3617037..9e4993b0d97411a8b64ad5f7e950b91e8677e656 100644 --- a/src/arch/aarch64/Emit.zig +++ b/src/arch/aarch64/Emit.zig @@ -1060,10 +1060,10 @@ fn mirDataProcessing3Source(emit: *Emit, inst: Mir.Inst.Index) !void { switch (tag) { .mul => try emit.writeInstruction(Instruction.mul(rrr.rd, rrr.rn, rrr.rm)), - .smulh => try emit.writeInstruction(Instruction.smulh(rrr.rd.to64(), rrr.rn.to64(), rrr.rm.to64())), - .smull => try emit.writeInstruction(Instruction.smull(rrr.rd.to64(), rrr.rn.to32(), rrr.rm.to32())), - .umulh => try emit.writeInstruction(Instruction.umulh(rrr.rd.to64(), rrr.rn.to64(), rrr.rm.to64())), - .umull => try emit.writeInstruction(Instruction.umull(rrr.rd.to64(), rrr.rn.to32(), rrr.rm.to32())), + .smulh => try emit.writeInstruction(Instruction.smulh(rrr.rd, rrr.rn, rrr.rm)), + .smull => try emit.writeInstruction(Instruction.smull(rrr.rd, rrr.rn, rrr.rm)), + .umulh => try emit.writeInstruction(Instruction.umulh(rrr.rd, rrr.rn, rrr.rm)), + .umull => try emit.writeInstruction(Instruction.umull(rrr.rd, rrr.rn, rrr.rm)), else => unreachable, } } -- 2.54.0