llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-powerpc

Author: Lei Huang (lei137)

<details>
<summary>Changes</summary>

Add the following AES builtins:

__vector_pair __builtin_aes_encrypt_paired (__vector_pair, __vector_pair, 
uint2);
__vector_pair __builtin_aes128_encrypt_paired (__vector_pair, __vector_pair);
__vector_pair __builtin_aes192_encrypt_paired (__vector_pair, __vector_pair);
__vector_pair __builtin_aes256_encrypt_paired (__vector_pair, __vector_pair);

__vector_pair __builtin_aes_decrypt_paired (__vector_pair, __vector_pair, 
uint2);
__vector_pair__builtin_aes128_decrypt_paired (__vector_pair, __vector_pair);
__vector_pair __builtin_aes192_decrypt_paired (__vector_pair, __vector_pair);
__vector_pair__builtin_aes256_decrypt_paired (__vector_pair, __vector_pair);

__vector_pair __builtin_aes_genlastkey_paired (__vector_pair, uint2);
__vector_pair __builtin_aes128_genlastkey_paired (__vector_pair);
__vector_pair  __builtin_aes192_genlastkey_paired (__vector_pair);
__vector_pair  __builtin_aes256_genlastkey_paired (__vector_pair);

vec_t __builtin_galois_field_mult (vec_t, vec_t, uint1);
vec_t __builtin_galois_field_mult_gcm (vec_t, vec_t);
vec_t __builtin_galois_field_mult_xts (vec_t, vec_t);


---

Patch is 39.08 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/186895.diff


7 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsPPC.def (+35) 
- (modified) clang/lib/CodeGen/TargetBuiltins/PPC.cpp (+57) 
- (added) clang/test/CodeGen/PowerPC/builtins-ppc-aes-acceleration.c (+205) 
- (added) clang/test/Sema/builtins-ppc-aes-acceleration-error.c (+181) 
- (modified) llvm/include/llvm/IR/IntrinsicsPowerPC.td (+21) 
- (modified) llvm/lib/Target/PowerPC/PPCInstrFuture.td (+20-9) 
- (added) llvm/test/CodeGen/PowerPC/builtins-ppc-aes-acceleration.ll (+174) 


``````````diff
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index c0c92c0b73793..592e070b5a6ab 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -1162,6 +1162,41 @@ UNALIASED_CUSTOM_MMA_BUILTIN(mma_dmxvf16gerx2, 
"vW1024*W256V",
 UNALIASED_CUSTOM_MMA_BUILTIN(mma_pmdmxvf16gerx2, "vW1024*W256Vi255i15i3",
                              "mma,isa-future-instructions")
 
+// AES Encrypt Paired builtins
+UNALIASED_CUSTOM_BUILTIN(aes_encrypt_paired, "W256W256W256i2", false,
+                         "isa-future-instructions")
+CUSTOM_BUILTIN(aes128_encrypt_paired, aes_encrypt_paired, "W256W256W256", 
false,
+               "isa-future-instructions")
+CUSTOM_BUILTIN(aes192_encrypt_paired, aes_encrypt_paired, "W256W256W256", 
false,
+               "isa-future-instructions")
+CUSTOM_BUILTIN(aes256_encrypt_paired, aes_encrypt_paired, "W256W256W256", 
false,
+               "isa-future-instructions")
+// AES Decrypt Paired builtins
+UNALIASED_CUSTOM_BUILTIN(aes_decrypt_paired, "W256W256W256i2", false,
+                         "isa-future-instructions")
+CUSTOM_BUILTIN(aes128_decrypt_paired, aes_decrypt_paired, "W256W256W256", 
false,
+               "isa-future-instructions")
+CUSTOM_BUILTIN(aes192_decrypt_paired, aes_decrypt_paired, "W256W256W256", 
false,
+               "isa-future-instructions")
+CUSTOM_BUILTIN(aes256_decrypt_paired, aes_decrypt_paired, "W256W256W256", 
false,
+               "isa-future-instructions")
+// AES Generate Last Key Paired builtins
+UNALIASED_CUSTOM_BUILTIN(aes_genlastkey_paired, "W256W256i2", false,
+                         "isa-future-instructions")
+CUSTOM_BUILTIN(aes128_genlastkey_paired, aes_genlastkey_paired, "W256W256", 
false,
+               "isa-future-instructions")
+CUSTOM_BUILTIN(aes192_genlastkey_paired, aes_genlastkey_paired, "W256W256", 
false,
+               "isa-future-instructions")
+CUSTOM_BUILTIN(aes256_genlastkey_paired, aes_genlastkey_paired, "W256W256", 
false,
+               "isa-future-instructions")
+// Galois Field Multiplication builtins
+UNALIASED_CUSTOM_BUILTIN(galois_field_mult, "VVVi1", false,
+                         "isa-future-instructions")
+CUSTOM_BUILTIN(galois_field_mult_gcm, galois_field_mult, "VVV", false,
+               "isa-future-instructions")
+CUSTOM_BUILTIN(galois_field_mult_xts, galois_field_mult, "VVV", false,
+               "isa-future-instructions")
+
 // FIXME: Obviously incomplete.
 
 #undef BUILTIN
diff --git a/clang/lib/CodeGen/TargetBuiltins/PPC.cpp 
b/clang/lib/CodeGen/TargetBuiltins/PPC.cpp
index 01926878085e0..763259eb40f88 100644
--- a/clang/lib/CodeGen/TargetBuiltins/PPC.cpp
+++ b/clang/lib/CodeGen/TargetBuiltins/PPC.cpp
@@ -1145,6 +1145,63 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
       llvm::Function *F = CGM.getIntrinsic(ID);
       return Builder.CreateCall(F, Ops, "");
     }
+    // Handle AES encrypt paired builtins - they return a value directly.
+    // For variant builtins, add the appropriate immediate value.
+    if (BuiltinID == PPC::BI__builtin_aes_encrypt_paired ||
+        BuiltinID == PPC::BI__builtin_aes128_encrypt_paired ||
+        BuiltinID == PPC::BI__builtin_aes192_encrypt_paired ||
+        BuiltinID == PPC::BI__builtin_aes256_encrypt_paired) {
+      if (BuiltinID == PPC::BI__builtin_aes128_encrypt_paired)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 0));
+      else if (BuiltinID == PPC::BI__builtin_aes192_encrypt_paired)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 1));
+      else if (BuiltinID == PPC::BI__builtin_aes256_encrypt_paired)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 2));
+      // For base builtin, Ops already has all 3 arguments.
+      llvm::Function *F = CGM.getIntrinsic(ID);
+      return Builder.CreateCall(F, Ops, "");
+    }
+    // Handle AES decrypt paired builtins - they return a value directly.
+    // For variant builtins, add the appropriate immediate value.
+    if (BuiltinID == PPC::BI__builtin_aes_decrypt_paired ||
+        BuiltinID == PPC::BI__builtin_aes128_decrypt_paired ||
+        BuiltinID == PPC::BI__builtin_aes192_decrypt_paired ||
+        BuiltinID == PPC::BI__builtin_aes256_decrypt_paired) {
+      if (BuiltinID == PPC::BI__builtin_aes128_decrypt_paired)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 0));
+      else if (BuiltinID == PPC::BI__builtin_aes192_decrypt_paired)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 1));
+      else if (BuiltinID == PPC::BI__builtin_aes256_decrypt_paired)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 2));
+      // For base builtin, Ops already has all 3 arguments.
+      llvm::Function *F = CGM.getIntrinsic(ID);
+      return Builder.CreateCall(F, Ops, "");
+    }
+    if (BuiltinID == PPC::BI__builtin_aes_genlastkey_paired ||
+        BuiltinID == PPC::BI__builtin_aes128_genlastkey_paired ||
+        BuiltinID == PPC::BI__builtin_aes192_genlastkey_paired ||
+        BuiltinID == PPC::BI__builtin_aes256_genlastkey_paired) {
+      if (BuiltinID == PPC::BI__builtin_aes128_genlastkey_paired)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 0));
+      else if (BuiltinID == PPC::BI__builtin_aes192_genlastkey_paired)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 1));
+      else if (BuiltinID == PPC::BI__builtin_aes256_genlastkey_paired)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 2));
+      // For base builtin, Ops already has all 2 arguments.
+      llvm::Function *F = CGM.getIntrinsic(ID);
+      return Builder.CreateCall(F, Ops, "");
+    }
+    if (BuiltinID == PPC::BI__builtin_galois_field_mult ||
+        BuiltinID == PPC::BI__builtin_galois_field_mult_gcm ||
+        BuiltinID == PPC::BI__builtin_galois_field_mult_xts) {
+      if (BuiltinID == PPC::BI__builtin_galois_field_mult_gcm)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 0));
+      else if (BuiltinID == PPC::BI__builtin_galois_field_mult_xts)
+        Ops.push_back(llvm::ConstantInt::get(Int32Ty, 1));
+      // For base builtin, Ops already has all 3 arguments.
+      llvm::Function *F = CGM.getIntrinsic(ID);
+      return Builder.CreateCall(F, Ops, "");
+    }
     SmallVector<Value*, 4> CallOps;
     if (Accumulate) {
       Address Addr = EmitPointerWithAlignment(E->getArg(0));
diff --git a/clang/test/CodeGen/PowerPC/builtins-ppc-aes-acceleration.c 
b/clang/test/CodeGen/PowerPC/builtins-ppc-aes-acceleration.c
new file mode 100644
index 0000000000000..d6e5bec7bb923
--- /dev/null
+++ b/clang/test/CodeGen/PowerPC/builtins-ppc-aes-acceleration.c
@@ -0,0 +1,205 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -O3 -triple powerpc64le-unknown-unknown -target-cpu future \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -O3 -triple powerpc64-unknown-unknown -target-cpu future \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+// Made with AI
+
+// CHECK-LABEL: @test_aes_encrypt_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6:![0-9]+]]
+// CHECK-NEXT:    [[TMP1:%.*]] = load <256 x i1>, ptr [[VPP2:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP2:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.encrypt.paired(<256 x i1> [[TMP0]], <256 x i1> [[TMP1]], i32 0)
+// CHECK-NEXT:    store <256 x i1> [[TMP2]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes_encrypt_paired(unsigned char *vpp1, unsigned char *vpp2, 
unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair vp2 = *((__vector_pair *)vpp2);
+  __vector_pair res = __builtin_aes_encrypt_paired(vp1, vp2, 0);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_aes128_encrypt_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = load <256 x i1>, ptr [[VPP2:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP2:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.encrypt.paired(<256 x i1> [[TMP0]], <256 x i1> [[TMP1]], i32 0)
+// CHECK-NEXT:    store <256 x i1> [[TMP2]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes128_encrypt_paired(unsigned char *vpp1, unsigned char *vpp2, 
unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair vp2 = *((__vector_pair *)vpp2);
+  __vector_pair res = __builtin_aes128_encrypt_paired(vp1, vp2);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_aes192_encrypt_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = load <256 x i1>, ptr [[VPP2:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP2:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.encrypt.paired(<256 x i1> [[TMP0]], <256 x i1> [[TMP1]], i32 1)
+// CHECK-NEXT:    store <256 x i1> [[TMP2]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes192_encrypt_paired(unsigned char *vpp1, unsigned char *vpp2, 
unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair vp2 = *((__vector_pair *)vpp2);
+  __vector_pair res = __builtin_aes192_encrypt_paired(vp1, vp2);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_aes256_encrypt_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = load <256 x i1>, ptr [[VPP2:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP2:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.encrypt.paired(<256 x i1> [[TMP0]], <256 x i1> [[TMP1]], i32 2)
+// CHECK-NEXT:    store <256 x i1> [[TMP2]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes256_encrypt_paired(unsigned char *vpp1, unsigned char *vpp2, 
unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair vp2 = *((__vector_pair *)vpp2);
+  __vector_pair res = __builtin_aes256_encrypt_paired(vp1, vp2);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_aes_decrypt_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = load <256 x i1>, ptr [[VPP2:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP2:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.decrypt.paired(<256 x i1> [[TMP0]], <256 x i1> [[TMP1]], i32 0)
+// CHECK-NEXT:    store <256 x i1> [[TMP2]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes_decrypt_paired(unsigned char *vpp1, unsigned char *vpp2, 
unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair vp2 = *((__vector_pair *)vpp2);
+  __vector_pair res = __builtin_aes_decrypt_paired(vp1, vp2, 0);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_aes128_decrypt_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = load <256 x i1>, ptr [[VPP2:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP2:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.decrypt.paired(<256 x i1> [[TMP0]], <256 x i1> [[TMP1]], i32 0)
+// CHECK-NEXT:    store <256 x i1> [[TMP2]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes128_decrypt_paired(unsigned char *vpp1, unsigned char *vpp2, 
unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair vp2 = *((__vector_pair *)vpp2);
+  __vector_pair res = __builtin_aes128_decrypt_paired(vp1, vp2);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_aes192_decrypt_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = load <256 x i1>, ptr [[VPP2:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP2:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.decrypt.paired(<256 x i1> [[TMP0]], <256 x i1> [[TMP1]], i32 1)
+// CHECK-NEXT:    store <256 x i1> [[TMP2]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes192_decrypt_paired(unsigned char *vpp1, unsigned char *vpp2, 
unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair vp2 = *((__vector_pair *)vpp2);
+  __vector_pair res = __builtin_aes192_decrypt_paired(vp1, vp2);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_aes256_decrypt_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = load <256 x i1>, ptr [[VPP2:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP2:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.decrypt.paired(<256 x i1> [[TMP0]], <256 x i1> [[TMP1]], i32 2)
+// CHECK-NEXT:    store <256 x i1> [[TMP2]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes256_decrypt_paired(unsigned char *vpp1, unsigned char *vpp2, 
unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair vp2 = *((__vector_pair *)vpp2);
+  __vector_pair res = __builtin_aes256_decrypt_paired(vp1, vp2);
+  *((__vector_pair *)resp) = res;
+}
+// CHECK-LABEL: @test_aes_genlastkey_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.genlastkey.paired(<256 x i1> [[TMP0]], i32 0)
+// CHECK-NEXT:    store <256 x i1> [[TMP1]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes_genlastkey_paired(unsigned char *vpp1, unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair res = __builtin_aes_genlastkey_paired(vp1, 0);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_aes128_genlastkey_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.genlastkey.paired(<256 x i1> [[TMP0]], i32 0)
+// CHECK-NEXT:    store <256 x i1> [[TMP1]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes128_genlastkey_paired(unsigned char *vpp1, unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair res = __builtin_aes128_genlastkey_paired(vp1);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_aes192_genlastkey_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.genlastkey.paired(<256 x i1> [[TMP0]], i32 1)
+// CHECK-NEXT:    store <256 x i1> [[TMP1]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes192_genlastkey_paired(unsigned char *vpp1, unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair res = __builtin_aes192_genlastkey_paired(vp1);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_aes256_genlastkey_paired(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = load <256 x i1>, ptr [[VPP1:%.*]], align 32, 
!tbaa [[TBAA6]]
+// CHECK-NEXT:    [[TMP1:%.*]] = tail call <256 x i1> 
@llvm.ppc.aes.genlastkey.paired(<256 x i1> [[TMP0]], i32 2)
+// CHECK-NEXT:    store <256 x i1> [[TMP1]], ptr [[RESP:%.*]], align 32, !tbaa 
[[TBAA6]]
+// CHECK-NEXT:    ret void
+//
+void test_aes256_genlastkey_paired(unsigned char *vpp1, unsigned char *resp) {
+  __vector_pair vp1 = *((__vector_pair *)vpp1);
+  __vector_pair res = __builtin_aes256_genlastkey_paired(vp1);
+  *((__vector_pair *)resp) = res;
+}
+
+// CHECK-LABEL: @test_galois_field_mult(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = tail call <16 x i8> 
@llvm.ppc.galois.field.mult(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]], i32 0)
+// CHECK-NEXT:    ret <16 x i8> [[TMP0]]
+//
+vector unsigned char test_galois_field_mult(vector unsigned char a, vector 
unsigned char b) {
+  return __builtin_galois_field_mult(a, b, 0);
+}
+
+// CHECK-LABEL: @test_galois_field_mult_gcm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = tail call <16 x i8> 
@llvm.ppc.galois.field.mult(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]], i32 0)
+// CHECK-NEXT:    ret <16 x i8> [[TMP0]]
+//
+vector unsigned char test_galois_field_mult_gcm(vector unsigned char a, vector 
unsigned char b) {
+  return __builtin_galois_field_mult_gcm(a, b);
+}
+
+// CHECK-LABEL: @test_galois_field_mult_xts(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:    [[TMP0:%.*]] = tail call <16 x i8> 
@llvm.ppc.galois.field.mult(<16 x i8> [[A:%.*]], <16 x i8> [[B:%.*]], i32 1)
+// CHECK-NEXT:    ret <16 x i8> [[TMP0]]
+//
+vector unsigned char test_galois_field_mult_xts(vector unsigned char a, vector 
unsigned char b) {
+  return __builtin_galois_field_mult_xts(a, b);
+}
diff --git a/clang/test/Sema/builtins-ppc-aes-acceleration-error.c 
b/clang/test/Sema/builtins-ppc-aes-acceleration-error.c
new file mode 100644
index 0000000000000..5c590825e3558
--- /dev/null
+++ b/clang/test/Sema/builtins-ppc-aes-acceleration-error.c
@@ -0,0 +1,181 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu future \
+// RUN:   -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-cpu future \
+// RUN:   -fsyntax-only -verify %s
+
+// Made with AI
+
+void test_aes_encrypt_paired_invalid_imm(void) {
+  __vector_pair vp1, vp2;
+
+  // Test invalid immediate values (valid range is 0-2)
+  __vector_pair res1 = __builtin_aes_encrypt_paired(vp1, vp2, 3);  // 
expected-error-re {{argument value {{.*}} is outside the valid range}}
+  __vector_pair res2 = __builtin_aes_encrypt_paired(vp1, vp2, -1); // 
expected-error-re {{argument value {{.*}} is outside the valid range}}
+  __vector_pair res3 = __builtin_aes_encrypt_paired(vp1, vp2, 10); // 
expected-error-re {{argument value {{.*}} is outside the valid range}}
+}
+
+void test_aes_encrypt_paired_type_mismatch(void) {
+  __vector_pair vp;
+  vector unsigned char vc;
+  int i = 0;
+
+  // Test type mismatches
+  __vector_pair res1 = __builtin_aes_encrypt_paired(vc, vp, 0);    // 
expected-error {{passing '__vector unsigned char' (vector of 16 'unsigned char' 
values) to parameter of incompatible type '__vector_pair'}}
+  __vector_pair res2 = __builtin_aes_encrypt_paired(vp, vc, 0);    // 
expected-error {{passing '__vector unsigned char' (vector of 16 'unsigned char' 
values) to parameter of incompatible type '__vector_pair'}}
+  __vector_pair res3 = __builtin_aes_encrypt_paired(vp, vp, vc);   // 
expected-error {{passing '__vector unsigned char' (vector of 16 'unsigned char' 
values) to parameter of incompatible type 'int'}}
+}
+
+void test_aes128_encrypt_paired_type_mismatch(void) {
+  __vector_pair vp;
+  vector unsigned char vc;
+
+  // Test type mismatches for aes128 variant
+  __vector_pair res1 = __builtin_aes128_encrypt_paired(vc, vp);    // 
expected-error {{passing '__vector unsigned char' (vector of 16 'unsigned char' 
values) to parameter of incompatible type '__vector_pair'}}
+  __vector_pair res2 = __builtin_aes128_encrypt_paired(vp, vc);    // 
expected-error {{passing '__vector unsigned char' (vector of 16 'unsigned char' 
values) to parameter of incompatible type '__vector_pair'}}
+}
+
+void test_aes192_encrypt_paired_type_mismatch(void) {
+  __vector_pair vp;
+  vector unsigned char vc;
+
+  // Test type mismatches for aes192 variant
+  __vector_pair res1 = __builtin_aes192_encrypt_paired(vc, vp);    // 
expected-error {{passing '__vector unsigned char' (vector of 16 'unsigned char' 
values) to parameter of incompatible type '__vector_pair'}}
+  __vector_pair res2 = __builtin_aes192_encrypt_paired(vp, vc);    // 
expected-error {{passing '__vector unsigned char' (vector of 16 'unsigned char' 
values) to parameter of incompatible type '__vector_pair'}}
+}
+
+void test_aes256_encrypt_paired_type_mismatch(void) {
+  __vector_pair vp;
+  vector unsigned char vc;
+
+  // Test type mismatches for aes256 variant
+  __vector_pair res1...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/186895
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to