Change ConstantSDNode to store an APInt instead of a uint64_t, and
begin adding some methods to use it this way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46899 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index a62ea53..6c357d2 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -706,18 +706,25 @@
 }
 
 SDOperand SelectionDAG::getConstant(uint64_t Val, MVT::ValueType VT, bool isT) {
+  MVT::ValueType EltVT =
+    MVT::isVector(VT) ? MVT::getVectorElementType(VT) : VT;
+
+  return getConstant(APInt(MVT::getSizeInBits(EltVT), Val), VT, isT);
+}
+
+SDOperand SelectionDAG::getConstant(const APInt &Val, MVT::ValueType VT, bool isT) {
   assert(MVT::isInteger(VT) && "Cannot create FP integer constant!");
 
   MVT::ValueType EltVT =
     MVT::isVector(VT) ? MVT::getVectorElementType(VT) : VT;
   
-  // Mask out any bits that are not valid for this constant.
-  Val &= MVT::getIntVTBitMask(EltVT);
+  assert(Val.getBitWidth() == MVT::getSizeInBits(EltVT) &&
+         "APInt size does not match type size!");
 
   unsigned Opc = isT ? ISD::TargetConstant : ISD::Constant;
   FoldingSetNodeID ID;
   AddNodeIDNode(ID, Opc, getVTList(EltVT), 0, 0);
-  ID.AddInteger(Val);
+  ID.AddAPInt(Val);
   void *IP = 0;
   SDNode *N = NULL;
   if ((N = CSEMap.FindNodeOrInsertPos(ID, IP)))