summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-08-17 00:34:06 +0000
committerChris Lattner <sabre@nondot.org>2005-08-17 00:34:06 +0000
commit0d2456e1f0aa4046c79e4a6ef44598650f7596c5 (patch)
treee1f14c4cf7e1802e6616371cb9a33c9c315dde96 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
parent12214cf5779356786a162571a14f652b5f085d8b (diff)
downloadbcm5719-llvm-0d2456e1f0aa4046c79e4a6ef44598650f7596c5.tar.gz
bcm5719-llvm-0d2456e1f0aa4046c79e4a6ef44598650f7596c5.zip
add a new TargetConstant node
llvm-svn: 22813
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index dae19b9768f..ef7ffb24601 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -218,6 +218,10 @@ void SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) {
Constants.erase(std::make_pair(cast<ConstantSDNode>(N)->getValue(),
N->getValueType(0)));
break;
+ case ISD::TargetConstant:
+ TargetConstants.erase(std::make_pair(cast<ConstantSDNode>(N)->getValue(),
+ N->getValueType(0)));
+ break;
case ISD::ConstantFP: {
union {
double DV;
@@ -309,7 +313,20 @@ SDOperand SelectionDAG::getConstant(uint64_t Val, MVT::ValueType VT) {
SDNode *&N = Constants[std::make_pair(Val, VT)];
if (N) return SDOperand(N, 0);
- N = new ConstantSDNode(Val, VT);
+ N = new ConstantSDNode(false, Val, VT);
+ AllNodes.push_back(N);
+ return SDOperand(N, 0);
+}
+
+SDOperand SelectionDAG::getTargetConstant(uint64_t Val, MVT::ValueType VT) {
+ assert(MVT::isInteger(VT) && "Cannot create FP integer constant!");
+ // Mask out any bits that are not valid for this constant.
+ if (VT != MVT::i64)
+ Val &= ((uint64_t)1 << MVT::getSizeInBits(VT)) - 1;
+
+ SDNode *&N = TargetConstants[std::make_pair(Val, VT)];
+ if (N) return SDOperand(N, 0);
+ N = new ConstantSDNode(true, Val, VT);
AllNodes.push_back(N);
return SDOperand(N, 0);
}
@@ -1792,6 +1809,7 @@ const char *SDNode::getOperationName(const SelectionDAG *G) const {
case ISD::EntryToken: return "EntryToken";
case ISD::TokenFactor: return "TokenFactor";
case ISD::Constant: return "Constant";
+ case ISD::TargetConstant: return "TargetConstant";
case ISD::ConstantFP: return "ConstantFP";
case ISD::GlobalAddress: return "GlobalAddress";
case ISD::FrameIndex: return "FrameIndex";
OpenPOWER on IntegriCloud