[PowerPC] Fix types for vcipher builtins.
authorStefan Pintilie <stefanp@ca.ibm.com>
Thu, 6 Oct 2022 18:34:09 +0000 (13:34 -0500)
committerStefan Pintilie <stefanp@ca.ibm.com>
Thu, 6 Oct 2022 19:21:34 +0000 (14:21 -0500)
The documentation specifies that the parameters for the vcipher builtins are
```
vector unsigned char
```
The code used
```
vector unsigned long long
```

This patch fixes the types for the vcipher builtins.

Reviewed By: amyk

Differential Revision: https://reviews.llvm.org/D135300

clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
clang/test/CodeGen/PowerPC/builtins-ppc-crypto.c

index a7a242b..df36c60 100644 (file)
@@ -423,10 +423,10 @@ BUILTIN(__builtin_altivec_crypto_vpermxor, "V16UcV16UcV16UcV16Uc", "")
 BUILTIN(__builtin_altivec_crypto_vpermxor_be, "V16UcV16UcV16UcV16Uc", "")
 BUILTIN(__builtin_altivec_crypto_vshasigmaw, "V4UiV4UiIiIi", "")
 BUILTIN(__builtin_altivec_crypto_vshasigmad, "V2ULLiV2ULLiIiIi", "")
-BUILTIN(__builtin_altivec_crypto_vcipher, "V2ULLiV2ULLiV2ULLi", "")
-BUILTIN(__builtin_altivec_crypto_vcipherlast, "V2ULLiV2ULLiV2ULLi", "")
-BUILTIN(__builtin_altivec_crypto_vncipher, "V2ULLiV2ULLiV2ULLi", "")
-BUILTIN(__builtin_altivec_crypto_vncipherlast, "V2ULLiV2ULLiV2ULLi", "")
+BUILTIN(__builtin_altivec_crypto_vcipher, "V16UcV16UcV16Uc", "")
+BUILTIN(__builtin_altivec_crypto_vcipherlast, "V16UcV16UcV16Uc", "")
+BUILTIN(__builtin_altivec_crypto_vncipher, "V16UcV16UcV16Uc", "")
+BUILTIN(__builtin_altivec_crypto_vncipherlast, "V16UcV16UcV16Uc", "")
 BUILTIN(__builtin_altivec_crypto_vpmsumb, "V16UcV16UcV16Uc", "")
 BUILTIN(__builtin_altivec_crypto_vpmsumh, "V8UsV8UsV8Us", "")
 BUILTIN(__builtin_altivec_crypto_vpmsumw, "V4UiV4UiV4Ui", "")
index 0b1e76e..b4dbe0d 100644 (file)
@@ -17328,27 +17328,27 @@ __builtin_crypto_vsbox(vector unsigned long long __a) {
   return __builtin_altivec_crypto_vsbox(__a);
 }
 
-static __inline__ vector unsigned long long __attribute__((__always_inline__))
-__builtin_crypto_vcipher(vector unsigned long long __a,
-                         vector unsigned long long __b) {
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+__builtin_crypto_vcipher(vector unsigned char __a,
+                         vector unsigned char __b) {
   return __builtin_altivec_crypto_vcipher(__a, __b);
 }
 
-static __inline__ vector unsigned long long __attribute__((__always_inline__))
-__builtin_crypto_vcipherlast(vector unsigned long long __a,
-                             vector unsigned long long __b) {
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+__builtin_crypto_vcipherlast(vector unsigned char __a,
+                             vector unsigned char __b) {
   return __builtin_altivec_crypto_vcipherlast(__a, __b);
 }
 
-static __inline__ vector unsigned long long __attribute__((__always_inline__))
-__builtin_crypto_vncipher(vector unsigned long long __a,
-                          vector unsigned long long __b) {
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+__builtin_crypto_vncipher(vector unsigned char __a,
+                          vector unsigned char __b) {
   return __builtin_altivec_crypto_vncipher(__a, __b);
 }
 
-static __inline__ vector unsigned long long __attribute__((__always_inline__))
-__builtin_crypto_vncipherlast(vector unsigned long long __a,
-                              vector unsigned long long __b) {
+static __inline__ vector unsigned char  __attribute__((__always_inline__))
+__builtin_crypto_vncipherlast(vector unsigned char __a,
+                              vector unsigned char __b) {
   return __builtin_altivec_crypto_vncipherlast(__a, __b);
 }
 #endif /* __VSX__ */
index 9e04284..0c4d54c 100644 (file)
@@ -110,38 +110,38 @@ vector unsigned char test_vpermxoruc_be(vector unsigned char a,
 // CHECK: @llvm.ppc.altivec.crypto.vpermxor.be
 }
 
-// CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipher
-vector unsigned long long test_vcipher(void)
+// CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipher
+vector unsigned char test_vcipher(void)
 {
-  vector unsigned long long a = D_INIT1
-  vector unsigned long long b = D_INIT2
+  vector unsigned char a = B_INIT1
+  vector unsigned char b = B_INIT2
   return __builtin_altivec_crypto_vcipher(a, b);
 // CHECK: @llvm.ppc.altivec.crypto.vcipher
 }
 
-// CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipherlast
-vector unsigned long long test_vcipherlast(void)
+// CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipherlast
+vector unsigned char test_vcipherlast(void)
 {
-  vector unsigned long long a = D_INIT1
-  vector unsigned long long b = D_INIT2
+  vector unsigned char a = B_INIT1
+  vector unsigned char b = B_INIT2
   return __builtin_altivec_crypto_vcipherlast(a, b);
 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast
 }
 
 // CHECK-LABEL: @test_vncipher
-vector unsigned long long test_vncipher(void)
+vector unsigned char test_vncipher(void)
 {
-  vector unsigned long long a = D_INIT1
-  vector unsigned long long b = D_INIT2
+  vector unsigned char a = B_INIT1
+  vector unsigned char b = B_INIT2
   return __builtin_altivec_crypto_vncipher(a, b);
 // CHECK: @llvm.ppc.altivec.crypto.vncipher
 }
 
-// CHECK-LABEL: define{{.*}} <2 x i64> @test_vncipherlast
-vector unsigned long long test_vncipherlast(void)
+// CHECK-LABEL: define{{.*}} <16 x i8> @test_vncipherlast
+vector unsigned char test_vncipherlast(void)
 {
-  vector unsigned long long a = D_INIT1
-  vector unsigned long long b = D_INIT2
+  vector unsigned char a = B_INIT1
+  vector unsigned char b = B_INIT2
   return __builtin_altivec_crypto_vncipherlast(a, b);
 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast
 }
@@ -248,20 +248,20 @@ vector unsigned long long test_vpermxord_e(void)
 // CHECK: @llvm.ppc.altivec.crypto.vpermxor
 }
 
-// CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipher_e
-vector unsigned long long test_vcipher_e(void)
+// CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipher_e
+vector unsigned char test_vcipher_e(void)
 {
-  vector unsigned long long a = D_INIT1
-  vector unsigned long long b = D_INIT2
+  vector unsigned char a = B_INIT1
+  vector unsigned char b = B_INIT2
   return __builtin_crypto_vcipher(a, b);
 // CHECK: @llvm.ppc.altivec.crypto.vcipher
 }
 
-// CHECK-LABEL: define{{.*}} <2 x i64> @test_vcipherlast_e
-vector unsigned long long test_vcipherlast_e(void)
+// CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipherlast_e
+vector unsigned char test_vcipherlast_e(void)
 {
-  vector unsigned long long a = D_INIT1
-  vector unsigned long long b = D_INIT2
+  vector unsigned char a = B_INIT1
+  vector unsigned char b = B_INIT2
   return __builtin_crypto_vcipherlast(a, b);
 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast
 }
@@ -291,37 +291,37 @@ vector unsigned long long test_vec_sbox_be(void)
 }
 
 // CHECK-LABEL: @test_vec_cipher_be
-vector unsigned long long test_vec_cipher_be(void)
+vector unsigned char test_vec_cipher_be(void)
 {
-  vector unsigned long long a = D_INIT1
-  vector unsigned long long b = D_INIT2
+  vector unsigned char a = B_INIT1
+  vector unsigned char b = B_INIT2
   return vec_cipher_be(a, b);
 // CHECK: @llvm.ppc.altivec.crypto.vcipher
 }
 
 // CHECK-LABEL: @test_vec_cipherlast_be
-vector unsigned long long test_vec_cipherlast_be(void)
+vector unsigned char test_vec_cipherlast_be(void)
 {
-  vector unsigned long long a = D_INIT1
-  vector unsigned long long b = D_INIT2
+  vector unsigned char a = B_INIT1
+  vector unsigned char b = B_INIT2
   return vec_cipherlast_be(a, b);
 // CHECK: @llvm.ppc.altivec.crypto.vcipherlast
 }
 
 // CHECK-LABEL: @test_vec_ncipher_be
-vector unsigned long long test_vec_ncipher_be(void)
+vector unsigned char test_vec_ncipher_be(void)
 {
-  vector unsigned long long a = D_INIT1
-  vector unsigned long long b = D_INIT2
+  vector unsigned char a = B_INIT1
+  vector unsigned char b = B_INIT2
   return vec_ncipher_be(a, b);
 // CHECK: @llvm.ppc.altivec.crypto.vncipher
 }
 
 // CHECK-LABEL: @test_vec_ncipherlast_be
-vector unsigned long long test_vec_ncipherlast_be(void)
+vector unsigned char test_vec_ncipherlast_be(void)
 {
-  vector unsigned long long a = D_INIT1
-  vector unsigned long long b = D_INIT2
+  vector unsigned char a = B_INIT1
+  vector unsigned char b = B_INIT2
   return vec_ncipherlast_be(a, b);
 // CHECK: @llvm.ppc.altivec.crypto.vncipherlast
 }