X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FSelectionDAG%2FScheduleDAGEmit.cpp;h=4ea29063ab58eb1163aed05427129d42dd3fb6db;hb=b3bc6352defdf1a5c6b1b0770d0c4d603f6524a8;hp=52b2cf40d06105826d0710b6d8a839f0c1ebf141;hpb=f5aeb1a8e4cf272c7348376d185ef8d8267653e0;p=oota-llvm.git diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGEmit.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGEmit.cpp index 52b2cf40d06..4ea29063ab5 100644 --- a/lib/CodeGen/SelectionDAG/ScheduleDAGEmit.cpp +++ b/lib/CodeGen/SelectionDAG/ScheduleDAGEmit.cpp @@ -65,6 +65,7 @@ void ScheduleDAG::EmitCopyFromReg(SDNode *Node, unsigned ResNo, // If the node is only used by a CopyToReg and the dest reg is a vreg, use // the CopyToReg'd destination register instead of creating a new vreg. bool MatchReg = true; + const TargetRegisterClass *UseRC = NULL; for (SDNode::use_iterator UI = Node->use_begin(), E = Node->use_end(); UI != E; ++UI) { SDNode *User = *UI; @@ -84,8 +85,19 @@ void ScheduleDAG::EmitCopyFromReg(SDNode *Node, unsigned ResNo, if (Op.getNode() != Node || Op.getResNo() != ResNo) continue; MVT VT = Node->getValueType(Op.getResNo()); - if (VT != MVT::Other && VT != MVT::Flag) - Match = false; + if (VT == MVT::Other || VT == MVT::Flag) + continue; + Match = false; + if (User->isMachineOpcode()) { + const TargetInstrDesc &II = TII->get(User->getMachineOpcode()); + const TargetRegisterClass *RC = + getInstrOperandRegClass(TRI,TII,II,i+II.getNumDefs()); + if (!UseRC) + UseRC = RC; + else if (RC) + assert(UseRC == RC && + "Multiple uses expecting different register classes!"); + } } } MatchReg &= Match; @@ -93,14 +105,18 @@ void ScheduleDAG::EmitCopyFromReg(SDNode *Node, unsigned ResNo, break; } + MVT VT = Node->getValueType(ResNo); const TargetRegisterClass *SrcRC = 0, *DstRC = 0; - SrcRC = TRI->getPhysicalRegisterRegClass(SrcReg, Node->getValueType(ResNo)); + SrcRC = TRI->getPhysicalRegisterRegClass(SrcReg, VT); // Figure out the register class to create for the destreg. if (VRBase) { DstRC = MRI.getRegClass(VRBase); + } else if (UseRC) { + assert(UseRC->hasType(VT) && "Incompatible phys register def and uses!"); + DstRC = UseRC; } else { - DstRC = TLI->getRegClassFor(Node->getValueType(ResNo)); + DstRC = TLI->getRegClassFor(VT); } // If all uses are reading from the src physical register and copying the @@ -110,7 +126,10 @@ void ScheduleDAG::EmitCopyFromReg(SDNode *Node, unsigned ResNo, } else { // Create the reg, emit the copy. VRBase = MRI.createVirtualRegister(DstRC); - TII->copyRegToReg(*BB, BB->end(), VRBase, SrcReg, DstRC, SrcRC); + bool Emitted = + TII->copyRegToReg(*BB, BB->end(), VRBase, SrcReg, DstRC, SrcRC); + Emitted = Emitted; // Silence compiler warning. + assert(Emitted && "Unable to issue a copy instruction!"); } SDValue Op(Node, ResNo); @@ -256,7 +275,7 @@ void ScheduleDAG::AddOperand(MachineInstr *MI, SDValue Op, } else if (ConstantSDNode *C = dyn_cast(Op)) { MI->addOperand(MachineOperand::CreateImm(C->getZExtValue())); } else if (ConstantFPSDNode *F = dyn_cast(Op)) { - ConstantFP *CFP = ConstantFP::get(F->getValueAPF()); + const ConstantFP *CFP = F->getConstantFPValue(); MI->addOperand(MachineOperand::CreateFPImm(CFP)); } else if (RegisterSDNode *R = dyn_cast(Op)) { MI->addOperand(MachineOperand::CreateReg(R->getReg(), false)); @@ -592,6 +611,13 @@ void ScheduleDAG::EmitNode(SDNode *Node, bool IsClone, MI->addOperand(MachineOperand::CreateReg(Reg, true)); } break; + case 6: // Def of earlyclobber register. + for (; NumVals; --NumVals, ++i) { + unsigned Reg = cast(Node->getOperand(i))->getReg(); + MI->addOperand(MachineOperand::CreateReg(Reg, true, false, false, + false, 0, true)); + } + break; case 1: // Use of register. case 3: // Immediate. case 4: // Addressing mode.