diff options
author | James Y Knight <jyknight@google.com> | 2022-09-05 12:10:21 -0400 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2022-09-24 09:40:44 -0400 |
commit | a538d1f13a1375c212c7018e36deab2cd896bf6e (patch) | |
tree | c7b20adf0e0c5c7daecf147d6884c159295508a8 /llvm/utils/TableGen/CodeEmitterGen.cpp | |
parent | e657acd449a8b765db8bb333e3e969c9f787b640 (diff) | |
download | llvm-a538d1f13a1375c212c7018e36deab2cd896bf6e.zip llvm-a538d1f13a1375c212c7018e36deab2cd896bf6e.tar.gz llvm-a538d1f13a1375c212c7018e36deab2cd896bf6e.tar.bz2 |
[TableGen][CodeEmitterGen] Allow local names for sub-operands in a operand list.
These names can then be matched by name against 'bits' fields in a
record, to populate an instruction's encoding.
This does _not_ yet change DecoderEmitter to allow by-name matching of
sub-operands. Unlike the encoder, the decoder already defaulted to not
supporting positional matching, and backends had workarounds in place
for the missing decoding support.
Additionally, use this new capability to allow the ARM and AArch64
backends not to require any positional operand matching.
Differential Revision: https://reviews.llvm.org/D131003
Diffstat (limited to 'llvm/utils/TableGen/CodeEmitterGen.cpp')
-rw-r--r-- | llvm/utils/TableGen/CodeEmitterGen.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp index 004f94f..31b2eb9 100644 --- a/llvm/utils/TableGen/CodeEmitterGen.cpp +++ b/llvm/utils/TableGen/CodeEmitterGen.cpp @@ -105,7 +105,10 @@ AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName, // operand number. Non-matching operands are assumed to be in // order. unsigned OpIdx; - if (CGI.Operands.hasOperandNamed(VarName, OpIdx)) { + std::pair<unsigned, unsigned> SubOp; + if (CGI.Operands.hasSubOperandAlias(VarName, SubOp)) { + OpIdx = CGI.Operands[SubOp.first].MIOperandNo + SubOp.second; + } else if (CGI.Operands.hasOperandNamed(VarName, OpIdx)) { // Get the machine operand number for the indicated operand. OpIdx = CGI.Operands[OpIdx].MIOperandNo; assert(!CGI.Operands.isFlatOperandNotEmitted(OpIdx) && @@ -133,7 +136,7 @@ AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName, OpIdx = NumberedOp++; } - + std::pair<unsigned, unsigned> SO = CGI.Operands.getSubOperandNumber(OpIdx); std::string &EncoderMethodName = CGI.Operands[SO.first].EncoderMethodName; |