LLVM API Documentation
00001 //===-- llvm/CodeGen/SelectionDAG.h - InstSelection DAG ---------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file declares the SelectionDAG class, and transitively defines the 00011 // SDNode class and subclasses. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_CODEGEN_SELECTIONDAG_H 00016 #define LLVM_CODEGEN_SELECTIONDAG_H 00017 00018 #include "llvm/ADT/ilist.h" 00019 #include "llvm/ADT/DenseSet.h" 00020 #include "llvm/ADT/FoldingSet.h" 00021 #include "llvm/ADT/StringMap.h" 00022 #include "llvm/CodeGen/SelectionDAGNodes.h" 00023 00024 #include <cassert> 00025 #include <vector> 00026 #include <map> 00027 #include <string> 00028 00029 namespace llvm { 00030 00031 class AliasAnalysis; 00032 class TargetLowering; 00033 class TargetMachine; 00034 class MachineModuleInfo; 00035 class DwarfWriter; 00036 class MachineFunction; 00037 class MachineConstantPoolValue; 00038 class FunctionLoweringInfo; 00039 00040 template<> struct ilist_traits<SDNode> : public ilist_default_traits<SDNode> { 00041 private: 00042 mutable SDNode Sentinel; 00043 public: 00044 ilist_traits() : Sentinel(ISD::DELETED_NODE, SDVTList()) {} 00045 00046 SDNode *createSentinel() const { 00047 return &Sentinel; 00048 } 00049 static void destroySentinel(SDNode *) {} 00050 00051 static void deleteNode(SDNode *) { 00052 assert(0 && "ilist_traits<SDNode> shouldn't see a deleteNode call!"); 00053 } 00054 private: 00055 static void createNode(const SDNode &); 00056 }; 00057 00058 enum CombineLevel { 00059 Unrestricted, // Combine may create illegal operations and illegal types. 00060 NoIllegalTypes, // Combine may create illegal operations but no illegal types. 00061 NoIllegalOperations // Combine may only create legal operations and types. 00062 }; 00063 00064 /// SelectionDAG class - This is used to represent a portion of an LLVM function 00065 /// in a low-level Data Dependence DAG representation suitable for instruction 00066 /// selection. This DAG is constructed as the first step of instruction 00067 /// selection in order to allow implementation of machine specific optimizations 00068 /// and code simplifications. 00069 /// 00070 /// The representation used by the SelectionDAG is a target-independent 00071 /// representation, which has some similarities to the GCC RTL representation, 00072 /// but is significantly more simple, powerful, and is a graph form instead of a 00073 /// linear form. 00074 /// 00075 class SelectionDAG { 00076 TargetLowering &TLI; 00077 MachineFunction *MF; 00078 FunctionLoweringInfo &FLI; 00079 MachineModuleInfo *MMI; 00080 DwarfWriter *DW; 00081 00082 /// EntryNode - The starting token. 00083 SDNode EntryNode; 00084 00085 /// Root - The root of the entire DAG. 00086 SDValue Root; 00087 00088 /// AllNodes - A linked list of nodes in the current DAG. 00089 ilist<SDNode> AllNodes; 00090 00091 /// NodeAllocatorType - The AllocatorType for allocating SDNodes. We use 00092 /// pool allocation with recycling. 00093 typedef RecyclingAllocator<BumpPtrAllocator, SDNode, sizeof(LargestSDNode), 00094 AlignOf<MostAlignedSDNode>::Alignment> 00095 NodeAllocatorType; 00096 00097 /// NodeAllocator - Pool allocation for nodes. 00098 NodeAllocatorType NodeAllocator; 00099 00100 /// CSEMap - This structure is used to memoize nodes, automatically performing 00101 /// CSE with existing nodes with a duplicate is requested. 00102 FoldingSet<SDNode> CSEMap; 00103 00104 /// OperandAllocator - Pool allocation for machine-opcode SDNode operands. 00105 BumpPtrAllocator OperandAllocator; 00106 00107 /// Allocator - Pool allocation for misc. objects that are created once per 00108 /// SelectionDAG. 00109 BumpPtrAllocator Allocator; 00110 00111 /// VerifyNode - Sanity check the given node. Aborts if it is invalid. 00112 void VerifyNode(SDNode *N); 00113 00114 /// setGraphColorHelper - Implementation of setSubgraphColor. 00115 /// Return whether we had to truncate the search. 00116 /// 00117 bool setSubgraphColorHelper(SDNode *N, const char *Color, DenseSet<SDNode *> &visited, 00118 int level, bool &printed); 00119 00120 public: 00121 SelectionDAG(TargetLowering &tli, FunctionLoweringInfo &fli); 00122 ~SelectionDAG(); 00123 00124 /// init - Prepare this SelectionDAG to process code in the given 00125 /// MachineFunction. 00126 /// 00127 void init(MachineFunction &mf, MachineModuleInfo *mmi, DwarfWriter *dw); 00128 00129 /// clear - Clear state and free memory necessary to make this 00130 /// SelectionDAG ready to process a new block. 00131 /// 00132 void clear(); 00133 00134 MachineFunction &getMachineFunction() const { return *MF; } 00135 const TargetMachine &getTarget() const; 00136 TargetLowering &getTargetLoweringInfo() const { return TLI; } 00137 FunctionLoweringInfo &getFunctionLoweringInfo() const { return FLI; } 00138 MachineModuleInfo *getMachineModuleInfo() const { return MMI; } 00139 DwarfWriter *getDwarfWriter() const { return DW; } 00140 00141 /// viewGraph - Pop up a GraphViz/gv window with the DAG rendered using 'dot'. 00142 /// 00143 void viewGraph(const std::string &Title); 00144 void viewGraph(); 00145 00146 #ifndef NDEBUG 00147 std::map<const SDNode *, std::string> NodeGraphAttrs; 00148 #endif 00149 00150 /// clearGraphAttrs - Clear all previously defined node graph attributes. 00151 /// Intended to be used from a debugging tool (eg. gdb). 00152 void clearGraphAttrs(); 00153 00154 /// setGraphAttrs - Set graph attributes for a node. (eg. "color=red".) 00155 /// 00156 void setGraphAttrs(const SDNode *N, const char *Attrs); 00157 00158 /// getGraphAttrs - Get graph attributes for a node. (eg. "color=red".) 00159 /// Used from getNodeAttributes. 00160 const std::string getGraphAttrs(const SDNode *N) const; 00161 00162 /// setGraphColor - Convenience for setting node color attribute. 00163 /// 00164 void setGraphColor(const SDNode *N, const char *Color); 00165 00166 /// setGraphColor - Convenience for setting subgraph color attribute. 00167 /// 00168 void setSubgraphColor(SDNode *N, const char *Color); 00169 00170 typedef ilist<SDNode>::const_iterator allnodes_const_iterator; 00171 allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); } 00172 allnodes_const_iterator allnodes_end() const { return AllNodes.end(); } 00173 typedef ilist<SDNode>::iterator allnodes_iterator; 00174 allnodes_iterator allnodes_begin() { return AllNodes.begin(); } 00175 allnodes_iterator allnodes_end() { return AllNodes.end(); } 00176 ilist<SDNode>::size_type allnodes_size() const { 00177 return AllNodes.size(); 00178 } 00179 00180 /// getRoot - Return the root tag of the SelectionDAG. 00181 /// 00182 const SDValue &getRoot() const { return Root; } 00183 00184 /// getEntryNode - Return the token chain corresponding to the entry of the 00185 /// function. 00186 SDValue getEntryNode() const { 00187 return SDValue(const_cast<SDNode *>(&EntryNode), 0); 00188 } 00189 00190 /// setRoot - Set the current root tag of the SelectionDAG. 00191 /// 00192 const SDValue &setRoot(SDValue N) { 00193 assert((!N.getNode() || N.getValueType() == MVT::Other) && 00194 "DAG root value is not a chain!"); 00195 return Root = N; 00196 } 00197 00198 /// Combine - This iterates over the nodes in the SelectionDAG, folding 00199 /// certain types of nodes together, or eliminating superfluous nodes. The 00200 /// Level argument controls whether Combine is allowed to produce nodes and 00201 /// types that are illegal on the target. 00202 void Combine(CombineLevel Level, AliasAnalysis &AA, bool Fast); 00203 00204 /// LegalizeTypes - This transforms the SelectionDAG into a SelectionDAG that 00205 /// only uses types natively supported by the target. Returns "true" if it 00206 /// made any changes. 00207 /// 00208 /// Note that this is an involved process that may invalidate pointers into 00209 /// the graph. 00210 bool LegalizeTypes(); 00211 00212 /// Legalize - This transforms the SelectionDAG into a SelectionDAG that is 00213 /// compatible with the target instruction selector, as indicated by the 00214 /// TargetLowering object. 00215 /// 00216 /// Note that this is an involved process that may invalidate pointers into 00217 /// the graph. 00218 void Legalize(bool TypesNeedLegalizing); 00219 00220 /// RemoveDeadNodes - This method deletes all unreachable nodes in the 00221 /// SelectionDAG. 00222 void RemoveDeadNodes(); 00223 00224 /// DeleteNode - Remove the specified node from the system. This node must 00225 /// have no referrers. 00226 void DeleteNode(SDNode *N); 00227 00228 /// getVTList - Return an SDVTList that represents the list of values 00229 /// specified. 00230 SDVTList getVTList(MVT VT); 00231 SDVTList getVTList(MVT VT1, MVT VT2); 00232 SDVTList getVTList(MVT VT1, MVT VT2, MVT VT3); 00233 SDVTList getVTList(MVT VT1, MVT VT2, MVT VT3, MVT VT4); 00234 SDVTList getVTList(const MVT *VTs, unsigned NumVTs); 00235 00236 /// getNodeValueTypes - These are obsolete, use getVTList instead. 00237 const MVT *getNodeValueTypes(MVT VT) { 00238 return getVTList(VT).VTs; 00239 } 00240 const MVT *getNodeValueTypes(MVT VT1, MVT VT2) { 00241 return getVTList(VT1, VT2).VTs; 00242 } 00243 const MVT *getNodeValueTypes(MVT VT1, MVT VT2, MVT VT3) { 00244 return getVTList(VT1, VT2, VT3).VTs; 00245 } 00246 const MVT *getNodeValueTypes(MVT VT1, MVT VT2, MVT VT3, MVT VT4) { 00247 return getVTList(VT1, VT2, VT3, VT4).VTs; 00248 } 00249 const MVT *getNodeValueTypes(const std::vector<MVT> &vtList) { 00250 return getVTList(&vtList[0], (unsigned)vtList.size()).VTs; 00251 } 00252 00253 00254 //===--------------------------------------------------------------------===// 00255 // Node creation methods. 00256 // 00257 SDValue getConstant(uint64_t Val, MVT VT, bool isTarget = false); 00258 SDValue getConstant(const APInt &Val, MVT VT, bool isTarget = false); 00259 SDValue getConstant(const ConstantInt &Val, MVT VT, bool isTarget = false); 00260 SDValue getIntPtrConstant(uint64_t Val, bool isTarget = false); 00261 SDValue getTargetConstant(uint64_t Val, MVT VT) { 00262 return getConstant(Val, VT, true); 00263 } 00264 SDValue getTargetConstant(const APInt &Val, MVT VT) { 00265 return getConstant(Val, VT, true); 00266 } 00267 SDValue getTargetConstant(const ConstantInt &Val, MVT VT) { 00268 return getConstant(Val, VT, true); 00269 } 00270 SDValue getConstantFP(double Val, MVT VT, bool isTarget = false); 00271 SDValue getConstantFP(const APFloat& Val, MVT VT, bool isTarget = false); 00272 SDValue getConstantFP(const ConstantFP &CF, MVT VT, bool isTarget = false); 00273 SDValue getTargetConstantFP(double Val, MVT VT) { 00274 return getConstantFP(Val, VT, true); 00275 } 00276 SDValue getTargetConstantFP(const APFloat& Val, MVT VT) { 00277 return getConstantFP(Val, VT, true); 00278 } 00279 SDValue getTargetConstantFP(const ConstantFP &Val, MVT VT) { 00280 return getConstantFP(Val, VT, true); 00281 } 00282 SDValue getGlobalAddress(const GlobalValue *GV, MVT VT, 00283 int64_t offset = 0, bool isTargetGA = false); 00284 SDValue getTargetGlobalAddress(const GlobalValue *GV, MVT VT, 00285 int64_t offset = 0) { 00286 return getGlobalAddress(GV, VT, offset, true); 00287 } 00288 SDValue getFrameIndex(int FI, MVT VT, bool isTarget = false); 00289 SDValue getTargetFrameIndex(int FI, MVT VT) { 00290 return getFrameIndex(FI, VT, true); 00291 } 00292 SDValue getJumpTable(int JTI, MVT VT, bool isTarget = false); 00293 SDValue getTargetJumpTable(int JTI, MVT VT) { 00294 return getJumpTable(JTI, VT, true); 00295 } 00296 SDValue getConstantPool(Constant *C, MVT VT, 00297 unsigned Align = 0, int Offs = 0, bool isT=false); 00298 SDValue getTargetConstantPool(Constant *C, MVT VT, 00299 unsigned Align = 0, int Offset = 0) { 00300 return getConstantPool(C, VT, Align, Offset, true); 00301 } 00302 SDValue getConstantPool(MachineConstantPoolValue *C, MVT VT, 00303 unsigned Align = 0, int Offs = 0, bool isT=false); 00304 SDValue getTargetConstantPool(MachineConstantPoolValue *C, 00305 MVT VT, unsigned Align = 0, 00306 int Offset = 0) { 00307 return getConstantPool(C, VT, Align, Offset, true); 00308 } 00309 SDValue getBasicBlock(MachineBasicBlock *MBB); 00310 SDValue getBasicBlock(MachineBasicBlock *MBB, DebugLoc dl); 00311 SDValue getExternalSymbol(const char *Sym, MVT VT); 00312 SDValue getExternalSymbol(const char *Sym, DebugLoc dl, MVT VT); 00313 SDValue getTargetExternalSymbol(const char *Sym, MVT VT); 00314 SDValue getTargetExternalSymbol(const char *Sym, DebugLoc dl, MVT VT); 00315 SDValue getArgFlags(ISD::ArgFlagsTy Flags); 00316 SDValue getValueType(MVT); 00317 SDValue getRegister(unsigned Reg, MVT VT); 00318 SDValue getDbgStopPoint(SDValue Root, unsigned Line, unsigned Col, 00319 Value *CU); 00320 SDValue getLabel(unsigned Opcode, SDValue Root, unsigned LabelID); 00321 SDValue getLabel(unsigned Opcode, DebugLoc dl, SDValue Root, 00322 unsigned LabelID); 00323 00324 SDValue getCopyToReg(SDValue Chain, unsigned Reg, SDValue N) { 00325 return getNode(ISD::CopyToReg, MVT::Other, Chain, 00326 getRegister(Reg, N.getValueType()), N); 00327 } 00328 00329 // This version of the getCopyToReg method takes an extra operand, which 00330 // indicates that there is potentially an incoming flag value (if Flag is not 00331 // null) and that there should be a flag result. 00332 SDValue getCopyToReg(SDValue Chain, unsigned Reg, SDValue N, 00333 SDValue Flag) { 00334 const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag); 00335 SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Flag }; 00336 return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.getNode() ? 4 : 3); 00337 } 00338 00339 // Similar to last getCopyToReg() except parameter Reg is a SDValue 00340 SDValue getCopyToReg(SDValue Chain, SDValue Reg, SDValue N, 00341 SDValue Flag) { 00342 const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag); 00343 SDValue Ops[] = { Chain, Reg, N, Flag }; 00344 return getNode(ISD::CopyToReg, VTs, 2, Ops, Flag.getNode() ? 4 : 3); 00345 } 00346 00347 SDValue getCopyFromReg(SDValue Chain, unsigned Reg, MVT VT) { 00348 const MVT *VTs = getNodeValueTypes(VT, MVT::Other); 00349 SDValue Ops[] = { Chain, getRegister(Reg, VT) }; 00350 return getNode(ISD::CopyFromReg, VTs, 2, Ops, 2); 00351 } 00352 00353 // This version of the getCopyFromReg method takes an extra operand, which 00354 // indicates that there is potentially an incoming flag value (if Flag is not 00355 // null) and that there should be a flag result. 00356 SDValue getCopyFromReg(SDValue Chain, unsigned Reg, MVT VT, 00357 SDValue Flag) { 00358 const MVT *VTs = getNodeValueTypes(VT, MVT::Other, MVT::Flag); 00359 SDValue Ops[] = { Chain, getRegister(Reg, VT), Flag }; 00360 return getNode(ISD::CopyFromReg, VTs, 3, Ops, Flag.getNode() ? 3 : 2); 00361 } 00362 00363 SDValue getCondCode(ISD::CondCode Cond); 00364 00365 /// Returns the ConvertRndSat Note: Avoid using this node because it may 00366 /// disappear in the future and most targets don't support it. 00367 SDValue getConvertRndSat(MVT VT, SDValue Val, SDValue DTy, SDValue STy, 00368 SDValue Rnd, SDValue Sat, ISD::CvtCode Code); 00369 00370 /// getZeroExtendInReg - Return the expression required to zero extend the Op 00371 /// value assuming it was the smaller SrcTy value. 00372 SDValue getZeroExtendInReg(SDValue Op, MVT SrcTy); 00373 SDValue getZeroExtendInReg(SDValue Op, DebugLoc DL, MVT SrcTy); 00374 00375 /// getNOT - Create a bitwise NOT operation as (XOR Val, -1). 00376 SDValue getNOT(DebugLoc DL, SDValue Val, MVT VT); 00377 00378 /// getCALLSEQ_START - Return a new CALLSEQ_START node, which always must have 00379 /// a flag result (to ensure it's not CSE'd). 00380 SDValue getCALLSEQ_START(SDValue Chain, SDValue Op) { 00381 const MVT *VTs = getNodeValueTypes(MVT::Other, MVT::Flag); 00382 SDValue Ops[] = { Chain, Op }; 00383 return getNode(ISD::CALLSEQ_START, VTs, 2, Ops, 2); 00384 } 00385 00386 /// getCALLSEQ_END - Return a new CALLSEQ_END node, which always must have a 00387 /// flag result (to ensure it's not CSE'd). 00388 SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, 00389 SDValue InFlag) { 00390 SDVTList NodeTys = getVTList(MVT::Other, MVT::Flag); 00391 SmallVector<SDValue, 4> Ops; 00392 Ops.push_back(Chain); 00393 Ops.push_back(Op1); 00394 Ops.push_back(Op2); 00395 Ops.push_back(InFlag); 00396 return getNode(ISD::CALLSEQ_END, NodeTys, &Ops[0], 00397 (unsigned)Ops.size() - (InFlag.getNode() == 0 ? 1 : 0)); 00398 } 00399 00400 /// getNode - Gets or creates the specified node. 00401 /// 00402 SDValue getNode(unsigned Opcode, MVT VT); 00403 SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT); 00404 SDValue getNode(unsigned Opcode, MVT VT, SDValue N); 00405 SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT, SDValue N); 00406 SDValue getNode(unsigned Opcode, MVT VT, SDValue N1, SDValue N2); 00407 SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT, SDValue N1, SDValue N2); 00408 SDValue getNode(unsigned Opcode, MVT VT, 00409 SDValue N1, SDValue N2, SDValue N3); 00410 SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT, 00411 SDValue N1, SDValue N2, SDValue N3); 00412 SDValue getNode(unsigned Opcode, MVT VT, 00413 SDValue N1, SDValue N2, SDValue N3, SDValue N4); 00414 SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT, 00415 SDValue N1, SDValue N2, SDValue N3, SDValue N4); 00416 SDValue getNode(unsigned Opcode, MVT VT, 00417 SDValue N1, SDValue N2, SDValue N3, SDValue N4, 00418 SDValue N5); 00419 SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT, 00420 SDValue N1, SDValue N2, SDValue N3, SDValue N4, 00421 SDValue N5); 00422 SDValue getNode(unsigned Opcode, MVT VT, 00423 const SDUse *Ops, unsigned NumOps); 00424 SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT, 00425 const SDUse *Ops, unsigned NumOps); 00426 SDValue getNode(unsigned Opcode, MVT VT, 00427 const SDValue *Ops, unsigned NumOps); 00428 SDValue getNode(unsigned Opcode, DebugLoc DL, MVT VT, 00429 const SDValue *Ops, unsigned NumOps); 00430 SDValue getNode(unsigned Opcode, const std::vector<MVT> &ResultTys, 00431 const SDValue *Ops, unsigned NumOps); 00432 SDValue getNode(unsigned Opcode, DebugLoc DL, 00433 const std::vector<MVT> &ResultTys, 00434 const SDValue *Ops, unsigned NumOps); 00435 SDValue getNode(unsigned Opcode, const MVT *VTs, unsigned NumVTs, 00436 const SDValue *Ops, unsigned NumOps); 00437 SDValue getNode(unsigned Opcode, DebugLoc DL, const MVT *VTs, unsigned NumVTs, 00438 const SDValue *Ops, unsigned NumOps); 00439 SDValue getNode(unsigned Opcode, SDVTList VTs, 00440 const SDValue *Ops, unsigned NumOps); 00441 SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs, 00442 const SDValue *Ops, unsigned NumOps); 00443 00444 SDValue getNode(unsigned Opcode, SDVTList VTs); 00445 SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs); 00446 SDValue getNode(unsigned Opcode, SDVTList VTs, SDValue N); 00447 SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs, SDValue N); 00448 SDValue getNode(unsigned Opcode, SDVTList VTs, SDValue N1, SDValue N2); 00449 SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs, 00450 SDValue N1, SDValue N2); 00451 SDValue getNode(unsigned Opcode, SDVTList VTs, 00452 SDValue N1, SDValue N2, SDValue N3); 00453 SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs, 00454 SDValue N1, SDValue N2, SDValue N3); 00455 SDValue getNode(unsigned Opcode, SDVTList VTs, 00456 SDValue N1, SDValue N2, SDValue N3, SDValue N4); 00457 SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs, 00458 SDValue N1, SDValue N2, SDValue N3, SDValue N4); 00459 SDValue getNode(unsigned Opcode, SDVTList VTs, 00460 SDValue N1, SDValue N2, SDValue N3, SDValue N4, 00461 SDValue N5); 00462 SDValue getNode(unsigned Opcode, DebugLoc DL, SDVTList VTs, 00463 SDValue N1, SDValue N2, SDValue N3, SDValue N4, 00464 SDValue N5); 00465 00466 SDValue getMemcpy(SDValue Chain, SDValue Dst, SDValue Src, 00467 SDValue Size, unsigned Align, bool AlwaysInline, 00468 const Value *DstSV, uint64_t DstSVOff, 00469 const Value *SrcSV, uint64_t SrcSVOff); 00470 00471 SDValue getMemmove(SDValue Chain, SDValue Dst, SDValue Src, 00472 SDValue Size, unsigned Align, 00473 const Value *DstSV, uint64_t DstOSVff, 00474 const Value *SrcSV, uint64_t SrcSVOff); 00475 00476 SDValue getMemset(SDValue Chain, SDValue Dst, SDValue Src, 00477 SDValue Size, unsigned Align, 00478 const Value *DstSV, uint64_t DstSVOff); 00479 00480 /// getSetCC - Helper function to make it easier to build SetCC's if you just 00481 /// have an ISD::CondCode instead of an SDValue. 00482 /// 00483 SDValue getSetCC(MVT VT, SDValue LHS, SDValue RHS, 00484 ISD::CondCode Cond) { 00485 return getNode(ISD::SETCC, DebugLoc::getUnknownLoc(), VT, 00486 LHS, RHS, getCondCode(Cond)); 00487 } 00488 SDValue getSetCC(DebugLoc DL, MVT VT, SDValue LHS, SDValue RHS, 00489 ISD::CondCode Cond) { 00490 return getNode(ISD::SETCC, DL, VT, LHS, RHS, getCondCode(Cond)); 00491 } 00492 00493 /// getVSetCC - Helper function to make it easier to build VSetCC's nodes 00494 /// if you just have an ISD::CondCode instead of an SDValue. 00495 /// 00496 SDValue getVSetCC(MVT VT, SDValue LHS, SDValue RHS, 00497 ISD::CondCode Cond) { 00498 return getNode(ISD::VSETCC, DebugLoc::getUnknownLoc(), VT, 00499 LHS, RHS, getCondCode(Cond)); 00500 } 00501 SDValue getVSetCC(DebugLoc DL, MVT VT, SDValue LHS, SDValue RHS, 00502 ISD::CondCode Cond) { 00503 return getNode(ISD::VSETCC, DL, VT, LHS, RHS, getCondCode(Cond)); 00504 } 00505 00506 /// getSelectCC - Helper function to make it easier to build SelectCC's if you 00507 /// just have an ISD::CondCode instead of an SDValue. 00508 /// 00509 SDValue getSelectCC(SDValue LHS, SDValue RHS, 00510 SDValue True, SDValue False, ISD::CondCode Cond) { 00511 return getNode(ISD::SELECT_CC, DebugLoc::getUnknownLoc(), True.getValueType(), 00512 LHS, RHS, True, False, getCondCode(Cond)); 00513 } 00514 SDValue getSelectCC(DebugLoc DL, SDValue LHS, SDValue RHS, 00515 SDValue True, SDValue False, ISD::CondCode Cond) { 00516 return getNode(ISD::SELECT_CC, DL, True.getValueType(), 00517 LHS, RHS, True, False, getCondCode(Cond)); 00518 } 00519 00520 /// getVAArg - VAArg produces a result and token chain, and takes a pointer 00521 /// and a source value as input. 00522 SDValue getVAArg(MVT VT, SDValue Chain, SDValue Ptr, 00523 SDValue SV); 00524 00525 /// getAtomic - Gets a node for an atomic op, produces result and chain and 00526 /// takes 3 operands 00527 SDValue getAtomic(unsigned Opcode, MVT MemVT, SDValue Chain, SDValue Ptr, 00528 SDValue Cmp, SDValue Swp, const Value* PtrVal, 00529 unsigned Alignment=0); 00530 SDValue getAtomic(unsigned Opcode, DebugLoc dl, MVT MemVT, SDValue Chain, 00531 SDValue Ptr, SDValue Cmp, SDValue Swp, const Value* PtrVal, 00532 unsigned Alignment=0); 00533 00534 /// getAtomic - Gets a node for an atomic op, produces result and chain and 00535 /// takes 2 operands. 00536 SDValue getAtomic(unsigned Opcode, MVT MemVT, SDValue Chain, SDValue Ptr, 00537 SDValue Val, const Value* PtrVal, 00538 unsigned Alignment = 0); 00539 SDValue getAtomic(unsigned Opcode, DebugLoc dl, MVT MemVT, SDValue Chain, 00540 SDValue Ptr, SDValue Val, const Value* PtrVal, 00541 unsigned Alignment = 0); 00542 00543 /// getMemIntrinsicNode - Creates a MemIntrinsicNode that may produce a 00544 /// result and takes a list of operands. 00545 SDValue getMemIntrinsicNode(unsigned Opcode, 00546 const MVT *VTs, unsigned NumVTs, 00547 const SDValue *Ops, unsigned NumOps, 00548 MVT MemVT, const Value *srcValue, int SVOff, 00549 unsigned Align = 0, bool Vol = false, 00550 bool ReadMem = true, bool WriteMem = true); 00551 SDValue getMemIntrinsicNode(unsigned Opcode, DebugLoc dl, 00552 const MVT *VTs, unsigned NumVTs, 00553 const SDValue *Ops, unsigned NumOps, 00554 MVT MemVT, const Value *srcValue, int SVOff, 00555 unsigned Align = 0, bool Vol = false, 00556 bool ReadMem = true, bool WriteMem = true); 00557 00558 SDValue getMemIntrinsicNode(unsigned Opcode, SDVTList VTList, 00559 const SDValue *Ops, unsigned NumOps, 00560 MVT MemVT, const Value *srcValue, int SVOff, 00561 unsigned Align = 0, bool Vol = false, 00562 bool ReadMem = true, bool WriteMem = true); 00563 SDValue getMemIntrinsicNode(unsigned Opcode, DebugLoc dl, SDVTList VTList, 00564 const SDValue *Ops, unsigned NumOps, 00565 MVT MemVT, const Value *srcValue, int SVOff, 00566 unsigned Align = 0, bool Vol = false, 00567 bool ReadMem = true, bool WriteMem = true); 00568 00569 /// getMergeValues - Create a MERGE_VALUES node from the given operands. 00570 SDValue getMergeValues(const SDValue *Ops, unsigned NumOps); 00571 SDValue getMergeValues(const SDValue *Ops, unsigned NumOps, DebugLoc dl); 00572 00573 /// getCall - Create a CALL node from the given information. 00574 /// 00575 SDValue getCall(unsigned CallingConv, bool IsVarArgs, bool IsTailCall, 00576 bool isInreg, SDVTList VTs, const SDValue *Operands, 00577 unsigned NumOperands); 00578 SDValue getCall(unsigned CallingConv, DebugLoc dl, bool IsVarArgs, 00579 bool IsTailCall, bool isInreg, SDVTList VTs, 00580 const SDValue *Operands, unsigned NumOperands); 00581 00582 /// getLoad - Loads are not normal binary operators: their result type is not 00583 /// determined by their operands, and they produce a value AND a token chain. 00584 /// 00585 SDValue getLoad(MVT VT, SDValue Chain, SDValue Ptr, 00586 const Value *SV, int SVOffset, bool isVolatile=false, 00587 unsigned Alignment=0); 00588 SDValue getLoad(MVT VT, DebugLoc dl, SDValue Chain, SDValue Ptr, 00589 const Value *SV, int SVOffset, bool isVolatile=false, 00590 unsigned Alignment=0); 00591 SDValue getExtLoad(ISD::LoadExtType ExtType, MVT VT, 00592 SDValue Chain, SDValue Ptr, const Value *SV, 00593 int SVOffset, MVT EVT, bool isVolatile=false, 00594 unsigned Alignment=0); 00595 SDValue getExtLoad(ISD::LoadExtType ExtType, DebugLoc dl, MVT VT, 00596 SDValue Chain, SDValue Ptr, const Value *SV, 00597 int SVOffset, MVT EVT, bool isVolatile=false, 00598 unsigned Alignment=0); 00599 SDValue getIndexedLoad(SDValue OrigLoad, SDValue Base, 00600 SDValue Offset, ISD::MemIndexedMode AM); 00601 SDValue getIndexedLoad(SDValue OrigLoad, DebugLoc dl, SDValue Base, 00602 SDValue Offset, ISD::MemIndexedMode AM); 00603 SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, 00604 MVT VT, SDValue Chain, 00605 SDValue Ptr, SDValue Offset, 00606 const Value *SV, int SVOffset, MVT EVT, 00607 bool isVolatile=false, unsigned Alignment=0); 00608 SDValue getLoad(ISD::MemIndexedMode AM, DebugLoc dl, ISD::LoadExtType ExtType, 00609 MVT VT, SDValue Chain, 00610 SDValue Ptr, SDValue Offset, 00611 const Value *SV, int SVOffset, MVT EVT, 00612 bool isVolatile=false, unsigned Alignment=0); 00613 00614 /// getStore - Helper function to build ISD::STORE nodes. 00615 /// 00616 SDValue getStore(SDValue Chain, SDValue Val, SDValue Ptr, 00617 const Value *SV, int SVOffset, bool isVolatile=false, 00618 unsigned Alignment=0); 00619 SDValue getStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr, 00620 const Value *SV, int SVOffset, bool isVolatile=false, 00621 unsigned Alignment=0); 00622 SDValue getTruncStore(SDValue Chain, SDValue Val, SDValue Ptr, 00623 const Value *SV, int SVOffset, MVT TVT, 00624 bool isVolatile=false, unsigned Alignment=0); 00625 SDValue getTruncStore(SDValue Chain, DebugLoc dl, SDValue Val, SDValue Ptr, 00626 const Value *SV, int SVOffset, MVT TVT, 00627 bool isVolatile=false, unsigned Alignment=0); 00628 SDValue getIndexedStore(SDValue OrigStoe, SDValue Base, 00629 SDValue Offset, ISD::MemIndexedMode AM); 00630 SDValue getIndexedStore(SDValue OrigStoe, DebugLoc dl, SDValue Base, 00631 SDValue Offset, ISD::MemIndexedMode AM); 00632 00633 /// getSrcValue - Construct a node to track a Value* through the backend. 00634 SDValue getSrcValue(const Value *v); 00635 00636 /// getMemOperand - Construct a node to track a memory reference 00637 /// through the backend. 00638 SDValue getMemOperand(const MachineMemOperand &MO); 00639 00640 /// getShiftAmountOperand - Return the specified value casted to 00641 /// the target's desired shift amount type. 00642 SDValue getShiftAmountOperand(SDValue Op); 00643 00644 /// UpdateNodeOperands - *Mutate* the specified node in-place to have the 00645 /// specified operands. If the resultant node already exists in the DAG, 00646 /// this does not modify the specified node, instead it returns the node that 00647 /// already exists. If the resultant node does not exist in the DAG, the 00648 /// input node is returned. As a degenerate case, if you specify the same 00649 /// input operands as the node already has, the input node is returned. 00650 SDValue UpdateNodeOperands(SDValue N, SDValue Op); 00651 SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2); 00652 SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2, 00653 SDValue Op3); 00654 SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2, 00655 SDValue Op3, SDValue Op4); 00656 SDValue UpdateNodeOperands(SDValue N, SDValue Op1, SDValue Op2, 00657 SDValue Op3, SDValue Op4, SDValue Op5); 00658 SDValue UpdateNodeOperands(SDValue N, 00659 const SDValue *Ops, unsigned NumOps); 00660 00661 /// SelectNodeTo - These are used for target selectors to *mutate* the 00662 /// specified node to have the specified return type, Target opcode, and 00663 /// operands. Note that target opcodes are stored as 00664 /// ~TargetOpcode in the node opcode field. The resultant node is returned. 00665 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT); 00666 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, SDValue Op1); 00667 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, 00668 SDValue Op1, SDValue Op2); 00669 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, 00670 SDValue Op1, SDValue Op2, SDValue Op3); 00671 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT, 00672 const SDValue *Ops, unsigned NumOps); 00673 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, MVT VT2); 00674 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 00675 MVT VT2, const SDValue *Ops, unsigned NumOps); 00676 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 00677 MVT VT2, MVT VT3, const SDValue *Ops, unsigned NumOps); 00678 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, MVT VT1, 00679 MVT VT2, MVT VT3, MVT VT4, const SDValue *Ops, 00680 unsigned NumOps); 00681 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 00682 MVT VT2, SDValue Op1); 00683 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 00684 MVT VT2, SDValue Op1, SDValue Op2); 00685 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 00686 MVT VT2, SDValue Op1, SDValue Op2, SDValue Op3); 00687 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, MVT VT1, 00688 MVT VT2, MVT VT3, SDValue Op1, SDValue Op2, SDValue Op3); 00689 SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, SDVTList VTs, 00690 const SDValue *Ops, unsigned NumOps); 00691 00692 /// MorphNodeTo - These *mutate* the specified node to have the specified 00693 /// return type, opcode, and operands. 00694 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT); 00695 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT, SDValue Op1); 00696 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT, 00697 SDValue Op1, SDValue Op2); 00698 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT, 00699 SDValue Op1, SDValue Op2, SDValue Op3); 00700 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT, 00701 const SDValue *Ops, unsigned NumOps); 00702 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, MVT VT2); 00703 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, 00704 MVT VT2, const SDValue *Ops, unsigned NumOps); 00705 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, 00706 MVT VT2, MVT VT3, const SDValue *Ops, unsigned NumOps); 00707 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, 00708 MVT VT2, SDValue Op1); 00709 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, 00710 MVT VT2, SDValue Op1, SDValue Op2); 00711 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, MVT VT1, 00712 MVT VT2, SDValue Op1, SDValue Op2, SDValue Op3); 00713 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs, 00714 const SDValue *Ops, unsigned NumOps); 00715 00716 /// getTargetNode - These are used for target selectors to create a new node 00717 /// with specified return type(s), target opcode, and operands. 00718 /// 00719 /// Note that getTargetNode returns the resultant node. If there is already a 00720 /// node of the specified opcode and operands, it returns that node instead of 00721 /// the current one. 00722 SDNode *getTargetNode(unsigned Opcode, MVT VT); 00723 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT); 00724 00725 SDNode *getTargetNode(unsigned Opcode, MVT VT, SDValue Op1); 00726 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT, SDValue Op1); 00727 00728 SDNode *getTargetNode(unsigned Opcode, MVT VT, SDValue Op1, SDValue Op2); 00729 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT, SDValue Op1, 00730 SDValue Op2); 00731 00732 SDNode *getTargetNode(unsigned Opcode, MVT VT, 00733 SDValue Op1, SDValue Op2, SDValue Op3); 00734 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT, 00735 SDValue Op1, SDValue Op2, SDValue Op3); 00736 00737 SDNode *getTargetNode(unsigned Opcode, MVT VT, 00738 const SDValue *Ops, unsigned NumOps); 00739 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT, 00740 const SDValue *Ops, unsigned NumOps); 00741 00742 SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2); 00743 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2); 00744 00745 SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, SDValue Op1); 00746 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2, 00747 SDValue Op1); 00748 00749 SDNode *getTargetNode(unsigned Opcode, MVT VT1, 00750 MVT VT2, SDValue Op1, SDValue Op2); 00751 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, 00752 MVT VT2, SDValue Op1, SDValue Op2); 00753 00754 SDNode *getTargetNode(unsigned Opcode, MVT VT1, 00755 MVT VT2, SDValue Op1, SDValue Op2, SDValue Op3); 00756 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, 00757 MVT VT2, SDValue Op1, SDValue Op2, SDValue Op3); 00758 00759 SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, 00760 const SDValue *Ops, unsigned NumOps); 00761 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2, 00762 const SDValue *Ops, unsigned NumOps); 00763 00764 SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3, 00765 SDValue Op1, SDValue Op2); 00766 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2, MVT VT3, 00767 SDValue Op1, SDValue Op2); 00768 00769 SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3, 00770 SDValue Op1, SDValue Op2, SDValue Op3); 00771 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2, MVT VT3, 00772 SDValue Op1, SDValue Op2, SDValue Op3); 00773 00774 SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3, 00775 const SDValue *Ops, unsigned NumOps); 00776 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2, MVT VT3, 00777 const SDValue *Ops, unsigned NumOps); 00778 00779 SDNode *getTargetNode(unsigned Opcode, MVT VT1, MVT VT2, MVT VT3, MVT VT4, 00780 const SDValue *Ops, unsigned NumOps); 00781 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, MVT VT1, MVT VT2, MVT VT3, 00782 MVT VT4, const SDValue *Ops, unsigned NumOps); 00783 00784 SDNode *getTargetNode(unsigned Opcode, const std::vector<MVT> &ResultTys, 00785 const SDValue *Ops, unsigned NumOps); 00786 SDNode *getTargetNode(unsigned Opcode, DebugLoc dl, 00787 const std::vector<MVT> &ResultTys, const SDValue *Ops, 00788 unsigned NumOps); 00789 00790 /// getNodeIfExists - Get the specified node if it's already available, or 00791 /// else return NULL. 00792 SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs, 00793 const SDValue *Ops, unsigned NumOps); 00794 00795 /// DAGUpdateListener - Clients of various APIs that cause global effects on 00796 /// the DAG can optionally implement this interface. This allows the clients 00797 /// to handle the various sorts of updates that happen. 00798 class DAGUpdateListener { 00799 public: 00800 virtual ~DAGUpdateListener(); 00801 00802 /// NodeDeleted - The node N that was deleted and, if E is not null, an 00803 /// equivalent node E that replaced it. 00804 virtual void NodeDeleted(SDNode *N, SDNode *E) = 0; 00805 00806 /// NodeUpdated - The node N that was updated. 00807 virtual void NodeUpdated(SDNode *N) = 0; 00808 }; 00809 00810 /// RemoveDeadNode - Remove the specified node from the system. If any of its 00811 /// operands then becomes dead, remove them as well. Inform UpdateListener 00812 /// for each node deleted. 00813 void RemoveDeadNode(SDNode *N, DAGUpdateListener *UpdateListener = 0); 00814 00815 /// RemoveDeadNodes - This method deletes the unreachable nodes in the 00816 /// given list, and any nodes that become unreachable as a result. 00817 void RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes, 00818 DAGUpdateListener *UpdateListener = 0); 00819 00820 /// ReplaceAllUsesWith - Modify anything using 'From' to use 'To' instead. 00821 /// This can cause recursive merging of nodes in the DAG. Use the first 00822 /// version if 'From' is known to have a single result, use the second 00823 /// if you have two nodes with identical results, use the third otherwise. 00824 /// 00825 /// These methods all take an optional UpdateListener, which (if not null) is 00826 /// informed about nodes that are deleted and modified due to recursive 00827 /// changes in the dag. 00828 /// 00829 /// These functions only replace all existing uses. It's possible that as 00830 /// these replacements are being performed, CSE may cause the From node 00831 /// to be given new uses. These new uses of From are left in place, and 00832 /// not automatically transfered to To. 00833 /// 00834 void ReplaceAllUsesWith(SDValue From, SDValue Op, 00835 DAGUpdateListener *UpdateListener = 0); 00836 void ReplaceAllUsesWith(SDNode *From, SDNode *To, 00837 DAGUpdateListener *UpdateListener = 0); 00838 void ReplaceAllUsesWith(SDNode *From, const SDValue *To, 00839 DAGUpdateListener *UpdateListener = 0); 00840 00841 /// ReplaceAllUsesOfValueWith - Replace any uses of From with To, leaving 00842 /// uses of other values produced by From.Val alone. 00843 void ReplaceAllUsesOfValueWith(SDValue From, SDValue To, 00844 DAGUpdateListener *UpdateListener = 0); 00845 00846 /// ReplaceAllUsesOfValuesWith - Like ReplaceAllUsesOfValueWith, but 00847 /// for multiple values at once. This correctly handles the case where 00848 /// there is an overlap between the From values and the To values. 00849 void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, 00850 unsigned Num, 00851 DAGUpdateListener *UpdateListener = 0); 00852 00853 /// AssignTopologicalOrder - Topological-sort the AllNodes list and a 00854 /// assign a unique node id for each node in the DAG based on their 00855 /// topological order. Returns the number of nodes. 00856 unsigned AssignTopologicalOrder(); 00857 00858 /// RepositionNode - Move node N in the AllNodes list to be immediately 00859 /// before the given iterator Position. This may be used to update the 00860 /// topological ordering when the list of nodes is modified. 00861 void RepositionNode(allnodes_iterator Position, SDNode *N) { 00862 AllNodes.insert(Position, AllNodes.remove(N)); 00863 } 00864 00865 /// isCommutativeBinOp - Returns true if the opcode is a commutative binary 00866 /// operation. 00867 static bool isCommutativeBinOp(unsigned Opcode) { 00868 // FIXME: This should get its info from the td file, so that we can include 00869 // target info. 00870 switch (Opcode) { 00871 case ISD::ADD: 00872 case ISD::MUL: 00873 case ISD::MULHU: 00874 case ISD::MULHS: 00875 case ISD::SMUL_LOHI: 00876 case ISD::UMUL_LOHI: 00877 case ISD::FADD: 00878 case ISD::FMUL: 00879 case ISD::AND: 00880 case ISD::OR: 00881 case ISD::XOR: 00882 case ISD::ADDC: 00883 case ISD::ADDE: return true; 00884 default: return false; 00885 } 00886 } 00887 00888 void dump() const; 00889 00890 /// CreateStackTemporary - Create a stack temporary, suitable for holding the 00891 /// specified value type. If minAlign is specified, the slot size will have 00892 /// at least that alignment. 00893 SDValue CreateStackTemporary(MVT VT, unsigned minAlign = 1); 00894 00895 /// CreateStackTemporary - Create a stack temporary suitable for holding 00896 /// either of the specified value types. 00897 SDValue CreateStackTemporary(MVT VT1, MVT VT2); 00898 00899 /// FoldConstantArithmetic - 00900 SDValue FoldConstantArithmetic(unsigned Opcode, 00901 MVT VT, 00902 ConstantSDNode *Cst1, 00903 ConstantSDNode *Cst2); 00904 00905 /// FoldSetCC - Constant fold a setcc to true or false. 00906 SDValue FoldSetCC(MVT VT, SDValue N1, 00907 SDValue N2, ISD::CondCode Cond, DebugLoc dl); 00908 00909 /// SignBitIsZero - Return true if the sign bit of Op is known to be zero. We 00910 /// use this predicate to simplify operations downstream. 00911 bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const; 00912 00913 /// MaskedValueIsZero - Return true if 'Op & Mask' is known to be zero. We 00914 /// use this predicate to simplify operations downstream. Op and Mask are 00915 /// known to be the same type. 00916 bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth = 0) 00917 const; 00918 00919 /// ComputeMaskedBits - Determine which of the bits specified in Mask are 00920 /// known to be either zero or one and return them in the KnownZero/KnownOne 00921 /// bitsets. This code only analyzes bits in Mask, in order to short-circuit 00922 /// processing. Targets can implement the computeMaskedBitsForTargetNode 00923 /// method in the TargetLowering class to allow target nodes to be understood. 00924 void ComputeMaskedBits(SDValue Op, const APInt &Mask, APInt &KnownZero, 00925 APInt &KnownOne, unsigned Depth = 0) const; 00926 00927 /// ComputeNumSignBits - Return the number of times the sign bit of the 00928 /// register is replicated into the other bits. We know that at least 1 bit 00929 /// is always equal to the sign bit (itself), but other cases can give us 00930 /// information. For example, immediately after an "SRA X, 2", we know that 00931 /// the top 3 bits are all equal to each other, so we return 3. Targets can 00932 /// implement the ComputeNumSignBitsForTarget method in the TargetLowering 00933 /// class to allow target nodes to be understood. 00934 unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const; 00935 00936 /// isVerifiedDebugInfoDesc - Returns true if the specified SDValue has 00937 /// been verified as a debug information descriptor. 00938 bool isVerifiedDebugInfoDesc(SDValue Op) const; 00939 00940 /// getShuffleScalarElt - Returns the scalar element that will make up the ith 00941 /// element of the result of the vector shuffle. 00942 SDValue getShuffleScalarElt(const SDNode *N, unsigned Idx); 00943 00944 private: 00945 bool RemoveNodeFromCSEMaps(SDNode *N); 00946 void AddModifiedNodeToCSEMaps(SDNode *N, DAGUpdateListener *UpdateListener); 00947 SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos); 00948 SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2, 00949 void *&InsertPos); 00950 SDNode *FindModifiedNodeSlot(SDNode *N, const SDValue *Ops, unsigned NumOps, 00951 void *&InsertPos); 00952 00953 void DeleteNodeNotInCSEMaps(SDNode *N); 00954 void DeallocateNode(SDNode *N); 00955 00956 unsigned getMVTAlignment(MVT MemoryVT) const; 00957 00958 void allnodes_clear(); 00959 00960 /// VTList - List of non-single value types. 00961 std::vector<SDVTList> VTList; 00962 00963 /// CondCodeNodes - Maps to auto-CSE operations. 00964 std::vector<CondCodeSDNode*> CondCodeNodes; 00965 00966 std::vector<SDNode*> ValueTypeNodes; 00967 std::map<MVT, SDNode*, MVT::compareRawBits> ExtendedValueTypeNodes; 00968 StringMap<SDNode*> ExternalSymbols; 00969 StringMap<SDNode*> TargetExternalSymbols; 00970 }; 00971 00972 template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> { 00973 typedef SelectionDAG::allnodes_iterator nodes_iterator; 00974 static nodes_iterator nodes_begin(SelectionDAG *G) { 00975 return G->allnodes_begin(); 00976 } 00977 static nodes_iterator nodes_end(SelectionDAG *G) { 00978 return G->allnodes_end(); 00979 } 00980 }; 00981 00982 } // end namespace llvm 00983 00984 #endif