forked from OSchip/llvm-project
NFC: Uniformize the return of the LocationAttr 'get' methods to 'Location'.
PiperOrigin-RevId: 255078768
This commit is contained in:
parent
4842b2d42e
commit
49162524d8
|
@ -113,7 +113,7 @@ private:
|
||||||
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
|
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
|
||||||
|
|
||||||
/// Helper conversion for a Toy AST location to an MLIR location.
|
/// 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),
|
return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context),
|
||||||
loc.line, loc.col, &context);
|
loc.line, loc.col, &context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ private:
|
||||||
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
|
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
|
||||||
|
|
||||||
/// Helper conversion for a Toy AST location to an MLIR location.
|
/// 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),
|
return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context),
|
||||||
loc.line, loc.col, &context);
|
loc.line, loc.col, &context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ private:
|
||||||
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
|
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
|
||||||
|
|
||||||
/// Helper conversion for a Toy AST location to an MLIR location.
|
/// 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),
|
return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context),
|
||||||
loc.line, loc.col, &context);
|
loc.line, loc.col, &context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ private:
|
||||||
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
|
llvm::ScopedHashTable<StringRef, mlir::Value *> symbolTable;
|
||||||
|
|
||||||
/// Helper conversion for a Toy AST location to an MLIR location.
|
/// 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),
|
return mlir::FileLineColLoc::get(mlir::Identifier::get(*loc.file, &context),
|
||||||
loc.line, loc.col, &context);
|
loc.line, loc.col, &context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,9 @@ public:
|
||||||
Module *createModule();
|
Module *createModule();
|
||||||
|
|
||||||
// Locations.
|
// Locations.
|
||||||
UnknownLoc getUnknownLoc();
|
Location getUnknownLoc();
|
||||||
FileLineColLoc getFileLineColLoc(Identifier filename, unsigned line,
|
Location getFileLineColLoc(Identifier filename, unsigned line,
|
||||||
unsigned column);
|
unsigned column);
|
||||||
Location getFusedLoc(ArrayRef<Location> locs,
|
Location getFusedLoc(ArrayRef<Location> locs,
|
||||||
Attribute metadata = Attribute());
|
Attribute metadata = Attribute());
|
||||||
|
|
||||||
|
|
|
@ -109,14 +109,13 @@ public:
|
||||||
using Base::Base;
|
using Base::Base;
|
||||||
|
|
||||||
/// Return a uniqued call location object.
|
/// Return a uniqued call location object.
|
||||||
static CallSiteLoc get(Location callee, Location caller,
|
static Location get(Location callee, Location caller, MLIRContext *context);
|
||||||
MLIRContext *context);
|
|
||||||
|
|
||||||
/// Return a call site location which represents a name reference in one line
|
/// 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
|
/// or a stack of frames. The input frames are ordered from innermost to
|
||||||
/// outermost.
|
/// outermost.
|
||||||
static CallSiteLoc get(Location name, ArrayRef<Location> frames,
|
static Location get(Location name, ArrayRef<Location> frames,
|
||||||
MLIRContext *context);
|
MLIRContext *context);
|
||||||
|
|
||||||
/// The concrete location information this object presents.
|
/// The concrete location information this object presents.
|
||||||
Location getCallee() const;
|
Location getCallee() const;
|
||||||
|
@ -140,10 +139,10 @@ public:
|
||||||
using Base::Base;
|
using Base::Base;
|
||||||
|
|
||||||
/// Return a uniqued FileLineCol location object.
|
/// Return a uniqued FileLineCol location object.
|
||||||
static FileLineColLoc get(Identifier filename, unsigned line, unsigned column,
|
static Location get(Identifier filename, unsigned line, unsigned column,
|
||||||
MLIRContext *context);
|
MLIRContext *context);
|
||||||
static FileLineColLoc get(StringRef filename, unsigned line, unsigned column,
|
static Location get(StringRef filename, unsigned line, unsigned column,
|
||||||
MLIRContext *context);
|
MLIRContext *context);
|
||||||
|
|
||||||
StringRef getFilename() const;
|
StringRef getFilename() const;
|
||||||
|
|
||||||
|
@ -166,9 +165,9 @@ public:
|
||||||
/// Return a uniqued Fused Location object. The first location in the list
|
/// Return a uniqued Fused Location object. The first location in the list
|
||||||
/// will get precedence during diagnostic emission, with the rest being
|
/// will get precedence during diagnostic emission, with the rest being
|
||||||
/// displayed as supplementary "fused from here" style notes.
|
/// displayed as supplementary "fused from here" style notes.
|
||||||
static LocationAttr get(ArrayRef<Location> locs, Attribute metadata,
|
static Location get(ArrayRef<Location> locs, Attribute metadata,
|
||||||
MLIRContext *context);
|
MLIRContext *context);
|
||||||
static LocationAttr get(ArrayRef<Location> locs, MLIRContext *context) {
|
static Location get(ArrayRef<Location> locs, MLIRContext *context) {
|
||||||
return get(locs, Attribute(), context);
|
return get(locs, Attribute(), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,10 +191,10 @@ public:
|
||||||
|
|
||||||
/// Return a uniqued name location object. The child location must not be
|
/// Return a uniqued name location object. The child location must not be
|
||||||
/// another NameLoc.
|
/// 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.
|
/// 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.
|
/// Return the name identifier.
|
||||||
Identifier getName() const;
|
Identifier getName() const;
|
||||||
|
@ -216,7 +215,7 @@ public:
|
||||||
using Base::Base;
|
using Base::Base;
|
||||||
|
|
||||||
/// Get an instance of the UnknownLoc.
|
/// 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.
|
/// Methods for support type inquiry through isa, cast, and dyn_cast.
|
||||||
static bool kindof(unsigned kind) {
|
static bool kindof(unsigned kind) {
|
||||||
|
|
|
@ -38,10 +38,10 @@ Module *Builder::createModule() { return new Module(context); }
|
||||||
// Locations.
|
// Locations.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
UnknownLoc Builder::getUnknownLoc() { return UnknownLoc::get(context); }
|
Location Builder::getUnknownLoc() { return UnknownLoc::get(context); }
|
||||||
|
|
||||||
FileLineColLoc Builder::getFileLineColLoc(Identifier filename, unsigned line,
|
Location Builder::getFileLineColLoc(Identifier filename, unsigned line,
|
||||||
unsigned column) {
|
unsigned column) {
|
||||||
return FileLineColLoc::get(filename, line, column, context);
|
return FileLineColLoc::get(filename, line, column, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,14 +26,14 @@ using namespace mlir::detail;
|
||||||
// CallSiteLoc
|
// CallSiteLoc
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
CallSiteLoc CallSiteLoc::get(Location callee, Location caller,
|
Location CallSiteLoc::get(Location callee, Location caller,
|
||||||
MLIRContext *context) {
|
MLIRContext *context) {
|
||||||
return Base::get(context, StandardAttributes::CallSiteLocation, callee,
|
return Base::get(context, StandardAttributes::CallSiteLocation, callee,
|
||||||
caller);
|
caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallSiteLoc CallSiteLoc::get(Location name, ArrayRef<Location> frames,
|
Location CallSiteLoc::get(Location name, ArrayRef<Location> frames,
|
||||||
MLIRContext *context) {
|
MLIRContext *context) {
|
||||||
assert(!frames.empty() && "required at least 1 frames");
|
assert(!frames.empty() && "required at least 1 frames");
|
||||||
Location caller = frames.back();
|
Location caller = frames.back();
|
||||||
for (auto frame : llvm::reverse(frames.drop_back()))
|
for (auto frame : llvm::reverse(frames.drop_back()))
|
||||||
|
@ -49,14 +49,14 @@ Location CallSiteLoc::getCaller() const { return getImpl()->caller; }
|
||||||
// FileLineColLoc
|
// FileLineColLoc
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
FileLineColLoc FileLineColLoc::get(Identifier filename, unsigned line,
|
Location FileLineColLoc::get(Identifier filename, unsigned line,
|
||||||
unsigned column, MLIRContext *context) {
|
unsigned column, MLIRContext *context) {
|
||||||
return Base::get(context, StandardAttributes::FileLineColLocation, filename,
|
return Base::get(context, StandardAttributes::FileLineColLocation, filename,
|
||||||
line, column);
|
line, column);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLineColLoc FileLineColLoc::get(StringRef filename, unsigned line,
|
Location FileLineColLoc::get(StringRef filename, unsigned line, unsigned column,
|
||||||
unsigned column, MLIRContext *context) {
|
MLIRContext *context) {
|
||||||
return get(Identifier::get(filename.empty() ? "-" : filename, context), line,
|
return get(Identifier::get(filename.empty() ? "-" : filename, context), line,
|
||||||
column, context);
|
column, context);
|
||||||
}
|
}
|
||||||
|
@ -69,8 +69,8 @@ unsigned FileLineColLoc::getColumn() const { return getImpl()->column; }
|
||||||
// FusedLoc
|
// FusedLoc
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
LocationAttr FusedLoc::get(ArrayRef<Location> locs, Attribute metadata,
|
Location FusedLoc::get(ArrayRef<Location> locs, Attribute metadata,
|
||||||
MLIRContext *context) {
|
MLIRContext *context) {
|
||||||
// Unique the set of locations to be fused.
|
// Unique the set of locations to be fused.
|
||||||
llvm::SmallSetVector<Location, 4> decomposedLocs;
|
llvm::SmallSetVector<Location, 4> decomposedLocs;
|
||||||
for (auto loc : locs) {
|
for (auto loc : locs) {
|
||||||
|
@ -109,13 +109,13 @@ Attribute FusedLoc::getMetadata() const { return getImpl()->metadata; }
|
||||||
// NameLoc
|
// NameLoc
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
NameLoc NameLoc::get(Identifier name, Location child, MLIRContext *context) {
|
Location NameLoc::get(Identifier name, Location child, MLIRContext *context) {
|
||||||
assert(!child.isa<NameLoc>() &&
|
assert(!child.isa<NameLoc>() &&
|
||||||
"a NameLoc cannot be used as a child of another NameLoc");
|
"a NameLoc cannot be used as a child of another NameLoc");
|
||||||
return Base::get(context, StandardAttributes::NameLocation, name, child);
|
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);
|
return get(name, UnknownLoc::get(context), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -592,7 +592,7 @@ UnitAttr UnitAttr::get(MLIRContext *context) {
|
||||||
return context->getImpl().unitAttr;
|
return context->getImpl().unitAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnknownLoc UnknownLoc::get(MLIRContext *context) {
|
Location UnknownLoc::get(MLIRContext *context) {
|
||||||
return context->getImpl().unknownLocAttr;
|
return context->getImpl().unknownLocAttr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ private:
|
||||||
MLIRContext *context;
|
MLIRContext *context;
|
||||||
|
|
||||||
// TODO(antiagainst): create Location subclass for binary blob
|
// TODO(antiagainst): create Location subclass for binary blob
|
||||||
UnknownLoc unknownLoc;
|
Location unknownLoc;
|
||||||
|
|
||||||
/// The SPIR-V ModuleOp.
|
/// The SPIR-V ModuleOp.
|
||||||
Optional<spirv::ModuleOp> module;
|
Optional<spirv::ModuleOp> module;
|
||||||
|
|
|
@ -89,7 +89,7 @@ struct ArgConverter {
|
||||||
|
|
||||||
/// An instance of the unknown location that is used when generating
|
/// An instance of the unknown location that is used when generating
|
||||||
/// producers.
|
/// producers.
|
||||||
UnknownLoc loc;
|
Location loc;
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr StringLiteral ArgConverter::kCastName;
|
constexpr StringLiteral ArgConverter::kCastName;
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct StripDebugInfo : public FunctionPass<StripDebugInfo> {
|
||||||
|
|
||||||
void StripDebugInfo::runOnFunction() {
|
void StripDebugInfo::runOnFunction() {
|
||||||
Function &func = getFunction();
|
Function &func = getFunction();
|
||||||
UnknownLoc unknownLoc = UnknownLoc::get(&getContext());
|
auto unknownLoc = UnknownLoc::get(&getContext());
|
||||||
|
|
||||||
// Strip the debug info from the function and its operations.
|
// Strip the debug info from the function and its operations.
|
||||||
func.setLoc(unknownLoc);
|
func.setLoc(unknownLoc);
|
||||||
|
|
Loading…
Reference in New Issue