From bb621a5596acc846b1ed6af50b483b38af71c42a Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Mon, 25 Mar 2019 00:29:00 -0700 Subject: [PATCH] Using getContext() instead of getInstruction()->getContext() on Operation (NFC) PiperOrigin-RevId: 240088209 --- mlir/include/mlir/IR/OpDefinition.h | 2 +- mlir/lib/AffineOps/AffineOps.cpp | 8 +++----- mlir/lib/Analysis/LoopAnalysis.cpp | 2 +- mlir/lib/StandardOps/Ops.cpp | 2 +- mlir/lib/Transforms/MaterializeVectors.cpp | 2 +- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 14 ++++++-------- 6 files changed, 13 insertions(+), 17 deletions(-) diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index ecf6368bb17e..b03ef08f37ad 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -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. diff --git a/mlir/lib/AffineOps/AffineOps.cpp b/mlir/lib/AffineOps/AffineOps.cpp index 0c8dcb5ab562..4badde9012b5 100644 --- a/mlir/lib/AffineOps/AffineOps.cpp +++ b/mlir/lib/AffineOps/AffineOps.cpp @@ -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() { diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp index 78f8aeb978ad..ba9a29177fe2 100644 --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -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] == diff --git a/mlir/lib/StandardOps/Ops.cpp b/mlir/lib/StandardOps/Ops.cpp index 67c51d54789b..a14f3a24e82b 100644 --- a/mlir/lib/StandardOps/Ops.cpp +++ b/mlir/lib/StandardOps/Ops.cpp @@ -720,7 +720,7 @@ void CmpIOp::print(OpAsmPrinter *p) { assert(predicateValue >= static_cast(CmpIPredicate::FirstValidValue) && predicateValue < static_cast(CmpIPredicate::NumPredicates) && "unknown predicate index"); - Builder b(getInstruction()->getContext()); + Builder b(getContext()); auto predicateStringAttr = b.getStringAttr(getPredicateNames()[predicateValue]); p->printAttribute(predicateStringAttr); diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp index d1374e92dc8a..0a7eaabbb09d 100644 --- a/mlir/lib/Transforms/MaterializeVectors.cpp +++ b/mlir/lib/Transforms/MaterializeVectors.cpp @@ -454,7 +454,7 @@ static AffineMap projectedPermutationMap(VectorTransferOpTy transfer, "Shape and ratio not of the same size"); unsigned dim = 0; SmallVector 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"); diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index 1cb92f5390c7..8399a99bf5fa 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -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";