// RUN: mlir-pdll %s -I %S -split-input-file | FileCheck %s
// CHECK: Module
// CHECK: `-UserRewriteDecl {{.*}} Name<Foo> ResultType<Tuple<>>
Rewrite Foo();
// -----
// CHECK: Module
// CHECK: `-UserRewriteDecl {{.*}} Name<Foo> ResultType<Tuple<>> Code< /* Native Code */ >
Rewrite Foo() [{ /* Native Code */ }];
// -----
// CHECK: Module
// CHECK: `-UserRewriteDecl {{.*}} Name<Foo> ResultType<Value>
// CHECK: `Inputs`
// CHECK: `-VariableDecl {{.*}} Name<arg> Type<Op>
// CHECK: `Results`
// CHECK: `-VariableDecl {{.*}} Name<> Type<Value>
// CHECK: `-CompoundStmt {{.*}}
// CHECK: `-ReturnStmt {{.*}}
// CHECK: `-MemberAccessExpr {{.*}} Member<$results> Type<Value>
// CHECK: `-DeclRefExpr {{.*}} Type<Op>
// CHECK: `-VariableDecl {{.*}} Name<arg> Type<Op>
Rewrite Foo(arg: Op) -> Value => arg;
// -----
// CHECK: Module
// CHECK: `-UserRewriteDecl {{.*}} Name<Foo> ResultType<Tuple<result1: Value, result2: Attr>>
// CHECK: `Results`
// CHECK: |-VariableDecl {{.*}} Name<result1> Type<Value>
// CHECK: | `Constraints`
// CHECK: | `-ValueConstraintDecl {{.*}}
// CHECK: `-VariableDecl {{.*}} Name<result2> Type<Attr>
// CHECK: `Constraints`
// CHECK: `-AttrConstraintDecl {{.*}}
// CHECK: `-CompoundStmt {{.*}}
// CHECK: `-ReturnStmt {{.*}}
// CHECK: `-TupleExpr {{.*}} Type<Tuple<result1: Value, result2: Attr>>
// CHECK: |-MemberAccessExpr {{.*}} Member<0> Type<Value>
// CHECK: | `-TupleExpr {{.*}} Type<Tuple<Value, Attr>>
// CHECK: `-MemberAccessExpr {{.*}} Member<1> Type<Attr>
// CHECK: `-TupleExpr {{.*}} Type<Tuple<Value, Attr>>
Rewrite Foo() -> (result1: Value, result2: Attr) => (_: Value, attr<"10">);
// -----
// Test that anonymous Rewrites are uniquely named.
// CHECK: Module
// CHECK: UserRewriteDecl {{.*}} Name<<anonymous_rewrite_0>> ResultType<Tuple<>>
// CHECK: UserRewriteDecl {{.*}} Name<<anonymous_rewrite_1>> ResultType<Attr>
Rewrite Outer() {
Rewrite() {};
Rewrite() => attr<"10">;
}