diff options
Diffstat (limited to 'llvm/utils/TableGen/CodeGenDAGPatterns.h')
-rw-r--r-- | llvm/utils/TableGen/CodeGenDAGPatterns.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h index b04a928e0f3..4be9afdcacd 100644 --- a/llvm/utils/TableGen/CodeGenDAGPatterns.h +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h @@ -19,6 +19,7 @@ #include "CodeGenIntrinsics.h" #include "CodeGenTarget.h" #include "SDNodeProperties.h" +#include "llvm/ADT/MapVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringSet.h" @@ -28,6 +29,7 @@ #include <array> #include <functional> #include <map> +#include <numeric> #include <set> #include <vector> @@ -620,6 +622,9 @@ class TreePatternNode { /// each is a single concrete type. std::vector<TypeSetByHwMode> Types; + /// The index of each result in results of the pattern. + std::vector<unsigned> ResultPerm; + /// Operator - The Record for the operator if this is an interior node (not /// a leaf). Record *Operator; @@ -650,10 +655,14 @@ public: : Operator(Op), Val(nullptr), TransformFn(nullptr), Children(std::move(Ch)) { Types.resize(NumResults); + ResultPerm.resize(NumResults); + std::iota(ResultPerm.begin(), ResultPerm.end(), 0); } TreePatternNode(Init *val, unsigned NumResults) // leaf ctor : Operator(nullptr), Val(val), TransformFn(nullptr) { Types.resize(NumResults); + ResultPerm.resize(NumResults); + std::iota(ResultPerm.begin(), ResultPerm.end(), 0); } bool hasName() const { return !Name.empty(); } @@ -694,6 +703,10 @@ public: return Types[ResNo].empty(); } + unsigned getNumResults() const { return ResultPerm.size(); } + unsigned getResultIndex(unsigned ResNo) const { return ResultPerm[ResNo]; } + void setResultIndex(unsigned ResNo, unsigned RI) { ResultPerm[ResNo] = RI; } + Init *getLeafValue() const { assert(isLeaf()); return Val; } Record *getOperator() const { assert(!isLeaf()); return Operator; } @@ -1281,7 +1294,8 @@ private: void FindPatternInputsAndOutputs( TreePattern &I, TreePatternNodePtr Pat, std::map<std::string, TreePatternNodePtr> &InstInputs, - std::map<std::string, TreePatternNodePtr> &InstResults, + MapVector<std::string, TreePatternNodePtr, + std::map<std::string, unsigned>> &InstResults, std::vector<Record *> &InstImpResults); }; |