Skip to content

[CIR][CIRGen][Builtin][NFC] Mirror X86 OG intrinsic test file structure #1732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/test/CIR/CodeGen/X86/avx-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
// 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
// RUN: FileCheck --check-prefixes=LLVM-CHECK,LLVM-X64 --input-file=%t.ll %s

// This test mimics clang/test/CodeGen/X86/avx-builtins.c, which eventually
// CIR shall be able to support fully.

#include <immintrin.h>

int test_mm256_extract_epi8(__m256i A) {
Expand Down
5 changes: 4 additions & 1 deletion clang/test/CIR/CodeGen/X86/bmi-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s

// This test mimics clang/test/CodeGen/X86/bmi-builtins.c, which eventually
// CIR shall be able to support fully.

#include <immintrin.h>

unsigned short test__tzcnt_u16(unsigned short __X) {
Expand All @@ -29,4 +32,4 @@ unsigned long long test__tzcnt_u64(unsigned long long __X) {
// CIR: {{%.*}} = cir.llvm.intrinsic "cttz" {{%.*}} : (!u64i, !cir.bool) -> !u64i
// LLVM: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
}
#endif
#endif
47 changes: 0 additions & 47 deletions clang/test/CIR/CodeGen/X86/builtins-x86.c

This file was deleted.

3 changes: 3 additions & 0 deletions clang/test/CIR/CodeGen/X86/lzcnt-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -fclangir -emit-llvm -o %t.ll %s
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s

// This test mimics clang/test/CodeGen/X86/lzcnt-builtins.c, which eventually
// CIR shall be able to support fully.

#include <immintrin.h>

unsigned int test_lzcnt_u32(unsigned int __X)
Expand Down
3 changes: 3 additions & 0 deletions clang/test/CIR/CodeGen/X86/mmx-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// 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
// RUN: FileCheck --check-prefix=LLVM-CHECK --implicit-check-not=x86mmx --input-file=%t.ll %s

// This test mimics clang/test/CodeGen/X86/mmx-builtins.c, which eventually
// CIR shall be able to support fully.

#include <immintrin.h>

int test_mm_extract_pi16(__m64 a) {
Expand Down
22 changes: 22 additions & 0 deletions clang/test/CIR/CodeGen/X86/pause.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -target-feature +sse2 -fclangir -emit-cir -o %t.cir %s
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -target-feature +sse2 -fclangir -emit-llvm -o %t.ll %s
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s

// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -target-feature -sse2 -fclangir -emit-cir -o %t.cir %s
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-linux -Wno-implicit-function-declaration -target-feature -sse2 -fclangir -emit-llvm -o %t.ll %s
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s

// This test mimics clang/test/CodeGen/X86/pause.c, which eventually
// CIR shall be able to support fully.

#include <x86intrin.h>

void test_mm_pause(void) {
// CIR-LABEL: test_mm_pause
// LLVM-LABEL: test_mm_pause
_mm_pause();
// CIR: {{%.*}} = cir.llvm.intrinsic "x86.sse2.pause" : () -> !void
// LLVM: call void @llvm.x86.sse2.pause()
}
3 changes: 1 addition & 2 deletions clang/test/CIR/CodeGen/X86/rd-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <x86intrin.h>

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

11 changes: 11 additions & 0 deletions clang/test/CIR/CodeGen/X86/sse-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// 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
// RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s

// This test mimics clang/test/CodeGen/X86/sse-builtins.c, which eventually
// CIR shall be able to support fully.

#include <immintrin.h>


Expand All @@ -18,3 +21,11 @@ void test_mm_prefetch(char const* p) {
// CIR: cir.prefetch(%{{.*}} : !cir.ptr<!void>) locality(0) read
// LLVM: call void @llvm.prefetch.p0(ptr {{.*}}, i32 0, i32 0, i32 1)
}

void test_mm_sfence(void) {
// CIR-LABEL: test_mm_sfence
// LLVM-LABEL: test_mm_sfence
_mm_sfence();
// CIR: {{%.*}} = cir.llvm.intrinsic "x86.sse.sfence" : () -> !void
// LLVM: call void @llvm.x86.sse.sfence()
}
27 changes: 27 additions & 0 deletions clang/test/CIR/CodeGen/X86/sse2-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,19 @@
// 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
// RUN: FileCheck --check-prefixes=LLVM-CHECK --input-file=%t.ll %s

// This test mimics clang/test/CodeGen/X86/sse2-builtins.c, which eventually
// CIR shall be able to support fully.

#include <immintrin.h>

void test_mm_clflush(void* A) {
// CIR-LABEL: test_mm_clflush
// LLVM-LABEL: test_mm_clflush
_mm_clflush(A);
// CIR-CHECK: {{%.*}} = cir.llvm.intrinsic "x86.sse2.clflush" {{%.*}} : (!cir.ptr<!void>) -> !void
// LLVM-CHECK: call void @llvm.x86.sse2.clflush(ptr {{%.*}})
}

// Lowering to pextrw requires optimization.
int test_mm_extract_epi16(__m128i A) {

Expand All @@ -22,3 +33,19 @@ int test_mm_extract_epi16(__m128i A) {
// LLVM-CHECK: zext i16 %{{.*}} to i32
return _mm_extract_epi16(A, 1);
}

void test_mm_lfence(void) {
// CIR-CHECK-LABEL: test_mm_lfence
// LLVM-CHECK-LABEL: test_mm_lfence
_mm_lfence();
// CIR-CHECK: {{%.*}} = cir.llvm.intrinsic "x86.sse2.lfence" : () -> !void
// LLVM-CHECK: call void @llvm.x86.sse2.lfence()
}

void test_mm_mfence(void) {
// CIR-CHECK-LABEL: test_mm_mfence
// LLVM-CHECK-LABEL: test_mm_mfence
_mm_mfence();
// CIR-CHECK: {{%.*}} = cir.llvm.intrinsic "x86.sse2.mfence" : () -> !void
// LLVM-CHECK: call void @llvm.x86.sse2.mfence()
}
2 changes: 2 additions & 0 deletions clang/test/CIR/CodeGen/X86/sse41-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// 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
// RUN: FileCheck --check-prefix=LLVM-CHECK --input-file=%t.ll %s

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

#include <immintrin.h>

Expand Down
5 changes: 4 additions & 1 deletion clang/test/CIR/CodeGen/X86/x86_64-xsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
// RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-linux -target-feature +xsave -target-feature +xsaves -fno-signed-char -fclangir -emit-llvm -o %t.ll -Wall -Wno-unused-but-set-variable -Werror
// RUN: FileCheck --check-prefix=LLVM-XSAVES --input-file=%t.ll %s

// This test mimics clang/test/CodeGen/X86/x86_64-xsave.c, which eventually
// CIR shall be able to support fully.

// Don't include mm_malloc.h, it's system specific.
#define __MM_MALLOC_H
#include <x86intrin.h>
Expand Down Expand Up @@ -333,4 +336,4 @@ void test(void) {
// LLVM-XSETBV: call void @llvm.x86.xsetbv
(void)_xsetbv(tmp_Ui, tmp_ULLi);
#endif
}
}
Loading