|
22 | 22 | #include <cassert>
|
23 | 23 | #include <fstream>
|
24 | 24 | #include <iostream>
|
| 25 | +#include <list> |
25 | 26 | #include <string>
|
26 | 27 | #include <unordered_map>
|
27 | 28 | #include <vector>
|
@@ -70,8 +71,10 @@ class InstrBuilder {
|
70 | 71 | /// Stores the decl and body of a new public method that will be added to the
|
71 | 72 | /// class.
|
72 | 73 | std::vector<std::pair<std::string, std::string>> extraMethods_;
|
73 |
| - /// A list of operands that are declared as 'inplace' operands. |
74 |
| - std::vector<std::string> inplaceOperands_; |
| 74 | + /// A list of list of operands that are declared as 'inplace' operands. |
| 75 | + /// Each list depicts the 'inplace' operands for one output. |
| 76 | + /// The output is the first element of the related list. |
| 77 | + std::list<std::vector<std::string>> inplaceOperands_; |
75 | 78 | /// A list of (VerifyKind, {op1, op2, ...}) pairs. Each pair represents a
|
76 | 79 | /// specific kind of verification to apply on the list of operands.
|
77 | 80 | std::vector<std::pair<VerifyKind, std::vector<std::string>>>
|
@@ -150,8 +153,16 @@ class InstrBuilder {
|
150 | 153 | /// the operand \p lst[0].
|
151 | 154 | InstrBuilder &inplaceOperand(llvm::ArrayRef<llvm::StringRef> lst) {
|
152 | 155 | assert(lst.size() > 1 && "Not enough operands");
|
153 |
| - assert(!inplaceOperands_.size() && "Initializing field twice"); |
154 |
| - inplaceOperands_.insert(inplaceOperands_.begin(), lst.begin(), lst.end()); |
| 156 | + inplaceOperands_.emplace_back(lst.begin(), lst.end()); |
| 157 | + // Check that the output parameter is described at most once. |
| 158 | + for (auto it = inplaceOperands_.begin(), end = inplaceOperands_.end(); |
| 159 | + it != end; ++it) { |
| 160 | + for (auto secondIt = std::next(it); secondIt != end; ++secondIt) { |
| 161 | + assert(getOperandIndexByName((*it)[0]) != |
| 162 | + getOperandIndexByName((*secondIt)[0]) && |
| 163 | + "Inplace operands for output appears more than once"); |
| 164 | + } |
| 165 | + } |
155 | 166 | return *this;
|
156 | 167 | }
|
157 | 168 |
|
|
0 commit comments