Refactor the constant folding code into it's own function. And call it from both
[oota-llvm.git] / include / llvm / CodeGen / SelectionDAG.h
index b2611dfa796e9edcee62e99d271f4578a1509c0e..6ca8a8c861f8f5431b37592a320033bf8bcd24fb 100644 (file)
@@ -36,7 +36,8 @@ class MachineFunction;
 class MachineConstantPoolValue;
 class FunctionLoweringInfo;
 
-template<> class ilist_traits<SDNode> : public ilist_default_traits<SDNode> {
+template<> struct ilist_traits<SDNode> : public ilist_default_traits<SDNode> {
+private:
   mutable SDNode Sentinel;
 public:
   ilist_traits() : Sentinel(ISD::DELETED_NODE, SDVTList()) {}
@@ -282,11 +283,8 @@ public:
     return getConstantPool(C, VT, Align, Offset, true);
   }
   SDValue getBasicBlock(MachineBasicBlock *MBB);
-  SDValue getSymbol(const char *Sym, MVT VT,
-                   GlobalValue::LinkageTypes LT = GlobalValue::ExternalLinkage);
-  SDValue getTargetSymbol(const char *Sym, MVT VT,
-                          GlobalValue::LinkageTypes LT =
-                            GlobalValue::ExternalLinkage);
+  SDValue getExternalSymbol(const char *Sym, MVT VT);
+  SDValue getTargetExternalSymbol(const char *Sym, MVT VT);
   SDValue getArgFlags(ISD::ArgFlagsTy Flags);
   SDValue getValueType(MVT);
   SDValue getRegister(unsigned Reg, MVT VT);
@@ -699,9 +697,15 @@ public:
   /// at least that alignment.
   SDValue CreateStackTemporary(MVT VT, unsigned minAlign = 1);
   
+  /// FoldConstantArithmetic - 
+  SDValue FoldConstantArithmetic(unsigned Opcode,
+                                 MVT VT,
+                                 ConstantSDNode *Cst1,
+                                 ConstantSDNode *Cst2);
+
   /// FoldSetCC - Constant fold a setcc to true or false.
   SDValue FoldSetCC(MVT VT, SDValue N1,
-                      SDValue N2, ISD::CondCode Cond);
+                    SDValue N2, ISD::CondCode Cond);
   
   /// SignBitIsZero - Return true if the sign bit of Op is known to be zero.  We
   /// use this predicate to simplify operations downstream.
@@ -761,8 +765,8 @@ private:
 
   std::vector<SDNode*> ValueTypeNodes;
   std::map<MVT, SDNode*, MVT::compareRawBits> ExtendedValueTypeNodes;
-  StringMap<SDNode*> Symbols;
-  StringMap<SDNode*> TargetSymbols;
+  StringMap<SDNode*> ExternalSymbols;
+  StringMap<SDNode*> TargetExternalSymbols;
 };
 
 template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {