Using getContext() instead of getInstruction()->getContext() on Operation (NFC)

PiperOrigin-RevId: 240088209
This commit is contained in:
Mehdi Amini 2019-03-25 00:29:00 -07:00 committed by jpienaar
parent 63e8725bc2
commit bb621a5596
6 changed files with 13 additions and 17 deletions

View File

@ -94,7 +94,7 @@ public:
state->setAttr(name, value);
}
void setAttr(StringRef name, Attribute value) {
setAttr(Identifier::get(name, getInstruction()->getContext()), value);
setAttr(Identifier::get(name, getContext()), value);
}
/// Return true if there are no users of any results of this operation.

View File

@ -1063,7 +1063,7 @@ Block *AffineForOp::createBody() {
// Create a new block for the body, and add an argument for the induction
// variable.
Block *body = new Block();
body->addArgument(IndexType::get(getInstruction()->getContext()));
body->addArgument(IndexType::get(getContext()));
bodyRegion.push_back(body);
return body;
}
@ -1139,13 +1139,11 @@ int64_t AffineForOp::getConstantUpperBound() {
}
void AffineForOp::setConstantLowerBound(int64_t value) {
setLowerBound(
{}, AffineMap::getConstantMap(value, getInstruction()->getContext()));
setLowerBound({}, AffineMap::getConstantMap(value, getContext()));
}
void AffineForOp::setConstantUpperBound(int64_t value) {
setUpperBound(
{}, AffineMap::getConstantMap(value, getInstruction()->getContext()));
setUpperBound({}, AffineMap::getConstantMap(value, getContext()));
}
AffineForOp::operand_range AffineForOp::getLowerBoundOperands() {

View File

@ -244,7 +244,7 @@ static bool isContiguousAccess(Value &iv, LoadOrStoreOp memoryOp,
auto layoutMap = memRefType.getAffineMaps();
// TODO(ntv): remove dependence on Builder once we support non-identity
// layout map.
Builder b(memoryOp->getInstruction()->getContext());
Builder b(memoryOp.getContext());
if (layoutMap.size() >= 2 ||
(layoutMap.size() == 1 &&
!(layoutMap[0] ==

View File

@ -720,7 +720,7 @@ void CmpIOp::print(OpAsmPrinter *p) {
assert(predicateValue >= static_cast<int>(CmpIPredicate::FirstValidValue) &&
predicateValue < static_cast<int>(CmpIPredicate::NumPredicates) &&
"unknown predicate index");
Builder b(getInstruction()->getContext());
Builder b(getContext());
auto predicateStringAttr =
b.getStringAttr(getPredicateNames()[predicateValue]);
p->printAttribute(predicateStringAttr);

View File

@ -454,7 +454,7 @@ static AffineMap projectedPermutationMap(VectorTransferOpTy transfer,
"Shape and ratio not of the same size");
unsigned dim = 0;
SmallVector<AffineExpr, 4> keep;
MLIRContext *context = transfer->getInstruction()->getContext();
MLIRContext *context = transfer.getContext();
functional::zipApply(
[&dim, &keep, context](int64_t shape, int64_t ratio) {
assert(shape >= ratio && "shape dim must be greater than ratio dim");

View File

@ -456,14 +456,12 @@ void OpEmitter::genAttrGetters() {
// Returns the default value if not set.
// TODO: this is inefficient, we are recreating the attribute for every
// call. This should be set instead.
method.body()
<< " if (!attr)\n"
" return "
<< formatv(
attr.getConvertFromStorageCall(),
formatv(attr.getDefaultValueTemplate(),
"mlir::Builder(this->getInstruction()->getContext())"))
<< ";\n";
method.body() << " if (!attr)\n"
" return "
<< formatv(attr.getConvertFromStorageCall(),
formatv(attr.getDefaultValueTemplate(),
"mlir::Builder(this->getContext())"))
<< ";\n";
}
method.body() << " return "
<< formatv(attr.getConvertFromStorageCall(), "attr") << ";\n";