[PATCH] D28057: [ARM] Add custom MachineInstr builder. NFC.
Matthias Braun via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 2 05:09:32 PST 2017
MatzeB added a comment.
I wonder if the added complexity of a custom arm instruction builder is worth it. How about a solution that just provides functions to construct the operands but keeps using the default MachineInstrBuilder to add them:
MachineOperand CCRegOp(unsigned CCReg = 0) {
return MachineOperand::CreateReg(CCReg, false);
}
// Use:
BuildMI(). ... .addOperand(CCRegOp())
- We could rename MachineInstrBuilder::addOperand() to add() to make this a bit shorter.
For the predicate condition code + register pair you could either provide two functions or maybe extend MachineInstrBuilder to accept pairs of operands:
class MachineInstrBuilder {
// ...
add(std::pair<MachineOperand, MachineOperand> Operands) {
add(Operands.first);
add(Operands.second);
}
};
// ...
std::pair<MachineOperand, MachineOperand> predOps(ARMCC::CondCodes Pred = ARMCC::AL,
unsigned PredReg = 0) const {
return std::make_pair(
MachineOperand::CreateImm(static_cast<int64_t>(Pred))),
MachineOperand::CreateReg(PredReg, false)
);
}
// ...
// Use
BuildMI(). ... .add(predOps(Pred))
https://reviews.llvm.org/D28057
More information about the llvm-commits
mailing list