diff options
| author | Lei Zhang <antiagainst@google.com> | 2019-11-25 17:26:16 -0800 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-11-25 17:26:50 -0800 |
| commit | 13c6e419ca68cd4a5434f4349db5433395e6fbf0 (patch) | |
| tree | 3c880b0becb1e573af20fa3224abef75377d3d12 /mlir/lib/TableGen | |
| parent | 174076a1572047cf7945199ec5e7507d61f64e65 (diff) | |
| download | bcm5719-llvm-13c6e419ca68cd4a5434f4349db5433395e6fbf0.tar.gz bcm5719-llvm-13c6e419ca68cd4a5434f4349db5433395e6fbf0.zip | |
Add support for AttrSizedOperandSegments/AttrSizedResultSegments
Certain operations can have multiple variadic operands and their size
relationship is not always known statically. For such cases, we need
a per-op-instance specification to divide the operands into logical
groups or segments. This can be modeled by attributes.
This CL introduces C++ trait AttrSizedOperandSegments for operands and
AttrSizedResultSegments for results. The C++ trait just guarantees
such size attribute has the correct type (1D vector) and values
(non-negative), etc. It serves as the basis for ODS sugaring that
with ODS argument declarations we can further verify the number of
elements match the number of ODS-declared operands and we can generate
handy getter methods.
PiperOrigin-RevId: 282467075
Diffstat (limited to 'mlir/lib/TableGen')
| -rw-r--r-- | mlir/lib/TableGen/Operator.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp index 927f275e080..4529208a39c 100644 --- a/mlir/lib/TableGen/Operator.cpp +++ b/mlir/lib/TableGen/Operator.cpp @@ -145,20 +145,20 @@ StringRef tblgen::Operator::getArgName(int index) const { return argumentValues->getArgName(index)->getValue(); } -bool tblgen::Operator::hasTrait(StringRef trait) const { - for (auto t : getTraits()) { +const tblgen::OpTrait *tblgen::Operator::getTrait(StringRef trait) const { + for (const auto &t : traits) { if (auto opTrait = dyn_cast<tblgen::NativeOpTrait>(&t)) { if (opTrait->getTrait() == trait) - return true; + return opTrait; } else if (auto opTrait = dyn_cast<tblgen::InternalOpTrait>(&t)) { if (opTrait->getTrait() == trait) - return true; + return opTrait; } else if (auto opTrait = dyn_cast<tblgen::InterfaceOpTrait>(&t)) { if (opTrait->getTrait() == trait) - return true; + return opTrait; } } - return false; + return nullptr; } unsigned tblgen::Operator::getNumRegions() const { return regions.size(); } |

