forked from OSchip/llvm-project
NFC: Simplify Operation::getContext to use the context within the location.
PiperOrigin-RevId: 254771979
This commit is contained in:
parent
7e7ed9104a
commit
52ba785758
|
@ -260,19 +260,7 @@ void Operation::destroy() {
|
|||
}
|
||||
|
||||
/// Return the context this operation is associated with.
|
||||
MLIRContext *Operation::getContext() {
|
||||
// If the op has an attribute, a result type, or an operand type, we have a
|
||||
// constant time way to get to the context.
|
||||
if (auto dict = attrs.getDictionary())
|
||||
return dict.getContext();
|
||||
if (getNumResults())
|
||||
return getResult(0)->getType().getContext();
|
||||
if (getNumOperands())
|
||||
return getOperand(0)->getType().getContext();
|
||||
|
||||
// For the rest, fallback to find the context by the enclosing region.
|
||||
return getContainingRegion()->getContext();
|
||||
}
|
||||
MLIRContext *Operation::getContext() { return location->getContext(); }
|
||||
|
||||
/// Return the dialact this operation is associated with, or nullptr if the
|
||||
/// associated dialect is not registered.
|
||||
|
|
Loading…
Reference in New Issue