-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[MLIR][LLVMIR] Add elementtype attribute #129918
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
[MLIR][LLVMIR] Add elementtype attribute #129918
Conversation
These are very common when using intrinsics (e.g. ARM NEON). For more context: ClangIR has currently been blocked on such intrinsics emission because of this lacking capability.
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-llvm Author: Bruno Cardoso Lopes (bcardosolopes) ChangesThese are very common when using intrinsics (e.g. ARM NEON). For more context: ClangIR has currently been blocked on such intrinsics emission because of this lacking capability. Full diff: https://github.com/llvm/llvm-project/pull/129918.diff 5 Files Affected:
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.td
index b5526bda9f2de..3ea9b58039c98 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.td
@@ -44,6 +44,7 @@ def LLVM_Dialect : Dialect {
static StringRef getNoUndefAttrName() { return "llvm.noundef"; }
static StringRef getDereferenceableAttrName() { return "llvm.dereferenceable"; }
static StringRef getDereferenceableOrNullAttrName() { return "llvm.dereferenceable_or_null"; }
+ static StringRef getElementTypeAttrName() { return "llvm.element_type"; }
static StringRef getInAllocaAttrName() { return "llvm.inalloca"; }
static StringRef getInRegAttrName() { return "llvm.inreg"; }
static StringRef getNestAttrName() { return "llvm.nest"; }
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index d37f9f97fffe3..8a6325af201f4 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -3942,6 +3942,7 @@ LogicalResult LLVMDialect::verifyParameterAttribute(Operation *op,
if (name == LLVMDialect::getStructRetAttrName() ||
name == LLVMDialect::getByValAttrName() ||
name == LLVMDialect::getByRefAttrName() ||
+ name == LLVMDialect::getElementTypeAttrName() ||
name == LLVMDialect::getInAllocaAttrName() ||
name == LLVMDialect::getPreallocatedAttrName()) {
if (failed(checkTypeAttrType()))
diff --git a/mlir/lib/Target/LLVMIR/AttrKindDetail.h b/mlir/lib/Target/LLVMIR/AttrKindDetail.h
index 19ffc02aba3c6..051ed1edc4fd1 100644
--- a/mlir/lib/Target/LLVMIR/AttrKindDetail.h
+++ b/mlir/lib/Target/LLVMIR/AttrKindDetail.h
@@ -35,6 +35,8 @@ getAttrKindToNameMapping() {
LLVMDialect::getDereferenceableAttrName()},
{llvm::Attribute::AttrKind::DereferenceableOrNull,
LLVMDialect::getDereferenceableOrNullAttrName()},
+ {llvm::Attribute::AttrKind::ElementType,
+ LLVMDialect::getElementTypeAttrName()},
{llvm::Attribute::AttrKind::InAlloca, LLVMDialect::getInAllocaAttrName()},
{llvm::Attribute::AttrKind::InReg, LLVMDialect::getInRegAttrName()},
{llvm::Attribute::AttrKind::Nest, LLVMDialect::getNestAttrName()},
diff --git a/mlir/test/Dialect/LLVMIR/call-intrin.mlir b/mlir/test/Dialect/LLVMIR/call-intrin.mlir
index ea15ec2d5f654..def3be05feeb8 100644
--- a/mlir/test/Dialect/LLVMIR/call-intrin.mlir
+++ b/mlir/test/Dialect/LLVMIR/call-intrin.mlir
@@ -114,3 +114,12 @@ llvm.func @intrinsic_call_arg_attrs(%arg0: i32) -> i32 {
%0 = llvm.call_intrinsic "llvm.riscv.sha256sig0"(%arg0) : (i32 {llvm.signext}) -> (i32)
llvm.return %0 : i32
}
+
+// -----
+
+// CHECK-LABEL: intrinsic_element_type
+llvm.func @intrinsic_element_type(%arg0: !llvm.ptr) {
+ // CHECK: call i64 @llvm.aarch64.ldxr.p0(ptr elementtype(i8) %{{.*}})
+ %0 = llvm.call_intrinsic "llvm.aarch64.ldxr.p0"(%arg0) : (!llvm.ptr {llvm.element_type = i8}) -> i64
+ llvm.return
+}
diff --git a/mlir/test/Target/LLVMIR/Import/intrinsic-unregistered.ll b/mlir/test/Target/LLVMIR/Import/intrinsic-unregistered.ll
index 5afc29a5642fc..bd0803c3a04b3 100644
--- a/mlir/test/Target/LLVMIR/Import/intrinsic-unregistered.ll
+++ b/mlir/test/Target/LLVMIR/Import/intrinsic-unregistered.ll
@@ -9,7 +9,7 @@ define dso_local void @t0(ptr %a) {
; 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.call_intrinsic "llvm.aarch64.ldxr.p0"({{.*}}) : (!llvm.ptr {llvm.element_type = i8}) -> i64
; CHECK: llvm.return
; CHECK: }
|
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.
LGTM modulo nit naming comment.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/9111 Here is the relevant piece of the build log for the reference
|
These are very common when using intrinsics (e.g. ARM NEON). For more context: ClangIR has currently been blocked on such intrinsics emission because of this lacking capability.
These are very common when using intrinsics (e.g. ARM NEON).
For more context: ClangIR has currently been blocked on such intrinsics emission because of this lacking capability.