Skip to content

Commit f9d47e9

Browse files
authored
[CIR][CIRGen][Builtin][NFC] Mirror X86 OG intrinsic test file structure (#1732)
just a few improvements to mirror og test cases in x86 for better reference.
1 parent 33c739f commit f9d47e9

File tree

11 files changed

+80
-51
lines changed

11 files changed

+80
-51
lines changed

clang/test/CIR/CodeGen/X86/avx-builtins.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx -fno-signed-char -fclangir -emit-llvm -o %t.ll -Wall -Werror
1919
// RUN: FileCheck --check-prefixes=LLVM-CHECK,LLVM-X64 --input-file=%t.ll %s
2020

21+
// This test mimics clang/test/CodeGen/X86/avx-builtins.c, which eventually
22+
// CIR shall be able to support fully.
23+
2124
#include <immintrin.h>
2225

2326
int test_mm256_extract_epi8(__m256i A) {

clang/test/CIR/CodeGen/X86/bmi-builtins.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s
44
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
55

6+
// This test mimics clang/test/CodeGen/X86/bmi-builtins.c, which eventually
7+
// CIR shall be able to support fully.
8+
69
#include <immintrin.h>
710

811
unsigned short test__tzcnt_u16(unsigned short __X) {
@@ -29,4 +32,4 @@ unsigned long long test__tzcnt_u64(unsigned long long __X) {
2932
// CIR: {{%.*}} = cir.llvm.intrinsic "cttz" {{%.*}} : (!u64i, !cir.bool) -> !u64i
3033
// LLVM: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
3134
}
32-
#endif
35+
#endif

clang/test/CIR/CodeGen/X86/builtins-x86.c

Lines changed: 0 additions & 47 deletions
This file was deleted.

clang/test/CIR/CodeGen/X86/lzcnt-builtins.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s
44
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
55

6+
// This test mimics clang/test/CodeGen/X86/lzcnt-builtins.c, which eventually
7+
// CIR shall be able to support fully.
8+
69
#include <immintrin.h>
710

811
unsigned int test_lzcnt_u32(unsigned int __X)

clang/test/CIR/CodeGen/X86/mmx-builtins.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +ssse3 -fno-signed-char -fclangir -emit-llvm -o %t.ll -Wall -Werror
99
// RUN: FileCheck --check-prefix=LLVM-CHECK --implicit-check-not=x86mmx --input-file=%t.ll %s
1010

11+
// This test mimics clang/test/CodeGen/X86/mmx-builtins.c, which eventually
12+
// CIR shall be able to support fully.
13+
1114
#include <immintrin.h>
1215

1316
int test_mm_extract_pi16(__m64 a) {

clang/test/CIR/CodeGen/X86/pause.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -target-feature +sse2 -fclangir -emit-cir -o %t.cir %s
2+
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3+
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -target-feature +sse2 -fclangir -emit-llvm -o %t.ll %s
4+
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
5+
6+
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -target-feature -sse2 -fclangir -emit-cir -o %t.cir %s
7+
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
8+
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -target-feature -sse2 -fclangir -emit-llvm -o %t.ll %s
9+
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
10+
11+
// This test mimics clang/test/CodeGen/X86/pause.c, which eventually
12+
// CIR shall be able to support fully.
13+
14+
#include <x86intrin.h>
15+
16+
void test_mm_pause(void) {
17+
// CIR-LABEL: test_mm_pause
18+
// LLVM-LABEL: test_mm_pause
19+
_mm_pause();
20+
// CIR: {{%.*}} = cir.llvm.intrinsic "x86.sse2.pause" : () -> !void
21+
// LLVM: call void @llvm.x86.sse2.pause()
22+
}

clang/test/CIR/CodeGen/X86/rd-builtins.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#include <x86intrin.h>
1010

11-
unsigned long long test_rdtsc() {
11+
int test_rdtsc(void) {
1212
// CIR-LABEL: @test_rdtsc
1313
// LLVM-LABEL: @test_rdtsc
1414
return __rdtsc();
@@ -32,4 +32,3 @@ unsigned long long test_rdtscp(unsigned int *a) {
3232
// LLVM: store i32 [[TSC_AUX]], ptr %{{.*}}
3333
// LLVM: [[TSC:%.*]] = extractvalue { i64, i32 } [[RDTSCP]], 0
3434
}
35-

clang/test/CIR/CodeGen/X86/sse-builtins.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -fclangir -emit-llvm -o %t.ll -Wall -Werror
99
// RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
1010

11+
// This test mimics clang/test/CodeGen/X86/sse-builtins.c, which eventually
12+
// CIR shall be able to support fully.
13+
1114
#include <immintrin.h>
1215

1316

@@ -18,3 +21,11 @@ void test_mm_prefetch(char const* p) {
1821
// CIR: cir.prefetch(%{{.*}} : !cir.ptr<!void>) locality(0) read
1922
// LLVM: call void @llvm.prefetch.p0(ptr {{.*}}, i32 0, i32 0, i32 1)
2023
}
24+
25+
void test_mm_sfence(void) {
26+
// CIR-LABEL: test_mm_sfence
27+
// LLVM-LABEL: test_mm_sfence
28+
_mm_sfence();
29+
// CIR: {{%.*}} = cir.llvm.intrinsic "x86.sse.sfence" : () -> !void
30+
// LLVM: call void @llvm.x86.sse.sfence()
31+
}

clang/test/CIR/CodeGen/X86/sse2-builtins.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,19 @@
88
// RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse2 -fno-signed-char -fclangir -emit-llvm -o %t.ll -Wall -Werror
99
// RUN: FileCheck --check-prefixes=LLVM-CHECK --input-file=%t.ll %s
1010

11+
// This test mimics clang/test/CodeGen/X86/sse2-builtins.c, which eventually
12+
// CIR shall be able to support fully.
13+
1114
#include <immintrin.h>
1215

16+
void test_mm_clflush(void* A) {
17+
// CIR-LABEL: test_mm_clflush
18+
// LLVM-LABEL: test_mm_clflush
19+
_mm_clflush(A);
20+
// CIR-CHECK: {{%.*}} = cir.llvm.intrinsic "x86.sse2.clflush" {{%.*}} : (!cir.ptr<!void>) -> !void
21+
// LLVM-CHECK: call void @llvm.x86.sse2.clflush(ptr {{%.*}})
22+
}
23+
1324
// Lowering to pextrw requires optimization.
1425
int test_mm_extract_epi16(__m128i A) {
1526

@@ -22,3 +33,19 @@ int test_mm_extract_epi16(__m128i A) {
2233
// LLVM-CHECK: zext i16 %{{.*}} to i32
2334
return _mm_extract_epi16(A, 1);
2435
}
36+
37+
void test_mm_lfence(void) {
38+
// CIR-CHECK-LABEL: test_mm_lfence
39+
// LLVM-CHECK-LABEL: test_mm_lfence
40+
_mm_lfence();
41+
// CIR-CHECK: {{%.*}} = cir.llvm.intrinsic "x86.sse2.lfence" : () -> !void
42+
// LLVM-CHECK: call void @llvm.x86.sse2.lfence()
43+
}
44+
45+
void test_mm_mfence(void) {
46+
// CIR-CHECK-LABEL: test_mm_mfence
47+
// LLVM-CHECK-LABEL: test_mm_mfence
48+
_mm_mfence();
49+
// CIR-CHECK: {{%.*}} = cir.llvm.intrinsic "x86.sse2.mfence" : () -> !void
50+
// LLVM-CHECK: call void @llvm.x86.sse2.mfence()
51+
}

clang/test/CIR/CodeGen/X86/sse41-builtins.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse4.1 -fno-signed-char -fclangir -emit-llvm -o %t.ll -Wall -Werror
99
// RUN: FileCheck --check-prefix=LLVM-CHECK --input-file=%t.ll %s
1010

11+
// This test mimics clang/test/CodeGen/X86/sse41-builtins.c, which eventually
12+
// CIR shall be able to support fully.
1113

1214
#include <immintrin.h>
1315

0 commit comments

Comments
 (0)