minor cleanups
[oota-llvm.git] / lib / Target / Mips / MipsISelLowering.cpp
index d17c980b3725ea16829ee487c2f13046b9db3587..453082c6e25b8931430c69298798502dfeda3873 100644 (file)
@@ -25,8 +25,8 @@
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineFunction.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
+#include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/SelectionDAGISel.h"
-#include "llvm/CodeGen/SSARegMap.h"
 #include "llvm/CodeGen/ValueTypes.h"
 #include "llvm/Support/Debug.h"
 #include <queue>
@@ -52,7 +52,6 @@ MipsTargetLowering(MipsTargetMachine &TM): TargetLowering(TM)
 {
   // Mips does not have i1 type, so use i32 for
   // setcc operations results (slt, sgt, ...). 
-  setSetCCResultType(MVT::i32);
   setSetCCResultContents(ZeroOrOneSetCCResult);
 
   // JumpTable targets must use GOT when using PIC_
@@ -72,9 +71,6 @@ MipsTargetLowering(MipsTargetMachine &TM): TargetLowering(TM)
   setLoadXAction(ISD::ZEXTLOAD, MVT::i1,  Promote);
   setLoadXAction(ISD::SEXTLOAD, MVT::i1,  Promote);
 
-  // Store operations for i1 types must be promoted
-  setStoreXAction(MVT::i1, Promote);
-
   // Mips does not have these NodeTypes below.
   setOperationAction(ISD::BR_JT,     MVT::Other, Expand);
   setOperationAction(ISD::BR_CC,     MVT::Other, Expand);
@@ -87,6 +83,7 @@ MipsTargetLowering(MipsTargetMachine &TM): TargetLowering(TM)
   setOperationAction(ISD::MEMMOVE, MVT::Other, Expand);
   setOperationAction(ISD::MEMSET, MVT::Other, Expand);
   setOperationAction(ISD::MEMCPY, MVT::Other, Expand);
+  setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand);
 
   setOperationAction(ISD::CTPOP, MVT::i32, Expand);
   setOperationAction(ISD::CTTZ , MVT::i32, Expand);
@@ -113,6 +110,12 @@ MipsTargetLowering(MipsTargetMachine &TM): TargetLowering(TM)
 }
 
 
+MVT::ValueType
+MipsTargetLowering::getSetCCResultType(const SDOperand &) const {
+  return MVT::i32;
+}
+
+
 SDOperand MipsTargetLowering::
 LowerOperation(SDOperand Op, SelectionDAG &DAG) 
 {
@@ -139,8 +142,8 @@ static unsigned
 AddLiveIn(MachineFunction &MF, unsigned PReg, TargetRegisterClass *RC) 
 {
   assert(RC->contains(PReg) && "Not the correct regclass!");
-  unsigned VReg = MF.getSSARegMap()->createVirtualRegister(RC);
-  MF.addLiveIn(PReg, VReg);
+  unsigned VReg = MF.getRegInfo().createVirtualRegister(RC);
+  MF.getRegInfo().addLiveIn(PReg, VReg);
   return VReg;
 }
 
@@ -224,11 +227,10 @@ LowerJumpTable(SDOperand Op, SelectionDAG &DAG)
 SDOperand MipsTargetLowering::
 LowerCALL(SDOperand Op, SelectionDAG &DAG)
 {
-  unsigned CallingConv= cast<ConstantSDNode>(Op.getOperand(1))->getValue();
+  unsigned CallingConv = cast<ConstantSDNode>(Op.getOperand(1))->getValue();
 
   // By now, only CallingConv::C implemented
-  switch (CallingConv) 
-  {
+  switch (CallingConv) {
     default:
       assert(0 && "Unsupported calling convention");
     case CallingConv::Fast:
@@ -245,7 +247,6 @@ SDOperand MipsTargetLowering::
 LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC) 
 {
   MachineFunction &MF = DAG.getMachineFunction();
-  unsigned StackReg   = MF.getTarget().getRegisterInfo()->getFrameRegister(MF);
 
   SDOperand Chain  = Op.getOperand(0);
   SDOperand Callee = Op.getOperand(4);
@@ -272,8 +273,7 @@ LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC)
   SmallVector<std::pair<unsigned, SDOperand>, 8> RegsToPass;
   SmallVector<SDOperand, 8> MemOpChains;
 
-  SDOperand StackPtr;
-  int LastStackLoc=0;
+  int LastStackLoc = 0;
 
   // Walk the register/memloc assignments, inserting copies/loads.
   for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
@@ -284,43 +284,40 @@ LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC)
     
     // Promote the value if needed.
     switch (VA.getLocInfo()) {
-      default: assert(0 && "Unknown loc info!");
-      case CCValAssign::Full: break;
-      case CCValAssign::SExt:
-        Arg = DAG.getNode(ISD::SIGN_EXTEND, VA.getLocVT(), Arg);
-        break;
-      case CCValAssign::ZExt:
-        Arg = DAG.getNode(ISD::ZERO_EXTEND, VA.getLocVT(), Arg);
-        break;
-      case CCValAssign::AExt:
-        Arg = DAG.getNode(ISD::ANY_EXTEND, VA.getLocVT(), Arg);
-        break;
+    default: assert(0 && "Unknown loc info!");
+    case CCValAssign::Full: break;
+    case CCValAssign::SExt:
+      Arg = DAG.getNode(ISD::SIGN_EXTEND, VA.getLocVT(), Arg);
+      break;
+    case CCValAssign::ZExt:
+      Arg = DAG.getNode(ISD::ZERO_EXTEND, VA.getLocVT(), Arg);
+      break;
+    case CCValAssign::AExt:
+      Arg = DAG.getNode(ISD::ANY_EXTEND, VA.getLocVT(), Arg);
+      break;
     }
     
     // Arguments that can be passed on register must be kept at 
     // RegsToPass vector
     if (VA.isRegLoc()) {
       RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg));
-    } else {
-
-      assert(VA.isMemLoc());
-
-      if (StackPtr.Val == 0)
-        StackPtr = DAG.getRegister(StackReg, getPointerTy());
-     
-      // Create the frame index object for this incoming parameter
-      // This guarantees that when allocating Local Area the firsts
-      // 16 bytes which are alwayes reserved won't be overwritten.
-      LastStackLoc = (16 + VA.getLocMemOffset());
-      int FI = MFI->CreateFixedObject(MVT::getSizeInBits(VA.getValVT())/8,
-                                      LastStackLoc);
-
-      SDOperand PtrOff = DAG.getFrameIndex(FI,getPointerTy());
-
-      // emit ISD::STORE whichs stores the 
-      // parameter value to a stack Location
-      MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0));
+      continue;
     }
+    
+    assert(VA.isMemLoc());
+    
+    // Create the frame index object for this incoming parameter
+    // This guarantees that when allocating Local Area the firsts
+    // 16 bytes which are alwayes reserved won't be overwritten.
+    LastStackLoc = (16 + VA.getLocMemOffset());
+    int FI = MFI->CreateFixedObject(MVT::getSizeInBits(VA.getValVT())/8,
+                                    LastStackLoc);
+
+    SDOperand PtrOff = DAG.getFrameIndex(FI,getPointerTy());
+
+    // emit ISD::STORE whichs stores the 
+    // parameter value to a stack Location
+    MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0));
   }
 
   // Transform all store nodes into one single node because
@@ -596,10 +593,10 @@ LowerRET(SDOperand Op, SelectionDAG &DAG)
 
   // If this is the first return lowered for this function, add 
   // the regs to the liveout set for the function.
-  if (DAG.getMachineFunction().liveout_empty()) {
+  if (DAG.getMachineFunction().getRegInfo().liveout_empty()) {
     for (unsigned i = 0; i != RVLocs.size(); ++i)
       if (RVLocs[i].isRegLoc())
-        DAG.getMachineFunction().addLiveOut(RVLocs[i].getLocReg());
+        DAG.getMachineFunction().getRegInfo().addLiveOut(RVLocs[i].getLocReg());
   }
 
   // The chain is always operand #0