Move tests and add missing BUILD file.

Updated the extracted base classes here. The test wasn't updated post the move.

PiperOrigin-RevId: 229353434
This commit is contained in:
Jacques Pienaar 2019-01-15 05:14:18 -08:00 committed by jpienaar
parent 11ab300ad5
commit 02ba8fd6d9

View File

@ -1,7 +1,9 @@
// RUN: mlir-rewriter-gen %s | FileCheck %s
// RUN: mlir-tblgen -gen-rewriters %s | FileCheck %s
// Extracted & simplified from op_base.td to do more directed testing.
class Type;
class Type {
code builderCall = ?;
}
class Pattern<dag patternToMatch, list<dag> resultOps> {
dag PatternToMatch = patternToMatch;
list<dag> ResultOps = resultOps;
@ -9,26 +11,32 @@ class Pattern<dag patternToMatch, list<dag> resultOps> {
class Pat<dag pattern, dag result> : Pattern<pattern, [result]>;
def ins;
class Op<string mnemonic> {
string name = mnemonic;
dag operands = (ins);
string opName = mnemonic;
dag arguments = (ins);
}
class Attr<Type t> {
Type type = t;
code storageType = ?;
code returnType = ?;
}
// Create a Type and Attribute.
def YT : Type;
def YT : Type {
let builderCall = "buildYT()";
}
def Y_Attr : Attr<YT>;
def Y_Const_Attr {
Type type = YT;
Attr attr = Y_Attr;
string value = "attrValue";
}
// Define ops to rewrite.
def T1: Type;
def X_AddOp : Op<"x.add">;
def X_AddOp : Op<"x.add"> {
let arguments = (ins T1, T1);
}
def Y_AddOp : Op<"y.add"> {
let operands = (ins T1, T1, Y_Attr:$attrName);
let arguments = (ins T1, T1, Y_Attr:$attrName);
}
// Define rewrite pattern.
@ -36,9 +44,9 @@ def : Pat<(X_AddOp $lhs, $rhs), (Y_AddOp $lhs, T1:$rhs, Y_Const_Attr:$x)>;
// CHECK: struct GeneratedConvert0 : public RewritePattern
// CHECK: RewritePattern("x.add", 1, context)
// CHECK: PatternMatchResult match(OperationInst *op)
// CHECK: void rewrite(OperationInst *op, PatternRewriter &rewriter)
// CHECK: rewriter.replaceOpWithNewOp<Y::AddOp>(op, op->getResult(0)->getType()
// CHECK: PatternMatchResult match(OperationInst *
// CHECK: void rewrite(OperationInst *op, std::unique_ptr<PatternState>
// CHECK: PatternRewriter &rewriter)
// CHECK: rewriter.replaceOpWithNewOp<AddOp>(op, op->getResult(0)->getType()
// CHECK: void populateWithGenerated
// CHECK: patterns->push_back(std::make_unique<GeneratedConvert0>(context))
// CHECK: patterns->push_back(std::make_unique<GeneratedConvert0>(context))