1 // RUN: %clang_cc1 -ffreestanding -triple armv8 -target-cpu cortex-a57 -O -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch32 2 // RUN: %clang_cc1 -ffreestanding -triple aarch64 -target-cpu cortex-a57 -O -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 3 4 #include <arm_acle.h> 5 6 /* Miscellaneous data-processing intrinsics */ 7 // ARM-LABEL: test_rev 8 // ARM: call i32 @llvm.bswap.i32(i32 %t) 9 uint32_t test_rev(uint32_t t) { 10 return __rev(t); 11 } 12 13 // ARM-LABEL: test_revl 14 // AArch32: call i32 @llvm.bswap.i32(i32 %t) 15 // AArch64: call i64 @llvm.bswap.i64(i64 %t) 16 long test_revl(long t) { 17 return __revl(t); 18 } 19 20 // ARM-LABEL: test_revll 21 // ARM: call i64 @llvm.bswap.i64(i64 %t) 22 uint64_t test_revll(uint64_t t) { 23 return __revll(t); 24 } 25 26 // ARM-LABEL: test_clz 27 // ARM: call i32 @llvm.ctlz.i32(i32 %t, i1 false) 28 uint32_t test_clz(uint32_t t) { 29 return __clz(t); 30 } 31 32 // ARM-LABEL: test_clzl 33 // AArch32: call i32 @llvm.ctlz.i32(i32 %t, i1 false) 34 // AArch64: call i64 @llvm.ctlz.i64(i64 %t, i1 false) 35 long test_clzl(long t) { 36 return __clzl(t); 37 } 38 39 // ARM-LABEL: test_clzll 40 // ARM: call i64 @llvm.ctlz.i64(i64 %t, i1 false) 41 uint64_t test_clzll(uint64_t t) { 42 return __clzll(t); 43 } 44 45 /* Saturating intrinsics */ 46 #ifdef __ARM_32BIT_STATE 47 // AArch32-LABEL: test_ssat 48 // AArch32: call i32 @llvm.arm.ssat(i32 %t, i32 1) 49 int32_t test_ssat(int32_t t) { 50 return __ssat(t, 1); 51 } 52 53 // AArch32-LABEL: test_usat 54 // AArch32: call i32 @llvm.arm.usat(i32 %t, i32 2) 55 int32_t test_usat(int32_t t) { 56 return __usat(t, 2); 57 } 58 // AArch32-LABEL: test_qadd 59 // AArch32: call i32 @llvm.arm.qadd(i32 %a, i32 %b) 60 int32_t test_qadd(int32_t a, int32_t b) { 61 return __qadd(a, b); 62 } 63 64 // AArch32-LABEL: test_qsub 65 // AArch32: call i32 @llvm.arm.qsub(i32 %a, i32 %b) 66 int32_t test_qsub(int32_t a, int32_t b) { 67 return __qsub(a, b); 68 } 69 70 extern int32_t f(); 71 // AArch32-LABEL: test_qdbl 72 // AArch32: [[VAR:%[a-z0-9]+]] = {{.*}} call {{.*}} @f 73 // AArch32-NOT: call {{.*}} @f 74 // AArch32: call i32 @llvm.arm.qadd(i32 [[VAR]], i32 [[VAR]]) 75 int32_t test_qdbl() { 76 return __qdbl(f()); 77 } 78 #endif 79 80 /* CRC32 intrinsics */ 81 // ARM-LABEL: test_crc32b 82 // AArch32: call i32 @llvm.arm.crc32b 83 // AArch64: call i32 @llvm.aarch64.crc32b 84 uint32_t test_crc32b(uint32_t a, uint8_t b) { 85 return __crc32b(a, b); 86 } 87 88 // ARM-LABEL: test_crc32h 89 // AArch32: call i32 @llvm.arm.crc32h 90 // AArch64: call i32 @llvm.aarch64.crc32h 91 uint32_t test_crc32h(uint32_t a, uint16_t b) { 92 return __crc32h(a, b); 93 } 94 95 // ARM-LABEL: test_crc32w 96 // AArch32: call i32 @llvm.arm.crc32w 97 // AArch64: call i32 @llvm.aarch64.crc32w 98 uint32_t test_crc32w(uint32_t a, uint32_t b) { 99 return __crc32w(a, b); 100 } 101 102 // ARM-LABEL: test_crc32d 103 // AArch32: call i32 @llvm.arm.crc32w 104 // AArch32: call i32 @llvm.arm.crc32w 105 // AArch64: call i32 @llvm.aarch64.crc32x 106 uint32_t test_crc32d(uint32_t a, uint64_t b) { 107 return __crc32d(a, b); 108 } 109 110 // ARM-LABEL: test_crc32cb 111 // AArch32: call i32 @llvm.arm.crc32cb 112 // AArch64: call i32 @llvm.aarch64.crc32cb 113 uint32_t test_crc32cb(uint32_t a, uint8_t b) { 114 return __crc32cb(a, b); 115 } 116 117 // ARM-LABEL: test_crc32ch 118 // AArch32: call i32 @llvm.arm.crc32ch 119 // AArch64: call i32 @llvm.aarch64.crc32ch 120 uint32_t test_crc32ch(uint32_t a, uint16_t b) { 121 return __crc32ch(a, b); 122 } 123 124 // ARM-LABEL: test_crc32cw 125 // AArch32: call i32 @llvm.arm.crc32cw 126 // AArch64: call i32 @llvm.aarch64.crc32cw 127 uint32_t test_crc32cw(uint32_t a, uint32_t b) { 128 return __crc32cw(a, b); 129 } 130 131 // ARM-LABEL: test_crc32cd 132 // AArch32: call i32 @llvm.arm.crc32cw 133 // AArch32: call i32 @llvm.arm.crc32cw 134 // AArch64: call i32 @llvm.aarch64.crc32cx 135 uint32_t test_crc32cd(uint32_t a, uint64_t b) { 136 return __crc32cd(a, b); 137 } 138