83 lines · plain
1// RUN: mlir-pdll %s -I %S -split-input-file | FileCheck %s2 3// CHECK: Module4// CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Tuple<>>5Constraint Foo();6 7// -----8 9// CHECK: Module10// CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Tuple<>> Code< /* Native Code */ >11Constraint Foo() [{ /* Native Code */ }];12 13// -----14 15// Test that native constraints support returning results.16 17// CHECK: Module18// CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Attr>19Constraint Foo() -> Attr;20 21// -----22 23// CHECK: Module24// CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Value>25// CHECK: `Inputs`26// CHECK: `-VariableDecl {{.*}} Name<arg> Type<Value>27// CHECK: `Results`28// CHECK: `-VariableDecl {{.*}} Name<> Type<Value>29// CHECK: `-CompoundStmt {{.*}}30// CHECK: `-ReturnStmt {{.*}}31// CHECK: `-DeclRefExpr {{.*}} Type<Value>32// CHECK: `-VariableDecl {{.*}} Name<arg> Type<Value>33Constraint Foo(arg: Value) -> Value => arg;34 35// -----36 37// CHECK: Module38// CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Tuple<result1: Value, result2: Attr>>39// CHECK: `Results`40// CHECK: |-VariableDecl {{.*}} Name<result1> Type<Value>41// CHECK: | `Constraints`42// CHECK: | `-ValueConstraintDecl {{.*}}43// CHECK: `-VariableDecl {{.*}} Name<result2> Type<Attr>44// CHECK: `Constraints`45// CHECK: `-AttrConstraintDecl {{.*}}46// CHECK: `-CompoundStmt {{.*}}47// CHECK: `-ReturnStmt {{.*}}48// CHECK: `-TupleExpr {{.*}} Type<Tuple<result1: Value, result2: Attr>>49// CHECK: |-MemberAccessExpr {{.*}} Member<0> Type<Value>50// CHECK: | `-TupleExpr {{.*}} Type<Tuple<Value, Attr>>51// CHECK: `-MemberAccessExpr {{.*}} Member<1> Type<Attr>52// CHECK: `-TupleExpr {{.*}} Type<Tuple<Value, Attr>>53Constraint Foo() -> (result1: Value, result2: Attr) => (_: Value, attr<"10">);54 55// -----56 57// CHECK: Module58// CHECK: |-UserConstraintDecl {{.*}} Name<Bar> ResultType<Tuple<>>59// CHECK: `-UserConstraintDecl {{.*}} Name<Foo> ResultType<Value>60// CHECK: `Inputs`61// CHECK: `-VariableDecl {{.*}} Name<arg> Type<Value>62// CHECK: `Constraints`63// CHECK: `-UserConstraintDecl {{.*}} Name<Bar> ResultType<Tuple<>>64// CHECK: `Results`65// CHECK: `-VariableDecl {{.*}} Name<> Type<Value>66// CHECK: `Constraints`67// CHECK: `-UserConstraintDecl {{.*}} Name<Bar> ResultType<Tuple<>>68Constraint Bar(input: Value);69 70Constraint Foo(arg: Bar) -> Bar => arg;71 72// -----73 74// Test that anonymous constraints are uniquely named.75 76// CHECK: Module77// CHECK: UserConstraintDecl {{.*}} Name<<anonymous_constraint_0>> ResultType<Tuple<>>78// CHECK: UserConstraintDecl {{.*}} Name<<anonymous_constraint_1>> ResultType<Attr>79Constraint Outer() {80 Constraint() {};81 Constraint() => attr<"10">;82}83