[Mlir-commits] [mlir] 67cc5ce - [mlir][llvm] Expose getters for alias and align attribute names
Stephan Herhut
llvmlistbot at llvm.org
Wed Nov 11 00:41:00 PST 2020
Author: Stephan Herhut
Date: 2020-11-11T09:38:08+01:00
New Revision: 67cc5cec774d9881926fd0bbb9e2f68596e55300
URL: https://github.com/llvm/llvm-project/commit/67cc5cec774d9881926fd0bbb9e2f68596e55300
DIFF: https://github.com/llvm/llvm-project/commit/67cc5cec774d9881926fd0bbb9e2f68596e55300.diff
LOG: [mlir][llvm] Expose getters for alias and align attribute names
This adds getters for `llvm.align` and `llvm.noalias` strings that are used
as attribute names in the llvm dialect.
Differential Revision: https://reviews.llvm.org/D91166
Added:
Modified:
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
index 5530c5dd0f99..58dc908183f6 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
@@ -30,6 +30,8 @@ def LLVM_Dialect : Dialect {
let extraClassDeclaration = [{
/// Name of the data layout attributes.
static StringRef getDataLayoutAttrName() { return "llvm.data_layout"; }
+ static StringRef getAlignAttrName() { return "llvm.align"; }
+ static StringRef getNoAliasAttrName() { return "llvm.noalias"; }
/// Verifies if the given string is a well-formed data layout descriptor.
/// Uses `reportError` to report errors.
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index e67f09f9c167..5cdb8f326d41 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -1833,11 +1833,13 @@ LogicalResult LLVMDialect::verifyRegionArgAttribute(Operation *op,
unsigned argIdx,
NamedAttribute argAttr) {
// Check that llvm.noalias is a boolean attribute.
- if (argAttr.first == "llvm.noalias" && !argAttr.second.isa<BoolAttr>())
+ if (argAttr.first == LLVMDialect::getNoAliasAttrName() &&
+ !argAttr.second.isa<BoolAttr>())
return op->emitError()
<< "llvm.noalias argument attribute of non boolean type";
// Check that llvm.align is an integer attribute.
- if (argAttr.first == "llvm.align" && !argAttr.second.isa<IntegerAttr>())
+ if (argAttr.first == LLVMDialect::getAlignAttrName() &&
+ !argAttr.second.isa<IntegerAttr>())
return op->emitError()
<< "llvm.align argument attribute of non integer type";
return success();
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index f8c49e743b2a..a275c83e61e2 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -823,7 +823,8 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
llvm::Argument &llvmArg = std::get<1>(kvp);
BlockArgument mlirArg = std::get<0>(kvp);
- if (auto attr = func.getArgAttrOfType<BoolAttr>(argIdx, "llvm.noalias")) {
+ if (auto attr = func.getArgAttrOfType<BoolAttr>(
+ argIdx, LLVMDialect::getNoAliasAttrName())) {
// NB: Attribute already verified to be boolean, so check if we can indeed
// attach the attribute to this argument, based on its type.
auto argTy = mlirArg.getType().dyn_cast<LLVM::LLVMType>();
@@ -834,7 +835,8 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
llvmArg.addAttr(llvm::Attribute::AttrKind::NoAlias);
}
- if (auto attr = func.getArgAttrOfType<IntegerAttr>(argIdx, "llvm.align")) {
+ if (auto attr = func.getArgAttrOfType<IntegerAttr>(
+ argIdx, LLVMDialect::getAlignAttrName())) {
// NB: Attribute already verified to be int, so check if we can indeed
// attach the attribute to this argument, based on its type.
auto argTy = mlirArg.getType().dyn_cast<LLVM::LLVMType>();
More information about the Mlir-commits
mailing list