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