Commit a1ed4bd796

Jacob Young <jacobly0@users.noreply.github.com>
2023-04-20 06:49:38
cbe: fix remaining aarch64 issues
1 parent d98974e
Changed files (5)
lib/std/crypto/aes.zig
@@ -8,7 +8,7 @@ const has_armaes = std.Target.aarch64.featureSetHas(builtin.cpu.features, .aes);
 // C backend doesn't currently support passing vectors to inline asm.
 const impl = if (builtin.cpu.arch == .x86_64 and builtin.zig_backend != .stage2_c and has_aesni and has_avx) impl: {
     break :impl @import("aes/aesni.zig");
-} else if (builtin.cpu.arch == .aarch64 and has_armaes)
+} else if (builtin.cpu.arch == .aarch64 and builtin.zig_backend != .stage2_c and has_armaes)
 impl: {
     break :impl @import("aes/armcrypto.zig");
 } else impl: {
lib/std/crypto/ghash_polyval.zig
@@ -251,7 +251,7 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type {
         // C backend doesn't currently support passing vectors to inline asm.
         const clmul = if (builtin.cpu.arch == .x86_64 and builtin.zig_backend != .stage2_c and has_pclmul and has_avx) impl: {
             break :impl clmulPclmul;
-        } else if (builtin.cpu.arch == .aarch64 and has_armaes) impl: {
+        } else if (builtin.cpu.arch == .aarch64 and builtin.zig_backend != .stage2_c and has_armaes) impl: {
             break :impl clmulPmull;
         } else impl: {
             break :impl clmulSoft;
lib/std/crypto/sha2.zig
@@ -205,7 +205,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
 
             if (!isComptime()) {
                 switch (builtin.cpu.arch) {
-                    .aarch64 => if (comptime std.Target.aarch64.featureSetHas(builtin.cpu.features, .sha2)) {
+                    .aarch64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.aarch64.featureSetHas(builtin.cpu.features, .sha2)) {
                         var x: v4u32 = d.s[0..4].*;
                         var y: v4u32 = d.s[4..8].*;
                         const s_v = @ptrCast(*[16]v4u32, &s);
src/codegen/c.zig
@@ -6070,9 +6070,18 @@ fn airAtomicRmw(f: *Function, inst: Air.Inst.Index) !CValue {
     if (is_float) try writer.writeAll("_float");
     try writer.writeByte('(');
     try f.writeCValue(writer, local, .Other);
-    try writer.writeAll(", (zig_atomic(");
-    try f.renderType(writer, ty);
-    try writer.writeByte(')');
+    try writer.writeAll(", (");
+    switch (extra.op()) {
+        else => {
+            try writer.writeAll("zig_atomic(");
+            try f.renderType(writer, ty);
+            try writer.writeByte(')');
+        },
+        .Nand, .Min, .Max => {
+            // These are missing from stdatomic.h, so no atomic types for now.
+            try f.renderType(writer, ty);
+        },
+    }
     if (ptr_ty.isVolatilePtr()) try writer.writeAll(" volatile");
     try writer.writeAll(" *)");
     try f.writeCValue(writer, ptr, .Other);
test/cases/compile_errors/atomicrmw_with_float_op_not_.Xchg_.Add_or_.Sub.zig → test/cases/compile_errors/atomicrmw_with_float_op_not_.Xchg_.Add_.Sub_.Max_or_.Min.zig
@@ -7,4 +7,4 @@ export fn entry() void {
 // backend=stage2
 // target=native
 //
-// :3:30: error: @atomicRmw with float only allowed with .Xchg, .Add, and .Sub
+// :3:30: error: @atomicRmw with float only allowed with .Xchg, .Add, .Sub, .Max, and .Min