Skip to content

[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

Merged
merged 2 commits into from
Mar 5, 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
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.td
Original file line number Diff line number Diff line change
Expand Up @@ -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.elementtype"; }
static StringRef getInAllocaAttrName() { return "llvm.inalloca"; }
static StringRef getInRegAttrName() { return "llvm.inreg"; }
static StringRef getNestAttrName() { return "llvm.nest"; }
Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
2 changes: 2 additions & 0 deletions mlir/lib/Target/LLVMIR/AttrKindDetail.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()},
Expand Down
9 changes: 9 additions & 0 deletions mlir/test/Dialect/LLVMIR/call-intrin.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -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.elementtype = i8}) -> i64
llvm.return
}
2 changes: 1 addition & 1 deletion mlir/test/Target/LLVMIR/Import/intrinsic-unregistered.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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.elementtype = i8}) -> i64
; CHECK: llvm.return
; CHECK: }

Expand Down