More constification of things. More comments added. No functionality
[oota-llvm.git] / lib / CodeGen / SelectionDAG / LegalizeDAG.cpp
index a8e9c221737a9abaccde20878619ca50089df65a..9355e4871fe4dc38b2e25f242f3f8121c5f95e0a 100644 (file)
@@ -510,10 +510,11 @@ static SDOperand ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP,
   SDOperand CPIdx = DAG.getConstantPool(LLVMC, TLI.getPointerTy());
   if (Extend) {
     return DAG.getExtLoad(ISD::EXTLOAD, MVT::f64, DAG.getEntryNode(),
-                          CPIdx, &PseudoSourceValue::CPRel, 0, MVT::f32);
+                          CPIdx, PseudoSourceValue::getConstantPool(),
+                          0, MVT::f32);
   } else {
     return DAG.getLoad(VT, DAG.getEntryNode(), CPIdx,
-                       &PseudoSourceValue::CPRel, 0);
+                       PseudoSourceValue::getConstantPool(), 0);
   }
 }
 
@@ -1058,9 +1059,10 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
         } else {
           unsigned Line = cast<ConstantSDNode>(LineOp)->getValue();
           unsigned Col = cast<ConstantSDNode>(ColOp)->getValue();
-          unsigned ID = MMI->RecordLabel(Line, Col, SrcFile);
+          unsigned ID = MMI->RecordSourceLine(Line, Col, SrcFile);
           Ops.push_back(DAG.getConstant(ID, MVT::i32));
-          Result = DAG.getNode(ISD::LABEL, MVT::Other,&Ops[0],Ops.size());
+          Ops.push_back(DAG.getConstant(0, MVT::i32)); // a debug label
+          Result = DAG.getNode(ISD::LABEL, MVT::Other, &Ops[0], Ops.size());
         }
       } else {
         Result = Tmp1;  // chain
@@ -1087,6 +1089,19 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       break;
     }
     break;
+
+  case ISD::DECLARE:
+    assert(Node->getNumOperands() == 3 && "Invalid DECLARE node!");
+    switch (TLI.getOperationAction(ISD::DECLARE, MVT::Other)) {
+    default: assert(0 && "This action is not supported yet!");
+    case TargetLowering::Legal:
+      Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
+      Tmp2 = LegalizeOp(Node->getOperand(1));  // Legalize the address.
+      Tmp3 = LegalizeOp(Node->getOperand(2));  // Legalize the variable.
+      Result = DAG.UpdateNodeOperands(Result, Tmp1, Tmp2, Tmp3);
+      break;
+    }
+    break;    
     
   case ISD::DEBUG_LOC:
     assert(Node->getNumOperands() == 4 && "Invalid DEBUG_LOC node!");
@@ -1103,13 +1118,14 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
     break;    
 
   case ISD::LABEL:
-    assert(Node->getNumOperands() == 2 && "Invalid LABEL node!");
+    assert(Node->getNumOperands() == 3 && "Invalid LABEL node!");
     switch (TLI.getOperationAction(ISD::LABEL, MVT::Other)) {
     default: assert(0 && "This action is not supported yet!");
     case TargetLowering::Legal:
       Tmp1 = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
       Tmp2 = LegalizeOp(Node->getOperand(1));  // Legalize the label id.
-      Result = DAG.UpdateNodeOperands(Result, Tmp1, Tmp2);
+      Tmp3 = LegalizeOp(Node->getOperand(2));  // Legalize the "flavor" operand.
+      Result = DAG.UpdateNodeOperands(Result, Tmp1, Tmp2, Tmp3);
       break;
     case TargetLowering::Expand:
       Result = LegalizeOp(Node->getOperand(0));
@@ -1117,6 +1133,26 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
     }
     break;
 
+  case ISD::MEMBARRIER: {
+    assert(Node->getNumOperands() == 6 && "Invalid MemBarrier node!");
+    switch (TLI.getOperationAction(ISD::MEMBARRIER, MVT::Other)) {
+    default: assert(0 && "This action is not supported yet!");
+    case TargetLowering::Legal: {
+      SDOperand Ops[6];
+      Ops[0] = LegalizeOp(Node->getOperand(0));  // Legalize the chain.
+      for (int x = 1; x < 6; ++x)
+        Ops[x] = PromoteOp(Node->getOperand(x));
+      Result = DAG.UpdateNodeOperands(Result, &Ops[0], 6);
+      break;
+    }
+    case TargetLowering::Expand:
+      //There is no libgcc call for this op
+      Result = Node->getOperand(0);  // Noop
+    break;
+    }
+    break;
+  }
+
   case ISD::Constant: {
     ConstantSDNode *CN = cast<ConstantSDNode>(Node);
     unsigned opAction =
@@ -1139,24 +1175,10 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
     // leave these constants as ConstantFP nodes for the target to deal with.
     ConstantFPSDNode *CFP = cast<ConstantFPSDNode>(Node);
 
-    // Check to see if this FP immediate is already legal.
-    bool isLegal = false;
-    for (TargetLowering::legal_fpimm_iterator I = TLI.legal_fpimm_begin(),
-           E = TLI.legal_fpimm_end(); I != E; ++I)
-      if (CFP->isExactlyValue(*I)) {
-        isLegal = true;
-        break;
-      }
-
-    // If this is a legal constant, turn it into a TargetConstantFP node.
-    if (isLegal) {
-      Result = DAG.getTargetConstantFP(CFP->getValueAPF(), 
-                                       CFP->getValueType(0));
-      break;
-    }
-
     switch (TLI.getOperationAction(ISD::ConstantFP, CFP->getValueType(0))) {
     default: assert(0 && "This action is not supported yet!");
+    case TargetLowering::Legal:
+      break;
     case TargetLowering::Custom:
       Tmp3 = TLI.LowerOperation(Result, DAG);
       if (Tmp3.Val) {
@@ -1164,9 +1186,22 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
         break;
       }
       // FALLTHROUGH
-    case TargetLowering::Expand:
+    case TargetLowering::Expand: {
+      // Check to see if this FP immediate is already legal.
+      bool isLegal = false;
+      for (TargetLowering::legal_fpimm_iterator I = TLI.legal_fpimm_begin(),
+             E = TLI.legal_fpimm_end(); I != E; ++I) {
+        if (CFP->isExactlyValue(*I)) {
+          isLegal = true;
+          break;
+        }
+      }
+      // If this is a legal constant, turn it into a TargetConstantFP node.
+      if (isLegal)
+        break;
       Result = ExpandConstantFP(CFP, true, DAG, TLI);
     }
+    }
     break;
   }
   case ISD::TokenFactor:
@@ -1247,8 +1282,16 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
     break;
   case ISD::INSERT_VECTOR_ELT:
     Tmp1 = LegalizeOp(Node->getOperand(0));  // InVec
-    Tmp2 = LegalizeOp(Node->getOperand(1));  // InVal
     Tmp3 = LegalizeOp(Node->getOperand(2));  // InEltNo
+
+    // The type of the value to insert may not be legal, even though the vector
+    // type is legal.  Legalize/Promote accordingly.  We do not handle Expand
+    // here.
+    switch (getTypeAction(Node->getOperand(1).getValueType())) {
+    default: assert(0 && "Cannot expand insert element operand");
+    case Legal:   Tmp2 = LegalizeOp(Node->getOperand(1)); break;
+    case Promote: Tmp2 = PromoteOp(Node->getOperand(1));  break;
+    }
     Result = DAG.UpdateNodeOperands(Result, Tmp1, Tmp2, Tmp3);
     
     switch (TLI.getOperationAction(ISD::INSERT_VECTOR_ELT,
@@ -1267,30 +1310,35 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       // If the insert index is a constant, codegen this as a scalar_to_vector,
       // then a shuffle that inserts it into the right position in the vector.
       if (ConstantSDNode *InsertPos = dyn_cast<ConstantSDNode>(Tmp3)) {
-        SDOperand ScVec = DAG.getNode(ISD::SCALAR_TO_VECTOR, 
-                                      Tmp1.getValueType(), Tmp2);
-        
-        unsigned NumElts = MVT::getVectorNumElements(Tmp1.getValueType());
-        MVT::ValueType ShufMaskVT = MVT::getIntVectorWithNumElements(NumElts);
-        MVT::ValueType ShufMaskEltVT = MVT::getVectorElementType(ShufMaskVT);
-        
-        // We generate a shuffle of InVec and ScVec, so the shuffle mask should
-        // be 0,1,2,3,4,5... with the appropriate element replaced with elt 0 of
-        // the RHS.
-        SmallVector<SDOperand, 8> ShufOps;
-        for (unsigned i = 0; i != NumElts; ++i) {
-          if (i != InsertPos->getValue())
-            ShufOps.push_back(DAG.getConstant(i, ShufMaskEltVT));
-          else
-            ShufOps.push_back(DAG.getConstant(NumElts, ShufMaskEltVT));
+        // SCALAR_TO_VECTOR requires that the type of the value being inserted
+        // match the element type of the vector being created.
+        if (Tmp2.getValueType() == 
+            MVT::getVectorElementType(Op.getValueType())) {
+          SDOperand ScVec = DAG.getNode(ISD::SCALAR_TO_VECTOR, 
+                                        Tmp1.getValueType(), Tmp2);
+          
+          unsigned NumElts = MVT::getVectorNumElements(Tmp1.getValueType());
+          MVT::ValueType ShufMaskVT = MVT::getIntVectorWithNumElements(NumElts);
+          MVT::ValueType ShufMaskEltVT = MVT::getVectorElementType(ShufMaskVT);
+          
+          // We generate a shuffle of InVec and ScVec, so the shuffle mask
+          // should be 0,1,2,3,4,5... with the appropriate element replaced with
+          // elt 0 of the RHS.
+          SmallVector<SDOperand, 8> ShufOps;
+          for (unsigned i = 0; i != NumElts; ++i) {
+            if (i != InsertPos->getValue())
+              ShufOps.push_back(DAG.getConstant(i, ShufMaskEltVT));
+            else
+              ShufOps.push_back(DAG.getConstant(NumElts, ShufMaskEltVT));
+          }
+          SDOperand ShufMask = DAG.getNode(ISD::BUILD_VECTOR, ShufMaskVT,
+                                           &ShufOps[0], ShufOps.size());
+          
+          Result = DAG.getNode(ISD::VECTOR_SHUFFLE, Tmp1.getValueType(),
+                               Tmp1, ScVec, ShufMask);
+          Result = LegalizeOp(Result);
+          break;
         }
-        SDOperand ShufMask = DAG.getNode(ISD::BUILD_VECTOR, ShufMaskVT,
-                                         &ShufOps[0], ShufOps.size());
-        
-        Result = DAG.getNode(ISD::VECTOR_SHUFFLE, Tmp1.getValueType(),
-                             Tmp1, ScVec, ShufMask);
-        Result = LegalizeOp(Result);
-        break;
       }
       
       // If the target doesn't support this, we have to spill the input vector
@@ -1300,18 +1348,18 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       // permute it into place, if the idx is a constant and if the idx is
       // supported by the target.
       MVT::ValueType VT    = Tmp1.getValueType();
-      MVT::ValueType EltVT = Tmp2.getValueType();
+      MVT::ValueType EltVT = MVT::getVectorElementType(VT);
       MVT::ValueType IdxVT = Tmp3.getValueType();
       MVT::ValueType PtrVT = TLI.getPointerTy();
       SDOperand StackPtr = DAG.CreateStackTemporary(VT);
 
-      FrameIndexSDNode *StackPtrFI = dyn_cast<FrameIndexSDNode>(StackPtr.Val);
-      assert(StackPtrFI);
+      FrameIndexSDNode *StackPtrFI = cast<FrameIndexSDNode>(StackPtr.Val);
       int SPFI = StackPtrFI->getIndex();
 
       // Store the vector.
       SDOperand Ch = DAG.getStore(DAG.getEntryNode(), Tmp1, StackPtr,
-                                  &PseudoSourceValue::FPRel, SPFI);
+                                  PseudoSourceValue::getFixedStack(),
+                                  SPFI);
 
       // Truncate or zero extend offset to target pointer type.
       unsigned CastOpc = (IdxVT > PtrVT) ? ISD::TRUNCATE : ISD::ZERO_EXTEND;
@@ -1321,9 +1369,11 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       Tmp3 = DAG.getNode(ISD::MUL, IdxVT, Tmp3,DAG.getConstant(EltSize, IdxVT));
       SDOperand StackPtr2 = DAG.getNode(ISD::ADD, IdxVT, Tmp3, StackPtr);
       // Store the scalar value.
-      Ch = DAG.getStore(Ch, Tmp2, StackPtr2, &PseudoSourceValue::FPRel, SPFI);
+      Ch = DAG.getTruncStore(Ch, Tmp2, StackPtr2,
+                             PseudoSourceValue::getFixedStack(), SPFI, EltVT);
       // Load the updated vector.
-      Result = DAG.getLoad(VT, Ch, StackPtr, &PseudoSourceValue::FPRel, SPFI);
+      Result = DAG.getLoad(VT, Ch, StackPtr,
+                           PseudoSourceValue::getFixedStack(), SPFI);
       break;
     }
     }
@@ -1673,9 +1723,9 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       switch (EntrySize) {
       default: assert(0 && "Size of jump table not supported yet."); break;
       case 4: LD = DAG.getLoad(MVT::i32, Chain, Addr,
-                               &PseudoSourceValue::JTRel, 0); break;
+                               PseudoSourceValue::getJumpTable(), 0); break;
       case 8: LD = DAG.getLoad(MVT::i64, Chain, Addr,
-                               &PseudoSourceValue::JTRel, 0); break;
+                               PseudoSourceValue::getJumpTable(), 0); break;
       }
 
       Addr = LD;
@@ -2098,7 +2148,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
           ExpandOp(Tmp2, Lo, Hi);
 
           // Big endian systems want the hi reg first.
-          if (!TLI.isLittleEndian())
+          if (TLI.isBigEndian())
             std::swap(Lo, Hi);
           
           if (Hi.Val)
@@ -2237,7 +2287,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
             uint64_t IntVal =CFP->getValueAPF().convertToAPInt().getZExtValue();
             SDOperand Lo = DAG.getConstant(uint32_t(IntVal), MVT::i32);
             SDOperand Hi = DAG.getConstant(uint32_t(IntVal >>32), MVT::i32);
-            if (!TLI.isLittleEndian()) std::swap(Lo, Hi);
+            if (TLI.isBigEndian()) std::swap(Lo, Hi);
 
             Lo = DAG.getStore(Tmp1, Lo, Tmp2, ST->getSrcValue(),
                               SVOffset, isVolatile, Alignment);
@@ -2314,14 +2364,14 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
           MVT::ValueType TVT = MVT::getVectorType(EVT, NumElems);
           if (TLI.isTypeLegal(TVT)) {
             // Turn this into a normal store of the vector type.
-            Tmp3 = LegalizeOp(Node->getOperand(1));
+            Tmp3 = LegalizeOp(ST->getValue());
             Result = DAG.getStore(Tmp1, Tmp3, Tmp2, ST->getSrcValue(),
                                   SVOffset, isVolatile, Alignment);
             Result = LegalizeOp(Result);
             break;
           } else if (NumElems == 1) {
             // Turn this into a normal store of the scalar type.
-            Tmp3 = ScalarizeVectorOp(Node->getOperand(1));
+            Tmp3 = ScalarizeVectorOp(ST->getValue());
             Result = DAG.getStore(Tmp1, Tmp3, Tmp2, ST->getSrcValue(),
                                   SVOffset, isVolatile, Alignment);
             // The scalarized value type may not be legal, e.g. it might require
@@ -2329,15 +2379,15 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
             Result = LegalizeOp(Result);
             break;
           } else {
-            SplitVectorOp(Node->getOperand(1), Lo, Hi);
+            SplitVectorOp(ST->getValue(), Lo, Hi);
             IncrementSize = MVT::getVectorNumElements(Lo.Val->getValueType(0)) * 
                             MVT::getSizeInBits(EVT)/8;
           }
         } else {
-          ExpandOp(Node->getOperand(1), Lo, Hi);
+          ExpandOp(ST->getValue(), Lo, Hi);
           IncrementSize = Hi.Val ? MVT::getSizeInBits(Hi.getValueType())/8 : 0;
 
-          if (!TLI.isLittleEndian())
+          if (TLI.isBigEndian())
             std::swap(Lo, Hi);
         }
 
@@ -2832,7 +2882,8 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       }
 
       std::pair<SDOperand,SDOperand> CallResult =
-        TLI.LowerCallTo(Tmp1, Type::VoidTy, false, false, CallingConv::C, false,
+        TLI.LowerCallTo(Tmp1, Type::VoidTy,
+                        false, false, false, CallingConv::C, false,
                         DAG.getExternalSymbol(FnName, IntPtr), Args, DAG);
       Result = CallResult.second;
       break;
@@ -3821,6 +3872,13 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
     case Expand: assert(0 && "Shouldn't need to expand other operators here!");
     case Legal:
       Tmp1 = LegalizeOp(Node->getOperand(0));
+      if (TLI.getOperationAction(Node->getOpcode(), Node->getValueType(0)) ==
+          TargetLowering::Custom) {
+        Tmp2 = TLI.LowerOperation(Result, DAG);
+        if (Tmp2.Val) {
+          Tmp1 = Tmp2;
+        }
+      }
       Result = DAG.UpdateNodeOperands(Result, Tmp1);
       break;
     case Promote:
@@ -3902,7 +3960,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
     AddLegalizedOperand(SDOperand(Node, 1), Tmp1);
     return Op.ResNo ? Tmp1 : Result;
   }
-   case ISD::FLT_ROUNDS: {
+   case ISD::FLT_ROUNDS_: {
     MVT::ValueType VT = Node->getValueType(0);
     switch (TLI.getOperationAction(Node->getOpcode(), VT)) {
     default: assert(0 && "This action not supported for this op yet!");
@@ -3933,7 +3991,8 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
       Tmp1 = LegalizeOp(Node->getOperand(0));
       TargetLowering::ArgListTy Args;
       std::pair<SDOperand,SDOperand> CallResult =
-        TLI.LowerCallTo(Tmp1, Type::VoidTy, false, false, CallingConv::C, false,
+        TLI.LowerCallTo(Tmp1, Type::VoidTy,
+                        false, false, false, CallingConv::C, false,
                         DAG.getExternalSymbol("abort", TLI.getPointerTy()),
                         Args, DAG);
       Result = CallResult.second;
@@ -4740,8 +4799,7 @@ SDOperand SelectionDAGLegalize::EmitStackConvert(SDOperand SrcOp,
   // Create the stack frame object.
   SDOperand FIPtr = DAG.CreateStackTemporary(SlotVT);
 
-  FrameIndexSDNode *StackPtrFI = dyn_cast<FrameIndexSDNode>(FIPtr);
-  assert(StackPtrFI);
+  FrameIndexSDNode *StackPtrFI = cast<FrameIndexSDNode>(FIPtr);
   int SPFI = StackPtrFI->getIndex();
 
   unsigned SrcSize = MVT::getSizeInBits(SrcOp.getValueType());
@@ -4753,11 +4811,13 @@ SDOperand SelectionDAGLegalize::EmitStackConvert(SDOperand SrcOp,
   SDOperand Store;
   if (SrcSize > SlotSize)
     Store = DAG.getTruncStore(DAG.getEntryNode(), SrcOp, FIPtr,
-                              &PseudoSourceValue::FPRel, SPFI, SlotVT);
+                              PseudoSourceValue::getFixedStack(),
+                              SPFI, SlotVT);
   else {
     assert(SrcSize == SlotSize && "Invalid store");
     Store = DAG.getStore(DAG.getEntryNode(), SrcOp, FIPtr,
-                         &PseudoSourceValue::FPRel, SPFI, SlotVT);
+                         PseudoSourceValue::getFixedStack(),
+                         SPFI, SlotVT);
   }
   
   // Result is a load from the stack slot.
@@ -4773,14 +4833,13 @@ SDOperand SelectionDAGLegalize::ExpandSCALAR_TO_VECTOR(SDNode *Node) {
   // then load the whole vector back out.
   SDOperand StackPtr = DAG.CreateStackTemporary(Node->getValueType(0));
 
-  FrameIndexSDNode *StackPtrFI = dyn_cast<FrameIndexSDNode>(StackPtr);
-  assert(StackPtrFI);
+  FrameIndexSDNode *StackPtrFI = cast<FrameIndexSDNode>(StackPtr);
   int SPFI = StackPtrFI->getIndex();
 
   SDOperand Ch = DAG.getStore(DAG.getEntryNode(), Node->getOperand(0), StackPtr,
-                              &PseudoSourceValue::FPRel, SPFI);
+                              PseudoSourceValue::getFixedStack(), SPFI);
   return DAG.getLoad(Node->getValueType(0), Ch, StackPtr,
-                     &PseudoSourceValue::FPRel, SPFI);
+                     PseudoSourceValue::getFixedStack(), SPFI);
 }
 
 
@@ -4845,7 +4904,7 @@ SDOperand SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) {
     Constant *CP = ConstantVector::get(CV);
     SDOperand CPIdx = DAG.getConstantPool(CP, TLI.getPointerTy());
     return DAG.getLoad(VT, DAG.getEntryNode(), CPIdx,
-                       &PseudoSourceValue::CPRel, 0);
+                       PseudoSourceValue::getConstantPool(), 0);
   }
   
   if (SplatValue.Val) {   // Splat of one value?
@@ -5123,6 +5182,7 @@ SDOperand SelectionDAGLegalize::ExpandLibCall(const char *Name, SDNode *Node,
     const Type *ArgTy = MVT::getTypeForValueType(ArgVT);
     Entry.Node = Node->getOperand(i); Entry.Ty = ArgTy; 
     Entry.isSExt = isSigned;
+    Entry.isZExt = !isSigned;
     Args.push_back(Entry);
   }
   SDOperand Callee = DAG.getExternalSymbol(Name, TLI.getPointerTy());
@@ -5130,8 +5190,8 @@ SDOperand SelectionDAGLegalize::ExpandLibCall(const char *Name, SDNode *Node,
   // Splice the libcall in wherever FindInputOutputChains tells us to.
   const Type *RetTy = MVT::getTypeForValueType(Node->getValueType(0));
   std::pair<SDOperand,SDOperand> CallInfo =
-    TLI.LowerCallTo(InChain, RetTy, isSigned, false, CallingConv::C, false,
-                    Callee, Args, DAG);
+    TLI.LowerCallTo(InChain, RetTy, isSigned, !isSigned, false, CallingConv::C,
+                    false, Callee, Args, DAG);
 
   // Legalize the call sequence, starting with the chain.  This will advance
   // the LastCALLSEQ_END to the legalized version of the CALLSEQ_END node that
@@ -5188,11 +5248,12 @@ ExpandIntToFP(bool isSigned, MVT::ValueType DestTy, SDOperand Source) {
     SDOperand FudgeInReg;
     if (DestTy == MVT::f32)
       FudgeInReg = DAG.getLoad(MVT::f32, DAG.getEntryNode(), CPIdx,
-                               &PseudoSourceValue::CPRel, 0);
+                               PseudoSourceValue::getConstantPool(), 0);
     else if (MVT::getSizeInBits(DestTy) > MVT::getSizeInBits(MVT::f32))
       // FIXME: Avoid the extend by construction the right constantpool?
       FudgeInReg = DAG.getExtLoad(ISD::EXTLOAD, DestTy, DAG.getEntryNode(),
-                                  CPIdx, &PseudoSourceValue::CPRel, 0,
+                                  CPIdx,
+                                  PseudoSourceValue::getConstantPool(), 0,
                                   MVT::f32);
     else 
       assert(0 && "Unexpected conversion");
@@ -5336,12 +5397,13 @@ SDOperand SelectionDAGLegalize::ExpandLegalINT_TO_FP(bool isSigned,
   SDOperand FudgeInReg;
   if (DestVT == MVT::f32)
     FudgeInReg = DAG.getLoad(MVT::f32, DAG.getEntryNode(), CPIdx,
-                             &PseudoSourceValue::CPRel, 0);
+                             PseudoSourceValue::getConstantPool(), 0);
   else {
-    FudgeInReg = LegalizeOp(DAG.getExtLoad(ISD::EXTLOAD, DestVT,
-                                           DAG.getEntryNode(), CPIdx,
-                                           &PseudoSourceValue::CPRel, 0,
-                                           MVT::f32));
+    FudgeInReg =
+      LegalizeOp(DAG.getExtLoad(ISD::EXTLOAD, DestVT,
+                                DAG.getEntryNode(), CPIdx,
+                                PseudoSourceValue::getConstantPool(), 0,
+                                MVT::f32));
   }
 
   return DAG.getNode(ISD::FADD, DestVT, Tmp1, FudgeInReg);
@@ -5743,7 +5805,7 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){
     // Remember that we legalized the chain.
     Hi = LegalizeOp(Hi);
     AddLegalizedOperand(Op.getValue(1), Hi.getValue(1));
-    if (!TLI.isLittleEndian())
+    if (TLI.isBigEndian())
       std::swap(Lo, Hi);
     break;
   }
@@ -5786,7 +5848,7 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){
 
       // Remember that we legalized the chain.
       AddLegalizedOperand(Op.getValue(1), LegalizeOp(TF));
-      if (!TLI.isLittleEndian())
+      if (TLI.isBigEndian())
         std::swap(Lo, Hi);
     } else {
       MVT::ValueType EVT = LD->getMemoryVT();
@@ -6750,14 +6812,15 @@ void SelectionDAGLegalize::SplitVectorOp(SDOperand Op, SDOperand &Lo,
       // Lower to a store/load so that it can be split.
       // FIXME: this could be improved probably.
       SDOperand Ptr = DAG.CreateStackTemporary(InOp.getValueType());
-      FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(Ptr.Val);
-      assert(FI && "Expecting CreateStackTemporary to return a frame index.\n");
+      FrameIndexSDNode *FI = cast<FrameIndexSDNode>(Ptr.Val);
 
       SDOperand St = DAG.getStore(DAG.getEntryNode(),
                                   InOp, Ptr,
-                                  &PseudoSourceValue::FPRel, FI->getIndex());
+                                  PseudoSourceValue::getFixedStack(),
+                                  FI->getIndex());
       InOp = DAG.getLoad(Op.getValueType(), St, Ptr,
-                         &PseudoSourceValue::FPRel, FI->getIndex());
+                         PseudoSourceValue::getFixedStack(),
+                         FI->getIndex());
     }
     // Split the vector and convert each of the pieces now.
     SplitVectorOp(InOp, Lo, Hi);