llvm-project/mlir/lib/TableGen
Chris Lattner 9eb3e564d3 [ODS] Make the getType() method on a OneResult instruction return a specific type.
Implement Bug 46698, making ODS synthesize a getType() method that returns a
specific C++ class for OneResult methods where we know that class.  This eliminates
a common source of casts in things like:

   myOp.getType().cast<FIRRTLType>().getPassive()

because we know that myOp always returns a FIRRTLType.  This also encourages
op authors to type their results more tightly (which is also good for
verification).

I chose to implement this by splitting the OneResult trait into itself plus a
OneTypedResult trait, given that many things are using `hasTrait<OneResult>`
to conditionalize various logic.

While this changes makes many many ops get more specific getType() results, it
is generally drop-in compatible with the previous behavior because 'x.cast<T>()'
is allowed when x is already known to be a T.  The one exception to this is that
we need declarations of the types used by ops, which is why a couple headers
needed additional #includes.

I updated a few things in tree to remove the now-redundant `.cast<>`'s, but there
are probably many more than can be removed.

Differential Revision: https://reviews.llvm.org/D93790
2020-12-26 13:52:40 -08:00
..
Argument.cpp [MLIR][NFC] Remove tblgen:: prefix in TableGen/*.cpp files 2020-08-12 14:41:18 -07:00
Attribute.cpp [TableGen] Eliminate the 'code' type 2020-12-03 10:19:11 -05:00
CMakeLists.txt [mlir] NFC: fix trivial typos 2020-10-29 04:05:22 +09:00
Constraint.cpp [mlir][IR] Define the singleton builtin types in ODS instead of C++ 2020-12-15 13:42:19 -08:00
Dialect.cpp [TableGen] Eliminate the 'code' type 2020-12-03 10:19:11 -05:00
Format.cpp Import llvm::StringSwitch into mlir namespace. 2020-10-08 11:39:24 +02:00
Interfaces.cpp [mlir][ODS] Add support for specifying the namespace of an interface. 2020-07-12 14:18:32 -07:00
OpClass.cpp [mlir][IR] Use tablegen for the BuiltinDialect and operations 2020-11-17 00:53:40 -08:00
OpTrait.cpp [MLIR][NFC] Remove tblgen:: prefix in TableGen/*.cpp files 2020-08-12 14:41:18 -07:00
Operator.cpp [TableGen] Eliminate the 'code' type 2020-12-03 10:19:11 -05:00
Pass.cpp Separate the Registration from Loading dialects in the Context 2020-08-19 01:19:03 +00:00
Pattern.cpp [TableGen] Eliminate the 'code' type 2020-12-03 10:19:11 -05:00
Predicate.cpp Import llvm::StringSwitch into mlir namespace. 2020-10-08 11:39:24 +02:00
Region.cpp [mlir][ODS] Add support for variadic regions. 2020-04-05 01:03:38 -07:00
SideEffects.cpp [mlir][ODS] Add support for specifying the namespace of an interface. 2020-07-12 14:18:32 -07:00
Successor.cpp [llvm][ADT] Move TypeSwitch class from MLIR to LLVM 2020-04-14 15:14:41 -07:00
Type.cpp [ODS] Make the getType() method on a OneResult instruction return a specific type. 2020-12-26 13:52:40 -08:00
TypeDef.cpp [mlir][IR] Define the singleton builtin types in ODS instead of C++ 2020-12-15 13:42:19 -08:00