-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[MLIR][LLVMIR] Import unregistered intrinsics via llvm.intrinsic_call #128626
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
bcardosolopes
merged 11 commits into
llvm:main
from
bcardosolopes:llvm-dialect-unreg-intrin
Feb 26, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3896bb9
[MLIR][LLVMIR] Import unregistered intrinsics via llvm.intrinsic_call
bcardosolopes 17bad5a
Fix newlines
bcardosolopes 69239c9
Simplify and remove tablegen fine grained tracking
bcardosolopes bf15901
Update mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.cpp
bcardosolopes 69721c0
Update mlir/include/mlir/Target/LLVMIR/LLVMImportInterface.h
bcardosolopes a5ab682
Outdated comment and turn check+failure into assert
bcardosolopes bf5770a
Simplify logic further
bcardosolopes d602737
Update mlir/include/mlir/Target/LLVMIR/LLVMImportInterface.h
bcardosolopes c454af7
Update mlir/include/mlir/Target/LLVMIR/LLVMImportInterface.h
bcardosolopes 5ebd56a
Update mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.cpp
bcardosolopes 7e02345
Apply last round of reviews
bcardosolopes 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
; RUN: mlir-translate -import-llvm %s -split-input-file | FileCheck %s | ||
|
||
declare i64 @llvm.aarch64.ldxr.p0(ptr) | ||
|
||
define dso_local void @t0(ptr %a) { | ||
%x = call i64 @llvm.aarch64.ldxr.p0(ptr elementtype(i8) %a) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: llvm.func @llvm.aarch64.ldxr.p0(!llvm.ptr) | ||
; CHECK-LABEL: llvm.func @t0 | ||
; CHECK: llvm.call_intrinsic "llvm.aarch64.ldxr.p0"({{.*}}) : (!llvm.ptr) -> i64 | ||
; CHECK: llvm.return | ||
; CHECK: } | ||
|
||
; // ----- | ||
|
||
declare <8 x i8> @llvm.aarch64.neon.uabd.v8i8(<8 x i8>, <8 x i8>) | ||
|
||
define dso_local <8 x i8> @t1(<8 x i8> %lhs, <8 x i8> %rhs) { | ||
%r = call <8 x i8> @llvm.aarch64.neon.uabd.v8i8(<8 x i8> %lhs, <8 x i8> %rhs) | ||
ret <8 x i8> %r | ||
} | ||
|
||
; CHECK: llvm.func @t1(%[[A0:.*]]: vector<8xi8>, %[[A1:.*]]: vector<8xi8>) -> vector<8xi8> {{.*}} { | ||
; CHECK: %[[R:.*]] = llvm.call_intrinsic "llvm.aarch64.neon.uabd.v8i8"(%[[A0]], %[[A1]]) : (vector<8xi8>, vector<8xi8>) -> vector<8xi8> | ||
; CHECK: llvm.return %[[R]] : vector<8xi8> | ||
; CHECK: } | ||
|
||
; // ----- | ||
|
||
declare void @llvm.aarch64.neon.st2.v8i8.p0(<8 x i8>, <8 x i8>, ptr) | ||
|
||
define dso_local void @t2(<8 x i8> %lhs, <8 x i8> %rhs, ptr %a) { | ||
call void @llvm.aarch64.neon.st2.v8i8.p0(<8 x i8> %lhs, <8 x i8> %rhs, ptr %a) | ||
ret void | ||
} | ||
|
||
; CHECK: llvm.func @t2(%[[A0:.*]]: vector<8xi8>, %[[A1:.*]]: vector<8xi8>, %[[A2:.*]]: !llvm.ptr) {{.*}} { | ||
; CHECK: llvm.call_intrinsic "llvm.aarch64.neon.st2.v8i8.p0"(%[[A0]], %[[A1]], %[[A2]]) : (vector<8xi8>, vector<8xi8>, !llvm.ptr) -> !llvm.void | ||
; CHECK: llvm.return | ||
; CHECK: } | ||
|
||
; // ----- | ||
|
||
declare void @llvm.gcroot(ptr %arg1, ptr %arg2) | ||
define void @gctest() gc "example" { | ||
%arg1 = alloca ptr | ||
call void @llvm.gcroot(ptr %arg1, ptr null) | ||
ret void | ||
} | ||
|
||
; CHECK-LABEL: @gctest | ||
; CHECK: llvm.call_intrinsic "llvm.gcroot"({{.*}}, {{.*}}) : (!llvm.ptr, !llvm.ptr) -> !llvm.void | ||
|
||
; // ----- | ||
|
||
; Test we get the supported version, not the unregistered one. | ||
|
||
declare i32 @llvm.lround.i32.f32(float) | ||
|
||
; CHECK-LABEL: llvm.func @lround_test | ||
define void @lround_test(float %0, double %1) { | ||
; CHECK-NOT: llvm.call_intrinsic "llvm.lround | ||
; CHECK: llvm.intr.lround(%{{.*}}) : (f32) -> i32 | ||
%3 = call i32 @llvm.lround.i32.f32(float %0) | ||
ret void | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.