authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-13 00:11:42+01:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2024-02-25 11:22:10+01:00
logab6f9e3d10a6fdcbfca6d079645bfcb063b376bb
tree8237d43808c6b8ddda1d1a49bea72193ed3989df
parent55f437b92bb394f7df558bb3209f057f9f46274f

x86_64: fix incorrect mnemonic selection


3 files changed, 21 insertions(+), 20 deletions(-)

lib/std/crypto/aes.zig+1-1
......@@ -6,7 +6,7 @@ const has_aesni = std.Target.x86.featureSetHas(builtin.cpu.features, .aes);
66const has_avx = std.Target.x86.featureSetHas(builtin.cpu.features, .avx);
77const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes);
88// C backend doesn't currently support passing vectors to inline asm.
9const impl = if (builtin.cpu.arch == .x86_64 and builtin.zig_backend != .stage2_c and builtin.zig_backend != .stage2_x86_64 and has_aesni and has_avx) impl: {
9const impl = if (builtin.cpu.arch == .x86_64 and builtin.zig_backend != .stage2_c and has_aesni and has_avx) impl: {
1010 break :impl @import("aes/aesni.zig");
1111} else if (builtin.cpu.arch == .aarch64 and builtin.zig_backend != .stage2_c and has_armaes)
1212impl: {
lib/std/crypto/sha2.zig+1-1
......@@ -238,7 +238,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
238238 return;
239239 },
240240 // C backend doesn't currently support passing vectors to inline asm.
241 .x86_64 => if (builtin.zig_backend != .stage2_c and builtin.zig_backend != .stage2_x86_64 and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) {
241 .x86_64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) {
242242 var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] };
243243 var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] };
244244 const s_v = @as(*[16]v4u32, @ptrCast(&s));
src/arch/x86_64/CodeGen.zig+19-18
......@@ -13619,25 +13619,26 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
1361913619 label_gop.value_ptr.target = @intCast(self.mir_instructions.len);
1362013620 } else continue;
1362113621
13622 var mnem_size: ?Memory.Size = null;
13623 const mnem_tag = mnem: {
13624 mnem_size = if (mem.endsWith(u8, mnem_str, "b"))
13625 .byte
13626 else if (mem.endsWith(u8, mnem_str, "w"))
13627 .word
13628 else if (mem.endsWith(u8, mnem_str, "l"))
13629 .dword
13630 else if (mem.endsWith(u8, mnem_str, "q"))
13631 .qword
13632 else if (mem.endsWith(u8, mnem_str, "t"))
13633 .tbyte
13634 else
13635 break :mnem null;
13636 break :mnem std.meta.stringToEnum(Instruction.Mnemonic, mnem_str[0 .. mnem_str.len - 1]);
13637 } orelse mnem: {
13622 var mnem_size: ?Memory.Size = if (mem.endsWith(u8, mnem_str, "b"))
13623 .byte
13624 else if (mem.endsWith(u8, mnem_str, "w"))
13625 .word
13626 else if (mem.endsWith(u8, mnem_str, "l"))
13627 .dword
13628 else if (mem.endsWith(u8, mnem_str, "q") and
13629 (std.mem.indexOfScalar(u8, "vp", mnem_str[0]) == null or !mem.endsWith(u8, mnem_str, "dq")))
13630 .qword
13631 else if (mem.endsWith(u8, mnem_str, "t"))
13632 .tbyte
13633 else
13634 null;
13635 const mnem_tag = while (true) break std.meta.stringToEnum(
13636 Instruction.Mnemonic,
13637 mnem_str[0 .. mnem_str.len - @intFromBool(mnem_size != null)],
13638 ) orelse if (mnem_size) |_| {
1363813639 mnem_size = null;
13639 break :mnem std.meta.stringToEnum(Instruction.Mnemonic, mnem_str);
13640 } orelse return self.fail("invalid mnemonic: '{s}'", .{mnem_str});
13640 continue;
13641 } else return self.fail("invalid mnemonic: '{s}'", .{mnem_str});
1364113642 if (@as(?Memory.Size, switch (mnem_tag) {
1364213643 .clflush => .byte,
1364313644 .fldenv, .fnstenv, .fstenv => .none,