From 49162524d8251cdb5d954dcc90e96fe4210d0cec Mon Sep 17 00:00:00 2001 From: River Riddle Date: Tue, 25 Jun 2019 16:57:32 -0700 Subject: [PATCH] NFC: Uniformize the return of the LocationAttr 'get' methods to 'Location'. PiperOrigin-RevId: 255078768 --- mlir/examples/toy/Ch2/mlir/MLIRGen.cpp | 2 +- mlir/examples/toy/Ch3/mlir/MLIRGen.cpp | 2 +- mlir/examples/toy/Ch4/mlir/MLIRGen.cpp | 2 +- mlir/examples/toy/Ch5/mlir/MLIRGen.cpp | 2 +- mlir/include/mlir/IR/Builders.h | 6 +++--- mlir/include/mlir/IR/Location.h | 27 +++++++++++++-------------- mlir/lib/IR/Builders.cpp | 6 +++--- mlir/lib/IR/Location.cpp | 24 ++++++++++++------------ mlir/lib/IR/MLIRContext.cpp | 2 +- mlir/lib/SPIRV/Serialization/Deserializer.cpp | 2 +- mlir/lib/Transforms/DialectConversion.cpp | 2 +- mlir/lib/Transforms/StripDebugInfo.cpp | 2 +- 12 files changed, 39 insertions(+), 40 deletions(-) diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp index 1abcc97..f4ad20f 100644 --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -113,7 +113,7 @@ private: llvm::ScopedHashTable symbolTable; /// Helper conversion for a Toy AST location to an MLIR location. - mlir::FileLineColLoc loc(Location loc) { + mlir::Location loc(Location loc) { return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context), loc.line, loc.col, &context); } diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp index 1aa57c1..715f401 100644 --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -114,7 +114,7 @@ private: llvm::ScopedHashTable symbolTable; /// Helper conversion for a Toy AST location to an MLIR location. - mlir::FileLineColLoc loc(Location loc) { + mlir::Location loc(Location loc) { return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context), loc.line, loc.col, &context); } diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp index 16542e9..03049ed 100644 --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -114,7 +114,7 @@ private: llvm::ScopedHashTable symbolTable; /// Helper conversion for a Toy AST location to an MLIR location. - mlir::FileLineColLoc loc(Location loc) { + mlir::Location loc(Location loc) { return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context), loc.line, loc.col, &context); } diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp index 16542e9..03049ed 100644 --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -114,7 +114,7 @@ private: llvm::ScopedHashTable symbolTable; /// Helper conversion for a Toy AST location to an MLIR location. - mlir::FileLineColLoc loc(Location loc) { + mlir::Location loc(Location loc) { return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context), loc.line, loc.col, &context); } diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h index ce35336..b99f091 100644 --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -65,9 +65,9 @@ public: Module *createModule(); // Locations. - UnknownLoc getUnknownLoc(); - FileLineColLoc getFileLineColLoc(Identifier filename, unsigned line, - unsigned column); + Location getUnknownLoc(); + Location getFileLineColLoc(Identifier filename, unsigned line, + unsigned column); Location getFusedLoc(ArrayRef locs, Attribute metadata = Attribute()); diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h index 0209356..32fe0f4 100644 --- a/mlir/include/mlir/IR/Location.h +++ b/mlir/include/mlir/IR/Location.h @@ -109,14 +109,13 @@ public: using Base::Base; /// Return a uniqued call location object. - static CallSiteLoc get(Location callee, Location caller, - MLIRContext *context); + static Location get(Location callee, Location caller, MLIRContext *context); /// Return a call site location which represents a name reference in one line /// or a stack of frames. The input frames are ordered from innermost to /// outermost. - static CallSiteLoc get(Location name, ArrayRef frames, - MLIRContext *context); + static Location get(Location name, ArrayRef frames, + MLIRContext *context); /// The concrete location information this object presents. Location getCallee() const; @@ -140,10 +139,10 @@ public: using Base::Base; /// Return a uniqued FileLineCol location object. - static FileLineColLoc get(Identifier filename, unsigned line, unsigned column, - MLIRContext *context); - static FileLineColLoc get(StringRef filename, unsigned line, unsigned column, - MLIRContext *context); + static Location get(Identifier filename, unsigned line, unsigned column, + MLIRContext *context); + static Location get(StringRef filename, unsigned line, unsigned column, + MLIRContext *context); StringRef getFilename() const; @@ -166,9 +165,9 @@ public: /// Return a uniqued Fused Location object. The first location in the list /// will get precedence during diagnostic emission, with the rest being /// displayed as supplementary "fused from here" style notes. - static LocationAttr get(ArrayRef locs, Attribute metadata, - MLIRContext *context); - static LocationAttr get(ArrayRef locs, MLIRContext *context) { + static Location get(ArrayRef locs, Attribute metadata, + MLIRContext *context); + static Location get(ArrayRef locs, MLIRContext *context) { return get(locs, Attribute(), context); } @@ -192,10 +191,10 @@ public: /// Return a uniqued name location object. The child location must not be /// another NameLoc. - static NameLoc get(Identifier name, Location child, MLIRContext *context); + static Location get(Identifier name, Location child, MLIRContext *context); /// Return a uniqued name location object with an unknown child. - static NameLoc get(Identifier name, MLIRContext *context); + static Location get(Identifier name, MLIRContext *context); /// Return the name identifier. Identifier getName() const; @@ -216,7 +215,7 @@ public: using Base::Base; /// Get an instance of the UnknownLoc. - static UnknownLoc get(MLIRContext *context); + static Location get(MLIRContext *context); /// Methods for support type inquiry through isa, cast, and dyn_cast. static bool kindof(unsigned kind) { diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index e2c3a55..43e6a44f 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -38,10 +38,10 @@ Module *Builder::createModule() { return new Module(context); } // Locations. //===----------------------------------------------------------------------===// -UnknownLoc Builder::getUnknownLoc() { return UnknownLoc::get(context); } +Location Builder::getUnknownLoc() { return UnknownLoc::get(context); } -FileLineColLoc Builder::getFileLineColLoc(Identifier filename, unsigned line, - unsigned column) { +Location Builder::getFileLineColLoc(Identifier filename, unsigned line, + unsigned column) { return FileLineColLoc::get(filename, line, column, context); } diff --git a/mlir/lib/IR/Location.cpp b/mlir/lib/IR/Location.cpp index eae46fa..83b579c 100644 --- a/mlir/lib/IR/Location.cpp +++ b/mlir/lib/IR/Location.cpp @@ -26,14 +26,14 @@ using namespace mlir::detail; // CallSiteLoc //===----------------------------------------------------------------------===// -CallSiteLoc CallSiteLoc::get(Location callee, Location caller, - MLIRContext *context) { +Location CallSiteLoc::get(Location callee, Location caller, + MLIRContext *context) { return Base::get(context, StandardAttributes::CallSiteLocation, callee, caller); } -CallSiteLoc CallSiteLoc::get(Location name, ArrayRef frames, - MLIRContext *context) { +Location CallSiteLoc::get(Location name, ArrayRef frames, + MLIRContext *context) { assert(!frames.empty() && "required at least 1 frames"); Location caller = frames.back(); for (auto frame : llvm::reverse(frames.drop_back())) @@ -49,14 +49,14 @@ Location CallSiteLoc::getCaller() const { return getImpl()->caller; } // FileLineColLoc //===----------------------------------------------------------------------===// -FileLineColLoc FileLineColLoc::get(Identifier filename, unsigned line, - unsigned column, MLIRContext *context) { +Location FileLineColLoc::get(Identifier filename, unsigned line, + unsigned column, MLIRContext *context) { return Base::get(context, StandardAttributes::FileLineColLocation, filename, line, column); } -FileLineColLoc FileLineColLoc::get(StringRef filename, unsigned line, - unsigned column, MLIRContext *context) { +Location FileLineColLoc::get(StringRef filename, unsigned line, unsigned column, + MLIRContext *context) { return get(Identifier::get(filename.empty() ? "-" : filename, context), line, column, context); } @@ -69,8 +69,8 @@ unsigned FileLineColLoc::getColumn() const { return getImpl()->column; } // FusedLoc //===----------------------------------------------------------------------===// -LocationAttr FusedLoc::get(ArrayRef locs, Attribute metadata, - MLIRContext *context) { +Location FusedLoc::get(ArrayRef locs, Attribute metadata, + MLIRContext *context) { // Unique the set of locations to be fused. llvm::SmallSetVector decomposedLocs; for (auto loc : locs) { @@ -109,13 +109,13 @@ Attribute FusedLoc::getMetadata() const { return getImpl()->metadata; } // NameLoc //===----------------------------------------------------------------------===// -NameLoc NameLoc::get(Identifier name, Location child, MLIRContext *context) { +Location NameLoc::get(Identifier name, Location child, MLIRContext *context) { assert(!child.isa() && "a NameLoc cannot be used as a child of another NameLoc"); return Base::get(context, StandardAttributes::NameLocation, name, child); } -NameLoc NameLoc::get(Identifier name, MLIRContext *context) { +Location NameLoc::get(Identifier name, MLIRContext *context) { return get(name, UnknownLoc::get(context), context); } diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp index 04a01c4..63206c3 100644 --- a/mlir/lib/IR/MLIRContext.cpp +++ b/mlir/lib/IR/MLIRContext.cpp @@ -592,7 +592,7 @@ UnitAttr UnitAttr::get(MLIRContext *context) { return context->getImpl().unitAttr; } -UnknownLoc UnknownLoc::get(MLIRContext *context) { +Location UnknownLoc::get(MLIRContext *context) { return context->getImpl().unknownLocAttr; } diff --git a/mlir/lib/SPIRV/Serialization/Deserializer.cpp b/mlir/lib/SPIRV/Serialization/Deserializer.cpp index 8341c88..f55805d 100644 --- a/mlir/lib/SPIRV/Serialization/Deserializer.cpp +++ b/mlir/lib/SPIRV/Serialization/Deserializer.cpp @@ -77,7 +77,7 @@ private: MLIRContext *context; // TODO(antiagainst): create Location subclass for binary blob - UnknownLoc unknownLoc; + Location unknownLoc; /// The SPIR-V ModuleOp. Optional module; diff --git a/mlir/lib/Transforms/DialectConversion.cpp b/mlir/lib/Transforms/DialectConversion.cpp index fee08e4..673544d 100644 --- a/mlir/lib/Transforms/DialectConversion.cpp +++ b/mlir/lib/Transforms/DialectConversion.cpp @@ -89,7 +89,7 @@ struct ArgConverter { /// An instance of the unknown location that is used when generating /// producers. - UnknownLoc loc; + Location loc; }; constexpr StringLiteral ArgConverter::kCastName; diff --git a/mlir/lib/Transforms/StripDebugInfo.cpp b/mlir/lib/Transforms/StripDebugInfo.cpp index 1691976..f97f549 100644 --- a/mlir/lib/Transforms/StripDebugInfo.cpp +++ b/mlir/lib/Transforms/StripDebugInfo.cpp @@ -30,7 +30,7 @@ struct StripDebugInfo : public FunctionPass { void StripDebugInfo::runOnFunction() { Function &func = getFunction(); - UnknownLoc unknownLoc = UnknownLoc::get(&getContext()); + auto unknownLoc = UnknownLoc::get(&getContext()); // Strip the debug info from the function and its operations. func.setLoc(unknownLoc); -- 2.7.4