diff options
author | River Riddle <riverriddle@google.com> | 2019-12-22 21:59:55 -0800 |
---|---|---|
committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-12-22 22:00:23 -0800 |
commit | 35807bc4c5c9d8abc31ba0b2f955a82abf276e12 (patch) | |
tree | d083d37d993a774239081509a50e3e6c65366421 /mlir/test/lib | |
parent | 22954a0e408afde1d8686dffb3a3dcab107a2cd3 (diff) | |
download | bcm5719-llvm-35807bc4c5c9d8abc31ba0b2f955a82abf276e12.tar.gz bcm5719-llvm-35807bc4c5c9d8abc31ba0b2f955a82abf276e12.zip |
NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to Value being value-typed.
This is an initial step to refactoring the representation of OpResult as proposed in: https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ
This change will make it much simpler to incrementally transition all of the existing code to use value-typed semantics.
PiperOrigin-RevId: 286844725
Diffstat (limited to 'mlir/test/lib')
-rw-r--r-- | mlir/test/lib/TestDialect/TestDialect.cpp | 8 | ||||
-rw-r--r-- | mlir/test/lib/TestDialect/TestOps.td | 2 | ||||
-rw-r--r-- | mlir/test/lib/TestDialect/TestPatterns.cpp | 33 | ||||
-rw-r--r-- | mlir/test/lib/Transforms/TestLoopMapping.cpp | 2 | ||||
-rw-r--r-- | mlir/test/lib/Transforms/TestVectorizationUtils.cpp | 2 |
5 files changed, 24 insertions, 23 deletions
diff --git a/mlir/test/lib/TestDialect/TestDialect.cpp b/mlir/test/lib/TestDialect/TestDialect.cpp index 7462db4544f..12d024f6593 100644 --- a/mlir/test/lib/TestDialect/TestDialect.cpp +++ b/mlir/test/lib/TestDialect/TestDialect.cpp @@ -100,7 +100,7 @@ struct TestInlinerInterface : public DialectInlinerInterface { /// Handle the given inlined terminator by replacing it with a new operation /// as necessary. void handleTerminator(Operation *op, - ArrayRef<Value *> valuesToRepl) const final { + ArrayRef<ValuePtr> valuesToRepl) const final { // Only handle "test.return" here. auto returnOp = dyn_cast<TestReturnOp>(op); if (!returnOp) @@ -117,7 +117,7 @@ struct TestInlinerInterface : public DialectInlinerInterface { /// operation that takes 'input' as the only operand, and produces a single /// result of 'resultType'. If a conversion can not be generated, nullptr /// should be returned. - Operation *materializeCallConversion(OpBuilder &builder, Value *input, + Operation *materializeCallConversion(OpBuilder &builder, ValuePtr input, Type resultType, Location conversionLoc) const final { // Only allow conversion for i16/i32 types. @@ -231,7 +231,7 @@ static ParseResult parseWrappingRegionOp(OpAsmParser &parser, // Create a return terminator in the inner region, pass as operand to the // terminator the returned values from the wrapped operation. - SmallVector<Value *, 8> return_operands(wrapped_op->getResults()); + SmallVector<ValuePtr, 8> return_operands(wrapped_op->getResults()); OpBuilder builder(parser.getBuilder().getContext()); builder.setInsertionPointToEnd(&block); builder.create<TestReturnOp>(wrapped_op->getLoc(), return_operands); @@ -297,7 +297,7 @@ OpFoldResult TestOpWithRegionFold::fold(ArrayRef<Attribute> operands) { LogicalResult TestOpWithVariadicResultsAndFolder::fold( ArrayRef<Attribute> operands, SmallVectorImpl<OpFoldResult> &results) { - for (Value *input : this->operands()) { + for (ValuePtr input : this->operands()) { results.push_back(input); } return success(); diff --git a/mlir/test/lib/TestDialect/TestOps.td b/mlir/test/lib/TestDialect/TestOps.td index e33d9c26c7f..ea071f0ddf4 100644 --- a/mlir/test/lib/TestDialect/TestOps.td +++ b/mlir/test/lib/TestDialect/TestOps.td @@ -644,7 +644,7 @@ def OpSymbolBindingB : TEST_Op<"symbol_binding_b", []> { let builders = [ OpBuilder< - "Builder *builder, OperationState &state, Value *operand", + "Builder *builder, OperationState &state, ValuePtr operand", [{ state.types.assign({builder->getIntegerType(32)}); state.addOperands({operand}); diff --git a/mlir/test/lib/TestDialect/TestPatterns.cpp b/mlir/test/lib/TestDialect/TestPatterns.cpp index 94eb792cc66..1f6224dba3a 100644 --- a/mlir/test/lib/TestDialect/TestPatterns.cpp +++ b/mlir/test/lib/TestDialect/TestPatterns.cpp @@ -22,11 +22,12 @@ using namespace mlir; // Native function for testing NativeCodeCall -static Value *chooseOperand(Value *input1, Value *input2, BoolAttr choice) { +static ValuePtr chooseOperand(ValuePtr input1, ValuePtr input2, + BoolAttr choice) { return choice.getValue() ? input1 : input2; } -static void createOpI(PatternRewriter &rewriter, Value *input) { +static void createOpI(PatternRewriter &rewriter, ValuePtr input) { rewriter.create<OpI>(rewriter.getUnknownLoc(), input); } @@ -73,7 +74,7 @@ struct ReturnTypeOpMatch : public RewritePattern { PatternMatchResult matchAndRewrite(Operation *op, PatternRewriter &rewriter) const final { if (auto retTypeFn = dyn_cast<InferTypeOpInterface>(op)) { - SmallVector<Value *, 4> values(op->getOperands()); + SmallVector<ValuePtr, 4> values(op->getOperands()); SmallVector<Type, 2> inferedReturnTypes; if (failed(retTypeFn.inferReturnTypes(op->getLoc(), values, op->getAttrs(), op->getRegions(), @@ -132,7 +133,7 @@ struct TestRegionRewriteBlockMovement : public ConversionPattern { : ConversionPattern("test.region", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef<Value *> operands, + matchAndRewrite(Operation *op, ArrayRef<ValuePtr> operands, ConversionPatternRewriter &rewriter) const final { // Inline this region into the parent region. auto &parentRegion = *op->getParentRegion(); @@ -165,7 +166,7 @@ struct TestRegionRewriteUndo : public RewritePattern { // Add an explicitly illegal operation to ensure the conversion fails. rewriter.create<ILLegalOpF>(op->getLoc(), rewriter.getIntegerType(32)); - rewriter.create<TestValidOp>(op->getLoc(), ArrayRef<Value *>()); + rewriter.create<TestValidOp>(op->getLoc(), ArrayRef<ValuePtr>()); // Drop this operation. rewriter.eraseOp(op); @@ -182,7 +183,7 @@ struct TestDropOpSignatureConversion : public ConversionPattern { : ConversionPattern("test.drop_region_op", 1, ctx), converter(converter) { } PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef<Value *> operands, + matchAndRewrite(Operation *op, ArrayRef<ValuePtr> operands, ConversionPatternRewriter &rewriter) const override { Region ®ion = op->getRegion(0); Block *entry = ®ion.front(); @@ -208,7 +209,7 @@ struct TestPassthroughInvalidOp : public ConversionPattern { TestPassthroughInvalidOp(MLIRContext *ctx) : ConversionPattern("test.invalid", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef<Value *> operands, + matchAndRewrite(Operation *op, ArrayRef<ValuePtr> operands, ConversionPatternRewriter &rewriter) const final { rewriter.replaceOpWithNewOp<TestValidOp>(op, llvm::None, operands, llvm::None); @@ -220,7 +221,7 @@ struct TestSplitReturnType : public ConversionPattern { TestSplitReturnType(MLIRContext *ctx) : ConversionPattern("test.return", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef<Value *> operands, + matchAndRewrite(Operation *op, ArrayRef<ValuePtr> operands, ConversionPatternRewriter &rewriter) const final { // Check for a return of F32. if (op->getNumOperands() != 1 || !op->getOperand(0)->getType().isF32()) @@ -245,7 +246,7 @@ struct TestChangeProducerTypeI32ToF32 : public ConversionPattern { TestChangeProducerTypeI32ToF32(MLIRContext *ctx) : ConversionPattern("test.type_producer", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef<Value *> operands, + matchAndRewrite(Operation *op, ArrayRef<ValuePtr> operands, ConversionPatternRewriter &rewriter) const final { // If the type is I32, change the type to F32. if (!(*op->result_type_begin()).isInteger(32)) @@ -258,7 +259,7 @@ struct TestChangeProducerTypeF32ToF64 : public ConversionPattern { TestChangeProducerTypeF32ToF64(MLIRContext *ctx) : ConversionPattern("test.type_producer", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef<Value *> operands, + matchAndRewrite(Operation *op, ArrayRef<ValuePtr> operands, ConversionPatternRewriter &rewriter) const final { // If the type is F32, change the type to F64. if (!(*op->result_type_begin()).isF32()) @@ -271,7 +272,7 @@ struct TestChangeProducerTypeF32ToInvalid : public ConversionPattern { TestChangeProducerTypeF32ToInvalid(MLIRContext *ctx) : ConversionPattern("test.type_producer", 10, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef<Value *> operands, + matchAndRewrite(Operation *op, ArrayRef<ValuePtr> operands, ConversionPatternRewriter &rewriter) const final { // Always convert to B16, even though it is not a legal type. This tests // that values are unmapped correctly. @@ -283,7 +284,7 @@ struct TestUpdateConsumerType : public ConversionPattern { TestUpdateConsumerType(MLIRContext *ctx) : ConversionPattern("test.type_consumer", 1, ctx) {} PatternMatchResult - matchAndRewrite(Operation *op, ArrayRef<Value *> operands, + matchAndRewrite(Operation *op, ArrayRef<ValuePtr> operands, ConversionPatternRewriter &rewriter) const final { // Verify that the incoming operand has been successfully remapped to F64. if (!operands[0]->getType().isF64()) @@ -344,7 +345,7 @@ struct TestTypeConverter : public TypeConverter { /// Override the hook to materialize a conversion. This is necessary because /// we generate 1->N type mappings. Operation *materializeConversion(PatternRewriter &rewriter, Type resultType, - ArrayRef<Value *> inputs, + ArrayRef<ValuePtr> inputs, Location loc) override { return rewriter.create<TestCastOp>(loc, resultType, inputs); } @@ -467,13 +468,13 @@ struct OneVResOneVOperandOp1Converter using OpConversionPattern<OneVResOneVOperandOp1>::OpConversionPattern; PatternMatchResult - matchAndRewrite(OneVResOneVOperandOp1 op, ArrayRef<Value *> operands, + matchAndRewrite(OneVResOneVOperandOp1 op, ArrayRef<ValuePtr> operands, ConversionPatternRewriter &rewriter) const override { auto origOps = op.getOperands(); assert(std::distance(origOps.begin(), origOps.end()) == 1 && "One operand expected"); - Value *origOp = *origOps.begin(); - SmallVector<Value *, 2> remappedOperands; + ValuePtr origOp = *origOps.begin(); + SmallVector<ValuePtr, 2> remappedOperands; // Replicate the remapped original operand twice. Note that we don't used // the remapped 'operand' since the goal is testing 'getRemappedValue'. remappedOperands.push_back(rewriter.getRemappedValue(origOp)); diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp index c25fea9aa13..7f587fc3170 100644 --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -41,7 +41,7 @@ public: // SSA values for the transformation are created out of thin air by // unregistered "new_processor_id_and_range" operations. This is enough to // emulate mapping conditions. - SmallVector<Value *, 8> processorIds, numProcessors; + SmallVector<ValuePtr, 8> processorIds, numProcessors; func.walk([&processorIds, &numProcessors](Operation *op) { if (op->getName().getStringRef() != "new_processor_id_and_range") return; diff --git a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp index 7efc74f2304..35df0631ca7 100644 --- a/mlir/test/lib/Transforms/TestVectorizationUtils.cpp +++ b/mlir/test/lib/Transforms/TestVectorizationUtils.cpp @@ -245,7 +245,7 @@ void VectorizerTestPass::testNormalizeMaps() { for (auto m : matches) { auto app = cast<AffineApplyOp>(m.getMatchedOperation()); OpBuilder b(m.getMatchedOperation()); - SmallVector<Value *, 8> operands(app.getOperands()); + SmallVector<ValuePtr, 8> operands(app.getOperands()); makeComposedAffineApply(b, app.getLoc(), app.getAffineMap(), operands); } } |