-
- // Check whether the implict subreg copy has side affects or not. Only copies
- // into an undef value have no side affects, that is they can be eliminated
- // without changing the semantics of the program.
- bool copyHasSideAffects = isImplicit?
- MI->getOperand(1).getImm() != TargetInstrInfo::IMPL_VAL_UNDEF
- : false;
-
- // If the inserted register is already allocated into a subregister
- // of the destination, we copy the subreg into the source
- // However, this is only safe if the insert instruction is the kill
- // of the source register
- bool revCopyOrder = TRI.isSubRegister(DstReg, InsReg);
- if (revCopyOrder && (InsReg != DstSubReg || copyHasSideAffects)) {
- if (isImplicit || MI->getOperand(1).isKill()) {
- DstSubReg = TRI.getSubReg(SrcReg, SubIdx);
- // Insert sub-register copy
- const TargetRegisterClass *TRC1 = 0;
- if (TargetRegisterInfo::isPhysicalRegister(InsReg)) {
- TRC1 = TRI.getPhysicalRegisterRegClass(InsReg);
- } else {
- TRC1 = MF.getRegInfo().getRegClass(InsReg);
- }
- TII.copyRegToReg(*MBB, MI, DstSubReg, InsReg, TRC1, TRC1);
-
-#ifndef NDEBUG
- MachineBasicBlock::iterator dMI = MI;
- DOUT << "subreg: " << *(--dMI);
-#endif
- } else {
- assert(0 && "Don't know how to convert this insert");
- }
- }
-#ifndef NDEBUG
- if (InsReg == DstSubReg && !copyHasSideAffects) {
- DOUT << "subreg: Eliminated subreg copy\n";
- }
-#endif
-
- if (SrcReg != DstReg) {
- // Insert super-register copy
- const TargetRegisterClass *TRC0 = 0;
- if (TargetRegisterInfo::isPhysicalRegister(DstReg)) {
- TRC0 = TRI.getPhysicalRegisterRegClass(DstReg);
- } else {
- TRC0 = MF.getRegInfo().getRegClass(DstReg);
- }
- assert(TRC0 == TRI.getPhysicalRegisterRegClass(SrcReg) &&
- "Insert superreg and Dst must be of same register class");