381 lines · c
1// REQUIRES: powerpc-registered-target2// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +altivec -triple powerpc64le-unknown-unknown \3// RUN: -target-feature +crypto -target-feature +power8-vector \4// RUN: -emit-llvm %s -o - | FileCheck %s5 6// RUN: %clang_cc1 -flax-vector-conversions=none -target-feature +altivec -triple powerpc64-unknown-unknown \7// RUN: -target-feature +crypto -target-feature +power8-vector \8// RUN: -emit-llvm %s -o - | FileCheck %s9#include <altivec.h>10#define B_INIT1 { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, \11 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 };12#define B_INIT2 { 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, \13 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, 0x70 };14#define H_INIT1 { 0x0102, 0x0304, 0x0506, 0x0708, \15 0x090A, 0x0B0C, 0x0D0E, 0x0F10 };16#define H_INIT2 { 0x7172, 0x7374, 0x7576, 0x7778, \17 0x797A, 0x7B7C, 0x7D7E, 0x7F70 };18#define W_INIT1 { 0x01020304, 0x05060708, \19 0x090A0B0C, 0x0D0E0F10 };20#define W_INIT2 { 0x71727374, 0x75767778, \21 0x797A7B7C, 0x7D7E7F70 };22#define D_INIT1 { 0x0102030405060708, \23 0x090A0B0C0D0E0F10 };24#define D_INIT2 { 0x7172737475767778, \25 0x797A7B7C7D7E7F70 };26 27// CHECK-LABEL: define{{.*}} <16 x i8> @test_vpmsumb28vector unsigned char test_vpmsumb(void)29{30 vector unsigned char a = B_INIT131 vector unsigned char b = B_INIT232 return __builtin_altivec_crypto_vpmsumb(a, b);33// CHECK: @llvm.ppc.altivec.crypto.vpmsumb34}35 36// CHECK-LABEL: define{{.*}} <8 x i16> @test_vpmsumh37vector unsigned short test_vpmsumh(void)38{39 vector unsigned short a = H_INIT140 vector unsigned short b = H_INIT241 return __builtin_altivec_crypto_vpmsumh(a, b);42// CHECK: @llvm.ppc.altivec.crypto.vpmsumh43}44 45// CHECK-LABEL: define{{.*}} <4 x i32> @test_vpmsumw46vector unsigned int test_vpmsumw(void)47{48 vector unsigned int a = W_INIT149 vector unsigned int b = W_INIT250 return __builtin_altivec_crypto_vpmsumw(a, b);51// CHECK: @llvm.ppc.altivec.crypto.vpmsumw52}53 54// CHECK-LABEL: define{{.*}} <2 x i64> @test_vpmsumd55vector unsigned long long test_vpmsumd(void)56{57 vector unsigned long long a = D_INIT158 vector unsigned long long b = D_INIT259 return __builtin_altivec_crypto_vpmsumd(a, b);60// CHECK: @llvm.ppc.altivec.crypto.vpmsumd61}62 63// CHECK-LABEL: define{{.*}} <16 x i8> @test_vsbox64vector unsigned char test_vsbox(void)65{66 vector unsigned char a = B_INIT167 return __builtin_altivec_crypto_vsbox(a);68// CHECK: @llvm.ppc.altivec.crypto.vsbox69}70 71// CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorb72vector unsigned char test_vpermxorb(void)73{74 vector unsigned char a = B_INIT175 vector unsigned char b = B_INIT276 vector unsigned char c = B_INIT277 return __builtin_altivec_crypto_vpermxor(a, b, c);78// CHECK: @llvm.ppc.altivec.crypto.vpermxor79}80 81// CHECK-LABEL: test_vpermxorbc82vector bool char test_vpermxorbc(vector bool char a,83 vector bool char b,84 vector bool char c) {85 return vec_permxor(a, b, c);86// CHECK: @llvm.ppc.altivec.crypto.vpermxor87}88 89// CHECK-LABEL: test_vpermxorsc90vector signed char test_vpermxorsc(vector signed char a,91 vector signed char b,92 vector signed char c) {93 return vec_permxor(a, b, c);94// CHECK: @llvm.ppc.altivec.crypto.vpermxor95}96 97// CHECK-LABEL: test_vpermxoruc98vector unsigned char test_vpermxoruc(vector unsigned char a,99 vector unsigned char b,100 vector unsigned char c) {101 return vec_permxor(a, b, c);102// CHECK: @llvm.ppc.altivec.crypto.vpermxor103}104 105// CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxoruc_be106vector unsigned char test_vpermxoruc_be(vector unsigned char a,107 vector unsigned char b,108 vector unsigned char c) {109 return __builtin_altivec_crypto_vpermxor_be(a, b, c);110// CHECK: @llvm.ppc.altivec.crypto.vpermxor.be111}112 113// CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipher114vector unsigned char test_vcipher(void)115{116 vector unsigned char a = B_INIT1117 vector unsigned char b = B_INIT2118 return __builtin_altivec_crypto_vcipher(a, b);119// CHECK: @llvm.ppc.altivec.crypto.vcipher120}121 122// CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipherlast123vector unsigned char test_vcipherlast(void)124{125 vector unsigned char a = B_INIT1126 vector unsigned char b = B_INIT2127 return __builtin_altivec_crypto_vcipherlast(a, b);128// CHECK: @llvm.ppc.altivec.crypto.vcipherlast129}130 131// CHECK-LABEL: @test_vncipher132vector unsigned char test_vncipher(void)133{134 vector unsigned char a = B_INIT1135 vector unsigned char b = B_INIT2136 return __builtin_altivec_crypto_vncipher(a, b);137// CHECK: @llvm.ppc.altivec.crypto.vncipher138}139 140// CHECK-LABEL: define{{.*}} <16 x i8> @test_vncipherlast141vector unsigned char test_vncipherlast(void)142{143 vector unsigned char a = B_INIT1144 vector unsigned char b = B_INIT2145 return __builtin_altivec_crypto_vncipherlast(a, b);146// CHECK: @llvm.ppc.altivec.crypto.vncipherlast147}148 149// CHECK-LABEL: define{{.*}} <4 x i32> @test_vshasigmaw150vector unsigned int test_vshasigmaw(void)151{152 vector unsigned int a = W_INIT1153 return __builtin_altivec_crypto_vshasigmaw(a, 1, 15);154// CHECK: @llvm.ppc.altivec.crypto.vshasigmaw155}156 157// CHECK-LABEL: define{{.*}} <2 x i64> @test_vshasigmad158vector unsigned long long test_vshasigmad(void)159{160 vector unsigned long long a = D_INIT2161 return __builtin_altivec_crypto_vshasigmad(a, 1, 15);162// CHECK: @llvm.ppc.altivec.crypto.vshasigmad163}164 165// Test cases for the builtins the way they are exposed to166// users through altivec.h167// CHECK-LABEL: define{{.*}} <16 x i8> @test_vpmsumb_e168vector unsigned char test_vpmsumb_e(void)169{170 vector unsigned char a = B_INIT1171 vector unsigned char b = B_INIT2172 return __builtin_crypto_vpmsumb(a, b);173// CHECK: @llvm.ppc.altivec.crypto.vpmsumb174}175 176// CHECK-LABEL: define{{.*}} <8 x i16> @test_vpmsumh_e177vector unsigned short test_vpmsumh_e(void)178{179 vector unsigned short a = H_INIT1180 vector unsigned short b = H_INIT2181 return __builtin_crypto_vpmsumb(a, b);182// CHECK: @llvm.ppc.altivec.crypto.vpmsumh183}184 185// CHECK-LABEL: define{{.*}} <4 x i32> @test_vpmsumw_e186vector unsigned int test_vpmsumw_e(void)187{188 vector unsigned int a = W_INIT1189 vector unsigned int b = W_INIT2190 return __builtin_crypto_vpmsumb(a, b);191// CHECK: @llvm.ppc.altivec.crypto.vpmsumw192}193 194// CHECK-LABEL: define{{.*}} <2 x i64> @test_vpmsumd_e195vector unsigned long long test_vpmsumd_e(void)196{197 vector unsigned long long a = D_INIT1198 vector unsigned long long b = D_INIT2199 return __builtin_crypto_vpmsumb(a, b);200// CHECK: @llvm.ppc.altivec.crypto.vpmsumd201}202 203// CHECK-LABEL: define{{.*}} <16 x i8> @test_vsbox_e204vector unsigned char test_vsbox_e(void)205{206 vector unsigned char a = B_INIT1207 return __builtin_crypto_vsbox(a);208// CHECK: @llvm.ppc.altivec.crypto.vsbox209}210 211// CHECK-LABEL: define{{.*}} <16 x i8> @test_vpermxorb_e212vector unsigned char test_vpermxorb_e(void)213{214 vector unsigned char a = B_INIT1215 vector unsigned char b = B_INIT2216 vector unsigned char c = B_INIT2217 return __builtin_crypto_vpermxor(a, b, c);218// CHECK: @llvm.ppc.altivec.crypto.vpermxor219}220 221// CHECK-LABEL: define{{.*}} <8 x i16> @test_vpermxorh_e222vector unsigned short test_vpermxorh_e(void)223{224 vector unsigned short a = H_INIT1225 vector unsigned short b = H_INIT2226 vector unsigned short c = H_INIT2227 return __builtin_crypto_vpermxor(a, b, c);228// CHECK: @llvm.ppc.altivec.crypto.vpermxor229}230 231// CHECK-LABEL: define{{.*}} <4 x i32> @test_vpermxorw_e232vector unsigned int test_vpermxorw_e(void)233{234 vector unsigned int a = W_INIT1235 vector unsigned int b = W_INIT2236 vector unsigned int c = W_INIT2237 return __builtin_crypto_vpermxor(a, b, c);238// CHECK: @llvm.ppc.altivec.crypto.vpermxor239}240 241// CHECK-LABEL: define{{.*}} <2 x i64> @test_vpermxord_e242vector unsigned long long test_vpermxord_e(void)243{244 vector unsigned long long a = D_INIT1245 vector unsigned long long b = D_INIT2246 vector unsigned long long c = D_INIT2247 return __builtin_crypto_vpermxor(a, b, c);248// CHECK: @llvm.ppc.altivec.crypto.vpermxor249}250 251// CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipher_e252vector unsigned char test_vcipher_e(void)253{254 vector unsigned char a = B_INIT1255 vector unsigned char b = B_INIT2256 return __builtin_crypto_vcipher(a, b);257// CHECK: @llvm.ppc.altivec.crypto.vcipher258}259 260// CHECK-LABEL: define{{.*}} <16 x i8> @test_vcipherlast_e261vector unsigned char test_vcipherlast_e(void)262{263 vector unsigned char a = B_INIT1264 vector unsigned char b = B_INIT2265 return __builtin_crypto_vcipherlast(a, b);266// CHECK: @llvm.ppc.altivec.crypto.vcipherlast267}268 269// CHECK-LABEL: define{{.*}} <4 x i32> @test_vshasigmaw_e270vector unsigned int test_vshasigmaw_e(void)271{272 vector unsigned int a = W_INIT1273 return __builtin_crypto_vshasigmaw(a, 1, 15);274// CHECK: @llvm.ppc.altivec.crypto.vshasigmaw275}276 277// CHECK-LABEL: define{{.*}} <2 x i64> @test_vshasigmad_e278vector unsigned long long test_vshasigmad_e(void)279{280 vector unsigned long long a = D_INIT2281 return __builtin_crypto_vshasigmad(a, 0, 15);282// CHECK: @llvm.ppc.altivec.crypto.vshasigmad283}284 285// CHECK-LABEL: @test_vec_sbox_be286vector unsigned char test_vec_sbox_be(void)287{288 vector unsigned char a = B_INIT1289 return vec_sbox_be(a);290// CHECK: @llvm.ppc.altivec.crypto.vsbox291}292 293// CHECK-LABEL: @test_vec_cipher_be294vector unsigned char test_vec_cipher_be(void)295{296 vector unsigned char a = B_INIT1297 vector unsigned char b = B_INIT2298 return vec_cipher_be(a, b);299// CHECK: @llvm.ppc.altivec.crypto.vcipher300}301 302// CHECK-LABEL: @test_vec_cipherlast_be303vector unsigned char test_vec_cipherlast_be(void)304{305 vector unsigned char a = B_INIT1306 vector unsigned char b = B_INIT2307 return vec_cipherlast_be(a, b);308// CHECK: @llvm.ppc.altivec.crypto.vcipherlast309}310 311// CHECK-LABEL: @test_vec_ncipher_be312vector unsigned char test_vec_ncipher_be(void)313{314 vector unsigned char a = B_INIT1315 vector unsigned char b = B_INIT2316 return vec_ncipher_be(a, b);317// CHECK: @llvm.ppc.altivec.crypto.vncipher318}319 320// CHECK-LABEL: @test_vec_ncipherlast_be321vector unsigned char test_vec_ncipherlast_be(void)322{323 vector unsigned char a = B_INIT1324 vector unsigned char b = B_INIT2325 return vec_ncipherlast_be(a, b);326// CHECK: @llvm.ppc.altivec.crypto.vncipherlast327}328 329// CHECK-LABEL: @test_vec_shasigma_bew330vector unsigned int test_vec_shasigma_bew(void)331{332 vector unsigned int a = W_INIT1333 return vec_shasigma_be(a, 1, 15);334// CHECK: @llvm.ppc.altivec.crypto.vshasigmaw335}336 337// CHECK-LABEL: @test_vec_shasigma_bed338vector unsigned long long test_vec_shasigma_bed(void)339{340 vector unsigned long long a = D_INIT2341 return vec_shasigma_be(a, 1, 15);342// CHECK: @llvm.ppc.altivec.crypto.vshasigmad343}344 345// CHECK-LABEL: @test_vec_pmsum_beb346vector unsigned char test_vec_pmsum_beb(void)347{348 vector unsigned char a = B_INIT1349 vector unsigned char b = B_INIT2350 return vec_pmsum_be(a, b);351// CHECK: @llvm.ppc.altivec.crypto.vpmsumb352}353 354// CHECK-LABEL: @test_vec_pmsum_beh355vector unsigned short test_vec_pmsum_beh(void)356{357 vector unsigned short a = H_INIT1358 vector unsigned short b = H_INIT2359 return vec_pmsum_be(a, b);360// CHECK: @llvm.ppc.altivec.crypto.vpmsumh361}362 363// CHECK-LABEL: @test_vec_pmsum_bew364vector unsigned int test_vec_pmsum_bew(void)365{366 vector unsigned int a = W_INIT1367 vector unsigned int b = W_INIT2368 return vec_pmsum_be(a, b);369// CHECK: @llvm.ppc.altivec.crypto.vpmsumw370}371 372// CHECK-LABEL: @test_vec_pmsum_bed373vector unsigned long long test_vec_pmsum_bed(void)374{375 vector unsigned long long a = D_INIT1376 vector unsigned long long b = D_INIT2377 return vec_pmsum_be(a, b);378// CHECK: @llvm.ppc.altivec.crypto.vpmsumd379}380 381