aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-03-09 09:15:31 +0000
committerChris Lattner <sabre@nondot.org>2008-03-09 09:15:31 +0000
commitf30e1cf9b7f96395768e710b4707ecd5587e1185 (patch)
treeacdea8cc957815844a9ff9d31b7f7f9ef0419314 /lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
parent91436992606d80d0b938160be8bacdc2e07d48d4 (diff)
teach X86InstrInfo::copyRegToReg how to copy into ST(0) from
an RFP register class. Teach ScheduleDAG how to handle CopyToReg with different src/dst reg classes. This allows us to compile trivial inline asms that expect stuff on the top of x87-fp stack. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48107 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/ScheduleDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/ScheduleDAG.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
index 5a2b4ede27..31a784eca8 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
@@ -844,23 +844,31 @@ void ScheduleDAG::EmitNode(SDNode *Node, unsigned InstanceNo,
case ISD::SRCVALUE:
break;
case ISD::CopyToReg: {
- unsigned InReg;
- if (RegisterSDNode *R = dyn_cast<RegisterSDNode>(Node->getOperand(2)))
- InReg = R->getReg();
+ unsigned SrcReg;
+ SDOperand SrcVal = Node->getOperand(2);
+ if (RegisterSDNode *R = dyn_cast<RegisterSDNode>(SrcVal))
+ SrcReg = R->getReg();
else
- InReg = getVR(Node->getOperand(2), VRBaseMap);
+ SrcReg = getVR(SrcVal, VRBaseMap);
+
unsigned DestReg = cast<RegisterSDNode>(Node->getOperand(1))->getReg();
- if (InReg != DestReg) {// Coalesced away the copy?
- const TargetRegisterClass *TRC = 0;
- // Get the target register class
- if (TargetRegisterInfo::isVirtualRegister(InReg))
- TRC = RegInfo.getRegClass(InReg);
- else
- TRC =
- TRI->getPhysicalRegisterRegClass(Node->getOperand(2).getValueType(),
- InReg);
- TII->copyRegToReg(*BB, BB->end(), DestReg, InReg, TRC, TRC);
- }
+ if (SrcReg == DestReg) // Coalesced away the copy? Ignore.
+ break;
+
+ const TargetRegisterClass *SrcTRC = 0, *DstTRC = 0;
+ // Get the register classes of the src/dst.
+ if (TargetRegisterInfo::isVirtualRegister(SrcReg))
+ SrcTRC = RegInfo.getRegClass(SrcReg);
+ else
+ SrcTRC = TRI->getPhysicalRegisterRegClass(SrcVal.getValueType(),SrcReg);
+
+ if (TargetRegisterInfo::isVirtualRegister(DestReg))
+ DstTRC = RegInfo.getRegClass(DestReg);
+ else
+ DstTRC = TRI->getPhysicalRegisterRegClass(
+ Node->getOperand(1).getValueType(),
+ DestReg);
+ TII->copyRegToReg(*BB, BB->end(), DestReg, SrcReg, DstTRC, SrcTRC);
break;
}
case ISD::CopyFromReg: {