[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 16 17:34:17 PDT 2005



Changes in directory llvm/lib/CodeGen/SelectionDAG:

SelectionDAG.cpp updated: 1.143 -> 1.144
---
Log message:

add a new TargetConstant node


---
Diffs of the changes:  (+19 -1)

 SelectionDAG.cpp |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletion(-)


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.143 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.144
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.143	Tue Aug 16 16:55:35 2005
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp	Tue Aug 16 19:34:06 2005
@@ -218,6 +218,10 @@
     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 @@
 
   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 @@
   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";






More information about the llvm-commits mailing list