From 74e6a5b2a3b0e1992fb38c986b18f1aa7ca6fabd Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 13 Apr 2020 11:17:35 -0700 Subject: [PATCH] Eliminate all uses of Identifier::is() in the source tree, this doesn't remove the definition of it (yet). NFC. Reviewers: mravishankar, antiagainst, herhut, rriddle! Subscribers: jholewinski, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, bader, grosul1, frgossen, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78042 --- mlir/include/mlir/IR/Identifier.h | 13 +++++++++---- mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp | 6 +++--- mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp | 4 ++-- mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp | 5 ++--- mlir/lib/Dialect/GPU/IR/GPUDialect.cpp | 2 +- mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp | 4 ++-- mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp | 4 ++-- mlir/lib/IR/Attributes.cpp | 2 +- mlir/lib/IR/TypeUtilities.cpp | 2 +- mlir/test/lib/Dialect/Test/TestDialect.cpp | 2 +- mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp | 2 +- 11 files changed, 25 insertions(+), 21 deletions(-) diff --git a/mlir/include/mlir/IR/Identifier.h b/mlir/include/mlir/IR/Identifier.h index ce0f119..98a792a 100644 --- a/mlir/include/mlir/IR/Identifier.h +++ b/mlir/include/mlir/IR/Identifier.h @@ -83,10 +83,15 @@ inline raw_ostream &operator<<(raw_ostream &os, Identifier identifier) { } // Identifier/Identifier equality comparisons are defined inline. -inline bool operator==(Identifier lhs, StringRef rhs) { return lhs.is(rhs); } -inline bool operator!=(Identifier lhs, StringRef rhs) { return !lhs.is(rhs); } -inline bool operator==(StringRef lhs, Identifier rhs) { return rhs.is(lhs); } -inline bool operator!=(StringRef lhs, Identifier rhs) { return !rhs.is(lhs); } +inline bool operator==(Identifier lhs, StringRef rhs) { + return lhs.strref() == rhs; +} +inline bool operator!=(Identifier lhs, StringRef rhs) { return !(lhs == rhs); } + +inline bool operator==(StringRef lhs, Identifier rhs) { + return rhs.strref() == lhs; +} +inline bool operator!=(StringRef lhs, Identifier rhs) { return !(lhs == rhs); } // Make identifiers hashable. inline llvm::hash_code hash_value(Identifier arg) { diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp index 9391466..66a0a94 100644 --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -138,9 +138,9 @@ struct GPUFuncOpLowering : ConvertToLLVMPattern { // not specific to function modeling. SmallVector attributes; for (const auto &attr : gpuFuncOp.getAttrs()) { - if (attr.first.is(SymbolTable::getSymbolAttrName()) || - attr.first.is(impl::getTypeAttrName()) || - attr.first.is(gpu::GPUFuncOp::getNumWorkgroupAttributionsAttrName())) + if (attr.first == SymbolTable::getSymbolAttrName() || + attr.first == impl::getTypeAttrName() || + attr.first == gpu::GPUFuncOp::getNumWorkgroupAttributionsAttrName()) continue; attributes.push_back(attr); } diff --git a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp index 7636f20..14f6474 100644 --- a/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp @@ -329,8 +329,8 @@ lowerAsEntryFunction(gpu::GPUFuncOp funcOp, SPIRVTypeConverter &typeConverter, rewriter.getFunctionType(signatureConverter.getConvertedTypes(), llvm::None)); for (const auto &namedAttr : funcOp.getAttrs()) { - if (namedAttr.first.is(impl::getTypeAttrName()) || - namedAttr.first.is(SymbolTable::getSymbolAttrName())) + if (namedAttr.first == impl::getTypeAttrName() || + namedAttr.first == SymbolTable::getSymbolAttrName()) continue; newFuncOp.setAttr(namedAttr.first, namedAttr.second); } diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp index ea4f996..2f3fdd0 100644 --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -797,9 +797,8 @@ static void filterFuncAttributes(ArrayRef attrs, bool filterArgAttrs, SmallVectorImpl &result) { for (const auto &attr : attrs) { - if (attr.first.is(SymbolTable::getSymbolAttrName()) || - attr.first.is(impl::getTypeAttrName()) || - attr.first.is("std.varargs") || + if (attr.first == SymbolTable::getSymbolAttrName() || + attr.first == impl::getTypeAttrName() || attr.first == "std.varargs" || (filterArgAttrs && impl::isArgAttrName(attr.first.strref()))) continue; result.push_back(attr); diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp index e2434e3..69d2c35 100644 --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -44,7 +44,7 @@ GPUDialect::GPUDialect(MLIRContext *context) LogicalResult GPUDialect::verifyOperationAttribute(Operation *op, NamedAttribute attr) { if (!attr.second.isa() || - !attr.first.is(getContainerModuleAttrName())) + attr.first != getContainerModuleAttrName()) return success(); auto module = dyn_cast(op); diff --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp index cfd16c3..0f83412 100644 --- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp @@ -468,8 +468,8 @@ FuncOpConversion::matchAndRewrite(FuncOp funcOp, ArrayRef operands, // Copy over all attributes other than the function name and type. for (const auto &namedAttr : funcOp.getAttrs()) { - if (!namedAttr.first.is(impl::getTypeAttrName()) && - !namedAttr.first.is(SymbolTable::getSymbolAttrName())) + if (namedAttr.first != impl::getTypeAttrName() && + namedAttr.first != SymbolTable::getSymbolAttrName()) newFuncOp.setAttr(namedAttr.first, namedAttr.second); } diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp index b25a99c..b951f5a 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -827,7 +827,7 @@ LogicalResult Serializer::processVariableOp(spirv::VariableOp op) { operands); for (auto attr : op.getAttrs()) { if (llvm::any_of(elidedAttrs, - [&](StringRef elided) { return attr.first.is(elided); })) { + [&](StringRef elided) { return attr.first == elided; })) { continue; } if (failed(processDecoration(op.getLoc(), resultID, attr))) { @@ -895,7 +895,7 @@ Serializer::processGlobalVariableOp(spirv::GlobalVariableOp varOp) { // Encode decorations. for (auto attr : varOp.getAttrs()) { if (llvm::any_of(elidedAttrs, - [&](StringRef elided) { return attr.first.is(elided); })) { + [&](StringRef elided) { return attr.first == elided; })) { continue; } if (failed(processDecoration(varOp.getLoc(), resultID, attr))) { diff --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp index 6829e8a..daa5f9c 100644 --- a/mlir/lib/IR/Attributes.cpp +++ b/mlir/lib/IR/Attributes.cpp @@ -161,7 +161,7 @@ Attribute DictionaryAttr::get(StringRef name) const { return strncmp(attr.first.data(), name.data(), name.size()) < 0; }; auto it = llvm::lower_bound(values, name, compare); - return it != values.end() && it->first.is(name) ? it->second : Attribute(); + return it != values.end() && it->first == name ? it->second : Attribute(); } Attribute DictionaryAttr::get(Identifier name) const { for (auto elt : getValue()) diff --git a/mlir/lib/IR/TypeUtilities.cpp b/mlir/lib/IR/TypeUtilities.cpp index 9b689dc..3b69a0a 100644 --- a/mlir/lib/IR/TypeUtilities.cpp +++ b/mlir/lib/IR/TypeUtilities.cpp @@ -43,7 +43,7 @@ SmallVector mlir::getFlattenedTypes(TupleType t) { bool mlir::isOpaqueTypeWithName(Type type, StringRef dialect, StringRef typeData) { if (auto opaque = type.dyn_cast()) - return opaque.getDialectNamespace().is(dialect) && + return opaque.getDialectNamespace() == dialect && opaque.getTypeData() == typeData; return false; } diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp index 21941f0..fa99d47 100644 --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -408,7 +408,7 @@ static ParseResult parseStringAttrPrettyNameOp(OpAsmParser &parser, // If the attribute dictionary contains no 'names' attribute, infer it from // the SSA name (if specified). bool hadNames = llvm::any_of(result.attributes, [](NamedAttribute attr) { - return attr.first.is("names"); + return attr.first == "names"; }); // If there was no name specified, check to see if there was a useful name diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp index 509b551..fa0d78e 100644 --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -617,7 +617,7 @@ static void emitDecorationSerialization(const Operator &op, StringRef tabs, os << tabs << formatv("for (auto attr : {0}.getAttrs()) {{\n", opVar); os << tabs << formatv(" if (llvm::any_of({0}, [&](StringRef elided)", elidedAttrs); - os << " {return attr.first.is(elided);})) {\n"; + os << " {return attr.first == elided;})) {\n"; os << tabs << " continue;\n"; os << tabs << " }\n"; os << tabs -- 2.7.4