diff options
author | Tobias Gysi <tobias.gysi@nextsilicon.com> | 2023-03-22 08:38:55 +0100 |
---|---|---|
committer | Tobias Gysi <tobias.gysi@nextsilicon.com> | 2023-03-22 09:02:15 +0100 |
commit | f809eb4db2d14a5a529f9f440b849b7489292976 (patch) | |
tree | 0954c754dcd80896845ff4a98b35b8693c225ecc /mlir/docs | |
parent | 9c16eef1ec46e10185713043663511d49ffff6b1 (diff) | |
download | llvm-f809eb4db2d14a5a529f9f440b849b7489292976.tar.gz |
[mlir] Argument and result attribute handling during inlining.
The revision adds the handleArgument and handleResult handlers that
allow users of the inlining interface to implement argument and result
conversions that take argument and result attributes into account. The
motivating use cases for this revision are taken from the LLVM dialect
inliner, which has to copy arguments that are marked as byval and that
also has to consider zeroext / signext when converting integers.
All type conversions are currently handled by the
materializeCallConversion hook. It runs before isLegalToInline and
supports only the introduction of a single cast operation since it may
have to rollback. The new handlers run shortly before and after
inlining and cannot fail. As a result, they can introduce more complex
ir such as copying a struct argument. At the moment, the new hooks
cannot be used to perform type conversions since all type conversions
have to be done using the materializeCallConversion. A follow up
revision will either relax this constraint or drop
materializeCallConversion in favor of the new and more flexible
handlers.
The revision also extends the CallableOpInterface to provide access
to the argument and result attributes if available.
Reviewed By: rriddle, Dinistro
Differential Revision: https://reviews.llvm.org/D145582
Diffstat (limited to 'mlir/docs')
-rw-r--r-- | mlir/docs/Interfaces.md | 2 | ||||
-rw-r--r-- | mlir/docs/Tutorials/Toy/Ch-4.md | 12 |
2 files changed, 14 insertions, 0 deletions
diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md index 6bb507013863..b51adec4fc4f 100644 --- a/mlir/docs/Interfaces.md +++ b/mlir/docs/Interfaces.md @@ -731,6 +731,8 @@ interface section goes as follows: * `CallableOpInterface` - Used to represent the target callee of call. - `Region * getCallableRegion()` - `ArrayRef<Type> getCallableResults()` + - `ArrayAttr getCallableArgAttrs()` + - `ArrayAttr getCallableResAttrs()` ##### RegionKindInterfaces diff --git a/mlir/docs/Tutorials/Toy/Ch-4.md b/mlir/docs/Tutorials/Toy/Ch-4.md index 77a52163774f..f462274fa592 100644 --- a/mlir/docs/Tutorials/Toy/Ch-4.md +++ b/mlir/docs/Tutorials/Toy/Ch-4.md @@ -169,6 +169,18 @@ Region *FuncOp::getCallableRegion() { return &getBody(); } /// executed. ArrayRef<Type> FuncOp::getCallableResults() { return getType().getResults(); } +/// Returns the argument attributes for all callable region arguments or +/// null if there are none. +ArrayAttr FuncOp::getCallableArgAttrs() { + return getArgAttrs().value_or(nullptr); +} + +/// Returns the result attributes for all callable region results or +/// null if there are none. +ArrayAttr FuncOp::getCallableResAttrs() { + return getResAttrs().value_or(nullptr); +} + // .... /// Return the callee of the generic call operation, this is required by the |