[clang] [llvm] [PowerPC] Add AES Builtins (PR #186895)
Lei Huang via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 28 06:46:18 PDT 2026
================
@@ -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;
+}
----------------
lei137 wrote:
I cleaned this up a bit but please note `__vector_pair` has these restrictions:
INVALID uses:
As function parameters (by value)
As function return types (by value)
As class/struct fields
As global variables
VALID uses:
As pointers (__vector_pair*) - parameters, returns, fields
As arrays (__vector_pair[])
As local variables inside functions
Dereferencing pointers to work with the values
https://github.com/llvm/llvm-project/pull/186895
More information about the cfe-commits
mailing list