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