diff options
| author | River Riddle <riverriddle@google.com> | 2020-01-11 08:54:04 -0800 |
|---|---|---|
| committer | River Riddle <riverriddle@google.com> | 2020-01-11 08:54:39 -0800 |
| commit | 2bdf33cc4c733342fc83081bc7410ac5e9a24f55 (patch) | |
| tree | 3306d769c2bbabda1060928e0cea79d021ea9da2 /mlir/include | |
| parent | 1d641daf260308815d014d1bf1b424a1ed1e7277 (diff) | |
| download | bcm5719-llvm-2bdf33cc4c733342fc83081bc7410ac5e9a24f55.tar.gz bcm5719-llvm-2bdf33cc4c733342fc83081bc7410ac5e9a24f55.zip | |
[mlir] NFC: Remove Value::operator* and Value::operator-> now that Value is properly value-typed.
Summary: These were temporary methods used to simplify the transition.
Reviewed By: antiagainst
Differential Revision: https://reviews.llvm.org/D72548
Diffstat (limited to 'mlir/include')
25 files changed, 121 insertions, 138 deletions
diff --git a/mlir/include/mlir/Analysis/Dominance.h b/mlir/include/mlir/Analysis/Dominance.h index ead54b93e80..c32fa0471f3 100644 --- a/mlir/include/mlir/Analysis/Dominance.h +++ b/mlir/include/mlir/Analysis/Dominance.h @@ -69,7 +69,7 @@ public: /// Return true if operation A dominates operation B. bool dominates(Value a, Operation *b) { - return (Operation *)a->getDefiningOp() == b || properlyDominates(a, b); + return (Operation *)a.getDefiningOp() == b || properlyDominates(a, b); } /// Return true if the specified block A dominates block B. diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h index b884ac5c2ce..ed6f453d914 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.h +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.h @@ -151,7 +151,7 @@ public: /// Returns the source MemRefType for this DMA operation. Value getSrcMemRef() { return getOperand(getSrcMemRefOperandIndex()); } MemRefType getSrcMemRefType() { - return getSrcMemRef()->getType().cast<MemRefType>(); + return getSrcMemRef().getType().cast<MemRefType>(); } /// Returns the rank (number of indices) of the source MemRefType. @@ -172,7 +172,7 @@ public: /// Returns the memory space of the src memref. unsigned getSrcMemorySpace() { - return getSrcMemRef()->getType().cast<MemRefType>().getMemorySpace(); + return getSrcMemRef().getType().cast<MemRefType>().getMemorySpace(); } /// Returns the operand index of the dst memref. @@ -183,17 +183,17 @@ public: /// Returns the destination MemRefType for this DMA operations. Value getDstMemRef() { return getOperand(getDstMemRefOperandIndex()); } MemRefType getDstMemRefType() { - return getDstMemRef()->getType().cast<MemRefType>(); + return getDstMemRef().getType().cast<MemRefType>(); } /// Returns the rank (number of indices) of the destination MemRefType. unsigned getDstMemRefRank() { - return getDstMemRef()->getType().cast<MemRefType>().getRank(); + return getDstMemRef().getType().cast<MemRefType>().getRank(); } /// Returns the memory space of the src memref. unsigned getDstMemorySpace() { - return getDstMemRef()->getType().cast<MemRefType>().getMemorySpace(); + return getDstMemRef().getType().cast<MemRefType>().getMemorySpace(); } /// Returns the affine map used to access the dst memref. @@ -217,12 +217,12 @@ public: /// Returns the Tag MemRef for this DMA operation. Value getTagMemRef() { return getOperand(getTagMemRefOperandIndex()); } MemRefType getTagMemRefType() { - return getTagMemRef()->getType().cast<MemRefType>(); + return getTagMemRef().getType().cast<MemRefType>(); } /// Returns the rank (number of indices) of the tag MemRefType. unsigned getTagMemRefRank() { - return getTagMemRef()->getType().cast<MemRefType>().getRank(); + return getTagMemRef().getType().cast<MemRefType>().getRank(); } /// Returns the affine map used to access the tag memref. @@ -335,7 +335,7 @@ public: // Returns the Tag MemRef associated with the DMA operation being waited on. Value getTagMemRef() { return getOperand(0); } MemRefType getTagMemRefType() { - return getTagMemRef()->getType().cast<MemRefType>(); + return getTagMemRef().getType().cast<MemRefType>(); } /// Returns the affine map used to access the tag memref. @@ -352,7 +352,7 @@ public: // Returns the rank (number of indices) of the tag memref. unsigned getTagMemRefRank() { - return getTagMemRef()->getType().cast<MemRefType>().getRank(); + return getTagMemRef().getType().cast<MemRefType>().getRank(); } /// Returns the AffineMapAttr associated with 'memref'. @@ -411,7 +411,7 @@ public: Value getMemRef() { return getOperand(getMemRefOperandIndex()); } void setMemRef(Value value) { setOperand(getMemRefOperandIndex(), value); } MemRefType getMemRefType() { - return getMemRef()->getType().cast<MemRefType>(); + return getMemRef().getType().cast<MemRefType>(); } /// Get affine map operands. @@ -482,7 +482,7 @@ public: void setMemRef(Value value) { setOperand(getMemRefOperandIndex(), value); } MemRefType getMemRefType() { - return getMemRef()->getType().cast<MemRefType>(); + return getMemRef().getType().cast<MemRefType>(); } /// Get affine map operands. diff --git a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td index 114e20513b2..ef256d4adc4 100644 --- a/mlir/include/mlir/Dialect/AffineOps/AffineOps.td +++ b/mlir/include/mlir/Dialect/AffineOps/AffineOps.td @@ -296,7 +296,7 @@ def AffinePrefetchOp : Affine_Op<"prefetch"> { let extraClassDeclaration = [{ MemRefType getMemRefType() { - return memref()->getType().cast<MemRefType>(); + return memref().getType().cast<MemRefType>(); } /// Returns the affine map used to index the memref for this operation. diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td index 2e47eb03474..85cc7cd4ee5 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -178,7 +178,7 @@ def LLVM_ICmpOp : LLVM_OneResultOp<"icmp", [NoSideEffect]>, let builders = [OpBuilder< "Builder *b, OperationState &result, ICmpPredicate predicate, Value lhs, " "Value rhs", [{ - LLVMDialect *dialect = &lhs->getType().cast<LLVMType>().getDialect(); + LLVMDialect *dialect = &lhs.getType().cast<LLVMType>().getDialect(); build(b, result, LLVMType::getInt1Ty(dialect), b->getI64IntegerAttr(static_cast<int64_t>(predicate)), lhs, rhs); }]>]; @@ -225,7 +225,7 @@ def LLVM_FCmpOp : LLVM_OneResultOp<"fcmp", [NoSideEffect]>, let builders = [OpBuilder< "Builder *b, OperationState &result, FCmpPredicate predicate, Value lhs, " "Value rhs", [{ - LLVMDialect *dialect = &lhs->getType().cast<LLVMType>().getDialect(); + LLVMDialect *dialect = &lhs.getType().cast<LLVMType>().getDialect(); build(b, result, LLVMType::getInt1Ty(dialect), b->getI64IntegerAttr(static_cast<int64_t>(predicate)), lhs, rhs); }]>]; @@ -285,7 +285,7 @@ def LLVM_LoadOp : LLVM_OneResultOp<"load">, Arguments<(ins LLVM_Type:$addr)>, let builders = [OpBuilder< "Builder *b, OperationState &result, Value addr", [{ - auto type = addr->getType().cast<LLVM::LLVMType>().getPointerElementTy(); + auto type = addr.getType().cast<LLVM::LLVMType>().getPointerElementTy(); build(b, result, type, addr); }]>]; let parser = [{ return parseLoadOp(parser, result); }]; @@ -378,7 +378,7 @@ def LLVM_InsertValueOp : LLVM_OneResultOp<"insertvalue", [NoSideEffect]>, "Builder *b, OperationState &result, Value container, Value value, " "ArrayAttr position", [{ - build(b, result, container->getType(), container, value, position); + build(b, result, container.getType(), container, value, position); }]>]; let parser = [{ return parseInsertValueOp(parser, result); }]; let printer = [{ printInsertValueOp(p, *this); }]; @@ -392,8 +392,8 @@ def LLVM_ShuffleVectorOp "Builder *b, OperationState &result, Value v1, Value v2, " "ArrayAttr mask, ArrayRef<NamedAttribute> attrs = {}">]; let verifier = [{ - auto wrappedVectorType1 = v1()->getType().cast<LLVM::LLVMType>(); - auto wrappedVectorType2 = v2()->getType().cast<LLVM::LLVMType>(); + auto wrappedVectorType1 = v1().getType().cast<LLVM::LLVMType>(); + auto wrappedVectorType2 = v2().getType().cast<LLVM::LLVMType>(); if (!wrappedVectorType2.getUnderlyingType()->isVectorTy()) return emitOpError("expected LLVM IR Dialect vector type for operand #2"); if (wrappedVectorType1.getVectorElementType() != @@ -415,7 +415,7 @@ def LLVM_SelectOp let builders = [OpBuilder< "Builder *b, OperationState &result, Value condition, Value lhs, " "Value rhs", [{ - build(b, result, lhs->getType(), condition, lhs, rhs); + build(b, result, lhs.getType(), condition, lhs, rhs); }]>]; let parser = [{ return parseSelectOp(parser, result); }]; let printer = [{ printSelectOp(p, *this); }]; diff --git a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h index c25c9d9f5ab..03f697a787b 100644 --- a/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h +++ b/mlir/include/mlir/Dialect/Linalg/EDSC/Builders.h @@ -56,7 +56,7 @@ struct StructuredIndexed { private: StructuredIndexed(Value v, ArrayRef<AffineExpr> indexings) : value(v), exprs(indexings.begin(), indexings.end()) { - assert(v->getType().isa<MemRefType>() && "MemRefType expected"); + assert(v.getType().isa<MemRefType>() && "MemRefType expected"); } StructuredIndexed(ValueHandle v, ArrayRef<AffineExpr> indexings) : StructuredIndexed(v.getValue(), indexings) {} diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td index e3fab873046..8e1f40f3620 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td @@ -165,7 +165,7 @@ def Linalg_SliceOp : Linalg_Op<"slice", [NoSideEffect]>, Type getElementType() { return getShapedType().getElementType(); } ShapedType getShapedType() { return getType().cast<ShapedType>(); } unsigned getBaseViewRank() { return getBaseViewType().getRank(); } - ShapedType getBaseViewType() { return view()->getType().cast<ShapedType>();} + ShapedType getBaseViewType() { return view().getType().cast<ShapedType>();} // Get the underlying indexing at a given rank. Value indexing(unsigned rank) { return *(indexings().begin() + rank); } @@ -174,7 +174,7 @@ def Linalg_SliceOp : Linalg_Op<"slice", [NoSideEffect]>, SmallVector<Value, 8> getRanges() { SmallVector<Value, 8> res; for (auto operand : indexings()) - if (!operand->getType().isa<IndexType>()) + if (!operand.getType().isa<IndexType>()) res.push_back(operand); return res; } @@ -211,7 +211,7 @@ def Linalg_TransposeOp : Linalg_Op<"transpose", [NoSideEffect]>, let extraClassDeclaration = [{ static StringRef getPermutationAttrName() { return "permutation"; } - ShapedType getShapedType() { return view()->getType().cast<ShapedType>(); } + ShapedType getShapedType() { return view().getType().cast<ShapedType>(); } }]; } diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td index 95963338491..d8c657c7209 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td @@ -236,7 +236,7 @@ def CopyOp : LinalgStructured_Op<"copy", [NInputs<1>, NOutputs<1>]> { ArrayAttr indexing_maps(); ArrayAttr iterator_types() { - unsigned nPar = input()->getType().cast<ShapedType>().getRank(); + unsigned nPar = input().getType().cast<ShapedType>().getRank(); MLIRContext *ctx = getContext(); SmallVector<Attribute, 8> iters( nPar, StringAttr::get(getParallelIteratorTypeName(), ctx)); @@ -253,7 +253,7 @@ def FillOp : LinalgStructured_Op<"fill", [NInputs<0>, NOutputs<1>]> { ArrayAttr indexing_maps(); ArrayAttr iterator_types() { - unsigned nPar = input()->getType().cast<ShapedType>().getRank(); + unsigned nPar = input().getType().cast<ShapedType>().getRank(); MLIRContext *ctx = getContext(); SmallVector<Attribute, 8> iters( nPar, StringAttr::get(getParallelIteratorTypeName(), ctx)); diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h index 58e4726bc35..7275863c5b6 100644 --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h @@ -83,7 +83,7 @@ public: } /// Return the `i`-th input buffer type. ShapedType getInputShapedType(unsigned i) { - return getInput(i)->getType().template cast<ShapedType>(); + return getInput(i).getType().template cast<ShapedType>(); } /// Return the range over inputs. Operation::operand_range getInputs() { @@ -104,7 +104,7 @@ public: } /// Return the `i`-th output buffer type. ShapedType getOutputShapedType(unsigned i) { - return getOutput(i)->getType().template cast<ShapedType>(); + return getOutput(i).getType().template cast<ShapedType>(); } /// Query whether the op has only MemRef input and outputs. bool hasBufferSemantics() { diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td index 532fda2411d..9f1189ba877 100644 --- a/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransformPatterns.td @@ -37,7 +37,7 @@ class AffineMapDomainHasDim<int n> : CPred<[{ class HasOperandsOfType<string type>: CPred<[{ llvm::any_of(op.getOperands(), [](Value v) { - return dyn_cast_or_null<}] # type # [{>(v->getDefiningOp()); + return dyn_cast_or_null<}] # type # [{>(v.getDefiningOp()); }) }]>; diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h index 1b0c3a950f6..2bd4a0d2c0b 100644 --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -120,7 +120,7 @@ template <typename ConcreteOp> SmallVector<Value, 8> getViewSizes(ConcreteOp linalgOp) { SmallVector<Value, 8> res; for (auto v : linalgOp.getInputsAndOutputs()) { - MemRefType t = v->getType().template cast<MemRefType>(); + MemRefType t = v.getType().template cast<MemRefType>(); for (unsigned i = 0; i < t.getRank(); ++i) res.push_back(edsc::intrinsics::dim(v, i)); } diff --git a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td index bbeb9419cc4..2cab8a9668c 100644 --- a/mlir/include/mlir/Dialect/QuantOps/QuantOps.td +++ b/mlir/include/mlir/Dialect/QuantOps/QuantOps.td @@ -199,7 +199,7 @@ def quant_StatisticsOp : quant_Op<"stats", [SameOperandsAndResultType]> { let results = (outs quant_RealValueType); let verifier = [{ - auto tensorArg = arg()->getType().dyn_cast<TensorType>(); + auto tensorArg = arg().getType().dyn_cast<TensorType>(); if (!tensorArg) return emitOpError("arg needs to be tensor type."); // Verify layerStats attribute. diff --git a/mlir/include/mlir/Dialect/StandardOps/Ops.h b/mlir/include/mlir/Dialect/StandardOps/Ops.h index 0ba16c56f8e..eb2430bdf8b 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Ops.h +++ b/mlir/include/mlir/Dialect/StandardOps/Ops.h @@ -183,7 +183,7 @@ public: Value getSrcMemRef() { return getOperand(0); } // Returns the rank (number of indices) of the source MemRefType. unsigned getSrcMemRefRank() { - return getSrcMemRef()->getType().cast<MemRefType>().getRank(); + return getSrcMemRef().getType().cast<MemRefType>().getRank(); } // Returns the source memref indices for this DMA operation. operand_range getSrcIndices() { @@ -195,13 +195,13 @@ public: Value getDstMemRef() { return getOperand(1 + getSrcMemRefRank()); } // Returns the rank (number of indices) of the destination MemRefType. unsigned getDstMemRefRank() { - return getDstMemRef()->getType().cast<MemRefType>().getRank(); + return getDstMemRef().getType().cast<MemRefType>().getRank(); } unsigned getSrcMemorySpace() { - return getSrcMemRef()->getType().cast<MemRefType>().getMemorySpace(); + return getSrcMemRef().getType().cast<MemRefType>().getMemorySpace(); } unsigned getDstMemorySpace() { - return getDstMemRef()->getType().cast<MemRefType>().getMemorySpace(); + return getDstMemRef().getType().cast<MemRefType>().getMemorySpace(); } // Returns the destination memref indices for this DMA operation. @@ -222,7 +222,7 @@ public: } // Returns the rank (number of indices) of the tag MemRefType. unsigned getTagMemRefRank() { - return getTagMemRef()->getType().cast<MemRefType>().getRank(); + return getTagMemRef().getType().cast<MemRefType>().getRank(); } // Returns the tag memref index for this DMA operation. @@ -313,7 +313,7 @@ public: // Returns the rank (number of indices) of the tag memref. unsigned getTagMemRefRank() { - return getTagMemRef()->getType().cast<MemRefType>().getRank(); + return getTagMemRef().getType().cast<MemRefType>().getRank(); } // Returns the number of elements transferred in the associated DMA operation. diff --git a/mlir/include/mlir/Dialect/StandardOps/Ops.td b/mlir/include/mlir/Dialect/StandardOps/Ops.td index 1c8bb251c02..c60aacdf66b 100644 --- a/mlir/include/mlir/Dialect/StandardOps/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/Ops.td @@ -192,7 +192,7 @@ def AllocOp : Std_Op<"alloc"> { let extraClassDeclaration = [{ static StringRef getAlignmentAttrName() { return "alignment"; } - MemRefType getType() { return getResult()->getType().cast<MemRefType>(); } + MemRefType getType() { return getResult().getType().cast<MemRefType>(); } /// Returns the number of symbolic operands (the ones in square brackets), /// which bind to the symbols of the memref's layout map. @@ -325,7 +325,7 @@ def CallIndirectOp : Std_Op<"call_indirect", [CallOpInterface]> { "ValueRange operands = {}", [{ result.operands.push_back(callee); result.addOperands(operands); - result.addTypes(callee->getType().cast<FunctionType>().getResults()); + result.addTypes(callee.getType().cast<FunctionType>().getResults()); }]>]; let extraClassDeclaration = [{ @@ -723,7 +723,7 @@ def ExtractElementOp : Std_Op<"extract_element", [NoSideEffect]> { let builders = [OpBuilder< "Builder *builder, OperationState &result, Value aggregate," "ValueRange indices = {}", [{ - auto resType = aggregate->getType().cast<ShapedType>() + auto resType = aggregate.getType().cast<ShapedType>() .getElementType(); build(builder, result, resType, aggregate, indices); }]>]; @@ -809,7 +809,7 @@ def LoadOp : Std_Op<"load"> { let builders = [OpBuilder< "Builder *, OperationState &result, Value memref," "ValueRange indices = {}", [{ - auto memrefType = memref->getType().cast<MemRefType>(); + auto memrefType = memref.getType().cast<MemRefType>(); result.addOperands(memref); result.addOperands(indices); result.types.push_back(memrefType.getElementType()); @@ -819,7 +819,7 @@ def LoadOp : Std_Op<"load"> { Value getMemRef() { return getOperand(0); } void setMemRef(Value value) { setOperand(0, value); } MemRefType getMemRefType() { - return getMemRef()->getType().cast<MemRefType>(); + return getMemRef().getType().cast<MemRefType>(); } operand_range getIndices() { return {operand_begin() + 1, operand_end()}; } @@ -890,7 +890,7 @@ def MemRefCastOp : CastOp<"memref_cast"> { static bool areCastCompatible(Type a, Type b); /// The result of a memref_cast is always a memref. - Type getType() { return getResult()->getType(); } + Type getType() { return getResult().getType(); } }]; } @@ -958,7 +958,7 @@ def PrefetchOp : Std_Op<"prefetch"> { let extraClassDeclaration = [{ MemRefType getMemRefType() { - return memref()->getType().cast<MemRefType>(); + return memref().getType().cast<MemRefType>(); } static StringRef getLocalityHintAttrName() { return "localityHint"; } static StringRef getIsWriteAttrName() { return "isWrite"; } @@ -1046,7 +1046,7 @@ def SelectOp : Std_Op<"select", [NoSideEffect, SameOperandsAndResultShape]> { "Builder *builder, OperationState &result, Value condition," "Value trueValue, Value falseValue", [{ result.addOperands({condition, trueValue, falseValue}); - result.addTypes(trueValue->getType()); + result.addTypes(trueValue.getType()); }]>]; let extraClassDeclaration = [{ @@ -1215,7 +1215,7 @@ def StoreOp : Std_Op<"store"> { Value getMemRef() { return getOperand(1); } void setMemRef(Value value) { setOperand(1, value); } MemRefType getMemRefType() { - return getMemRef()->getType().cast<MemRefType>(); + return getMemRef().getType().cast<MemRefType>(); } operand_range getIndices() { @@ -1367,11 +1367,11 @@ def SubViewOp : Std_Op<"subview", [AttrSizedOperandSegments, NoSideEffect]> { let extraClassDeclaration = [{ /// Returns the type of the base memref operand. MemRefType getBaseMemRefType() { - return source()->getType().cast<MemRefType>(); + return source().getType().cast<MemRefType>(); } /// The result of a subview is always a memref. - MemRefType getType() { return getResult()->getType().cast<MemRefType>(); } + MemRefType getType() { return getResult().getType().cast<MemRefType>(); } /// Returns as integer value the number of offset operands. int64_t getNumOffsets() { return llvm::size(offsets()); } @@ -1434,7 +1434,7 @@ def TensorCastOp : CastOp<"tensor_cast"> { static bool areCastCompatible(Type a, Type b); /// The result of a tensor_cast is always a tensor. - TensorType getType() { return getResult()->getType().cast<TensorType>(); } + TensorType getType() { return getResult().getType().cast<TensorType>(); } }]; } @@ -1457,7 +1457,7 @@ def TensorLoadOp : Std_Op<"tensor_load", let builders = [OpBuilder< "Builder *builder, OperationState &result, Value memref", [{ - auto memrefType = memref->getType().cast<MemRefType>(); + auto memrefType = memref.getType().cast<MemRefType>(); auto resultType = RankedTensorType::get(memrefType.getShape(), memrefType.getElementType()); result.addOperands(memref); @@ -1467,7 +1467,7 @@ def TensorLoadOp : Std_Op<"tensor_load", let extraClassDeclaration = [{ /// The result of a tensor_load is always a tensor. - TensorType getType() { return getResult()->getType().cast<TensorType>(); } + TensorType getType() { return getResult().getType().cast<TensorType>(); } }]; } @@ -1565,7 +1565,7 @@ def ViewOp : Std_Op<"view", [NoSideEffect]> { let extraClassDeclaration = [{ /// The result of a view is always a memref. - MemRefType getType() { return getResult()->getType().cast<MemRefType>(); } + MemRefType getType() { return getResult().getType().cast<MemRefType>(); } /// Returns the dynamic offset for this view operation if specified. /// Returns nullptr if no dynamic offset was specified. diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorOps.td b/mlir/include/mlir/Dialect/VectorOps/VectorOps.td index 8726b162fd6..20b008a689c 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorOps.td +++ b/mlir/include/mlir/Dialect/VectorOps/VectorOps.td @@ -123,24 +123,24 @@ def Vector_ContractionOp : "Value acc, ArrayAttr indexingMaps, ArrayAttr iteratorTypes">]; let extraClassDeclaration = [{ VectorType getLhsType() { - return lhs()->getType().cast<VectorType>(); + return lhs().getType().cast<VectorType>(); } VectorType getRhsType() { - return rhs()->getType().cast<VectorType>(); + return rhs().getType().cast<VectorType>(); } VectorType getAccType() { - return acc()->getType().cast<VectorType>(); + return acc().getType().cast<VectorType>(); } VectorType getLHSVectorMaskType() { if (llvm::size(masks()) != 2) return VectorType(); - return getOperand(3)->getType().cast<VectorType>(); + return getOperand(3).getType().cast<VectorType>(); } VectorType getRHSVectorMaskType() { if (llvm::size(masks()) != 2) return VectorType(); - return getOperand(4)->getType().cast<VectorType>(); + return getOperand(4).getType().cast<VectorType>(); } VectorType getResultType() { - return getResult()->getType().cast<VectorType>(); + return getResult().getType().cast<VectorType>(); } ArrayRef<StringRef> getTraitAttrNames(); SmallVector<AffineMap, 4> getIndexingMaps(); @@ -198,9 +198,9 @@ def Vector_BroadcastOp : ``` }]; let extraClassDeclaration = [{ - Type getSourceType() { return source()->getType(); } + Type getSourceType() { return source().getType(); } VectorType getVectorType() { - return vector()->getType().cast<VectorType>(); + return vector().getType().cast<VectorType>(); } }]; } @@ -248,13 +248,13 @@ def Vector_ShuffleOp : let extraClassDeclaration = [{ static StringRef getMaskAttrName() { return "mask"; } VectorType getV1VectorType() { - return v1()->getType().cast<VectorType>(); + return v1().getType().cast<VectorType>(); } VectorType getV2VectorType() { - return v2()->getType().cast<VectorType>(); + return v2().getType().cast<VectorType>(); } VectorType getVectorType() { - return vector()->getType().cast<VectorType>(); + return vector().getType().cast<VectorType>(); } }]; } @@ -281,7 +281,7 @@ def Vector_ExtractElementOp : }]; let extraClassDeclaration = [{ VectorType getVectorType() { - return vector()->getType().cast<VectorType>(); + return vector().getType().cast<VectorType>(); } }]; } @@ -309,7 +309,7 @@ def Vector_ExtractOp : let extraClassDeclaration = [{ static StringRef getPositionAttrName() { return "position"; } VectorType getVectorType() { - return vector()->getType().cast<VectorType>(); + return vector().getType().cast<VectorType>(); } }]; } @@ -354,10 +354,10 @@ def Vector_ExtractSlicesOp : "ArrayRef<int64_t> strides">]; let extraClassDeclaration = [{ VectorType getSourceVectorType() { - return vector()->getType().cast<VectorType>(); + return vector().getType().cast<VectorType>(); } TupleType getResultTupleType() { - return getResult()->getType().cast<TupleType>(); + return getResult().getType().cast<TupleType>(); } void getSizes(SmallVectorImpl<int64_t> &results); void getStrides(SmallVectorImpl<int64_t> &results); @@ -391,9 +391,9 @@ def Vector_InsertElementOp : ``` }]; let extraClassDeclaration = [{ - Type getSourceType() { return source()->getType(); } + Type getSourceType() { return source().getType(); } VectorType getDestVectorType() { - return dest()->getType().cast<VectorType>(); + return dest().getType().cast<VectorType>(); } }]; } @@ -425,9 +425,9 @@ def Vector_InsertOp : "Value dest, ArrayRef<int64_t>">]; let extraClassDeclaration = [{ static StringRef getPositionAttrName() { return "position"; } - Type getSourceType() { return source()->getType(); } + Type getSourceType() { return source().getType(); } VectorType getDestVectorType() { - return dest()->getType().cast<VectorType>(); + return dest().getType().cast<VectorType>(); } }]; } @@ -472,10 +472,10 @@ def Vector_InsertSlicesOp : let extraClassDeclaration = [{ TupleType getSourceTupleType() { - return vectors()->getType().cast<TupleType>(); + return vectors().getType().cast<TupleType>(); } VectorType getResultVectorType() { - return getResult()->getType().cast<VectorType>(); + return getResult().getType().cast<VectorType>(); } void getSizes(SmallVectorImpl<int64_t> &results); void getStrides(SmallVectorImpl<int64_t> &results); @@ -520,10 +520,10 @@ def Vector_InsertStridedSliceOp : static StringRef getOffsetsAttrName() { return "offsets"; } static StringRef getStridesAttrName() { return "strides"; } VectorType getSourceVectorType() { - return source()->getType().cast<VectorType>(); + return source().getType().cast<VectorType>(); } VectorType getDestVectorType() { - return dest()->getType().cast<VectorType>(); + return dest().getType().cast<VectorType>(); } }]; } @@ -552,17 +552,17 @@ def Vector_OuterProductOp : }]; let extraClassDeclaration = [{ VectorType getOperandVectorTypeLHS() { - return lhs()->getType().cast<VectorType>(); + return lhs().getType().cast<VectorType>(); } VectorType getOperandVectorTypeRHS() { - return rhs()->getType().cast<VectorType>(); + return rhs().getType().cast<VectorType>(); } VectorType getOperandVectorTypeACC() { return (llvm::size(acc()) == 0) ? VectorType() : - (*acc().begin())->getType().cast<VectorType>(); + (*acc().begin()).getType().cast<VectorType>(); } VectorType getVectorType() { - return getResult()->getType().cast<VectorType>(); + return getResult().getType().cast<VectorType>(); } }]; } @@ -662,10 +662,10 @@ def Vector_ReshapeOp : let extraClassDeclaration = [{ VectorType getInputVectorType() { - return vector()->getType().cast<VectorType>(); + return vector().getType().cast<VectorType>(); } VectorType getOutputVectorType() { - return getResult()->getType().cast<VectorType>(); + return getResult().getType().cast<VectorType>(); } /// Returns as integer value the number of input shape operands. @@ -723,7 +723,7 @@ def Vector_StridedSliceOp : static StringRef getOffsetsAttrName() { return "offsets"; } static StringRef getSizesAttrName() { return "sizes"; } static StringRef getStridesAttrName() { return "strides"; } - VectorType getVectorType(){ return vector()->getType().cast<VectorType>(); } + VectorType getVectorType(){ return vector().getType().cast<VectorType>(); } void getOffsets(SmallVectorImpl<int64_t> &results); }]; let hasCanonicalizer = 1; @@ -862,10 +862,10 @@ def Vector_TransferReadOp : let extraClassDeclaration = [{ MemRefType getMemRefType() { - return memref()->getType().cast<MemRefType>(); + return memref().getType().cast<MemRefType>(); } VectorType getVectorType() { - return vector()->getType().cast<VectorType>(); + return vector().getType().cast<VectorType>(); } }]; } @@ -933,10 +933,10 @@ def Vector_TransferWriteOp : let extraClassDeclaration = [{ VectorType getVectorType() { - return vector()->getType().cast<VectorType>(); + return vector().getType().cast<VectorType>(); } MemRefType getMemRefType() { - return memref()->getType().cast<MemRefType>(); + return memref().getType().cast<MemRefType>(); } }]; } @@ -976,10 +976,10 @@ def Vector_TypeCastOp : let extraClassDeclaration = [{ MemRefType getMemRefType() { - return memref()->getType().cast<MemRefType>(); + return memref().getType().cast<MemRefType>(); } MemRefType getResultMemRefType() { - return getResult()->getType().cast<MemRefType>(); + return getResult().getType().cast<MemRefType>(); } }]; } @@ -1078,7 +1078,7 @@ def Vector_TupleOp : let extraClassDeclaration = [{ TupleType getResultTupleType() { - return getResult()->getType().cast<TupleType>(); + return getResult().getType().cast<TupleType>(); } }]; } @@ -1108,7 +1108,7 @@ def Vector_TupleGetOp : let extraClassDeclaration = [{ VectorType getResultVectorType() { - return getResult()->getType().cast<VectorType>(); + return getResult().getType().cast<VectorType>(); } int64_t getIndex() { return getAttrOfType<IntegerAttr>("index").getValue().getSExtValue(); @@ -1144,7 +1144,7 @@ def Vector_PrintOp : let verifier = ?; let extraClassDeclaration = [{ Type getPrintType() { - return source()->getType(); + return source().getType(); } }]; } diff --git a/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td b/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td index 5d0244f6989..27c9038192e 100644 --- a/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td +++ b/mlir/include/mlir/Dialect/VectorOps/VectorTransformPatterns.td @@ -16,11 +16,11 @@ include "mlir/IR/OpBase.td" class HasShape<list<int> shape> : - CPred<"$0->getType().cast<ShapedType>().hasStaticShape({" # + CPred<"$0.getType().cast<ShapedType>().hasStaticShape({" # StrJoinInt<shape>.result # "})">; class UnrollVectorOp<list<int> factors> : NativeCodeCall< - "unrollSingleResultOpMatchingType($_builder, $0->getDefiningOp(), " # + "unrollSingleResultOpMatchingType($_builder, $0.getDefiningOp(), " # "{" # StrJoinInt<factors>.result # "})">; #endif // VECTOR_TRANSFORM_PATTERNS diff --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h index d598c1cfb23..14a4e5a4c9a 100644 --- a/mlir/include/mlir/EDSC/Builders.h +++ b/mlir/include/mlir/EDSC/Builders.h @@ -303,7 +303,7 @@ public: /// Value. An eager Value represents both the declaration and the definition /// (in the PL sense) of a placeholder for an mlir::Value that has already /// been constructed in the past and that is captured "now" in the program. - explicit ValueHandle(Value v) : t(v->getType()), v(v) {} + explicit ValueHandle(Value v) : t(v.getType()), v(v) {} /// Builds a ConstantIndexOp of value `cst`. The constant is created at the /// current insertion point. @@ -365,7 +365,7 @@ public: Operation *getOperation() const { if (!v) return nullptr; - return v->getDefiningOp(); + return v.getDefiningOp(); } protected: diff --git a/mlir/include/mlir/EDSC/Intrinsics.h b/mlir/include/mlir/EDSC/Intrinsics.h index 30cce6bb8d6..af620a7e545 100644 --- a/mlir/include/mlir/EDSC/Intrinsics.h +++ b/mlir/include/mlir/EDSC/Intrinsics.h @@ -36,7 +36,7 @@ struct IndexHandle : public ValueHandle { : ValueHandle(ScopedContext::getBuilder().getIndexType()) {} explicit IndexHandle(index_t v) : ValueHandle(v) {} explicit IndexHandle(Value v) : ValueHandle(v) { - assert(v->getType() == ScopedContext::getBuilder().getIndexType() && + assert(v.getType() == ScopedContext::getBuilder().getIndexType() && "Expected index type"); } explicit IndexHandle(ValueHandle v) : ValueHandle(v) { diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h index 2cfa2428bd5..d8d3308c7f0 100644 --- a/mlir/include/mlir/IR/Matchers.h +++ b/mlir/include/mlir/IR/Matchers.h @@ -86,7 +86,7 @@ struct constant_int_op_binder { Attribute attr; if (!constant_op_binder<Attribute>(&attr).match(op)) return false; - auto type = op->getResult(0)->getType(); + auto type = op->getResult(0).getType(); if (type.isIntOrIndex()) { return attr_value_binder<IntegerAttr>(bind_value).match(attr); @@ -145,7 +145,7 @@ typename std::enable_if_t<is_detected<detail::has_operation_or_value_matcher_t, MatcherClass, Operation *>::value, bool> matchOperandOrValueAtIndex(Operation *op, unsigned idx, MatcherClass &matcher) { - if (auto defOp = op->getOperand(idx)->getDefiningOp()) + if (auto defOp = op->getOperand(idx).getDefiningOp()) return matcher.match(defOp); return false; } @@ -228,7 +228,7 @@ inline detail::constant_int_not_value_matcher<0> m_NonZero() { template <typename Pattern> inline bool matchPattern(Value value, const Pattern &pattern) { // TODO: handle other cases - if (auto *op = value->getDefiningOp()) + if (auto *op = value.getDefiningOp()) return const_cast<Pattern &>(pattern).match(op); return false; } diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td index c457d25fc51..eeb55c9594a 100644 --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -85,7 +85,7 @@ class Pred; // constraints on each type definition reads naturally and we want to attach // type constraints directly to an operand/result, $_self will be replaced // by the operand/result's type. E.g., for `F32` in `F32:$operand`, its -// `$_self` will be expanded as `getOperand(...)->getType()`. +// `$_self` will be expanded as `getOperand(...).getType()`. class CPred<code pred> : Pred { code predExpr = "(" # pred # ")"; } @@ -1600,7 +1600,7 @@ class Results<dag rets> { //===----------------------------------------------------------------------===// def HasNoUseOf: Constraint< - CPred<"$_self->use_begin() == $_self->use_end()">, "has no use">; + CPred<"$_self.use_empty()">, "has no use">; //===----------------------------------------------------------------------===// // Common op type constraints @@ -1661,7 +1661,7 @@ class AllTypesMatch<list<string> names> : // Type Constraint operand `idx`'s Element type is `type`. class TCopVTEtIs<int idx, Type type> : And<[ CPred<"$_op.getNumOperands() > " # idx>, - SubstLeaves<"$_self", "$_op.getOperand(" # idx # ")->getType()", + SubstLeaves<"$_self", "$_op.getOperand(" # idx # ").getType()", IsShapedTypePred>, SubstLeaves<"$_self", "getElementTypeOrSelf($_op.getOperand(" # idx # "))", type.predicate>]>; @@ -1688,9 +1688,9 @@ class ElementTypeIs<string name, Type type> : PredOpTrait< // type. class TCopVTEtIsSameAs<int i, int j> : And<[ CPred<"$_op.getNumOperands() > std::max(" # i # "u," # j # "u)">, - SubstLeaves<"$_self", "$_op.getOperand(" # i # ")->getType()", + SubstLeaves<"$_self", "$_op.getOperand(" # i # ").getType()", IsShapedTypePred>, - SubstLeaves<"$_self", "$_op.getOperand(" # j # ")->getType()", + SubstLeaves<"$_self", "$_op.getOperand(" # j # ").getType()", IsShapedTypePred>, CPred<"mlir::getElementTypeOrSelf($_op.getOperand(" # i # ")) == " "mlir::getElementTypeOrSelf($_op.getOperand(" # j # "))">]>; @@ -1700,16 +1700,16 @@ class TCopVTEtIsSameAs<int i, int j> : And<[ class TCOpResIsShapedTypePred<int i, int j> : And<[ CPred<"$_op.getNumResults() > " # i>, CPred<"$_op.getNumOperands() > " # j>, - SubstLeaves<"$_self", "$_op.getResult(" # i # ")->getType()", + SubstLeaves<"$_self", "$_op.getResult(" # i # ").getType()", IsShapedTypePred>, - SubstLeaves<"$_self", "$_op.getOperand(" # j # ")->getType()", + SubstLeaves<"$_self", "$_op.getOperand(" # j # ").getType()", IsShapedTypePred>]>; // Predicate to verify that the i'th result and the j'th operand have the same // type. class TCresIsSameAsOpBase<int i, int j> : - CPred<"$_op.getResult(" # i # ")->getType() == " - "$_op.getOperand(" # j # ")->getType()">; + CPred<"$_op.getResult(" # i # ").getType() == " + "$_op.getOperand(" # j # ").getType()">; // Basic Predicate to verify that the i'th result and the j'th operand have the // same elemental type. @@ -1730,8 +1730,8 @@ class TCresVTEtIsSameAsOp<int i, int j> : And<[ class TCOpIsBroadcastableToRes<int opId, int resId> : And<[ TCOpResIsShapedTypePred<opId, resId>, CPred<"OpTrait::util::getBroadcastedType(" - "$_op.getOperand(" # opId # ")->getType(), " - "$_op.getResult(" # resId # ")->getType())">]>; + "$_op.getOperand(" # opId # ").getType(), " + "$_op.getResult(" # resId # ").getType())">]>; // Predicate to verify that all the operands at the given `indices` // have the same element type. diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index 1abf82f37ee..cc4dfd31190 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -550,7 +550,7 @@ struct MultiResultTraitBase : public TraitBase<ConcreteType, TraitType> { } /// Return the type of the `i`-th result. - Type getType(unsigned i) { return getResult(i)->getType(); } + Type getType(unsigned i) { return getResult(i).getType(); } /// Result iterator access. result_iterator result_begin() { @@ -578,13 +578,13 @@ template <typename ConcreteType> class OneResult : public TraitBase<ConcreteType, OneResult> { public: Value getResult() { return this->getOperation()->getResult(0); } - Type getType() { return getResult()->getType(); } + Type getType() { return getResult().getType(); } /// Replace all uses of 'this' value with the new value, updating anything in /// the IR that uses 'this' to use the other value instead. When this returns /// there are zero uses of 'this'. void replaceAllUsesWith(Value newValue) { - getResult()->replaceAllUsesWith(newValue); + getResult().replaceAllUsesWith(newValue); } /// Replace all uses of 'this' value with the result of 'op'. diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h index 41acdba1a05..98ce1015886 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -114,14 +114,14 @@ public: os << "("; interleaveComma(op->getNonSuccessorOperands(), os, [&](Value operand) { if (operand) - printType(operand->getType()); + printType(operand.getType()); else os << "<<NULL>"; }); os << ") -> "; if (op->getNumResults() == 1 && - !op->getResult(0)->getType().isa<FunctionType>()) { - printType(op->getResult(0)->getType()); + !op->getResult(0).getType().isa<FunctionType>()) { + printType(op->getResult(0).getType()); } else { os << '('; interleaveComma(op->getResultTypes(), os); diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index 71d77a2df3e..81fd83b3d25 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -149,14 +149,14 @@ public: auto valueIt = values.begin(); for (unsigned i = 0, e = getNumResults(); i != e; ++i) - getResult(i)->replaceAllUsesWith(*(valueIt++)); + getResult(i).replaceAllUsesWith(*(valueIt++)); } /// Replace all uses of results of this operation with results of 'op'. void replaceAllUsesWith(Operation *op) { assert(getNumResults() == op->getNumResults()); for (unsigned i = 0, e = getNumResults(); i != e; ++i) - getResult(i)->replaceAllUsesWith(op->getResult(i)); + getResult(i).replaceAllUsesWith(op->getResult(i)); } /// Destroys this operation and its subclass data. diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index 3fb5a91c73a..a2be7bb8a71 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -90,12 +90,6 @@ public: return U(ownerAndKind); } - /// Temporary methods to enable transition of Value to being used as a - /// value-type. - /// TODO(riverriddle) Remove these when all usages have been removed. - Value operator*() const { return *this; } - Value *operator->() const { return const_cast<Value *>(this); } - operator bool() const { return ownerAndKind.getPointer(); } bool operator==(const Value &other) const { return ownerAndKind == other.ownerAndKind; @@ -122,7 +116,7 @@ public: /// If this value is the result of an operation, use it as a location, /// otherwise return an unknown location. - Location getLoc(); + Location getLoc() const; /// Return the Region in which this Value is defined. Region *getParentRegion(); @@ -236,11 +230,6 @@ class BlockArgument : public Value { public: using Value::Value; - /// Temporary methods to enable transition of Value to being used as a - /// value-type. - /// TODO(riverriddle) Remove this when all usages have been removed. - BlockArgument *operator->() { return this; } - static bool classof(Value value) { return value.getKind() == Kind::BlockArgument; } @@ -288,12 +277,6 @@ class OpResult : public Value { public: using Value::Value; - /// Temporary methods to enable transition of Value to being used as a - /// value-type. - /// TODO(riverriddle) Remove these when all usages have been removed. - OpResult operator*() { return *this; } - OpResult *operator->() { return this; } - static bool classof(Value value) { return value.getKind() != Kind::BlockArgument; } diff --git a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h index d99db65b015..a691a6a38d3 100644 --- a/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h +++ b/mlir/include/mlir/Quantizer/Support/ConstraintAnalysisGraph.h @@ -221,7 +221,7 @@ public: return n->getKind() == Kind::Anchor || n->getKind() == Kind::ResultAnchor; } - Operation *getOp() const final { return resultValue->getDefiningOp(); } + Operation *getOp() const final { return resultValue.getDefiningOp(); } Value getValue() const final { return resultValue; } void printLabel(raw_ostream &os) const override; diff --git a/mlir/include/mlir/Transforms/RegionUtils.h b/mlir/include/mlir/Transforms/RegionUtils.h index bd71553e96b..8046dc458a4 100644 --- a/mlir/include/mlir/Transforms/RegionUtils.h +++ b/mlir/include/mlir/Transforms/RegionUtils.h @@ -22,7 +22,7 @@ namespace mlir { template <typename Range> bool areValuesDefinedAbove(Range values, Region &limit) { for (Value v : values) - if (!v->getParentRegion()->isProperAncestor(&limit)) + if (!v.getParentRegion()->isProperAncestor(&limit)) return false; return true; } |

