2019-11-15 02:34:46 +08:00
|
|
|
add_subdirectory(AffineToStandard)
|
2021-06-11 04:57:44 +08:00
|
|
|
add_subdirectory(ArmNeon2dToIntr)
|
2020-10-23 03:20:42 +08:00
|
|
|
add_subdirectory(AsyncToLLVM)
|
2021-01-16 02:53:15 +08:00
|
|
|
add_subdirectory(ComplexToLLVM)
|
2021-04-28 18:49:57 +08:00
|
|
|
add_subdirectory(ComplexToStandard)
|
2020-05-19 02:01:54 +08:00
|
|
|
add_subdirectory(GPUCommon)
|
2019-06-17 18:56:20 +08:00
|
|
|
add_subdirectory(GPUToNVVM)
|
2019-10-02 16:50:03 +08:00
|
|
|
add_subdirectory(GPUToROCDL)
|
2019-07-31 02:29:48 +08:00
|
|
|
add_subdirectory(GPUToSPIRV)
|
2020-02-14 02:29:13 +08:00
|
|
|
add_subdirectory(GPUToVulkan)
|
2019-11-22 07:19:52 +08:00
|
|
|
add_subdirectory(LinalgToLLVM)
|
2020-01-27 00:10:29 +08:00
|
|
|
add_subdirectory(LinalgToSPIRV)
|
2020-05-15 12:22:21 +08:00
|
|
|
add_subdirectory(LinalgToStandard)
|
2021-07-07 15:46:27 +08:00
|
|
|
add_subdirectory(LLVMCommon)
|
2021-04-13 16:18:34 +08:00
|
|
|
add_subdirectory(MathToLibm)
|
2021-05-12 23:31:18 +08:00
|
|
|
add_subdirectory(OpenACCToLLVM)
|
2021-06-08 00:09:25 +08:00
|
|
|
add_subdirectory(OpenACCToSCF)
|
2020-08-13 16:03:04 +08:00
|
|
|
add_subdirectory(OpenMPToLLVM)
|
[mlir] Add a conversion pass between PDL and the PDL Interpreter Dialect
The conversion between PDL and the interpreter is split into several different parts.
** The Matcher:
The matching section of all incoming pdl.pattern operations is converted into a predicate tree and merged. Each pattern is first converted into an ordered list of predicates starting from the root operation. A predicate is composed of three distinct parts:
* Position
- A position refers to a specific location on the input DAG, i.e. an
existing MLIR entity being matched. These can be attributes, operands,
operations, results, and types. Each position also defines a relation to
its parent. For example, the operand `[0] -> 1` has a parent operation
position `[0]` (the root).
* Question
- A question refers to a query on a specific positional value. For
example, an operation name question checks the name of an operation
position.
* Answer
- An answer is the expected result of a question. For example, when
matching an operation with the name "foo.op". The question would be an
operation name question, with an expected answer of "foo.op".
After the predicate lists have been created and ordered(based on occurrence of common predicates and other factors), they are formed into a tree of nodes that represent the branching flow of a pattern match. This structure allows for efficient construction and merging of the input patterns. There are currently only 4 simple nodes in the tree:
* ExitNode: Represents the termination of a match
* SuccessNode: Represents a successful match of a specific pattern
* BoolNode/SwitchNode: Branch to a specific child node based on the expected answer to a predicate question.
Once the matcher tree has been generated, this tree is walked to generate the corresponding interpreter operations.
** The Rewriter:
The rewriter portion of a pattern is generated in a very straightforward manor, similarly to lowerings in other dialects. Each PDL operation that may exist within a rewrite has a mapping into the interpreter dialect. The code for the rewriter is generated within a FuncOp, that is invoked by the interpreter on a successful pattern match. Referenced values defined in the matcher become inputs the generated rewriter function.
An example lowering is shown below:
```mlir
// The following high level PDL pattern:
pdl.pattern : benefit(1) {
%resultType = pdl.type
%inputOperand = pdl.input
%root, %results = pdl.operation "foo.op"(%inputOperand) -> %resultType
pdl.rewrite %root {
pdl.replace %root with (%inputOperand)
}
}
// is lowered to the following:
module {
// The matcher function takes the root operation as an input.
func @matcher(%arg0: !pdl.operation) {
pdl_interp.check_operation_name of %arg0 is "foo.op" -> ^bb2, ^bb1
^bb1:
pdl_interp.return
^bb2:
pdl_interp.check_operand_count of %arg0 is 1 -> ^bb3, ^bb1
^bb3:
pdl_interp.check_result_count of %arg0 is 1 -> ^bb4, ^bb1
^bb4:
%0 = pdl_interp.get_operand 0 of %arg0
pdl_interp.is_not_null %0 : !pdl.value -> ^bb5, ^bb1
^bb5:
%1 = pdl_interp.get_result 0 of %arg0
pdl_interp.is_not_null %1 : !pdl.value -> ^bb6, ^bb1
^bb6:
// This operation corresponds to a successful pattern match.
pdl_interp.record_match @rewriters::@rewriter(%0, %arg0 : !pdl.value, !pdl.operation) : benefit(1), loc([%arg0]), root("foo.op") -> ^bb1
}
module @rewriters {
// The inputs to the rewriter from the matcher are passed as arguments.
func @rewriter(%arg0: !pdl.value, %arg1: !pdl.operation) {
pdl_interp.replace %arg1 with(%arg0)
pdl_interp.return
}
}
}
```
Differential Revision: https://reviews.llvm.org/D84580
2020-10-27 08:23:16 +08:00
|
|
|
add_subdirectory(PDLToPDLInterp)
|
2020-05-14 20:41:35 +08:00
|
|
|
add_subdirectory(SCFToGPU)
|
2020-11-24 03:29:27 +08:00
|
|
|
add_subdirectory(SCFToOpenMP)
|
2020-07-02 07:54:26 +08:00
|
|
|
add_subdirectory(SCFToSPIRV)
|
2020-05-14 20:41:35 +08:00
|
|
|
add_subdirectory(SCFToStandard)
|
2020-06-04 00:14:42 +08:00
|
|
|
add_subdirectory(ShapeToStandard)
|
2020-06-09 06:20:52 +08:00
|
|
|
add_subdirectory(SPIRVToLLVM)
|
2019-06-15 06:54:21 +08:00
|
|
|
add_subdirectory(StandardToLLVM)
|
2019-07-03 08:22:21 +08:00
|
|
|
add_subdirectory(StandardToSPIRV)
|
2021-01-06 06:26:48 +08:00
|
|
|
add_subdirectory(TosaToLinalg)
|
2021-02-26 10:08:29 +08:00
|
|
|
add_subdirectory(TosaToSCF)
|
|
|
|
add_subdirectory(TosaToStandard)
|
2020-06-06 00:53:41 +08:00
|
|
|
add_subdirectory(VectorToROCDL)
|
2019-12-04 09:51:34 +08:00
|
|
|
add_subdirectory(VectorToLLVM)
|
2021-06-11 22:39:01 +08:00
|
|
|
add_subdirectory(VectorToGPU)
|
2020-05-14 20:41:35 +08:00
|
|
|
add_subdirectory(VectorToSCF)
|
2020-10-07 02:35:14 +08:00
|
|
|
add_subdirectory(VectorToSPIRV)
|