2019-11-15 02:34:46 +08:00
|
|
|
add_subdirectory(AffineToStandard)
|
2021-10-13 07:14:57 +08:00
|
|
|
add_subdirectory(ArithmeticToLLVM)
|
|
|
|
add_subdirectory(ArithmeticToSPIRV)
|
2021-06-11 04:57:44 +08:00
|
|
|
add_subdirectory(ArmNeon2dToIntr)
|
2020-10-23 03:20:42 +08:00
|
|
|
add_subdirectory(AsyncToLLVM)
|
2021-11-18 23:44:46 +08:00
|
|
|
add_subdirectory(BufferizationToMemRef)
|
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-07-09 22:41:36 +08:00
|
|
|
add_subdirectory(MathToLLVM)
|
2021-07-30 04:21:43 +08:00
|
|
|
add_subdirectory(MathToSPIRV)
|
2021-07-09 00:35:18 +08:00
|
|
|
add_subdirectory(MemRefToLLVM)
|
2021-07-30 04:22:46 +08:00
|
|
|
add_subdirectory(MemRefToSPIRV)
|
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)
|
[mlir] Factor type reconciliation out of Standard-to-LLVM conversion
Conversion to the LLVM dialect is being refactored to be more progressive and
is now performed as a series of independent passes converting different
dialects. These passes may produce `unrealized_conversion_cast` operations that
represent pending conversions between built-in and LLVM dialect types.
Historically, a more monolithic Standard-to-LLVM conversion pass did not need
these casts as all operations were converted in one shot. Previous refactorings
have led to the requirement of running the Standard-to-LLVM conversion pass to
clean up `unrealized_conversion_cast`s even though the IR had no standard
operations in it. The pass must have been also run the last among all to-LLVM
passes, in contradiction with the partial conversion logic. Additionally, the
way it was set up could produce invalid operations by removing casts between
LLVM and built-in types even when the consumer did not accept the uncasted
type, or could lead to cryptic conversion errors (recursive application of the
rewrite pattern on `unrealized_conversion_cast` as a means to indicate failure
to eliminate casts).
In fact, the need to eliminate A->B->A `unrealized_conversion_cast`s is not
specific to to-LLVM conversions and can be factored out into a separate type
reconciliation pass, which is achieved in this commit. While the cast operation
itself has a folder pattern, it is insufficient in most conversion passes as
the folder only applies to the second cast. Without complex legality setup in
the conversion target, the conversion infra will either consider the cast
operations valid and not fold them (a separate canonicalization would be
necessary to trigger the folding), or consider the first cast invalid upon
generation and stop with error. The pattern provided by the reconciliation pass
applies to the first cast operation instead. Furthermore, having a separate
pass makes it clear when `unrealized_conversion_cast`s could not have been
eliminated since it is the only reason why this pass can fail.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D109507
2021-09-09 22:06:10 +08:00
|
|
|
add_subdirectory(ReconcileUnrealizedCasts)
|
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)
|