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