[PATCH] D41446: [TableGen][AsmMatcherEmitter] Generate assembler checks for tied operands
Sander de Smalen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 3 08:35:55 PST 2018
sdesmalen marked an inline comment as done.
sdesmalen added inline comments.
================
Comment at: utils/TableGen/AsmMatcherEmitter.cpp:969
+ const auto &CGIOperands = getResultInst()->Operands;
+ for (const auto &CGIOp : CGIOperands) {
+ const auto &CGIConstraints = CGIOp.Constraints;
----------------
fhahn wrote:
> I think the loop body here can be simplified by using `CGIOp.getTiedRegister();` rather than checking the constraints here:
>
>
> ```
> + int TiedReg = CGIOp.getTiedRegister();
> + if (TiedReg == -1)
> + continue;
> +
> + Optional<size_t> LHSIdx = getAsmOperandIdx(AsmOperands, CGIOp.Name);
> + Optional<size_t> RHSIdx = getAsmOperandIdx(AsmOperands, CGIOperands[TiedReg].Name);
> + // Skipping operands with constraint but no reference in the
> + // AsmString. No need to throw a warning, as it's normal to have
> + // a $dst operand in the outs dag that is constrained to a $src
> + // operand in the ins dag but that does not appear in the AsmString.
> + if (!LHSIdx || !RHSIdx)
> + continue;
> +
> + // Add the constraint. Using min/max as we consider constraint
> + // pair {A,B} and {B,A} the same
> + size_t AddMnemonicIdx = HasMnemonicFirst;
> + AsmOperandTiedConstraints.emplace_back(
> + std::min(*LHSIdx, *RHSIdx) + AddMnemonicIdx,
> + std::max(*LHSIdx, *RHSIdx) + AddMnemonicIdx);
> + }
> ```
Thanks Florian, I've implemented your suggestion.
https://reviews.llvm.org/D41446
More information about the llvm-commits
mailing list