Dan Gohman | 2048b85 | 2009-11-23 18:04:58 +0000 | [diff] [blame] | 1 | //===-- SelectionDAGBuilder.h - Selection-DAG building --------------------===// |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This implements routines for translating from LLVM IR into SelectionDAG IR. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Dan Gohman | 2048b85 | 2009-11-23 18:04:58 +0000 | [diff] [blame] | 14 | #ifndef SELECTIONDAGBUILDER_H |
| 15 | #define SELECTIONDAGBUILDER_H |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 16 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/APInt.h" |
| 18 | #include "llvm/ADT/DenseMap.h" |
Chandler Carruth | a1514e2 | 2012-12-04 07:12:27 +0000 | [diff] [blame^] | 19 | #include "llvm/CodeGen/SelectionDAG.h" |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/SelectionDAGNodes.h" |
Bill Wendling | 0eb96fd | 2009-02-03 01:32:22 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/ValueTypes.h" |
Chandler Carruth | a1514e2 | 2012-12-04 07:12:27 +0000 | [diff] [blame^] | 22 | #include "llvm/Constants.h" |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 23 | #include "llvm/Support/CallSite.h" |
Torok Edwin | c25e758 | 2009-07-11 20:10:48 +0000 | [diff] [blame] | 24 | #include "llvm/Support/ErrorHandling.h" |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 25 | #include <vector> |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 26 | |
| 27 | namespace llvm { |
| 28 | |
| 29 | class AliasAnalysis; |
| 30 | class AllocaInst; |
| 31 | class BasicBlock; |
| 32 | class BitCastInst; |
| 33 | class BranchInst; |
| 34 | class CallInst; |
Devang Patel | 4cf81c4 | 2010-08-26 23:35:15 +0000 | [diff] [blame] | 35 | class DbgValueInst; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 36 | class ExtractElementInst; |
| 37 | class ExtractValueInst; |
| 38 | class FCmpInst; |
| 39 | class FPExtInst; |
| 40 | class FPToSIInst; |
| 41 | class FPToUIInst; |
| 42 | class FPTruncInst; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 43 | class Function; |
Dan Gohman | 6277eb2 | 2009-11-23 17:16:22 +0000 | [diff] [blame] | 44 | class FunctionLoweringInfo; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 45 | class GetElementPtrInst; |
| 46 | class GCFunctionInfo; |
| 47 | class ICmpInst; |
| 48 | class IntToPtrInst; |
Chris Lattner | ab21db7 | 2009-10-28 00:19:10 +0000 | [diff] [blame] | 49 | class IndirectBrInst; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 50 | class InvokeInst; |
| 51 | class InsertElementInst; |
| 52 | class InsertValueInst; |
| 53 | class Instruction; |
| 54 | class LoadInst; |
| 55 | class MachineBasicBlock; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 56 | class MachineInstr; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 57 | class MachineRegisterInfo; |
Evan Cheng | 2ad0fcf | 2010-04-28 23:08:54 +0000 | [diff] [blame] | 58 | class MDNode; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 59 | class PHINode; |
| 60 | class PtrToIntInst; |
| 61 | class ReturnInst; |
Dale Johannesen | bdc09d9 | 2010-07-16 00:02:08 +0000 | [diff] [blame] | 62 | class SDDbgValue; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 63 | class SExtInst; |
| 64 | class SelectInst; |
| 65 | class ShuffleVectorInst; |
| 66 | class SIToFPInst; |
| 67 | class StoreInst; |
| 68 | class SwitchInst; |
Micah Villmow | 3574eca | 2012-10-08 16:38:25 +0000 | [diff] [blame] | 69 | class DataLayout; |
Owen Anderson | 243eb9e | 2011-12-08 22:15:21 +0000 | [diff] [blame] | 70 | class TargetLibraryInfo; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 71 | class TargetLowering; |
| 72 | class TruncInst; |
| 73 | class UIToFPInst; |
| 74 | class UnreachableInst; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 75 | class VAArgInst; |
| 76 | class ZExtInst; |
| 77 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 78 | //===----------------------------------------------------------------------===// |
Dan Gohman | 2048b85 | 2009-11-23 18:04:58 +0000 | [diff] [blame] | 79 | /// SelectionDAGBuilder - This is the common target-independent lowering |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 80 | /// implementation that is parameterized by a TargetLowering object. |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 81 | /// |
Dan Gohman | 2048b85 | 2009-11-23 18:04:58 +0000 | [diff] [blame] | 82 | class SelectionDAGBuilder { |
Dale Johannesen | 66978ee | 2009-01-31 02:22:37 +0000 | [diff] [blame] | 83 | /// CurDebugLoc - current file + line number. Changes as we build the DAG. |
| 84 | DebugLoc CurDebugLoc; |
| 85 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 86 | DenseMap<const Value*, SDValue> NodeMap; |
Devang Patel | 9126c0d | 2010-06-01 19:59:01 +0000 | [diff] [blame] | 87 | |
| 88 | /// UnusedArgNodeMap - Maps argument value for unused arguments. This is used |
| 89 | /// to preserve debug information for incoming arguments. |
| 90 | DenseMap<const Value*, SDValue> UnusedArgNodeMap; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 91 | |
Dale Johannesen | bdc09d9 | 2010-07-16 00:02:08 +0000 | [diff] [blame] | 92 | /// DanglingDebugInfo - Helper type for DanglingDebugInfoMap. |
| 93 | class DanglingDebugInfo { |
Devang Patel | 4cf81c4 | 2010-08-26 23:35:15 +0000 | [diff] [blame] | 94 | const DbgValueInst* DI; |
Dale Johannesen | bdc09d9 | 2010-07-16 00:02:08 +0000 | [diff] [blame] | 95 | DebugLoc dl; |
| 96 | unsigned SDNodeOrder; |
| 97 | public: |
| 98 | DanglingDebugInfo() : DI(0), dl(DebugLoc()), SDNodeOrder(0) { } |
Devang Patel | 4cf81c4 | 2010-08-26 23:35:15 +0000 | [diff] [blame] | 99 | DanglingDebugInfo(const DbgValueInst *di, DebugLoc DL, unsigned SDNO) : |
Dale Johannesen | bdc09d9 | 2010-07-16 00:02:08 +0000 | [diff] [blame] | 100 | DI(di), dl(DL), SDNodeOrder(SDNO) { } |
Devang Patel | 4cf81c4 | 2010-08-26 23:35:15 +0000 | [diff] [blame] | 101 | const DbgValueInst* getDI() { return DI; } |
Dale Johannesen | bdc09d9 | 2010-07-16 00:02:08 +0000 | [diff] [blame] | 102 | DebugLoc getdl() { return dl; } |
| 103 | unsigned getSDNodeOrder() { return SDNodeOrder; } |
| 104 | }; |
| 105 | |
| 106 | /// DanglingDebugInfoMap - Keeps track of dbg_values for which we have not |
| 107 | /// yet seen the referent. We defer handling these until we do see it. |
| 108 | DenseMap<const Value*, DanglingDebugInfo> DanglingDebugInfoMap; |
| 109 | |
Chris Lattner | 8047d9a | 2009-12-24 00:37:38 +0000 | [diff] [blame] | 110 | public: |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 111 | /// PendingLoads - Loads are not emitted to the program immediately. We bunch |
| 112 | /// them up and then emit token factor nodes when possible. This allows us to |
| 113 | /// get simple disambiguation between loads without worrying about alias |
| 114 | /// analysis. |
| 115 | SmallVector<SDValue, 8> PendingLoads; |
Chris Lattner | 8047d9a | 2009-12-24 00:37:38 +0000 | [diff] [blame] | 116 | private: |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 117 | |
| 118 | /// PendingExports - CopyToReg nodes that copy values to virtual registers |
| 119 | /// for export to other blocks need to be emitted before any terminator |
| 120 | /// instruction, but they have no other ordering requirements. We bunch them |
| 121 | /// up and the emit a single tokenfactor for them just before terminator |
| 122 | /// instructions. |
| 123 | SmallVector<SDValue, 8> PendingExports; |
| 124 | |
Bill Wendling | b4e6a5d | 2009-12-18 23:32:53 +0000 | [diff] [blame] | 125 | /// SDNodeOrder - A unique monotonically increasing number used to order the |
| 126 | /// SDNodes we create. |
| 127 | unsigned SDNodeOrder; |
| 128 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 129 | /// Case - A struct to record the Value for a switch case, and the |
| 130 | /// case's target basic block. |
| 131 | struct Case { |
Stepan Dyatkovskiy | 2447312 | 2012-02-01 07:49:51 +0000 | [diff] [blame] | 132 | const Constant *Low; |
| 133 | const Constant *High; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 134 | MachineBasicBlock* BB; |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 135 | uint32_t ExtraWeight; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 136 | |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 137 | Case() : Low(0), High(0), BB(0), ExtraWeight(0) { } |
Stepan Dyatkovskiy | 2447312 | 2012-02-01 07:49:51 +0000 | [diff] [blame] | 138 | Case(const Constant *low, const Constant *high, MachineBasicBlock *bb, |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 139 | uint32_t extraweight) : Low(low), High(high), BB(bb), |
| 140 | ExtraWeight(extraweight) { } |
| 141 | |
Chris Lattner | e880efe | 2009-11-07 07:50:34 +0000 | [diff] [blame] | 142 | APInt size() const { |
| 143 | const APInt &rHigh = cast<ConstantInt>(High)->getValue(); |
| 144 | const APInt &rLow = cast<ConstantInt>(Low)->getValue(); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 145 | return (rHigh - rLow + 1ULL); |
| 146 | } |
| 147 | }; |
| 148 | |
| 149 | struct CaseBits { |
| 150 | uint64_t Mask; |
| 151 | MachineBasicBlock* BB; |
| 152 | unsigned Bits; |
Manman Ren | 1a710fd | 2012-08-24 18:14:27 +0000 | [diff] [blame] | 153 | uint32_t ExtraWeight; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 154 | |
Manman Ren | 1a710fd | 2012-08-24 18:14:27 +0000 | [diff] [blame] | 155 | CaseBits(uint64_t mask, MachineBasicBlock* bb, unsigned bits, |
| 156 | uint32_t Weight): |
| 157 | Mask(mask), BB(bb), Bits(bits), ExtraWeight(Weight) { } |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 158 | }; |
| 159 | |
| 160 | typedef std::vector<Case> CaseVector; |
| 161 | typedef std::vector<CaseBits> CaseBitsVector; |
| 162 | typedef CaseVector::iterator CaseItr; |
| 163 | typedef std::pair<CaseItr, CaseItr> CaseRange; |
| 164 | |
| 165 | /// CaseRec - A struct with ctor used in lowering switches to a binary tree |
| 166 | /// of conditional branches. |
| 167 | struct CaseRec { |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 168 | CaseRec(MachineBasicBlock *bb, const Constant *lt, const Constant *ge, |
| 169 | CaseRange r) : |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 170 | CaseBB(bb), LT(lt), GE(ge), Range(r) {} |
| 171 | |
| 172 | /// CaseBB - The MBB in which to emit the compare and branch |
| 173 | MachineBasicBlock *CaseBB; |
| 174 | /// LT, GE - If nonzero, we know the current case value must be less-than or |
| 175 | /// greater-than-or-equal-to these Constants. |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 176 | const Constant *LT; |
| 177 | const Constant *GE; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 178 | /// Range - A pair of iterators representing the range of case values to be |
| 179 | /// processed at this point in the binary search tree. |
| 180 | CaseRange Range; |
| 181 | }; |
| 182 | |
| 183 | typedef std::vector<CaseRec> CaseRecVector; |
| 184 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 185 | struct CaseBitsCmp { |
Chris Lattner | 53334ca | 2010-01-01 23:37:34 +0000 | [diff] [blame] | 186 | bool operator()(const CaseBits &C1, const CaseBits &C2) { |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 187 | return C1.Bits > C2.Bits; |
| 188 | } |
| 189 | }; |
| 190 | |
Chris Lattner | 53334ca | 2010-01-01 23:37:34 +0000 | [diff] [blame] | 191 | size_t Clusterify(CaseVector &Cases, const SwitchInst &SI); |
Anton Korobeynikov | 2321858 | 2008-12-23 22:25:27 +0000 | [diff] [blame] | 192 | |
Dan Gohman | 2048b85 | 2009-11-23 18:04:58 +0000 | [diff] [blame] | 193 | /// CaseBlock - This structure is used to communicate between |
| 194 | /// SelectionDAGBuilder and SDISel for the code generation of additional basic |
| 195 | /// blocks needed by multi-case switch statements. |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 196 | struct CaseBlock { |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 197 | CaseBlock(ISD::CondCode cc, const Value *cmplhs, const Value *cmprhs, |
| 198 | const Value *cmpmiddle, |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 199 | MachineBasicBlock *truebb, MachineBasicBlock *falsebb, |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 200 | MachineBasicBlock *me, |
| 201 | uint32_t trueweight = 0, uint32_t falseweight = 0) |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 202 | : CC(cc), CmpLHS(cmplhs), CmpMHS(cmpmiddle), CmpRHS(cmprhs), |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 203 | TrueBB(truebb), FalseBB(falsebb), ThisBB(me), |
| 204 | TrueWeight(trueweight), FalseWeight(falseweight) { } |
| 205 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 206 | // CC - the condition code to use for the case block's setcc node |
| 207 | ISD::CondCode CC; |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 208 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 209 | // CmpLHS/CmpRHS/CmpMHS - The LHS/MHS/RHS of the comparison to emit. |
| 210 | // Emit by default LHS op RHS. MHS is used for range comparisons: |
| 211 | // If MHS is not null: (LHS <= MHS) and (MHS <= RHS). |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 212 | const Value *CmpLHS, *CmpMHS, *CmpRHS; |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 213 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 214 | // TrueBB/FalseBB - the block to branch to if the setcc is true/false. |
| 215 | MachineBasicBlock *TrueBB, *FalseBB; |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 216 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 217 | // ThisBB - the block into which to emit the code for the setcc and branches |
| 218 | MachineBasicBlock *ThisBB; |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 219 | |
| 220 | // TrueWeight/FalseWeight - branch weights. |
| 221 | uint32_t TrueWeight, FalseWeight; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 222 | }; |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 223 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 224 | struct JumpTable { |
| 225 | JumpTable(unsigned R, unsigned J, MachineBasicBlock *M, |
| 226 | MachineBasicBlock *D): Reg(R), JTI(J), MBB(M), Default(D) {} |
| 227 | |
| 228 | /// Reg - the virtual register containing the index of the jump table entry |
| 229 | //. to jump to. |
| 230 | unsigned Reg; |
| 231 | /// JTI - the JumpTableIndex for this jump table in the function. |
| 232 | unsigned JTI; |
| 233 | /// MBB - the MBB into which to emit the code for the indirect jump. |
| 234 | MachineBasicBlock *MBB; |
| 235 | /// Default - the MBB of the default bb, which is a successor of the range |
| 236 | /// check MBB. This is when updating PHI nodes in successors. |
| 237 | MachineBasicBlock *Default; |
| 238 | }; |
| 239 | struct JumpTableHeader { |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 240 | JumpTableHeader(APInt F, APInt L, const Value *SV, MachineBasicBlock *H, |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 241 | bool E = false): |
| 242 | First(F), Last(L), SValue(SV), HeaderBB(H), Emitted(E) {} |
Anton Korobeynikov | 2321858 | 2008-12-23 22:25:27 +0000 | [diff] [blame] | 243 | APInt First; |
| 244 | APInt Last; |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 245 | const Value *SValue; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 246 | MachineBasicBlock *HeaderBB; |
| 247 | bool Emitted; |
| 248 | }; |
| 249 | typedef std::pair<JumpTableHeader, JumpTable> JumpTableBlock; |
| 250 | |
| 251 | struct BitTestCase { |
Manman Ren | 1a710fd | 2012-08-24 18:14:27 +0000 | [diff] [blame] | 252 | BitTestCase(uint64_t M, MachineBasicBlock* T, MachineBasicBlock* Tr, |
| 253 | uint32_t Weight): |
| 254 | Mask(M), ThisBB(T), TargetBB(Tr), ExtraWeight(Weight) { } |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 255 | uint64_t Mask; |
Chris Lattner | 53334ca | 2010-01-01 23:37:34 +0000 | [diff] [blame] | 256 | MachineBasicBlock *ThisBB; |
| 257 | MachineBasicBlock *TargetBB; |
Manman Ren | 1a710fd | 2012-08-24 18:14:27 +0000 | [diff] [blame] | 258 | uint32_t ExtraWeight; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 259 | }; |
| 260 | |
| 261 | typedef SmallVector<BitTestCase, 3> BitTestInfo; |
| 262 | |
| 263 | struct BitTestBlock { |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 264 | BitTestBlock(APInt F, APInt R, const Value* SV, |
Evan Cheng | d08e5b4 | 2011-01-06 01:02:44 +0000 | [diff] [blame] | 265 | unsigned Rg, EVT RgVT, bool E, |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 266 | MachineBasicBlock* P, MachineBasicBlock* D, |
| 267 | const BitTestInfo& C): |
Evan Cheng | d08e5b4 | 2011-01-06 01:02:44 +0000 | [diff] [blame] | 268 | First(F), Range(R), SValue(SV), Reg(Rg), RegVT(RgVT), Emitted(E), |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 269 | Parent(P), Default(D), Cases(C) { } |
Anton Korobeynikov | 2321858 | 2008-12-23 22:25:27 +0000 | [diff] [blame] | 270 | APInt First; |
| 271 | APInt Range; |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 272 | const Value *SValue; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 273 | unsigned Reg; |
Evan Cheng | d08e5b4 | 2011-01-06 01:02:44 +0000 | [diff] [blame] | 274 | EVT RegVT; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 275 | bool Emitted; |
| 276 | MachineBasicBlock *Parent; |
| 277 | MachineBasicBlock *Default; |
| 278 | BitTestInfo Cases; |
| 279 | }; |
| 280 | |
| 281 | public: |
| 282 | // TLI - This is information that describes the available target features we |
| 283 | // need for lowering. This indicates when operations are unavailable, |
| 284 | // implemented with a libcall, etc. |
Dan Gohman | 55e59c1 | 2010-04-19 19:05:59 +0000 | [diff] [blame] | 285 | const TargetMachine &TM; |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 286 | const TargetLowering &TLI; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 287 | SelectionDAG &DAG; |
Micah Villmow | 3574eca | 2012-10-08 16:38:25 +0000 | [diff] [blame] | 288 | const DataLayout *TD; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 289 | AliasAnalysis *AA; |
Owen Anderson | 243eb9e | 2011-12-08 22:15:21 +0000 | [diff] [blame] | 290 | const TargetLibraryInfo *LibInfo; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 291 | |
| 292 | /// SwitchCases - Vector of CaseBlock structures used to communicate |
| 293 | /// SwitchInst code generation information. |
| 294 | std::vector<CaseBlock> SwitchCases; |
| 295 | /// JTCases - Vector of JumpTable structures used to communicate |
| 296 | /// SwitchInst code generation information. |
| 297 | std::vector<JumpTableBlock> JTCases; |
| 298 | /// BitTestCases - Vector of BitTestBlock structures used to communicate |
| 299 | /// SwitchInst code generation information. |
| 300 | std::vector<BitTestBlock> BitTestCases; |
Evan Cheng | fb2e752 | 2009-09-18 21:02:19 +0000 | [diff] [blame] | 301 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 302 | // Emit PHI-node-operand constants only once even if used by multiple |
| 303 | // PHI nodes. |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 304 | DenseMap<const Constant *, unsigned> ConstantsOut; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 305 | |
| 306 | /// FuncInfo - Information about the function as a whole. |
| 307 | /// |
| 308 | FunctionLoweringInfo &FuncInfo; |
Bill Wendling | dfdacee | 2009-02-19 21:12:54 +0000 | [diff] [blame] | 309 | |
Bill Wendling | be8cc2a | 2009-04-29 00:15:41 +0000 | [diff] [blame] | 310 | /// OptLevel - What optimization level we're generating code for. |
Bill Wendling | dfdacee | 2009-02-19 21:12:54 +0000 | [diff] [blame] | 311 | /// |
Bill Wendling | 98a366d | 2009-04-29 23:29:43 +0000 | [diff] [blame] | 312 | CodeGenOpt::Level OptLevel; |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 313 | |
| 314 | /// GFI - Garbage collection metadata for the function. |
| 315 | GCFunctionInfo *GFI; |
| 316 | |
Bill Wendling | 30e6740 | 2011-10-05 22:24:35 +0000 | [diff] [blame] | 317 | /// LPadToCallSiteMap - Map a landing pad to the call site indexes. |
| 318 | DenseMap<MachineBasicBlock*, SmallVector<unsigned, 4> > LPadToCallSiteMap; |
Bill Wendling | a8512ed | 2011-10-04 22:00:35 +0000 | [diff] [blame] | 319 | |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 320 | /// HasTailCall - This is set to true if a call in the current |
| 321 | /// block has been translated as a tail call. In this case, |
| 322 | /// no subsequent DAG nodes should be created. |
| 323 | /// |
| 324 | bool HasTailCall; |
| 325 | |
Owen Anderson | 0a5372e | 2009-07-13 04:09:18 +0000 | [diff] [blame] | 326 | LLVMContext *Context; |
| 327 | |
Dan Gohman | 55e59c1 | 2010-04-19 19:05:59 +0000 | [diff] [blame] | 328 | SelectionDAGBuilder(SelectionDAG &dag, FunctionLoweringInfo &funcinfo, |
Dan Gohman | 2048b85 | 2009-11-23 18:04:58 +0000 | [diff] [blame] | 329 | CodeGenOpt::Level ol) |
Dan Gohman | 55e59c1 | 2010-04-19 19:05:59 +0000 | [diff] [blame] | 330 | : SDNodeOrder(0), TM(dag.getTarget()), TLI(dag.getTargetLoweringInfo()), |
| 331 | DAG(dag), FuncInfo(funcinfo), OptLevel(ol), |
Richard Smith | cb1f68d | 2012-08-22 00:42:39 +0000 | [diff] [blame] | 332 | HasTailCall(false) { |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 333 | } |
| 334 | |
Owen Anderson | 243eb9e | 2011-12-08 22:15:21 +0000 | [diff] [blame] | 335 | void init(GCFunctionInfo *gfi, AliasAnalysis &aa, |
| 336 | const TargetLibraryInfo *li); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 337 | |
Dan Gohman | b02b62a | 2010-04-14 18:24:06 +0000 | [diff] [blame] | 338 | /// clear - Clear out the current SelectionDAG and the associated |
Dan Gohman | 2048b85 | 2009-11-23 18:04:58 +0000 | [diff] [blame] | 339 | /// state and prepare this SelectionDAGBuilder object to be used |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 340 | /// for a new block. This doesn't clear out information about |
| 341 | /// additional blocks that are needed to complete switch lowering |
| 342 | /// or PHI node updating; that information is cleared out as it is |
| 343 | /// consumed. |
| 344 | void clear(); |
| 345 | |
Devang Patel | 2338575 | 2011-05-23 17:44:13 +0000 | [diff] [blame] | 346 | /// clearDanglingDebugInfo - Clear the dangling debug information |
Benjamin Kramer | d9b0b02 | 2012-06-02 10:20:22 +0000 | [diff] [blame] | 347 | /// map. This function is separated from the clear so that debug |
Devang Patel | 2338575 | 2011-05-23 17:44:13 +0000 | [diff] [blame] | 348 | /// information that is dangling in a basic block can be properly |
| 349 | /// resolved in a different basic block. This allows the |
| 350 | /// SelectionDAG to resolve dangling debug information attached |
| 351 | /// to PHI nodes. |
| 352 | void clearDanglingDebugInfo(); |
| 353 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 354 | /// getRoot - Return the current virtual root of the Selection DAG, |
| 355 | /// flushing any PendingLoad items. This must be done before emitting |
| 356 | /// a store or any other node that may need to be ordered after any |
| 357 | /// prior load instructions. |
| 358 | /// |
| 359 | SDValue getRoot(); |
| 360 | |
| 361 | /// getControlRoot - Similar to getRoot, but instead of flushing all the |
| 362 | /// PendingLoad items, flush all the PendingExports items. It is necessary |
| 363 | /// to do this before emitting a terminator instruction. |
| 364 | /// |
| 365 | SDValue getControlRoot(); |
| 366 | |
Dale Johannesen | 66978ee | 2009-01-31 02:22:37 +0000 | [diff] [blame] | 367 | DebugLoc getCurDebugLoc() const { return CurDebugLoc; } |
Devang Patel | 68e6bee | 2011-02-21 23:21:26 +0000 | [diff] [blame] | 368 | |
Bill Wendling | 3ea3c24 | 2009-12-22 02:10:19 +0000 | [diff] [blame] | 369 | unsigned getSDNodeOrder() const { return SDNodeOrder; } |
| 370 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 371 | void CopyValueToVirtualRegister(const Value *V, unsigned Reg); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 372 | |
Bill Wendling | 4533cac | 2010-01-28 21:51:40 +0000 | [diff] [blame] | 373 | /// AssignOrderingToNode - Assign an ordering to the node. The order is gotten |
| 374 | /// from how the code appeared in the source. The ordering is used by the |
| 375 | /// scheduler to effectively turn off scheduling. |
| 376 | void AssignOrderingToNode(const SDNode *Node); |
| 377 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 378 | void visit(const Instruction &I); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 379 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 380 | void visit(unsigned Opcode, const User &I); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 381 | |
Dale Johannesen | bdc09d9 | 2010-07-16 00:02:08 +0000 | [diff] [blame] | 382 | // resolveDanglingDebugInfo - if we saw an earlier dbg_value referring to V, |
| 383 | // generate the debug data structures now that we've seen its definition. |
| 384 | void resolveDanglingDebugInfo(const Value *V, SDValue Val); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 385 | SDValue getValue(const Value *V); |
Dan Gohman | 28a1735 | 2010-07-01 01:59:43 +0000 | [diff] [blame] | 386 | SDValue getNonRegisterValue(const Value *V); |
| 387 | SDValue getValueImpl(const Value *V); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 388 | |
| 389 | void setValue(const Value *V, SDValue NewN) { |
| 390 | SDValue &N = NodeMap[V]; |
| 391 | assert(N.getNode() == 0 && "Already set a value for this node!"); |
| 392 | N = NewN; |
| 393 | } |
| 394 | |
Devang Patel | 9126c0d | 2010-06-01 19:59:01 +0000 | [diff] [blame] | 395 | void setUnusedArgValue(const Value *V, SDValue NewN) { |
| 396 | SDValue &N = UnusedArgNodeMap[V]; |
| 397 | assert(N.getNode() == 0 && "Already set a value for this node!"); |
| 398 | N = NewN; |
| 399 | } |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 400 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 401 | void FindMergedConditions(const Value *Cond, MachineBasicBlock *TBB, |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 402 | MachineBasicBlock *FBB, MachineBasicBlock *CurBB, |
Dan Gohman | 99be8ae | 2010-04-19 22:41:47 +0000 | [diff] [blame] | 403 | MachineBasicBlock *SwitchBB, unsigned Opc); |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 404 | void EmitBranchForMergedCondition(const Value *Cond, MachineBasicBlock *TBB, |
Dan Gohman | c227734 | 2008-10-17 21:16:08 +0000 | [diff] [blame] | 405 | MachineBasicBlock *FBB, |
Dan Gohman | 99be8ae | 2010-04-19 22:41:47 +0000 | [diff] [blame] | 406 | MachineBasicBlock *CurBB, |
| 407 | MachineBasicBlock *SwitchBB); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 408 | bool ShouldEmitAsBranches(const std::vector<CaseBlock> &Cases); |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 409 | bool isExportableFromCurrentBlock(const Value *V, const BasicBlock *FromBB); |
| 410 | void CopyToExportRegsIfNeeded(const Value *V); |
| 411 | void ExportFromCurrentBlock(const Value *V); |
| 412 | void LowerCallTo(ImmutableCallSite CS, SDValue Callee, bool IsTailCall, |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 413 | MachineBasicBlock *LandingPad = NULL); |
| 414 | |
Jakob Stoklund Olesen | 2622f46 | 2010-09-30 19:44:31 +0000 | [diff] [blame] | 415 | /// UpdateSplitBlock - When an MBB was split during scheduling, update the |
| 416 | /// references that ned to refer to the last resulting block. |
| 417 | void UpdateSplitBlock(MachineBasicBlock *First, MachineBasicBlock *Last); |
| 418 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 419 | private: |
| 420 | // Terminator instructions. |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 421 | void visitRet(const ReturnInst &I); |
| 422 | void visitBr(const BranchInst &I); |
| 423 | void visitSwitch(const SwitchInst &I); |
| 424 | void visitIndirectBr(const IndirectBrInst &I); |
Bill Wendling | a60f0e7 | 2010-07-15 23:42:21 +0000 | [diff] [blame] | 425 | void visitUnreachable(const UnreachableInst &I) { /* noop */ } |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 426 | |
| 427 | // Helpers for visitSwitch |
| 428 | bool handleSmallSwitchRange(CaseRec& CR, |
| 429 | CaseRecVector& WorkList, |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 430 | const Value* SV, |
Dan Gohman | 99be8ae | 2010-04-19 22:41:47 +0000 | [diff] [blame] | 431 | MachineBasicBlock* Default, |
| 432 | MachineBasicBlock *SwitchBB); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 433 | bool handleJTSwitchCase(CaseRec& CR, |
| 434 | CaseRecVector& WorkList, |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 435 | const Value* SV, |
Dan Gohman | 99be8ae | 2010-04-19 22:41:47 +0000 | [diff] [blame] | 436 | MachineBasicBlock* Default, |
| 437 | MachineBasicBlock *SwitchBB); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 438 | bool handleBTSplitSwitchCase(CaseRec& CR, |
| 439 | CaseRecVector& WorkList, |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 440 | const Value* SV, |
Dan Gohman | 99be8ae | 2010-04-19 22:41:47 +0000 | [diff] [blame] | 441 | MachineBasicBlock* Default, |
| 442 | MachineBasicBlock *SwitchBB); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 443 | bool handleBitTestsSwitchCase(CaseRec& CR, |
| 444 | CaseRecVector& WorkList, |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 445 | const Value* SV, |
Dan Gohman | 99be8ae | 2010-04-19 22:41:47 +0000 | [diff] [blame] | 446 | MachineBasicBlock* Default, |
| 447 | MachineBasicBlock *SwitchBB); |
Jakub Staszak | 7cc2b07 | 2011-06-16 20:22:37 +0000 | [diff] [blame] | 448 | |
Jakub Staszak | 25101bb | 2011-12-20 20:03:10 +0000 | [diff] [blame] | 449 | uint32_t getEdgeWeight(const MachineBasicBlock *Src, |
| 450 | const MachineBasicBlock *Dst) const; |
Jakub Staszak | c8f34de | 2011-07-29 22:25:21 +0000 | [diff] [blame] | 451 | void addSuccessorWithWeight(MachineBasicBlock *Src, MachineBasicBlock *Dst, |
| 452 | uint32_t Weight = 0); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 453 | public: |
Dan Gohman | 99be8ae | 2010-04-19 22:41:47 +0000 | [diff] [blame] | 454 | void visitSwitchCase(CaseBlock &CB, |
| 455 | MachineBasicBlock *SwitchBB); |
| 456 | void visitBitTestHeader(BitTestBlock &B, MachineBasicBlock *SwitchBB); |
Evan Cheng | d08e5b4 | 2011-01-06 01:02:44 +0000 | [diff] [blame] | 457 | void visitBitTestCase(BitTestBlock &BB, |
| 458 | MachineBasicBlock* NextMBB, |
Manman Ren | 1a710fd | 2012-08-24 18:14:27 +0000 | [diff] [blame] | 459 | uint32_t BranchWeightToNext, |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 460 | unsigned Reg, |
Dan Gohman | 99be8ae | 2010-04-19 22:41:47 +0000 | [diff] [blame] | 461 | BitTestCase &B, |
| 462 | MachineBasicBlock *SwitchBB); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 463 | void visitJumpTable(JumpTable &JT); |
Dan Gohman | 99be8ae | 2010-04-19 22:41:47 +0000 | [diff] [blame] | 464 | void visitJumpTableHeader(JumpTable &JT, JumpTableHeader &JTH, |
| 465 | MachineBasicBlock *SwitchBB); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 466 | |
| 467 | private: |
| 468 | // These all get lowered before this pass. |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 469 | void visitInvoke(const InvokeInst &I); |
Bill Wendling | dccc03b | 2011-07-31 06:30:59 +0000 | [diff] [blame] | 470 | void visitResume(const ResumeInst &I); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 471 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 472 | void visitBinary(const User &I, unsigned OpCode); |
| 473 | void visitShift(const User &I, unsigned Opcode); |
| 474 | void visitAdd(const User &I) { visitBinary(I, ISD::ADD); } |
| 475 | void visitFAdd(const User &I) { visitBinary(I, ISD::FADD); } |
| 476 | void visitSub(const User &I) { visitBinary(I, ISD::SUB); } |
| 477 | void visitFSub(const User &I); |
| 478 | void visitMul(const User &I) { visitBinary(I, ISD::MUL); } |
| 479 | void visitFMul(const User &I) { visitBinary(I, ISD::FMUL); } |
| 480 | void visitURem(const User &I) { visitBinary(I, ISD::UREM); } |
| 481 | void visitSRem(const User &I) { visitBinary(I, ISD::SREM); } |
| 482 | void visitFRem(const User &I) { visitBinary(I, ISD::FREM); } |
| 483 | void visitUDiv(const User &I) { visitBinary(I, ISD::UDIV); } |
Benjamin Kramer | 9c64030 | 2011-07-08 10:31:30 +0000 | [diff] [blame] | 484 | void visitSDiv(const User &I); |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 485 | void visitFDiv(const User &I) { visitBinary(I, ISD::FDIV); } |
| 486 | void visitAnd (const User &I) { visitBinary(I, ISD::AND); } |
| 487 | void visitOr (const User &I) { visitBinary(I, ISD::OR); } |
| 488 | void visitXor (const User &I) { visitBinary(I, ISD::XOR); } |
| 489 | void visitShl (const User &I) { visitShift(I, ISD::SHL); } |
| 490 | void visitLShr(const User &I) { visitShift(I, ISD::SRL); } |
| 491 | void visitAShr(const User &I) { visitShift(I, ISD::SRA); } |
| 492 | void visitICmp(const User &I); |
| 493 | void visitFCmp(const User &I); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 494 | // Visit the conversion instructions |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 495 | void visitTrunc(const User &I); |
| 496 | void visitZExt(const User &I); |
| 497 | void visitSExt(const User &I); |
| 498 | void visitFPTrunc(const User &I); |
| 499 | void visitFPExt(const User &I); |
| 500 | void visitFPToUI(const User &I); |
| 501 | void visitFPToSI(const User &I); |
| 502 | void visitUIToFP(const User &I); |
| 503 | void visitSIToFP(const User &I); |
| 504 | void visitPtrToInt(const User &I); |
| 505 | void visitIntToPtr(const User &I); |
| 506 | void visitBitCast(const User &I); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 507 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 508 | void visitExtractElement(const User &I); |
| 509 | void visitInsertElement(const User &I); |
| 510 | void visitShuffleVector(const User &I); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 511 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 512 | void visitExtractValue(const ExtractValueInst &I); |
| 513 | void visitInsertValue(const InsertValueInst &I); |
Bill Wendling | e6e8826 | 2011-08-12 20:24:12 +0000 | [diff] [blame] | 514 | void visitLandingPad(const LandingPadInst &I); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 515 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 516 | void visitGetElementPtr(const User &I); |
| 517 | void visitSelect(const User &I); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 518 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 519 | void visitAlloca(const AllocaInst &I); |
| 520 | void visitLoad(const LoadInst &I); |
| 521 | void visitStore(const StoreInst &I); |
Eli Friedman | ff03048 | 2011-07-28 21:48:00 +0000 | [diff] [blame] | 522 | void visitAtomicCmpXchg(const AtomicCmpXchgInst &I); |
| 523 | void visitAtomicRMW(const AtomicRMWInst &I); |
Eli Friedman | 47f3513 | 2011-07-25 23:16:38 +0000 | [diff] [blame] | 524 | void visitFence(const FenceInst &I); |
Dan Gohman | ba5be5c | 2010-04-20 15:00:41 +0000 | [diff] [blame] | 525 | void visitPHI(const PHINode &I); |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 526 | void visitCall(const CallInst &I); |
| 527 | bool visitMemCmpCall(const CallInst &I); |
Bob Wilson | 53624a2 | 2012-08-03 23:29:17 +0000 | [diff] [blame] | 528 | bool visitUnaryFloatCall(const CallInst &I, unsigned Opcode); |
Eli Friedman | 327236c | 2011-08-24 20:50:09 +0000 | [diff] [blame] | 529 | void visitAtomicLoad(const LoadInst &I); |
| 530 | void visitAtomicStore(const StoreInst &I); |
| 531 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 532 | void visitInlineAsm(ImmutableCallSite CS); |
| 533 | const char *visitIntrinsicCall(const CallInst &I, unsigned Intrinsic); |
| 534 | void visitTargetIntrinsic(const CallInst &I, unsigned Intrinsic); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 535 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 536 | void visitVAStart(const CallInst &I); |
| 537 | void visitVAArg(const VAArgInst &I); |
| 538 | void visitVAEnd(const CallInst &I); |
| 539 | void visitVACopy(const CallInst &I); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 540 | |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 541 | void visitUserOp1(const Instruction &I) { |
Torok Edwin | c23197a | 2009-07-14 16:55:14 +0000 | [diff] [blame] | 542 | llvm_unreachable("UserOp1 should not exist at instruction selection time!"); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 543 | } |
Dan Gohman | 46510a7 | 2010-04-15 01:51:59 +0000 | [diff] [blame] | 544 | void visitUserOp2(const Instruction &I) { |
Torok Edwin | c23197a | 2009-07-14 16:55:14 +0000 | [diff] [blame] | 545 | llvm_unreachable("UserOp2 should not exist at instruction selection time!"); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 546 | } |
Dan Gohman | c105a2b | 2010-04-22 20:55:53 +0000 | [diff] [blame] | 547 | |
| 548 | void HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB); |
Evan Cheng | 2ad0fcf | 2010-04-28 23:08:54 +0000 | [diff] [blame] | 549 | |
Devang Patel | ab43add | 2010-08-25 20:41:24 +0000 | [diff] [blame] | 550 | /// EmitFuncArgumentDbgValue - If V is an function argument then create |
| 551 | /// corresponding DBG_VALUE machine instruction for it now. At the end of |
| 552 | /// instruction selection, they will be inserted to the entry BB. |
Devang Patel | 78a06e5 | 2010-08-25 20:39:26 +0000 | [diff] [blame] | 553 | bool EmitFuncArgumentDbgValue(const Value *V, MDNode *Variable, |
Devang Patel | 34ca5ed | 2010-08-31 06:12:08 +0000 | [diff] [blame] | 554 | int64_t Offset, const SDValue &N); |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 555 | }; |
| 556 | |
Dan Gohman | f0cbcd4 | 2008-09-03 16:12:24 +0000 | [diff] [blame] | 557 | } // end namespace llvm |
| 558 | |
| 559 | #endif |