-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[CIR] Upstream X86 builtin clflush, fence and pause #167401
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
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
539eebe
[CIR] Upstream X86 builtin _mm_prefetch and _mm_clflush
HendrikHuebner de47432
fix warning
HendrikHuebner 26d8914
Update clang/include/clang/CIR/Dialect/IR/CIROps.td
HendrikHuebner 93c0ded
feedback
HendrikHuebner 9eb5199
formatting
HendrikHuebner 776f5c1
formatting + refactor
HendrikHuebner 8a07992
Remove prefetch builtin and address feedback
HendrikHuebner e481360
formatting
HendrikHuebner a665f70
Improve tests
HendrikHuebner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -fclangir -emit-cir -o %t.cir -Wall -Werror | ||
| // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s | ||
| // 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 | ||
|
|
||
| // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -fno-signed-char -fclangir -emit-cir -o %t.cir -Wall -Werror | ||
| // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s | ||
| // 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 | ||
|
|
||
| // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG | ||
| // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG | ||
|
|
||
| // This test mimics clang/test/CodeGen/X86/sse-builtins.c, which eventually | ||
| // CIR shall be able to support fully. | ||
|
|
||
| #include <immintrin.h> | ||
|
|
||
|
|
||
| void test_mm_sfence(void) { | ||
| // CIR-LABEL: test_mm_sfence | ||
| // LLVM-LABEL: test_mm_sfence | ||
| // OGCG-LABEL: test_mm_sfence | ||
| _mm_sfence(); | ||
| // CIR: {{%.*}} = cir.call_llvm_intrinsic "x86.sse.sfence" : () -> !void | ||
| // LLVM: call void @llvm.x86.sse.sfence() | ||
| // OGCG: call void @llvm.x86.sse.sfence() | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse2 -fclangir -emit-cir -o %t.cir -Wall -Werror | ||
| // RUN: FileCheck --check-prefixes=CIR --input-file=%t.cir %s | ||
| // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse2 -fno-signed-char -fclangir -emit-cir -o %t.cir -Wall -Werror | ||
| // RUN: FileCheck --check-prefixes=CIR --input-file=%t.cir %s | ||
|
|
||
| // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse2 -fclangir -emit-llvm -o %t.ll -Wall -Werror | ||
| // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s | ||
| // 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 --input-file=%t.ll %s | ||
|
|
||
| // RUN: %clang_cc1 -x c -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG | ||
| // RUN: %clang_cc1 -x c++ -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s -check-prefix=OGCG | ||
|
|
||
| // 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 | ||
| // OGCG-LABEL: test_mm_clflush | ||
| _mm_clflush(A); | ||
| // CIR: {{%.*}} = cir.call_llvm_intrinsic "x86.sse2.clflush" {{%.*}} : (!cir.ptr<!void>) -> !void | ||
| // LLVM: call void @llvm.x86.sse2.clflush(ptr {{%.*}}) | ||
| // OGCG: call void @llvm.x86.sse2.clflush(ptr {{%.*}}) | ||
| } | ||
|
|
||
| void test_mm_lfence(void) { | ||
| // CIR-LABEL: test_mm_lfence | ||
| // LLVM-LABEL: test_mm_lfence | ||
| // OGCG-LABEL: test_mm_lfence | ||
| _mm_lfence(); | ||
| // CIR: {{%.*}} = cir.call_llvm_intrinsic "x86.sse2.lfence" : () -> !void | ||
| // LLVM: call void @llvm.x86.sse2.lfence() | ||
| // OGCG: call void @llvm.x86.sse2.lfence() | ||
| } | ||
|
|
||
| void test_mm_mfence(void) { | ||
| // CIR-LABEL: test_mm_mfence | ||
| // LLVM-LABEL: test_mm_mfence | ||
| // OGCG-LABEL: test_mm_mfence | ||
| _mm_mfence(); | ||
| // CIR: {{%.*}} = cir.call_llvm_intrinsic "x86.sse2.mfence" : () -> !void | ||
| // LLVM: call void @llvm.x86.sse2.mfence() | ||
| // OGCG: call void @llvm.x86.sse2.mfence() | ||
| } | ||
|
|
||
| void test_mm_pause(void) { | ||
| // CIR-LABEL: test_mm_pause | ||
| // LLVM-LABEL: test_mm_pause | ||
| // OGCG-LABEL: test_mm_pause | ||
| _mm_pause(); | ||
| // CIR: {{%.*}} = cir.call_llvm_intrinsic "x86.sse2.pause" : () -> !void | ||
| // LLVM: call void @llvm.x86.sse2.pause() | ||
| // OGCG: call void @llvm.x86.sse2.pause() | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add the OGCG checks. It's useful to manually verify that we're generating equivalent code.