1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[TableGen] Handle (outs variable_ops)

When `variable_ops` is specified in `InOperandList` of instruction,
it behaves as expected, i.e., does not count as operand.
So for `(ins variable_ops)` instruction description will have 0
operands.  However when used in OutOperandList it is counted as
operand. So `(outs variable_ops)` results in instruction with
one def.
This patch makes behavior of `variable_ops` in `out` list to match
that of `in` list.

Reviewed By: reames
Differential Revision: https://reviews.llvm.org/D81095
This commit is contained in:
Denis Antrushin 2020-06-03 17:08:48 +03:00
parent 5c6a96f031
commit 99d7b2a3a2

View File

@ -56,6 +56,7 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
std::set<std::string> OperandNames; std::set<std::string> OperandNames;
unsigned e = InDI->getNumArgs() + OutDI->getNumArgs(); unsigned e = InDI->getNumArgs() + OutDI->getNumArgs();
OperandList.reserve(e); OperandList.reserve(e);
bool VariadicOuts = false;
for (unsigned i = 0; i != e; ++i){ for (unsigned i = 0; i != e; ++i){
Init *ArgInit; Init *ArgInit;
StringRef ArgName; StringRef ArgName;
@ -109,6 +110,8 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
else if (Rec->isSubClassOf("OptionalDefOperand")) else if (Rec->isSubClassOf("OptionalDefOperand"))
hasOptionalDef = true; hasOptionalDef = true;
} else if (Rec->getName() == "variable_ops") { } else if (Rec->getName() == "variable_ops") {
if (i < NumDefs)
VariadicOuts = true;
isVariadic = true; isVariadic = true;
continue; continue;
} else if (Rec->isSubClassOf("RegisterClass")) { } else if (Rec->isSubClassOf("RegisterClass")) {
@ -137,6 +140,8 @@ CGIOperandList::CGIOperandList(Record *R) : TheDef(R) {
MIOperandNo += NumOps; MIOperandNo += NumOps;
} }
if (VariadicOuts)
--NumDefs;
// Make sure the constraints list for each operand is large enough to hold // Make sure the constraints list for each operand is large enough to hold
// constraint info, even if none is present. // constraint info, even if none is present.