aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-02-08 22:59:30 +0000
committerDan Gohman <gohman@apple.com>2008-02-08 22:59:30 +0000
commit6394b099e836f56a937cdcc7332c9487b504ca68 (patch)
tree28185f34de843851bd8e3fe1d9bdcf783fa2d03d /lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent82ada54da02a0b2a977fdeb6782c8e5ab9a9b9ea (diff)
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
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index a62ea53142..6c357d2507 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -706,18 +706,25 @@ SDOperand SelectionDAG::getString(const std::string &Val) {
}
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)))