76 lines · plain
1// RUN: mlir-opt -split-input-file %s | mlir-opt2// Verify the printed output can be parsed.3// RUN: mlir-opt %s | mlir-opt4// Verify the generic form can be parsed.5// RUN: mlir-opt -mlir-print-op-generic %s | mlir-opt6 7// -----8 9// Unused operation to force loading the `arithmetic` dialect for the10// test of type inferrence.11arith.constant true12 13func.func @operations(%attribute: !pdl.attribute,14 %input: !pdl.value,15 %type: !pdl.type) {16 // attributes, operands, and results17 %op0 = pdl_interp.create_operation "foo.op"(%input : !pdl.value) {"attr" = %attribute} -> (%type : !pdl.type)18 19 // attributes, and results20 %op1 = pdl_interp.create_operation "foo.op" {"attr" = %attribute} -> (%type : !pdl.type)21 22 // attributes23 %op2 = pdl_interp.create_operation "foo.op" {"attr" = %attribute, "attr1" = %attribute}24 25 // operands, and results26 %op3 = pdl_interp.create_operation "foo.op"(%input : !pdl.value) -> (%type : !pdl.type)27 28 // inferred results29 %op4 = pdl_interp.create_operation "arith.constant" -> <inferred>30 31 pdl_interp.finalize32}33 34// -----35 36func.func @extract(%attrs : !pdl.range<attribute>, %ops : !pdl.range<operation>, %types : !pdl.range<type>, %vals: !pdl.range<value>) {37 // attribute at index 038 %attr = pdl_interp.extract 0 of %attrs : !pdl.attribute39 40 // operation at index 141 %op = pdl_interp.extract 1 of %ops : !pdl.operation42 43 // type at index 244 %type = pdl_interp.extract 2 of %types : !pdl.type45 46 // value at index 347 %val = pdl_interp.extract 3 of %vals : !pdl.value48 49 pdl_interp.finalize50}51 52// -----53 54func.func @foreach(%ops: !pdl.range<operation>) {55 // iterate over a range of operations56 pdl_interp.foreach %op : !pdl.operation in %ops {57 %val = pdl_interp.get_result 0 of %op58 pdl_interp.continue59 } -> ^end60 61 ^end:62 pdl_interp.finalize63}64 65// -----66 67func.func @users(%value: !pdl.value, %values: !pdl.range<value>) {68 // all the users of a single value69 %ops1 = pdl_interp.get_users of %value : !pdl.value70 71 // all the users of all the values in a range72 %ops2 = pdl_interp.get_users of %values : !pdl.range<value>73 74 pdl_interp.finalize75}76