diff options
author | River Riddle <riddleriver@gmail.com> | 2020-03-12 14:06:41 -0700 |
---|---|---|
committer | River Riddle <riddleriver@gmail.com> | 2020-03-12 14:26:15 -0700 |
commit | 0ddba0bd59c337f16b51a00cb205ecfda46f97fa (patch) | |
tree | be1aaf1254f0c625d48ba66270d69b0db8b38a2e /mlir/docs/Tutorials | |
parent | 907403f342fe661b590f930a83f940c67b3ff855 (diff) | |
download | llvm-0ddba0bd59c337f16b51a00cb205ecfda46f97fa.zip llvm-0ddba0bd59c337f16b51a00cb205ecfda46f97fa.tar.gz llvm-0ddba0bd59c337f16b51a00cb205ecfda46f97fa.tar.bz2 |
[mlir][SideEffects] Replace HasNoSideEffect with the memory effect interfaces.
HasNoSideEffect can now be implemented using the MemoryEffectInterface, removing the need to check multiple things for the same information. This also removes an easy foot-gun for users as 'Operation::hasNoSideEffect' would ignore operations that dynamically, or recursively, have no side effects. This also leads to an immediate improvement in some of the existing users, such as DCE, now that they have access to more information.
Differential Revision: https://reviews.llvm.org/D76036
Diffstat (limited to 'mlir/docs/Tutorials')
-rwxr-xr-x | mlir/docs/Tutorials/Toy/Ch-2.md | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/mlir/docs/Tutorials/Toy/Ch-2.md b/mlir/docs/Tutorials/Toy/Ch-2.md index 881e077..c8be481 100755 --- a/mlir/docs/Tutorials/Toy/Ch-2.md +++ b/mlir/docs/Tutorials/Toy/Ch-2.md @@ -206,9 +206,7 @@ class ConstantOp : public mlir::Op<ConstantOp, /// The ConstantOp takes no inputs. mlir::OpTrait::ZeroOperands, /// The ConstantOp returns a single result. - mlir::OpTrait::OneResult, - /// The ConstantOp is pure and has no visible side-effects. - mlir::OpTrait::HasNoSideEffect> { + mlir::OpTrait::OneResult> { public: /// Inherit the constructors from the base Op class. @@ -335,15 +333,13 @@ operation. We define a toy operation by inheriting from our base 'Toy_Op' class above. Here we provide the mnemonic and a list of traits for the operation. The [mnemonic](../../OpDefinitions.md#operation-name) here matches the one given in -`ConstantOp::getOperationName` without the dialect prefix; `toy.`. The constant -operation here is also marked as 'NoSideEffect'. This is an ODS trait, and -matches one-to-one with the trait we providing when defining `ConstantOp`: -`mlir::OpTrait::HasNoSideEffect`. Missing here from our C++ definition are the -`ZeroOperands` and `OneResult` traits; these will be automatically inferred -based upon the `arguments` and `results` fields we define later. +`ConstantOp::getOperationName` without the dialect prefix; `toy.`. Missing here +from our C++ definition are the `ZeroOperands` and `OneResult` traits; these +will be automatically inferred based upon the `arguments` and `results` fields +we define later. ```tablegen -def ConstantOp : Toy_Op<"constant", [NoSideEffect]> { +def ConstantOp : Toy_Op<"constant"> { } ``` @@ -369,7 +365,7 @@ values. The results correspond to a set of types for the values produced by the operation: ```tablegen -def ConstantOp : Toy_Op<"constant", [NoSideEffect]> { +def ConstantOp : Toy_Op<"constant"> { // The constant operation takes an attribute as the only input. // `F64ElementsAttr` corresponds to a 64-bit floating-point ElementsAttr. let arguments = (ins F64ElementsAttr:$value); @@ -394,7 +390,7 @@ for users of the dialect and can even be used to auto-generate Markdown documents. ```tablegen -def ConstantOp : Toy_Op<"constant", [NoSideEffect]> { +def ConstantOp : Toy_Op<"constant"> { // Provide a summary and description for this operation. This can be used to // auto-generate documentation of the operations within our dialect. let summary = "constant operation"; @@ -432,7 +428,7 @@ as part of `ConstantOp::verify`. This blob can assume that all of the other invariants of the operation have already been verified: ```tablegen -def ConstantOp : Toy_Op<"constant", [NoSideEffect]> { +def ConstantOp : Toy_Op<"constant"> { // Provide a summary and description for this operation. This can be used to // auto-generate documentation of the operations within our dialect. let summary = "constant operation"; @@ -472,7 +468,7 @@ of C++ parameters, as well as an optional code block that can be used to specify the implementation inline. ```tablegen -def ConstantOp : Toy_Op<"constant", [NoSideEffect]> { +def ConstantOp : Toy_Op<"constant"> { ... // Add custom build methods for the constant operation. These methods populate |