forked from OSchip/llvm-project
Add a getLoc() method on mlir::Value that returns the loc of the defining Operations if any, otherwise an unknown location
-- PiperOrigin-RevId: 241354085
This commit is contained in:
parent
005d54329e
commit
51f6c0ea60
|
@ -77,6 +77,10 @@ public:
|
|||
/// defines it.
|
||||
Operation *getDefiningOp();
|
||||
|
||||
/// If this value is the result of an operation, use it as a location,
|
||||
/// otherwise return an unknown location.
|
||||
Location getLoc();
|
||||
|
||||
using use_iterator = ValueUseIterator<OpOperand>;
|
||||
using use_range = llvm::iterator_range<use_iterator>;
|
||||
|
||||
|
|
|
@ -38,6 +38,13 @@ Function *Value::getFunction() {
|
|||
}
|
||||
}
|
||||
|
||||
Location Value::getLoc() {
|
||||
if (auto *op = getDefiningOp()) {
|
||||
return op->getLoc();
|
||||
}
|
||||
return UnknownLoc::get(getContext());
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// IRObjectWithUseList implementation.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
Loading…
Reference in New Issue