[Mlir-commits] [mlir] 74e6a5b - Eliminate all uses of Identifier::is() in the source tree, this doesn't remove the definition of it (yet). NFC.

Chris Lattner llvmlistbot at llvm.org
Mon Apr 13 11:49:38 PDT 2020


Author: Chris Lattner
Date: 2020-04-13T11:49:31-07:00
New Revision: 74e6a5b2a3b0e1992fb38c986b18f1aa7ca6fabd

URL: https://github.com/llvm/llvm-project/commit/74e6a5b2a3b0e1992fb38c986b18f1aa7ca6fabd
DIFF: https://github.com/llvm/llvm-project/commit/74e6a5b2a3b0e1992fb38c986b18f1aa7ca6fabd.diff

LOG: 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

Added: 
    

Modified: 
    mlir/include/mlir/IR/Identifier.h
    mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
    mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
    mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
    mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
    mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
    mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
    mlir/lib/IR/Attributes.cpp
    mlir/lib/IR/TypeUtilities.cpp
    mlir/test/lib/Dialect/Test/TestDialect.cpp
    mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/Identifier.h b/mlir/include/mlir/IR/Identifier.h
index ce0f119e71e0..98a792a32ea8 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 9391466ffdc9..66a0a94a499e 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<NamedAttribute, 4> 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 7636f207ab64..14f6474f95df 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 ea4f996a13b2..2f3fdd01059f 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -797,9 +797,8 @@ static void filterFuncAttributes(ArrayRef<NamedAttribute> attrs,
                                  bool filterArgAttrs,
                                  SmallVectorImpl<NamedAttribute> &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 e2434e380a9c..69d2c3562891 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<UnitAttr>() ||
-      !attr.first.is(getContainerModuleAttrName()))
+      attr.first != getContainerModuleAttrName())
     return success();
 
   auto module = dyn_cast<ModuleOp>(op);

diff  --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
index cfd16c38a0ab..0f83412f1962 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
@@ -468,8 +468,8 @@ FuncOpConversion::matchAndRewrite(FuncOp funcOp, ArrayRef<Value> 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 b25a99c61c05..b951f5afccfb 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 6829e8a82569..daa5f9c58fc6 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 9b689dc18adf..3b69a0aff831 100644
--- a/mlir/lib/IR/TypeUtilities.cpp
+++ b/mlir/lib/IR/TypeUtilities.cpp
@@ -43,7 +43,7 @@ SmallVector<Type, 10> mlir::getFlattenedTypes(TupleType t) {
 bool mlir::isOpaqueTypeWithName(Type type, StringRef dialect,
                                 StringRef typeData) {
   if (auto opaque = type.dyn_cast<mlir::OpaqueType>())
-    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 21941f0da606..fa99d472676c 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 509b55105b21..fa0d78e4ec44 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


        


More information about the Mlir-commits mailing list