GlobalISel: add specialized buildCopy function to MachineInstrBuilder.

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276763 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tim Northover 2016-07-26 16:45:30 +00:00
parent 1123323be2
commit 27d9a7f410
4 changed files with 16 additions and 3 deletions

View File

@ -183,6 +183,15 @@ public:
/// \return The newly created instruction.
MachineInstr *buildBr(MachineBasicBlock &BB);
/// Build and insert \p Res<def> = COPY Op
///
/// Register-to-register COPY sets \p Res to \p Op.
///
/// \pre setBasicBlock or setMI must have been called.
///
/// \return The newly created instruction.
MachineInstr *buildCopy(unsigned Res, unsigned Op);
/// Build and insert `Res0<def>, ... = G_EXTRACT Ty Src, Idx0, ...`.
///
/// If \p Ty has size N bits, G_EXTRACT sets \p Res[0] to bits `[Idxs[0],

View File

@ -102,8 +102,8 @@ bool IRTranslator::translateBr(const Instruction &Inst) {
bool IRTranslator::translateBitCast(const CastInst &CI) {
if (LLT{*CI.getDestTy()} == LLT{*CI.getSrcTy()}) {
MIRBuilder.buildInstr(TargetOpcode::COPY, getOrCreateVReg(CI),
getOrCreateVReg(*CI.getOperand(0)));
MIRBuilder.buildCopy(getOrCreateVReg(CI),
getOrCreateVReg(*CI.getOperand(0)));
return true;
}
return translateCast(TargetOpcode::G_BITCAST, CI);

View File

@ -90,6 +90,10 @@ MachineInstr *MachineIRBuilder::buildBr(MachineBasicBlock &Dest) {
return NewMI;
}
MachineInstr *MachineIRBuilder::buildCopy(unsigned Res, unsigned Op) {
return buildInstr(TargetOpcode::COPY, Res, Op);
}
MachineInstr *MachineIRBuilder::buildExtract(LLT Ty, ArrayRef<unsigned> Results,
unsigned Src,
ArrayRef<unsigned> Indexes) {

View File

@ -126,7 +126,7 @@ void RegBankSelect::repairReg(
"We are about to create several defs for Dst");
// Build the instruction used to repair, then clone it at the right places.
MachineInstr *MI = MIRBuilder.buildInstr(TargetOpcode::COPY, Dst, Src);
MachineInstr *MI = MIRBuilder.buildCopy(Dst, Src);
MI->removeFromParent();
DEBUG(dbgs() << "Copy: " << PrintReg(Src) << " to: " << PrintReg(Dst)
<< '\n');