blob: 06acc8a6bfacea2dd249b18eff43c0ec3741cc58 [file] [log] [blame]
Dan Gohman13aeef92008-09-03 16:12:24 +00001//===-- SelectionDAGBuild.h - Selection-DAG building ----------------------===//
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
14#ifndef SELECTIONDAGBUILD_H
15#define SELECTIONDAGBUILD_H
16
17#include "llvm/Constants.h"
Owen Anderson15b39322009-07-13 04:09:18 +000018#include "llvm/CodeGen/SelectionDAG.h"
Dan Gohman13aeef92008-09-03 16:12:24 +000019#include "llvm/ADT/APInt.h"
20#include "llvm/ADT/DenseMap.h"
21#ifndef NDEBUG
22#include "llvm/ADT/SmallSet.h"
23#endif
Dan Gohman13aeef92008-09-03 16:12:24 +000024#include "llvm/CodeGen/SelectionDAGNodes.h"
Bill Wendling50293da2009-02-03 01:32:22 +000025#include "llvm/CodeGen/ValueTypes.h"
Dan Gohman13aeef92008-09-03 16:12:24 +000026#include "llvm/Support/CallSite.h"
Edwin Török675d5622009-07-11 20:10:48 +000027#include "llvm/Support/ErrorHandling.h"
Bill Wendling5ed22ac2009-04-29 23:29:43 +000028#include "llvm/Target/TargetMachine.h"
Dan Gohman13aeef92008-09-03 16:12:24 +000029#include <vector>
30#include <set>
31
32namespace llvm {
33
34class AliasAnalysis;
35class AllocaInst;
36class BasicBlock;
37class BitCastInst;
38class BranchInst;
39class CallInst;
40class ExtractElementInst;
41class ExtractValueInst;
42class FCmpInst;
43class FPExtInst;
44class FPToSIInst;
45class FPToUIInst;
46class FPTruncInst;
47class FreeInst;
48class Function;
49class GetElementPtrInst;
50class GCFunctionInfo;
51class ICmpInst;
52class IntToPtrInst;
53class InvokeInst;
54class InsertElementInst;
55class InsertValueInst;
56class Instruction;
57class LoadInst;
58class MachineBasicBlock;
59class MachineFunction;
60class MachineInstr;
61class MachineModuleInfo;
62class MachineRegisterInfo;
63class MallocInst;
64class PHINode;
65class PtrToIntInst;
66class ReturnInst;
67class SDISelAsmOperandInfo;
68class SExtInst;
69class SelectInst;
70class ShuffleVectorInst;
71class SIToFPInst;
72class StoreInst;
73class SwitchInst;
74class TargetData;
75class TargetLowering;
76class TruncInst;
77class UIToFPInst;
78class UnreachableInst;
79class UnwindInst;
Dan Gohman13aeef92008-09-03 16:12:24 +000080class VAArgInst;
81class ZExtInst;
82
83//===--------------------------------------------------------------------===//
84/// FunctionLoweringInfo - This contains information that is global to a
85/// function that is used when lowering a region of the function.
86///
87class FunctionLoweringInfo {
88public:
89 TargetLowering &TLI;
90 Function *Fn;
91 MachineFunction *MF;
92 MachineRegisterInfo *RegInfo;
93
94 explicit FunctionLoweringInfo(TargetLowering &TLI);
95
96 /// set - Initialize this FunctionLoweringInfo with the given Function
97 /// and its associated MachineFunction.
98 ///
Bill Wendling9391e1f2009-02-03 02:20:52 +000099 void set(Function &Fn, MachineFunction &MF, SelectionDAG &DAG,
100 bool EnableFastISel);
Dan Gohman13aeef92008-09-03 16:12:24 +0000101
102 /// MBBMap - A mapping from LLVM basic blocks to their machine code entry.
103 DenseMap<const BasicBlock*, MachineBasicBlock *> MBBMap;
104
105 /// ValueMap - Since we emit code for the function a basic block at a time,
106 /// we must remember which virtual registers hold the values for
107 /// cross-basic-block values.
108 DenseMap<const Value*, unsigned> ValueMap;
109
110 /// StaticAllocaMap - Keep track of frame indices for fixed sized allocas in
111 /// the entry block. This allows the allocas to be efficiently referenced
112 /// anywhere in the function.
113 DenseMap<const AllocaInst*, int> StaticAllocaMap;
114
115#ifndef NDEBUG
116 SmallSet<Instruction*, 8> CatchInfoLost;
117 SmallSet<Instruction*, 8> CatchInfoFound;
118#endif
119
Owen Andersonac9de032009-08-10 22:56:29 +0000120 unsigned MakeReg(EVT VT);
Dan Gohman13aeef92008-09-03 16:12:24 +0000121
122 /// isExportedInst - Return true if the specified value is an instruction
123 /// exported from its block.
124 bool isExportedInst(const Value *V) {
125 return ValueMap.count(V);
126 }
127
128 unsigned CreateRegForValue(const Value *V);
129
130 unsigned InitializeRegForValue(const Value *V) {
131 unsigned &R = ValueMap[V];
132 assert(R == 0 && "Already initialized this value register!");
133 return R = CreateRegForValue(V);
134 }
135
136 struct LiveOutInfo {
137 unsigned NumSignBits;
138 APInt KnownOne, KnownZero;
Dan Gohmanc6a39142009-03-27 23:51:02 +0000139 LiveOutInfo() : NumSignBits(0), KnownOne(1, 0), KnownZero(1, 0) {}
Dan Gohman13aeef92008-09-03 16:12:24 +0000140 };
141
142 /// LiveOutRegInfo - Information about live out vregs, indexed by their
143 /// register number offset by 'FirstVirtualRegister'.
144 std::vector<LiveOutInfo> LiveOutRegInfo;
145
146 /// clear - Clear out all the function-specific state. This returns this
147 /// FunctionLoweringInfo to an empty state, ready to be used for a
148 /// different function.
149 void clear() {
150 MBBMap.clear();
151 ValueMap.clear();
152 StaticAllocaMap.clear();
153#ifndef NDEBUG
154 CatchInfoLost.clear();
155 CatchInfoFound.clear();
156#endif
157 LiveOutRegInfo.clear();
158 }
159};
160
161//===----------------------------------------------------------------------===//
162/// SelectionDAGLowering - This is the common target-independent lowering
163/// implementation that is parameterized by a TargetLowering object.
164/// Also, targets can overload any lowering method.
165///
166class SelectionDAGLowering {
167 MachineBasicBlock *CurMBB;
168
Dale Johannesen32221462009-01-31 02:22:37 +0000169 /// CurDebugLoc - current file + line number. Changes as we build the DAG.
170 DebugLoc CurDebugLoc;
171
Dan Gohman13aeef92008-09-03 16:12:24 +0000172 DenseMap<const Value*, SDValue> NodeMap;
173
174 /// PendingLoads - Loads are not emitted to the program immediately. We bunch
175 /// them up and then emit token factor nodes when possible. This allows us to
176 /// get simple disambiguation between loads without worrying about alias
177 /// analysis.
178 SmallVector<SDValue, 8> PendingLoads;
179
180 /// PendingExports - CopyToReg nodes that copy values to virtual registers
181 /// for export to other blocks need to be emitted before any terminator
182 /// instruction, but they have no other ordering requirements. We bunch them
183 /// up and the emit a single tokenfactor for them just before terminator
184 /// instructions.
185 SmallVector<SDValue, 8> PendingExports;
186
187 /// Case - A struct to record the Value for a switch case, and the
188 /// case's target basic block.
189 struct Case {
190 Constant* Low;
191 Constant* High;
192 MachineBasicBlock* BB;
193
194 Case() : Low(0), High(0), BB(0) { }
195 Case(Constant* low, Constant* high, MachineBasicBlock* bb) :
196 Low(low), High(high), BB(bb) { }
197 uint64_t size() const {
198 uint64_t rHigh = cast<ConstantInt>(High)->getSExtValue();
199 uint64_t rLow = cast<ConstantInt>(Low)->getSExtValue();
200 return (rHigh - rLow + 1ULL);
201 }
202 };
203
204 struct CaseBits {
205 uint64_t Mask;
206 MachineBasicBlock* BB;
207 unsigned Bits;
208
209 CaseBits(uint64_t mask, MachineBasicBlock* bb, unsigned bits):
210 Mask(mask), BB(bb), Bits(bits) { }
211 };
212
213 typedef std::vector<Case> CaseVector;
214 typedef std::vector<CaseBits> CaseBitsVector;
215 typedef CaseVector::iterator CaseItr;
216 typedef std::pair<CaseItr, CaseItr> CaseRange;
217
218 /// CaseRec - A struct with ctor used in lowering switches to a binary tree
219 /// of conditional branches.
220 struct CaseRec {
221 CaseRec(MachineBasicBlock *bb, Constant *lt, Constant *ge, CaseRange r) :
222 CaseBB(bb), LT(lt), GE(ge), Range(r) {}
223
224 /// CaseBB - The MBB in which to emit the compare and branch
225 MachineBasicBlock *CaseBB;
226 /// LT, GE - If nonzero, we know the current case value must be less-than or
227 /// greater-than-or-equal-to these Constants.
228 Constant *LT;
229 Constant *GE;
230 /// Range - A pair of iterators representing the range of case values to be
231 /// processed at this point in the binary search tree.
232 CaseRange Range;
233 };
234
235 typedef std::vector<CaseRec> CaseRecVector;
236
237 /// The comparison function for sorting the switch case values in the vector.
238 /// WARNING: Case ranges should be disjoint!
239 struct CaseCmp {
240 bool operator () (const Case& C1, const Case& C2) {
241 assert(isa<ConstantInt>(C1.Low) && isa<ConstantInt>(C2.High));
242 const ConstantInt* CI1 = cast<const ConstantInt>(C1.Low);
243 const ConstantInt* CI2 = cast<const ConstantInt>(C2.High);
244 return CI1->getValue().slt(CI2->getValue());
245 }
246 };
247
248 struct CaseBitsCmp {
249 bool operator () (const CaseBits& C1, const CaseBits& C2) {
250 return C1.Bits > C2.Bits;
251 }
252 };
253
Anton Korobeynikov7e50c0d2008-12-23 22:25:27 +0000254 size_t Clusterify(CaseVector& Cases, const SwitchInst &SI);
255
Dan Gohman13aeef92008-09-03 16:12:24 +0000256 /// CaseBlock - This structure is used to communicate between SDLowering and
257 /// SDISel for the code generation of additional basic blocks needed by multi-
258 /// case switch statements.
259 struct CaseBlock {
260 CaseBlock(ISD::CondCode cc, Value *cmplhs, Value *cmprhs, Value *cmpmiddle,
261 MachineBasicBlock *truebb, MachineBasicBlock *falsebb,
262 MachineBasicBlock *me)
263 : CC(cc), CmpLHS(cmplhs), CmpMHS(cmpmiddle), CmpRHS(cmprhs),
264 TrueBB(truebb), FalseBB(falsebb), ThisBB(me) {}
265 // CC - the condition code to use for the case block's setcc node
266 ISD::CondCode CC;
267 // CmpLHS/CmpRHS/CmpMHS - The LHS/MHS/RHS of the comparison to emit.
268 // Emit by default LHS op RHS. MHS is used for range comparisons:
269 // If MHS is not null: (LHS <= MHS) and (MHS <= RHS).
270 Value *CmpLHS, *CmpMHS, *CmpRHS;
271 // TrueBB/FalseBB - the block to branch to if the setcc is true/false.
272 MachineBasicBlock *TrueBB, *FalseBB;
273 // ThisBB - the block into which to emit the code for the setcc and branches
274 MachineBasicBlock *ThisBB;
275 };
276 struct JumpTable {
277 JumpTable(unsigned R, unsigned J, MachineBasicBlock *M,
278 MachineBasicBlock *D): Reg(R), JTI(J), MBB(M), Default(D) {}
279
280 /// Reg - the virtual register containing the index of the jump table entry
281 //. to jump to.
282 unsigned Reg;
283 /// JTI - the JumpTableIndex for this jump table in the function.
284 unsigned JTI;
285 /// MBB - the MBB into which to emit the code for the indirect jump.
286 MachineBasicBlock *MBB;
287 /// Default - the MBB of the default bb, which is a successor of the range
288 /// check MBB. This is when updating PHI nodes in successors.
289 MachineBasicBlock *Default;
290 };
291 struct JumpTableHeader {
Anton Korobeynikov7e50c0d2008-12-23 22:25:27 +0000292 JumpTableHeader(APInt F, APInt L, Value* SV, MachineBasicBlock* H,
Dan Gohman13aeef92008-09-03 16:12:24 +0000293 bool E = false):
294 First(F), Last(L), SValue(SV), HeaderBB(H), Emitted(E) {}
Anton Korobeynikov7e50c0d2008-12-23 22:25:27 +0000295 APInt First;
296 APInt Last;
Dan Gohman13aeef92008-09-03 16:12:24 +0000297 Value *SValue;
298 MachineBasicBlock *HeaderBB;
299 bool Emitted;
300 };
301 typedef std::pair<JumpTableHeader, JumpTable> JumpTableBlock;
302
303 struct BitTestCase {
304 BitTestCase(uint64_t M, MachineBasicBlock* T, MachineBasicBlock* Tr):
305 Mask(M), ThisBB(T), TargetBB(Tr) { }
306 uint64_t Mask;
307 MachineBasicBlock* ThisBB;
308 MachineBasicBlock* TargetBB;
309 };
310
311 typedef SmallVector<BitTestCase, 3> BitTestInfo;
312
313 struct BitTestBlock {
Anton Korobeynikov7e50c0d2008-12-23 22:25:27 +0000314 BitTestBlock(APInt F, APInt R, Value* SV,
Dan Gohman13aeef92008-09-03 16:12:24 +0000315 unsigned Rg, bool E,
316 MachineBasicBlock* P, MachineBasicBlock* D,
317 const BitTestInfo& C):
318 First(F), Range(R), SValue(SV), Reg(Rg), Emitted(E),
319 Parent(P), Default(D), Cases(C) { }
Anton Korobeynikov7e50c0d2008-12-23 22:25:27 +0000320 APInt First;
321 APInt Range;
Dan Gohman13aeef92008-09-03 16:12:24 +0000322 Value *SValue;
323 unsigned Reg;
324 bool Emitted;
325 MachineBasicBlock *Parent;
326 MachineBasicBlock *Default;
327 BitTestInfo Cases;
328 };
329
330public:
331 // TLI - This is information that describes the available target features we
332 // need for lowering. This indicates when operations are unavailable,
333 // implemented with a libcall, etc.
334 TargetLowering &TLI;
335 SelectionDAG &DAG;
336 const TargetData *TD;
337 AliasAnalysis *AA;
338
339 /// SwitchCases - Vector of CaseBlock structures used to communicate
340 /// SwitchInst code generation information.
341 std::vector<CaseBlock> SwitchCases;
342 /// JTCases - Vector of JumpTable structures used to communicate
343 /// SwitchInst code generation information.
344 std::vector<JumpTableBlock> JTCases;
345 /// BitTestCases - Vector of BitTestBlock structures used to communicate
346 /// SwitchInst code generation information.
347 std::vector<BitTestBlock> BitTestCases;
Evan Chengd7dc9832009-09-18 21:02:19 +0000348
349 /// PHINodesToUpdate - A list of phi instructions whose operand list will
350 /// be updated after processing the current basic block.
Dan Gohman13aeef92008-09-03 16:12:24 +0000351 std::vector<std::pair<MachineInstr*, unsigned> > PHINodesToUpdate;
352
Evan Chengd7dc9832009-09-18 21:02:19 +0000353 /// EdgeMapping - If an edge from CurMBB to any MBB is changed (e.g. due to
354 /// scheduler custom lowering), track the change here.
355 DenseMap<MachineBasicBlock*, MachineBasicBlock*> EdgeMapping;
356
Dan Gohman13aeef92008-09-03 16:12:24 +0000357 // Emit PHI-node-operand constants only once even if used by multiple
358 // PHI nodes.
359 DenseMap<Constant*, unsigned> ConstantsOut;
360
361 /// FuncInfo - Information about the function as a whole.
362 ///
363 FunctionLoweringInfo &FuncInfo;
Bill Wendling9a48eb02009-02-19 21:12:54 +0000364
Bill Wendling58ed5d22009-04-29 00:15:41 +0000365 /// OptLevel - What optimization level we're generating code for.
Bill Wendling9a48eb02009-02-19 21:12:54 +0000366 ///
Bill Wendling5ed22ac2009-04-29 23:29:43 +0000367 CodeGenOpt::Level OptLevel;
Dan Gohman13aeef92008-09-03 16:12:24 +0000368
369 /// GFI - Garbage collection metadata for the function.
370 GCFunctionInfo *GFI;
371
Dan Gohman9178de12009-08-05 01:29:28 +0000372 /// HasTailCall - This is set to true if a call in the current
373 /// block has been translated as a tail call. In this case,
374 /// no subsequent DAG nodes should be created.
375 ///
376 bool HasTailCall;
377
Owen Anderson15b39322009-07-13 04:09:18 +0000378 LLVMContext *Context;
379
Dan Gohman13aeef92008-09-03 16:12:24 +0000380 SelectionDAGLowering(SelectionDAG &dag, TargetLowering &tli,
Bill Wendling5ed22ac2009-04-29 23:29:43 +0000381 FunctionLoweringInfo &funcinfo,
382 CodeGenOpt::Level ol)
Dale Johannesen32221462009-01-31 02:22:37 +0000383 : CurDebugLoc(DebugLoc::getUnknownLoc()),
Dan Gohman9178de12009-08-05 01:29:28 +0000384 TLI(tli), DAG(dag), FuncInfo(funcinfo), OptLevel(ol),
385 HasTailCall(false),
Owen Anderson15b39322009-07-13 04:09:18 +0000386 Context(dag.getContext()) {
Dan Gohman13aeef92008-09-03 16:12:24 +0000387 }
388
389 void init(GCFunctionInfo *gfi, AliasAnalysis &aa);
390
391 /// clear - Clear out the curret SelectionDAG and the associated
392 /// state and prepare this SelectionDAGLowering object to be used
393 /// for a new block. This doesn't clear out information about
394 /// additional blocks that are needed to complete switch lowering
395 /// or PHI node updating; that information is cleared out as it is
396 /// consumed.
397 void clear();
398
399 /// getRoot - Return the current virtual root of the Selection DAG,
400 /// flushing any PendingLoad items. This must be done before emitting
401 /// a store or any other node that may need to be ordered after any
402 /// prior load instructions.
403 ///
404 SDValue getRoot();
405
406 /// getControlRoot - Similar to getRoot, but instead of flushing all the
407 /// PendingLoad items, flush all the PendingExports items. It is necessary
408 /// to do this before emitting a terminator instruction.
409 ///
410 SDValue getControlRoot();
411
Dale Johannesen32221462009-01-31 02:22:37 +0000412 DebugLoc getCurDebugLoc() const { return CurDebugLoc; }
Devang Patel6bfb2052009-04-16 01:33:10 +0000413 void setCurDebugLoc(DebugLoc dl) { CurDebugLoc = dl; }
Dale Johannesen32221462009-01-31 02:22:37 +0000414
Dan Gohman13aeef92008-09-03 16:12:24 +0000415 void CopyValueToVirtualRegister(Value *V, unsigned Reg);
416
417 void visit(Instruction &I);
418
419 void visit(unsigned Opcode, User &I);
420
421 void setCurrentBasicBlock(MachineBasicBlock *MBB) { CurMBB = MBB; }
422
423 SDValue getValue(const Value *V);
424
425 void setValue(const Value *V, SDValue NewN) {
426 SDValue &N = NodeMap[V];
427 assert(N.getNode() == 0 && "Already set a value for this node!");
428 N = NewN;
429 }
430
Dale Johannesen47e30e42008-09-24 23:13:09 +0000431 void GetRegistersForValue(SDISelAsmOperandInfo &OpInfo,
Dan Gohman13aeef92008-09-03 16:12:24 +0000432 std::set<unsigned> &OutputRegs,
433 std::set<unsigned> &InputRegs);
434
435 void FindMergedConditions(Value *Cond, MachineBasicBlock *TBB,
436 MachineBasicBlock *FBB, MachineBasicBlock *CurBB,
437 unsigned Opc);
Dan Gohman001eaee2008-10-17 21:16:08 +0000438 void EmitBranchForMergedCondition(Value *Cond, MachineBasicBlock *TBB,
439 MachineBasicBlock *FBB,
440 MachineBasicBlock *CurBB);
Dan Gohman13aeef92008-09-03 16:12:24 +0000441 bool ShouldEmitAsBranches(const std::vector<CaseBlock> &Cases);
442 bool isExportableFromCurrentBlock(Value *V, const BasicBlock *FromBB);
Dan Gohmand4760a52009-04-23 23:13:24 +0000443 void CopyToExportRegsIfNeeded(Value *V);
Dan Gohman13aeef92008-09-03 16:12:24 +0000444 void ExportFromCurrentBlock(Value *V);
445 void LowerCallTo(CallSite CS, SDValue Callee, bool IsTailCall,
446 MachineBasicBlock *LandingPad = NULL);
447
448private:
449 // Terminator instructions.
450 void visitRet(ReturnInst &I);
451 void visitBr(BranchInst &I);
452 void visitSwitch(SwitchInst &I);
453 void visitUnreachable(UnreachableInst &I) { /* noop */ }
454
455 // Helpers for visitSwitch
456 bool handleSmallSwitchRange(CaseRec& CR,
457 CaseRecVector& WorkList,
458 Value* SV,
459 MachineBasicBlock* Default);
460 bool handleJTSwitchCase(CaseRec& CR,
461 CaseRecVector& WorkList,
462 Value* SV,
463 MachineBasicBlock* Default);
464 bool handleBTSplitSwitchCase(CaseRec& CR,
465 CaseRecVector& WorkList,
466 Value* SV,
467 MachineBasicBlock* Default);
468 bool handleBitTestsSwitchCase(CaseRec& CR,
469 CaseRecVector& WorkList,
470 Value* SV,
471 MachineBasicBlock* Default);
472public:
473 void visitSwitchCase(CaseBlock &CB);
474 void visitBitTestHeader(BitTestBlock &B);
475 void visitBitTestCase(MachineBasicBlock* NextMBB,
476 unsigned Reg,
477 BitTestCase &B);
478 void visitJumpTable(JumpTable &JT);
479 void visitJumpTableHeader(JumpTable &JT, JumpTableHeader &JTH);
480
481private:
482 // These all get lowered before this pass.
483 void visitInvoke(InvokeInst &I);
484 void visitUnwind(UnwindInst &I);
485
486 void visitBinary(User &I, unsigned OpCode);
487 void visitShift(User &I, unsigned Opcode);
Dan Gohman7ce405e2009-06-04 22:49:04 +0000488 void visitAdd(User &I) { visitBinary(I, ISD::ADD); }
489 void visitFAdd(User &I) { visitBinary(I, ISD::FADD); }
490 void visitSub(User &I) { visitBinary(I, ISD::SUB); }
491 void visitFSub(User &I);
492 void visitMul(User &I) { visitBinary(I, ISD::MUL); }
493 void visitFMul(User &I) { visitBinary(I, ISD::FMUL); }
Dan Gohman13aeef92008-09-03 16:12:24 +0000494 void visitURem(User &I) { visitBinary(I, ISD::UREM); }
495 void visitSRem(User &I) { visitBinary(I, ISD::SREM); }
496 void visitFRem(User &I) { visitBinary(I, ISD::FREM); }
497 void visitUDiv(User &I) { visitBinary(I, ISD::UDIV); }
498 void visitSDiv(User &I) { visitBinary(I, ISD::SDIV); }
499 void visitFDiv(User &I) { visitBinary(I, ISD::FDIV); }
500 void visitAnd (User &I) { visitBinary(I, ISD::AND); }
501 void visitOr (User &I) { visitBinary(I, ISD::OR); }
502 void visitXor (User &I) { visitBinary(I, ISD::XOR); }
503 void visitShl (User &I) { visitShift(I, ISD::SHL); }
504 void visitLShr(User &I) { visitShift(I, ISD::SRL); }
505 void visitAShr(User &I) { visitShift(I, ISD::SRA); }
506 void visitICmp(User &I);
507 void visitFCmp(User &I);
Dan Gohman13aeef92008-09-03 16:12:24 +0000508 // Visit the conversion instructions
509 void visitTrunc(User &I);
510 void visitZExt(User &I);
511 void visitSExt(User &I);
512 void visitFPTrunc(User &I);
513 void visitFPExt(User &I);
514 void visitFPToUI(User &I);
515 void visitFPToSI(User &I);
516 void visitUIToFP(User &I);
517 void visitSIToFP(User &I);
518 void visitPtrToInt(User &I);
519 void visitIntToPtr(User &I);
520 void visitBitCast(User &I);
521
522 void visitExtractElement(User &I);
523 void visitInsertElement(User &I);
524 void visitShuffleVector(User &I);
525
526 void visitExtractValue(ExtractValueInst &I);
527 void visitInsertValue(InsertValueInst &I);
528
529 void visitGetElementPtr(User &I);
530 void visitSelect(User &I);
531
532 void visitMalloc(MallocInst &I);
533 void visitFree(FreeInst &I);
534 void visitAlloca(AllocaInst &I);
535 void visitLoad(LoadInst &I);
536 void visitStore(StoreInst &I);
537 void visitPHI(PHINode &I) { } // PHI nodes are handled specially.
538 void visitCall(CallInst &I);
539 void visitInlineAsm(CallSite CS);
540 const char *visitIntrinsicCall(CallInst &I, unsigned Intrinsic);
541 void visitTargetIntrinsic(CallInst &I, unsigned Intrinsic);
542
Bill Wendling96f6fa12008-09-10 00:20:20 +0000543 void visitPow(CallInst &I);
Dale Johannesend93d7992008-09-05 01:48:15 +0000544 void visitExp2(CallInst &I);
Dale Johannesen062bb5d2008-09-05 18:38:42 +0000545 void visitExp(CallInst &I);
546 void visitLog(CallInst &I);
547 void visitLog2(CallInst &I);
548 void visitLog10(CallInst &I);
Dale Johannesend93d7992008-09-05 01:48:15 +0000549
Dan Gohman13aeef92008-09-03 16:12:24 +0000550 void visitVAStart(CallInst &I);
551 void visitVAArg(VAArgInst &I);
552 void visitVAEnd(CallInst &I);
553 void visitVACopy(CallInst &I);
554
555 void visitUserOp1(Instruction &I) {
Edwin Törökbd448e32009-07-14 16:55:14 +0000556 llvm_unreachable("UserOp1 should not exist at instruction selection time!");
Dan Gohman13aeef92008-09-03 16:12:24 +0000557 }
558 void visitUserOp2(Instruction &I) {
Edwin Törökbd448e32009-07-14 16:55:14 +0000559 llvm_unreachable("UserOp2 should not exist at instruction selection time!");
Dan Gohman13aeef92008-09-03 16:12:24 +0000560 }
561
562 const char *implVisitBinaryAtomic(CallInst& I, ISD::NodeType Op);
Bill Wendling7e04be62008-12-09 22:08:41 +0000563 const char *implVisitAluOverflow(CallInst &I, ISD::NodeType Op);
Dan Gohman13aeef92008-09-03 16:12:24 +0000564};
565
566/// AddCatchInfo - Extract the personality and type infos from an eh.selector
567/// call, and add them to the specified machine basic block.
568void AddCatchInfo(CallInst &I, MachineModuleInfo *MMI,
569 MachineBasicBlock *MBB);
570
571} // end namespace llvm
572
573#endif