[llvm-commits] CVS: llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Sep 13 12:33:51 PDT 2005



Changes in directory llvm/lib/Target/PowerPC:

PPC32ISelLowering.cpp updated: 1.24 -> 1.25
---
Log message:

Change the arg lowering code to use copyfromreg from vregs associated
with incoming arguments instead of the pregs themselves.  This fixes
the scheduler from causing problems by moving a copyfromreg for an argument
to after a select_cc node (now it can, and bad things won't happen).


---
Diffs of the changes:  (+17 -12)

 PPC32ISelLowering.cpp |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)


Index: llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp
diff -u llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp:1.24 llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp:1.25
--- llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp:1.24	Tue Sep 13 13:47:49 2005
+++ llvm/lib/Target/PowerPC/PPC32ISelLowering.cpp	Tue Sep 13 14:33:40 2005
@@ -17,6 +17,7 @@
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/SelectionDAG.h"
+#include "llvm/CodeGen/SSARegMap.h"
 #include "llvm/Constants.h"
 #include "llvm/Function.h"
 using namespace llvm;
@@ -310,6 +311,7 @@
   MachineFunction &MF = DAG.getMachineFunction();
   MachineFrameInfo *MFI = MF.getFrameInfo();
   MachineBasicBlock& BB = MF.front();
+  SSARegMap *RegMap = MF.getSSARegMap();
   std::vector<SDOperand> ArgValues;
   
   unsigned ArgOffset = 24;
@@ -344,9 +346,9 @@
       ObjSize = 4;
       if (!ArgLive) break;
       if (GPR_remaining > 0) {
-        MF.addLiveIn(GPR[GPR_idx]);
-        argt = newroot = DAG.getCopyFromReg(DAG.getRoot(),
-                                            GPR[GPR_idx], MVT::i32);
+        unsigned VReg = RegMap->createVirtualRegister(&PPC32::GPRCRegClass);
+        MF.addLiveIn(GPR[GPR_idx], VReg);
+        argt = newroot = DAG.getCopyFromReg(DAG.getRoot(), VReg, MVT::i32);
         if (ObjectVT != MVT::i32) {
           unsigned AssertOp = I->getType()->isSigned() ? ISD::AssertSext 
                                                        : ISD::AssertZext;
@@ -362,15 +364,17 @@
       if (!ArgLive) break;
       if (GPR_remaining > 0) {
         SDOperand argHi, argLo;
-        MF.addLiveIn(GPR[GPR_idx]);
-        argHi = DAG.getCopyFromReg(DAG.getRoot(), GPR[GPR_idx], MVT::i32);
+        unsigned VReg = RegMap->createVirtualRegister(&PPC32::GPRCRegClass);
+        MF.addLiveIn(GPR[GPR_idx], VReg);
+        argHi = DAG.getCopyFromReg(DAG.getRoot(), VReg, MVT::i32);
         // If we have two or more remaining argument registers, then both halves
         // of the i64 can be sourced from there.  Otherwise, the lower half will
         // have to come off the stack.  This can happen when an i64 is preceded
         // by 28 bytes of arguments.
         if (GPR_remaining > 1) {
-          MF.addLiveIn(GPR[GPR_idx+1]);
-          argLo = DAG.getCopyFromReg(argHi, GPR[GPR_idx+1], MVT::i32);
+          unsigned VReg = RegMap->createVirtualRegister(&PPC32::GPRCRegClass);
+          MF.addLiveIn(GPR[GPR_idx+1], VReg);
+          argLo = DAG.getCopyFromReg(argHi, VReg, MVT::i32);
         } else {
           int FI = MFI->CreateFixedObject(4, ArgOffset+4);
           SDOperand FIN = DAG.getFrameIndex(FI, MVT::i32);
@@ -389,9 +393,9 @@
       ObjSize = (ObjectVT == MVT::f64) ? 8 : 4;
       if (!ArgLive) break;
       if (FPR_remaining > 0) {
-        MF.addLiveIn(FPR[FPR_idx]);
-        argt = newroot = DAG.getCopyFromReg(DAG.getRoot(), 
-                                            FPR[FPR_idx], ObjectVT);
+        unsigned VReg = RegMap->createVirtualRegister(&PPC32::FPRCRegClass);
+        MF.addLiveIn(FPR[FPR_idx], VReg);
+        argt = newroot = DAG.getCopyFromReg(DAG.getRoot(), VReg, ObjectVT);
         --FPR_remaining;
         ++FPR_idx;
       } else {
@@ -438,8 +442,9 @@
     // result of va_next.
     std::vector<SDOperand> MemOps;
     for (; GPR_remaining > 0; --GPR_remaining, ++GPR_idx) {
-      MF.addLiveIn(GPR[GPR_idx]);
-      SDOperand Val = DAG.getCopyFromReg(DAG.getRoot(), GPR[GPR_idx], MVT::i32);
+      unsigned VReg = RegMap->createVirtualRegister(&PPC32::GPRCRegClass);
+      MF.addLiveIn(GPR[GPR_idx], VReg);
+      SDOperand Val = DAG.getCopyFromReg(DAG.getRoot(), VReg, MVT::i32);
       SDOperand Store = DAG.getNode(ISD::STORE, MVT::Other, Val.getValue(1),
                                     Val, FIN, DAG.getSrcValue(NULL));
       MemOps.push_back(Store);






More information about the llvm-commits mailing list