SelectionDAGBuilder.h revision 206124
1199989Srdivacky//===-- SelectionDAGBuilder.h - Selection-DAG building --------------------===// 2199989Srdivacky// 3199989Srdivacky// The LLVM Compiler Infrastructure 4199989Srdivacky// 5199989Srdivacky// This file is distributed under the University of Illinois Open Source 6199989Srdivacky// License. See LICENSE.TXT for details. 7199989Srdivacky// 8199989Srdivacky//===----------------------------------------------------------------------===// 9199989Srdivacky// 10199989Srdivacky// This implements routines for translating from LLVM IR into SelectionDAG IR. 11199989Srdivacky// 12199989Srdivacky//===----------------------------------------------------------------------===// 13199989Srdivacky 14199989Srdivacky#ifndef SELECTIONDAGBUILDER_H 15199989Srdivacky#define SELECTIONDAGBUILDER_H 16199989Srdivacky 17199989Srdivacky#include "llvm/Constants.h" 18199989Srdivacky#include "llvm/CodeGen/SelectionDAG.h" 19199989Srdivacky#include "llvm/ADT/APInt.h" 20199989Srdivacky#include "llvm/ADT/DenseMap.h" 21199989Srdivacky#ifndef NDEBUG 22199989Srdivacky#include "llvm/ADT/SmallSet.h" 23199989Srdivacky#endif 24199989Srdivacky#include "llvm/CodeGen/SelectionDAGNodes.h" 25199989Srdivacky#include "llvm/CodeGen/ValueTypes.h" 26199989Srdivacky#include "llvm/Support/CallSite.h" 27199989Srdivacky#include "llvm/Support/ErrorHandling.h" 28199989Srdivacky#include <vector> 29199989Srdivacky#include <set> 30199989Srdivacky 31199989Srdivackynamespace llvm { 32199989Srdivacky 33199989Srdivackyclass AliasAnalysis; 34199989Srdivackyclass AllocaInst; 35199989Srdivackyclass BasicBlock; 36199989Srdivackyclass BitCastInst; 37199989Srdivackyclass BranchInst; 38199989Srdivackyclass CallInst; 39199989Srdivackyclass ExtractElementInst; 40199989Srdivackyclass ExtractValueInst; 41199989Srdivackyclass FCmpInst; 42199989Srdivackyclass FPExtInst; 43199989Srdivackyclass FPToSIInst; 44199989Srdivackyclass FPToUIInst; 45199989Srdivackyclass FPTruncInst; 46199989Srdivackyclass Function; 47199989Srdivackyclass FunctionLoweringInfo; 48199989Srdivackyclass GetElementPtrInst; 49199989Srdivackyclass GCFunctionInfo; 50199989Srdivackyclass ICmpInst; 51199989Srdivackyclass IntToPtrInst; 52199989Srdivackyclass IndirectBrInst; 53199989Srdivackyclass InvokeInst; 54199989Srdivackyclass InsertElementInst; 55199989Srdivackyclass InsertValueInst; 56199989Srdivackyclass Instruction; 57199989Srdivackyclass LoadInst; 58199989Srdivackyclass MachineBasicBlock; 59199989Srdivackyclass MachineFunction; 60199989Srdivackyclass MachineInstr; 61199989Srdivackyclass MachineRegisterInfo; 62199989Srdivackyclass PHINode; 63199989Srdivackyclass PtrToIntInst; 64199989Srdivackyclass ReturnInst; 65199989Srdivackyclass SDISelAsmOperandInfo; 66199989Srdivackyclass SExtInst; 67199989Srdivackyclass SelectInst; 68199989Srdivackyclass ShuffleVectorInst; 69199989Srdivackyclass SIToFPInst; 70199989Srdivackyclass StoreInst; 71199989Srdivackyclass SwitchInst; 72199989Srdivackyclass TargetData; 73199989Srdivackyclass TargetLowering; 74199989Srdivackyclass TruncInst; 75199989Srdivackyclass UIToFPInst; 76199989Srdivackyclass UnreachableInst; 77199989Srdivackyclass UnwindInst; 78199989Srdivackyclass VAArgInst; 79199989Srdivackyclass ZExtInst; 80199989Srdivacky 81199989Srdivacky//===----------------------------------------------------------------------===// 82199989Srdivacky/// SelectionDAGBuilder - This is the common target-independent lowering 83199989Srdivacky/// implementation that is parameterized by a TargetLowering object. 84199989Srdivacky/// Also, targets can overload any lowering method. 85199989Srdivacky/// 86199989Srdivackyclass SelectionDAGBuilder { 87199989Srdivacky MachineBasicBlock *CurMBB; 88199989Srdivacky 89199989Srdivacky /// CurDebugLoc - current file + line number. Changes as we build the DAG. 90199989Srdivacky DebugLoc CurDebugLoc; 91199989Srdivacky 92199989Srdivacky DenseMap<const Value*, SDValue> NodeMap; 93199989Srdivacky 94201360Srdivackypublic: 95199989Srdivacky /// PendingLoads - Loads are not emitted to the program immediately. We bunch 96199989Srdivacky /// them up and then emit token factor nodes when possible. This allows us to 97199989Srdivacky /// get simple disambiguation between loads without worrying about alias 98199989Srdivacky /// analysis. 99199989Srdivacky SmallVector<SDValue, 8> PendingLoads; 100201360Srdivackyprivate: 101199989Srdivacky 102199989Srdivacky /// PendingExports - CopyToReg nodes that copy values to virtual registers 103199989Srdivacky /// for export to other blocks need to be emitted before any terminator 104199989Srdivacky /// instruction, but they have no other ordering requirements. We bunch them 105199989Srdivacky /// up and the emit a single tokenfactor for them just before terminator 106199989Srdivacky /// instructions. 107199989Srdivacky SmallVector<SDValue, 8> PendingExports; 108199989Srdivacky 109201360Srdivacky /// SDNodeOrder - A unique monotonically increasing number used to order the 110201360Srdivacky /// SDNodes we create. 111201360Srdivacky unsigned SDNodeOrder; 112201360Srdivacky 113199989Srdivacky /// Case - A struct to record the Value for a switch case, and the 114199989Srdivacky /// case's target basic block. 115199989Srdivacky struct Case { 116199989Srdivacky Constant* Low; 117199989Srdivacky Constant* High; 118199989Srdivacky MachineBasicBlock* BB; 119199989Srdivacky 120199989Srdivacky Case() : Low(0), High(0), BB(0) { } 121199989Srdivacky Case(Constant* low, Constant* high, MachineBasicBlock* bb) : 122199989Srdivacky Low(low), High(high), BB(bb) { } 123199989Srdivacky APInt size() const { 124199989Srdivacky const APInt &rHigh = cast<ConstantInt>(High)->getValue(); 125199989Srdivacky const APInt &rLow = cast<ConstantInt>(Low)->getValue(); 126199989Srdivacky return (rHigh - rLow + 1ULL); 127199989Srdivacky } 128199989Srdivacky }; 129199989Srdivacky 130199989Srdivacky struct CaseBits { 131199989Srdivacky uint64_t Mask; 132199989Srdivacky MachineBasicBlock* BB; 133199989Srdivacky unsigned Bits; 134199989Srdivacky 135199989Srdivacky CaseBits(uint64_t mask, MachineBasicBlock* bb, unsigned bits): 136199989Srdivacky Mask(mask), BB(bb), Bits(bits) { } 137199989Srdivacky }; 138199989Srdivacky 139199989Srdivacky typedef std::vector<Case> CaseVector; 140199989Srdivacky typedef std::vector<CaseBits> CaseBitsVector; 141199989Srdivacky typedef CaseVector::iterator CaseItr; 142199989Srdivacky typedef std::pair<CaseItr, CaseItr> CaseRange; 143199989Srdivacky 144199989Srdivacky /// CaseRec - A struct with ctor used in lowering switches to a binary tree 145199989Srdivacky /// of conditional branches. 146199989Srdivacky struct CaseRec { 147199989Srdivacky CaseRec(MachineBasicBlock *bb, Constant *lt, Constant *ge, CaseRange r) : 148199989Srdivacky CaseBB(bb), LT(lt), GE(ge), Range(r) {} 149199989Srdivacky 150199989Srdivacky /// CaseBB - The MBB in which to emit the compare and branch 151199989Srdivacky MachineBasicBlock *CaseBB; 152199989Srdivacky /// LT, GE - If nonzero, we know the current case value must be less-than or 153199989Srdivacky /// greater-than-or-equal-to these Constants. 154199989Srdivacky Constant *LT; 155199989Srdivacky Constant *GE; 156199989Srdivacky /// Range - A pair of iterators representing the range of case values to be 157199989Srdivacky /// processed at this point in the binary search tree. 158199989Srdivacky CaseRange Range; 159199989Srdivacky }; 160199989Srdivacky 161199989Srdivacky typedef std::vector<CaseRec> CaseRecVector; 162199989Srdivacky 163199989Srdivacky /// The comparison function for sorting the switch case values in the vector. 164199989Srdivacky /// WARNING: Case ranges should be disjoint! 165199989Srdivacky struct CaseCmp { 166202375Srdivacky bool operator()(const Case &C1, const Case &C2) { 167199989Srdivacky assert(isa<ConstantInt>(C1.Low) && isa<ConstantInt>(C2.High)); 168199989Srdivacky const ConstantInt* CI1 = cast<const ConstantInt>(C1.Low); 169199989Srdivacky const ConstantInt* CI2 = cast<const ConstantInt>(C2.High); 170199989Srdivacky return CI1->getValue().slt(CI2->getValue()); 171199989Srdivacky } 172199989Srdivacky }; 173199989Srdivacky 174199989Srdivacky struct CaseBitsCmp { 175202375Srdivacky bool operator()(const CaseBits &C1, const CaseBits &C2) { 176199989Srdivacky return C1.Bits > C2.Bits; 177199989Srdivacky } 178199989Srdivacky }; 179199989Srdivacky 180202375Srdivacky size_t Clusterify(CaseVector &Cases, const SwitchInst &SI); 181199989Srdivacky 182199989Srdivacky /// CaseBlock - This structure is used to communicate between 183199989Srdivacky /// SelectionDAGBuilder and SDISel for the code generation of additional basic 184199989Srdivacky /// blocks needed by multi-case switch statements. 185199989Srdivacky struct CaseBlock { 186199989Srdivacky CaseBlock(ISD::CondCode cc, Value *cmplhs, Value *cmprhs, Value *cmpmiddle, 187199989Srdivacky MachineBasicBlock *truebb, MachineBasicBlock *falsebb, 188199989Srdivacky MachineBasicBlock *me) 189199989Srdivacky : CC(cc), CmpLHS(cmplhs), CmpMHS(cmpmiddle), CmpRHS(cmprhs), 190199989Srdivacky TrueBB(truebb), FalseBB(falsebb), ThisBB(me) {} 191199989Srdivacky // CC - the condition code to use for the case block's setcc node 192199989Srdivacky ISD::CondCode CC; 193199989Srdivacky // CmpLHS/CmpRHS/CmpMHS - The LHS/MHS/RHS of the comparison to emit. 194199989Srdivacky // Emit by default LHS op RHS. MHS is used for range comparisons: 195199989Srdivacky // If MHS is not null: (LHS <= MHS) and (MHS <= RHS). 196199989Srdivacky Value *CmpLHS, *CmpMHS, *CmpRHS; 197199989Srdivacky // TrueBB/FalseBB - the block to branch to if the setcc is true/false. 198199989Srdivacky MachineBasicBlock *TrueBB, *FalseBB; 199199989Srdivacky // ThisBB - the block into which to emit the code for the setcc and branches 200199989Srdivacky MachineBasicBlock *ThisBB; 201199989Srdivacky }; 202199989Srdivacky struct JumpTable { 203199989Srdivacky JumpTable(unsigned R, unsigned J, MachineBasicBlock *M, 204199989Srdivacky MachineBasicBlock *D): Reg(R), JTI(J), MBB(M), Default(D) {} 205199989Srdivacky 206199989Srdivacky /// Reg - the virtual register containing the index of the jump table entry 207199989Srdivacky //. to jump to. 208199989Srdivacky unsigned Reg; 209199989Srdivacky /// JTI - the JumpTableIndex for this jump table in the function. 210199989Srdivacky unsigned JTI; 211199989Srdivacky /// MBB - the MBB into which to emit the code for the indirect jump. 212199989Srdivacky MachineBasicBlock *MBB; 213199989Srdivacky /// Default - the MBB of the default bb, which is a successor of the range 214199989Srdivacky /// check MBB. This is when updating PHI nodes in successors. 215199989Srdivacky MachineBasicBlock *Default; 216199989Srdivacky }; 217199989Srdivacky struct JumpTableHeader { 218202375Srdivacky JumpTableHeader(APInt F, APInt L, Value *SV, MachineBasicBlock *H, 219199989Srdivacky bool E = false): 220199989Srdivacky First(F), Last(L), SValue(SV), HeaderBB(H), Emitted(E) {} 221199989Srdivacky APInt First; 222199989Srdivacky APInt Last; 223199989Srdivacky Value *SValue; 224199989Srdivacky MachineBasicBlock *HeaderBB; 225199989Srdivacky bool Emitted; 226199989Srdivacky }; 227199989Srdivacky typedef std::pair<JumpTableHeader, JumpTable> JumpTableBlock; 228199989Srdivacky 229199989Srdivacky struct BitTestCase { 230199989Srdivacky BitTestCase(uint64_t M, MachineBasicBlock* T, MachineBasicBlock* Tr): 231199989Srdivacky Mask(M), ThisBB(T), TargetBB(Tr) { } 232199989Srdivacky uint64_t Mask; 233202375Srdivacky MachineBasicBlock *ThisBB; 234202375Srdivacky MachineBasicBlock *TargetBB; 235199989Srdivacky }; 236199989Srdivacky 237199989Srdivacky typedef SmallVector<BitTestCase, 3> BitTestInfo; 238199989Srdivacky 239199989Srdivacky struct BitTestBlock { 240199989Srdivacky BitTestBlock(APInt F, APInt R, Value* SV, 241199989Srdivacky unsigned Rg, bool E, 242199989Srdivacky MachineBasicBlock* P, MachineBasicBlock* D, 243199989Srdivacky const BitTestInfo& C): 244199989Srdivacky First(F), Range(R), SValue(SV), Reg(Rg), Emitted(E), 245199989Srdivacky Parent(P), Default(D), Cases(C) { } 246199989Srdivacky APInt First; 247199989Srdivacky APInt Range; 248199989Srdivacky Value *SValue; 249199989Srdivacky unsigned Reg; 250199989Srdivacky bool Emitted; 251199989Srdivacky MachineBasicBlock *Parent; 252199989Srdivacky MachineBasicBlock *Default; 253199989Srdivacky BitTestInfo Cases; 254199989Srdivacky }; 255199989Srdivacky 256199989Srdivackypublic: 257199989Srdivacky // TLI - This is information that describes the available target features we 258199989Srdivacky // need for lowering. This indicates when operations are unavailable, 259199989Srdivacky // implemented with a libcall, etc. 260199989Srdivacky TargetLowering &TLI; 261199989Srdivacky SelectionDAG &DAG; 262199989Srdivacky const TargetData *TD; 263199989Srdivacky AliasAnalysis *AA; 264199989Srdivacky 265199989Srdivacky /// SwitchCases - Vector of CaseBlock structures used to communicate 266199989Srdivacky /// SwitchInst code generation information. 267199989Srdivacky std::vector<CaseBlock> SwitchCases; 268199989Srdivacky /// JTCases - Vector of JumpTable structures used to communicate 269199989Srdivacky /// SwitchInst code generation information. 270199989Srdivacky std::vector<JumpTableBlock> JTCases; 271199989Srdivacky /// BitTestCases - Vector of BitTestBlock structures used to communicate 272199989Srdivacky /// SwitchInst code generation information. 273199989Srdivacky std::vector<BitTestBlock> BitTestCases; 274199989Srdivacky 275199989Srdivacky /// PHINodesToUpdate - A list of phi instructions whose operand list will 276199989Srdivacky /// be updated after processing the current basic block. 277199989Srdivacky std::vector<std::pair<MachineInstr*, unsigned> > PHINodesToUpdate; 278199989Srdivacky 279199989Srdivacky /// EdgeMapping - If an edge from CurMBB to any MBB is changed (e.g. due to 280199989Srdivacky /// scheduler custom lowering), track the change here. 281199989Srdivacky DenseMap<MachineBasicBlock*, MachineBasicBlock*> EdgeMapping; 282199989Srdivacky 283199989Srdivacky // Emit PHI-node-operand constants only once even if used by multiple 284199989Srdivacky // PHI nodes. 285199989Srdivacky DenseMap<Constant*, unsigned> ConstantsOut; 286199989Srdivacky 287199989Srdivacky /// FuncInfo - Information about the function as a whole. 288199989Srdivacky /// 289199989Srdivacky FunctionLoweringInfo &FuncInfo; 290199989Srdivacky 291199989Srdivacky /// OptLevel - What optimization level we're generating code for. 292199989Srdivacky /// 293199989Srdivacky CodeGenOpt::Level OptLevel; 294199989Srdivacky 295199989Srdivacky /// GFI - Garbage collection metadata for the function. 296199989Srdivacky GCFunctionInfo *GFI; 297199989Srdivacky 298199989Srdivacky /// HasTailCall - This is set to true if a call in the current 299199989Srdivacky /// block has been translated as a tail call. In this case, 300199989Srdivacky /// no subsequent DAG nodes should be created. 301199989Srdivacky /// 302199989Srdivacky bool HasTailCall; 303199989Srdivacky 304199989Srdivacky LLVMContext *Context; 305199989Srdivacky 306199989Srdivacky SelectionDAGBuilder(SelectionDAG &dag, TargetLowering &tli, 307199989Srdivacky FunctionLoweringInfo &funcinfo, 308199989Srdivacky CodeGenOpt::Level ol) 309206124Srdivacky : SDNodeOrder(0), TLI(tli), DAG(dag), FuncInfo(funcinfo), OptLevel(ol), 310206124Srdivacky HasTailCall(false), Context(dag.getContext()) { 311199989Srdivacky } 312199989Srdivacky 313199989Srdivacky void init(GCFunctionInfo *gfi, AliasAnalysis &aa); 314199989Srdivacky 315199989Srdivacky /// clear - Clear out the curret SelectionDAG and the associated 316199989Srdivacky /// state and prepare this SelectionDAGBuilder object to be used 317199989Srdivacky /// for a new block. This doesn't clear out information about 318199989Srdivacky /// additional blocks that are needed to complete switch lowering 319199989Srdivacky /// or PHI node updating; that information is cleared out as it is 320199989Srdivacky /// consumed. 321199989Srdivacky void clear(); 322199989Srdivacky 323199989Srdivacky /// getRoot - Return the current virtual root of the Selection DAG, 324199989Srdivacky /// flushing any PendingLoad items. This must be done before emitting 325199989Srdivacky /// a store or any other node that may need to be ordered after any 326199989Srdivacky /// prior load instructions. 327199989Srdivacky /// 328199989Srdivacky SDValue getRoot(); 329199989Srdivacky 330199989Srdivacky /// getControlRoot - Similar to getRoot, but instead of flushing all the 331199989Srdivacky /// PendingLoad items, flush all the PendingExports items. It is necessary 332199989Srdivacky /// to do this before emitting a terminator instruction. 333199989Srdivacky /// 334199989Srdivacky SDValue getControlRoot(); 335199989Srdivacky 336199989Srdivacky DebugLoc getCurDebugLoc() const { return CurDebugLoc; } 337199989Srdivacky void setCurDebugLoc(DebugLoc dl) { CurDebugLoc = dl; } 338199989Srdivacky 339201360Srdivacky unsigned getSDNodeOrder() const { return SDNodeOrder; } 340201360Srdivacky 341199989Srdivacky void CopyValueToVirtualRegister(Value *V, unsigned Reg); 342199989Srdivacky 343203954Srdivacky /// AssignOrderingToNode - Assign an ordering to the node. The order is gotten 344203954Srdivacky /// from how the code appeared in the source. The ordering is used by the 345203954Srdivacky /// scheduler to effectively turn off scheduling. 346203954Srdivacky void AssignOrderingToNode(const SDNode *Node); 347203954Srdivacky 348199989Srdivacky void visit(Instruction &I); 349199989Srdivacky 350199989Srdivacky void visit(unsigned Opcode, User &I); 351199989Srdivacky 352199989Srdivacky void setCurrentBasicBlock(MachineBasicBlock *MBB) { CurMBB = MBB; } 353199989Srdivacky 354199989Srdivacky SDValue getValue(const Value *V); 355199989Srdivacky 356199989Srdivacky void setValue(const Value *V, SDValue NewN) { 357199989Srdivacky SDValue &N = NodeMap[V]; 358199989Srdivacky assert(N.getNode() == 0 && "Already set a value for this node!"); 359199989Srdivacky N = NewN; 360199989Srdivacky } 361199989Srdivacky 362199989Srdivacky void GetRegistersForValue(SDISelAsmOperandInfo &OpInfo, 363199989Srdivacky std::set<unsigned> &OutputRegs, 364199989Srdivacky std::set<unsigned> &InputRegs); 365199989Srdivacky 366199989Srdivacky void FindMergedConditions(Value *Cond, MachineBasicBlock *TBB, 367199989Srdivacky MachineBasicBlock *FBB, MachineBasicBlock *CurBB, 368199989Srdivacky unsigned Opc); 369199989Srdivacky void EmitBranchForMergedCondition(Value *Cond, MachineBasicBlock *TBB, 370199989Srdivacky MachineBasicBlock *FBB, 371199989Srdivacky MachineBasicBlock *CurBB); 372199989Srdivacky bool ShouldEmitAsBranches(const std::vector<CaseBlock> &Cases); 373199989Srdivacky bool isExportableFromCurrentBlock(Value *V, const BasicBlock *FromBB); 374199989Srdivacky void CopyToExportRegsIfNeeded(Value *V); 375199989Srdivacky void ExportFromCurrentBlock(Value *V); 376199989Srdivacky void LowerCallTo(CallSite CS, SDValue Callee, bool IsTailCall, 377199989Srdivacky MachineBasicBlock *LandingPad = NULL); 378199989Srdivacky 379199989Srdivackyprivate: 380199989Srdivacky // Terminator instructions. 381199989Srdivacky void visitRet(ReturnInst &I); 382199989Srdivacky void visitBr(BranchInst &I); 383199989Srdivacky void visitSwitch(SwitchInst &I); 384199989Srdivacky void visitIndirectBr(IndirectBrInst &I); 385199989Srdivacky void visitUnreachable(UnreachableInst &I) { /* noop */ } 386199989Srdivacky 387199989Srdivacky // Helpers for visitSwitch 388199989Srdivacky bool handleSmallSwitchRange(CaseRec& CR, 389199989Srdivacky CaseRecVector& WorkList, 390199989Srdivacky Value* SV, 391199989Srdivacky MachineBasicBlock* Default); 392199989Srdivacky bool handleJTSwitchCase(CaseRec& CR, 393199989Srdivacky CaseRecVector& WorkList, 394199989Srdivacky Value* SV, 395199989Srdivacky MachineBasicBlock* Default); 396199989Srdivacky bool handleBTSplitSwitchCase(CaseRec& CR, 397199989Srdivacky CaseRecVector& WorkList, 398199989Srdivacky Value* SV, 399199989Srdivacky MachineBasicBlock* Default); 400199989Srdivacky bool handleBitTestsSwitchCase(CaseRec& CR, 401199989Srdivacky CaseRecVector& WorkList, 402199989Srdivacky Value* SV, 403199989Srdivacky MachineBasicBlock* Default); 404199989Srdivackypublic: 405199989Srdivacky void visitSwitchCase(CaseBlock &CB); 406199989Srdivacky void visitBitTestHeader(BitTestBlock &B); 407199989Srdivacky void visitBitTestCase(MachineBasicBlock* NextMBB, 408199989Srdivacky unsigned Reg, 409199989Srdivacky BitTestCase &B); 410199989Srdivacky void visitJumpTable(JumpTable &JT); 411199989Srdivacky void visitJumpTableHeader(JumpTable &JT, JumpTableHeader &JTH); 412199989Srdivacky 413199989Srdivackyprivate: 414199989Srdivacky // These all get lowered before this pass. 415199989Srdivacky void visitInvoke(InvokeInst &I); 416199989Srdivacky void visitUnwind(UnwindInst &I); 417199989Srdivacky 418199989Srdivacky void visitBinary(User &I, unsigned OpCode); 419199989Srdivacky void visitShift(User &I, unsigned Opcode); 420199989Srdivacky void visitAdd(User &I) { visitBinary(I, ISD::ADD); } 421199989Srdivacky void visitFAdd(User &I) { visitBinary(I, ISD::FADD); } 422199989Srdivacky void visitSub(User &I) { visitBinary(I, ISD::SUB); } 423199989Srdivacky void visitFSub(User &I); 424199989Srdivacky void visitMul(User &I) { visitBinary(I, ISD::MUL); } 425199989Srdivacky void visitFMul(User &I) { visitBinary(I, ISD::FMUL); } 426199989Srdivacky void visitURem(User &I) { visitBinary(I, ISD::UREM); } 427199989Srdivacky void visitSRem(User &I) { visitBinary(I, ISD::SREM); } 428199989Srdivacky void visitFRem(User &I) { visitBinary(I, ISD::FREM); } 429199989Srdivacky void visitUDiv(User &I) { visitBinary(I, ISD::UDIV); } 430199989Srdivacky void visitSDiv(User &I) { visitBinary(I, ISD::SDIV); } 431199989Srdivacky void visitFDiv(User &I) { visitBinary(I, ISD::FDIV); } 432199989Srdivacky void visitAnd (User &I) { visitBinary(I, ISD::AND); } 433199989Srdivacky void visitOr (User &I) { visitBinary(I, ISD::OR); } 434199989Srdivacky void visitXor (User &I) { visitBinary(I, ISD::XOR); } 435199989Srdivacky void visitShl (User &I) { visitShift(I, ISD::SHL); } 436199989Srdivacky void visitLShr(User &I) { visitShift(I, ISD::SRL); } 437199989Srdivacky void visitAShr(User &I) { visitShift(I, ISD::SRA); } 438199989Srdivacky void visitICmp(User &I); 439199989Srdivacky void visitFCmp(User &I); 440199989Srdivacky // Visit the conversion instructions 441199989Srdivacky void visitTrunc(User &I); 442199989Srdivacky void visitZExt(User &I); 443199989Srdivacky void visitSExt(User &I); 444199989Srdivacky void visitFPTrunc(User &I); 445199989Srdivacky void visitFPExt(User &I); 446199989Srdivacky void visitFPToUI(User &I); 447199989Srdivacky void visitFPToSI(User &I); 448199989Srdivacky void visitUIToFP(User &I); 449199989Srdivacky void visitSIToFP(User &I); 450199989Srdivacky void visitPtrToInt(User &I); 451199989Srdivacky void visitIntToPtr(User &I); 452199989Srdivacky void visitBitCast(User &I); 453199989Srdivacky 454199989Srdivacky void visitExtractElement(User &I); 455199989Srdivacky void visitInsertElement(User &I); 456199989Srdivacky void visitShuffleVector(User &I); 457199989Srdivacky 458199989Srdivacky void visitExtractValue(ExtractValueInst &I); 459199989Srdivacky void visitInsertValue(InsertValueInst &I); 460199989Srdivacky 461199989Srdivacky void visitGetElementPtr(User &I); 462199989Srdivacky void visitSelect(User &I); 463199989Srdivacky 464199989Srdivacky void visitAlloca(AllocaInst &I); 465199989Srdivacky void visitLoad(LoadInst &I); 466199989Srdivacky void visitStore(StoreInst &I); 467199989Srdivacky void visitPHI(PHINode &I) { } // PHI nodes are handled specially. 468199989Srdivacky void visitCall(CallInst &I); 469201360Srdivacky bool visitMemCmpCall(CallInst &I); 470201360Srdivacky 471199989Srdivacky void visitInlineAsm(CallSite CS); 472199989Srdivacky const char *visitIntrinsicCall(CallInst &I, unsigned Intrinsic); 473199989Srdivacky void visitTargetIntrinsic(CallInst &I, unsigned Intrinsic); 474199989Srdivacky 475199989Srdivacky void visitPow(CallInst &I); 476199989Srdivacky void visitExp2(CallInst &I); 477199989Srdivacky void visitExp(CallInst &I); 478199989Srdivacky void visitLog(CallInst &I); 479199989Srdivacky void visitLog2(CallInst &I); 480199989Srdivacky void visitLog10(CallInst &I); 481199989Srdivacky 482199989Srdivacky void visitVAStart(CallInst &I); 483199989Srdivacky void visitVAArg(VAArgInst &I); 484199989Srdivacky void visitVAEnd(CallInst &I); 485199989Srdivacky void visitVACopy(CallInst &I); 486199989Srdivacky 487199989Srdivacky void visitUserOp1(Instruction &I) { 488199989Srdivacky llvm_unreachable("UserOp1 should not exist at instruction selection time!"); 489199989Srdivacky } 490199989Srdivacky void visitUserOp2(Instruction &I) { 491199989Srdivacky llvm_unreachable("UserOp2 should not exist at instruction selection time!"); 492199989Srdivacky } 493199989Srdivacky 494199989Srdivacky const char *implVisitBinaryAtomic(CallInst& I, ISD::NodeType Op); 495199989Srdivacky const char *implVisitAluOverflow(CallInst &I, ISD::NodeType Op); 496199989Srdivacky}; 497199989Srdivacky 498199989Srdivacky} // end namespace llvm 499199989Srdivacky 500199989Srdivacky#endif 501