blob: bde2f3b232f4921a4e85b27d48abf88e98034310 [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
93 explicit FunctionLoweringInfo(TargetLowering &TLI);
94
95 /// set - Initialize this FunctionLoweringInfo with the given Function
96 /// and its associated MachineFunction.
97 ///
Bill Wendling6a8a0d72009-02-03 02:20:52 +000098 void set(Function &Fn, MachineFunction &MF, SelectionDAG &DAG,
99 bool EnableFastISel);
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000100
101 /// MBBMap - A mapping from LLVM basic blocks to their machine code entry.
102 DenseMap<const BasicBlock*, MachineBasicBlock *> MBBMap;
103
104 /// ValueMap - Since we emit code for the function a basic block at a time,
105 /// we must remember which virtual registers hold the values for
106 /// cross-basic-block values.
107 DenseMap<const Value*, unsigned> ValueMap;
108
109 /// StaticAllocaMap - Keep track of frame indices for fixed sized allocas in
110 /// the entry block. This allows the allocas to be efficiently referenced
111 /// anywhere in the function.
112 DenseMap<const AllocaInst*, int> StaticAllocaMap;
113
114#ifndef NDEBUG
115 SmallSet<Instruction*, 8> CatchInfoLost;
116 SmallSet<Instruction*, 8> CatchInfoFound;
117#endif
118
Owen Andersone50ed302009-08-10 22:56:29 +0000119 unsigned MakeReg(EVT VT);
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000120
121 /// isExportedInst - Return true if the specified value is an instruction
122 /// exported from its block.
123 bool isExportedInst(const Value *V) {
124 return ValueMap.count(V);
125 }
126
127 unsigned CreateRegForValue(const Value *V);
128
129 unsigned InitializeRegForValue(const Value *V) {
130 unsigned &R = ValueMap[V];
131 assert(R == 0 && "Already initialized this value register!");
132 return R = CreateRegForValue(V);
133 }
134
135 struct LiveOutInfo {
136 unsigned NumSignBits;
137 APInt KnownOne, KnownZero;
Dan Gohman84d08db2009-03-27 23:51:02 +0000138 LiveOutInfo() : NumSignBits(0), KnownOne(1, 0), KnownZero(1, 0) {}
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000139 };
140
141 /// LiveOutRegInfo - Information about live out vregs, indexed by their
142 /// register number offset by 'FirstVirtualRegister'.
143 std::vector<LiveOutInfo> LiveOutRegInfo;
144
145 /// clear - Clear out all the function-specific state. This returns this
146 /// FunctionLoweringInfo to an empty state, ready to be used for a
147 /// different function.
148 void clear() {
149 MBBMap.clear();
150 ValueMap.clear();
151 StaticAllocaMap.clear();
152#ifndef NDEBUG
153 CatchInfoLost.clear();
154 CatchInfoFound.clear();
155#endif
156 LiveOutRegInfo.clear();
157 }
158};
159
160//===----------------------------------------------------------------------===//
161/// SelectionDAGLowering - This is the common target-independent lowering
162/// implementation that is parameterized by a TargetLowering object.
163/// Also, targets can overload any lowering method.
164///
165class SelectionDAGLowering {
166 MachineBasicBlock *CurMBB;
167
Dale Johannesen66978ee2009-01-31 02:22:37 +0000168 /// CurDebugLoc - current file + line number. Changes as we build the DAG.
169 DebugLoc CurDebugLoc;
170
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000171 DenseMap<const Value*, SDValue> NodeMap;
172
173 /// PendingLoads - Loads are not emitted to the program immediately. We bunch
174 /// them up and then emit token factor nodes when possible. This allows us to
175 /// get simple disambiguation between loads without worrying about alias
176 /// analysis.
177 SmallVector<SDValue, 8> PendingLoads;
178
179 /// PendingExports - CopyToReg nodes that copy values to virtual registers
180 /// for export to other blocks need to be emitted before any terminator
181 /// instruction, but they have no other ordering requirements. We bunch them
182 /// up and the emit a single tokenfactor for them just before terminator
183 /// instructions.
184 SmallVector<SDValue, 8> PendingExports;
185
186 /// Case - A struct to record the Value for a switch case, and the
187 /// case's target basic block.
188 struct Case {
189 Constant* Low;
190 Constant* High;
191 MachineBasicBlock* BB;
192
193 Case() : Low(0), High(0), BB(0) { }
194 Case(Constant* low, Constant* high, MachineBasicBlock* bb) :
195 Low(low), High(high), BB(bb) { }
Chris Lattnere880efe2009-11-07 07:50:34 +0000196 APInt size() const {
197 const APInt &rHigh = cast<ConstantInt>(High)->getValue();
198 const APInt &rLow = cast<ConstantInt>(Low)->getValue();
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000199 return (rHigh - rLow + 1ULL);
200 }
201 };
202
203 struct CaseBits {
204 uint64_t Mask;
205 MachineBasicBlock* BB;
206 unsigned Bits;
207
208 CaseBits(uint64_t mask, MachineBasicBlock* bb, unsigned bits):
209 Mask(mask), BB(bb), Bits(bits) { }
210 };
211
212 typedef std::vector<Case> CaseVector;
213 typedef std::vector<CaseBits> CaseBitsVector;
214 typedef CaseVector::iterator CaseItr;
215 typedef std::pair<CaseItr, CaseItr> CaseRange;
216
217 /// CaseRec - A struct with ctor used in lowering switches to a binary tree
218 /// of conditional branches.
219 struct CaseRec {
220 CaseRec(MachineBasicBlock *bb, Constant *lt, Constant *ge, CaseRange r) :
221 CaseBB(bb), LT(lt), GE(ge), Range(r) {}
222
223 /// CaseBB - The MBB in which to emit the compare and branch
224 MachineBasicBlock *CaseBB;
225 /// LT, GE - If nonzero, we know the current case value must be less-than or
226 /// greater-than-or-equal-to these Constants.
227 Constant *LT;
228 Constant *GE;
229 /// Range - A pair of iterators representing the range of case values to be
230 /// processed at this point in the binary search tree.
231 CaseRange Range;
232 };
233
234 typedef std::vector<CaseRec> CaseRecVector;
235
236 /// The comparison function for sorting the switch case values in the vector.
237 /// WARNING: Case ranges should be disjoint!
238 struct CaseCmp {
239 bool operator () (const Case& C1, const Case& C2) {
240 assert(isa<ConstantInt>(C1.Low) && isa<ConstantInt>(C2.High));
241 const ConstantInt* CI1 = cast<const ConstantInt>(C1.Low);
242 const ConstantInt* CI2 = cast<const ConstantInt>(C2.High);
243 return CI1->getValue().slt(CI2->getValue());
244 }
245 };
246
247 struct CaseBitsCmp {
248 bool operator () (const CaseBits& C1, const CaseBits& C2) {
249 return C1.Bits > C2.Bits;
250 }
251 };
252
Anton Korobeynikov23218582008-12-23 22:25:27 +0000253 size_t Clusterify(CaseVector& Cases, const SwitchInst &SI);
254
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000255 /// CaseBlock - This structure is used to communicate between SDLowering and
256 /// SDISel for the code generation of additional basic blocks needed by multi-
257 /// case switch statements.
258 struct CaseBlock {
259 CaseBlock(ISD::CondCode cc, Value *cmplhs, Value *cmprhs, Value *cmpmiddle,
260 MachineBasicBlock *truebb, MachineBasicBlock *falsebb,
261 MachineBasicBlock *me)
262 : CC(cc), CmpLHS(cmplhs), CmpMHS(cmpmiddle), CmpRHS(cmprhs),
263 TrueBB(truebb), FalseBB(falsebb), ThisBB(me) {}
264 // CC - the condition code to use for the case block's setcc node
265 ISD::CondCode CC;
266 // CmpLHS/CmpRHS/CmpMHS - The LHS/MHS/RHS of the comparison to emit.
267 // Emit by default LHS op RHS. MHS is used for range comparisons:
268 // If MHS is not null: (LHS <= MHS) and (MHS <= RHS).
269 Value *CmpLHS, *CmpMHS, *CmpRHS;
270 // TrueBB/FalseBB - the block to branch to if the setcc is true/false.
271 MachineBasicBlock *TrueBB, *FalseBB;
272 // ThisBB - the block into which to emit the code for the setcc and branches
273 MachineBasicBlock *ThisBB;
274 };
275 struct JumpTable {
276 JumpTable(unsigned R, unsigned J, MachineBasicBlock *M,
277 MachineBasicBlock *D): Reg(R), JTI(J), MBB(M), Default(D) {}
278
279 /// Reg - the virtual register containing the index of the jump table entry
280 //. to jump to.
281 unsigned Reg;
282 /// JTI - the JumpTableIndex for this jump table in the function.
283 unsigned JTI;
284 /// MBB - the MBB into which to emit the code for the indirect jump.
285 MachineBasicBlock *MBB;
286 /// Default - the MBB of the default bb, which is a successor of the range
287 /// check MBB. This is when updating PHI nodes in successors.
288 MachineBasicBlock *Default;
289 };
290 struct JumpTableHeader {
Anton Korobeynikov23218582008-12-23 22:25:27 +0000291 JumpTableHeader(APInt F, APInt L, Value* SV, MachineBasicBlock* H,
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000292 bool E = false):
293 First(F), Last(L), SValue(SV), HeaderBB(H), Emitted(E) {}
Anton Korobeynikov23218582008-12-23 22:25:27 +0000294 APInt First;
295 APInt Last;
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000296 Value *SValue;
297 MachineBasicBlock *HeaderBB;
298 bool Emitted;
299 };
300 typedef std::pair<JumpTableHeader, JumpTable> JumpTableBlock;
301
302 struct BitTestCase {
303 BitTestCase(uint64_t M, MachineBasicBlock* T, MachineBasicBlock* Tr):
304 Mask(M), ThisBB(T), TargetBB(Tr) { }
305 uint64_t Mask;
306 MachineBasicBlock* ThisBB;
307 MachineBasicBlock* TargetBB;
308 };
309
310 typedef SmallVector<BitTestCase, 3> BitTestInfo;
311
312 struct BitTestBlock {
Anton Korobeynikov23218582008-12-23 22:25:27 +0000313 BitTestBlock(APInt F, APInt R, Value* SV,
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000314 unsigned Rg, bool E,
315 MachineBasicBlock* P, MachineBasicBlock* D,
316 const BitTestInfo& C):
317 First(F), Range(R), SValue(SV), Reg(Rg), Emitted(E),
318 Parent(P), Default(D), Cases(C) { }
Anton Korobeynikov23218582008-12-23 22:25:27 +0000319 APInt First;
320 APInt Range;
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000321 Value *SValue;
322 unsigned Reg;
323 bool Emitted;
324 MachineBasicBlock *Parent;
325 MachineBasicBlock *Default;
326 BitTestInfo Cases;
327 };
328
329public:
330 // TLI - This is information that describes the available target features we
331 // need for lowering. This indicates when operations are unavailable,
332 // implemented with a libcall, etc.
333 TargetLowering &TLI;
334 SelectionDAG &DAG;
335 const TargetData *TD;
336 AliasAnalysis *AA;
337
338 /// SwitchCases - Vector of CaseBlock structures used to communicate
339 /// SwitchInst code generation information.
340 std::vector<CaseBlock> SwitchCases;
341 /// JTCases - Vector of JumpTable structures used to communicate
342 /// SwitchInst code generation information.
343 std::vector<JumpTableBlock> JTCases;
344 /// BitTestCases - Vector of BitTestBlock structures used to communicate
345 /// SwitchInst code generation information.
346 std::vector<BitTestBlock> BitTestCases;
Evan Chengfb2e7522009-09-18 21:02:19 +0000347
348 /// PHINodesToUpdate - A list of phi instructions whose operand list will
349 /// be updated after processing the current basic block.
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000350 std::vector<std::pair<MachineInstr*, unsigned> > PHINodesToUpdate;
351
Evan Chengfb2e7522009-09-18 21:02:19 +0000352 /// EdgeMapping - If an edge from CurMBB to any MBB is changed (e.g. due to
353 /// scheduler custom lowering), track the change here.
354 DenseMap<MachineBasicBlock*, MachineBasicBlock*> EdgeMapping;
355
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000356 // Emit PHI-node-operand constants only once even if used by multiple
357 // PHI nodes.
358 DenseMap<Constant*, unsigned> ConstantsOut;
359
360 /// FuncInfo - Information about the function as a whole.
361 ///
362 FunctionLoweringInfo &FuncInfo;
Bill Wendlingdfdacee2009-02-19 21:12:54 +0000363
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +0000364 /// OptLevel - What optimization level we're generating code for.
Bill Wendlingdfdacee2009-02-19 21:12:54 +0000365 ///
Bill Wendling98a366d2009-04-29 23:29:43 +0000366 CodeGenOpt::Level OptLevel;
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000367
368 /// GFI - Garbage collection metadata for the function.
369 GCFunctionInfo *GFI;
370
Dan Gohman98ca4f22009-08-05 01:29:28 +0000371 /// HasTailCall - This is set to true if a call in the current
372 /// block has been translated as a tail call. In this case,
373 /// no subsequent DAG nodes should be created.
374 ///
375 bool HasTailCall;
376
Owen Anderson0a5372e2009-07-13 04:09:18 +0000377 LLVMContext *Context;
378
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000379 SelectionDAGLowering(SelectionDAG &dag, TargetLowering &tli,
Bill Wendling98a366d2009-04-29 23:29:43 +0000380 FunctionLoweringInfo &funcinfo,
381 CodeGenOpt::Level ol)
Dale Johannesen66978ee2009-01-31 02:22:37 +0000382 : CurDebugLoc(DebugLoc::getUnknownLoc()),
Dan Gohman98ca4f22009-08-05 01:29:28 +0000383 TLI(tli), DAG(dag), FuncInfo(funcinfo), OptLevel(ol),
384 HasTailCall(false),
Owen Anderson0a5372e2009-07-13 04:09:18 +0000385 Context(dag.getContext()) {
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000386 }
387
388 void init(GCFunctionInfo *gfi, AliasAnalysis &aa);
389
390 /// clear - Clear out the curret SelectionDAG and the associated
391 /// state and prepare this SelectionDAGLowering object to be used
392 /// for a new block. This doesn't clear out information about
393 /// additional blocks that are needed to complete switch lowering
394 /// or PHI node updating; that information is cleared out as it is
395 /// consumed.
396 void clear();
397
398 /// getRoot - Return the current virtual root of the Selection DAG,
399 /// flushing any PendingLoad items. This must be done before emitting
400 /// a store or any other node that may need to be ordered after any
401 /// prior load instructions.
402 ///
403 SDValue getRoot();
404
405 /// getControlRoot - Similar to getRoot, but instead of flushing all the
406 /// PendingLoad items, flush all the PendingExports items. It is necessary
407 /// to do this before emitting a terminator instruction.
408 ///
409 SDValue getControlRoot();
410
Dale Johannesen66978ee2009-01-31 02:22:37 +0000411 DebugLoc getCurDebugLoc() const { return CurDebugLoc; }
Devang Patel390f3ac2009-04-16 01:33:10 +0000412 void setCurDebugLoc(DebugLoc dl) { CurDebugLoc = dl; }
Dale Johannesen66978ee2009-01-31 02:22:37 +0000413
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000414 void CopyValueToVirtualRegister(Value *V, unsigned Reg);
415
416 void visit(Instruction &I);
417
418 void visit(unsigned Opcode, User &I);
419
420 void setCurrentBasicBlock(MachineBasicBlock *MBB) { CurMBB = MBB; }
421
422 SDValue getValue(const Value *V);
423
424 void setValue(const Value *V, SDValue NewN) {
425 SDValue &N = NodeMap[V];
426 assert(N.getNode() == 0 && "Already set a value for this node!");
427 N = NewN;
428 }
429
Dale Johannesen8e3455b2008-09-24 23:13:09 +0000430 void GetRegistersForValue(SDISelAsmOperandInfo &OpInfo,
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000431 std::set<unsigned> &OutputRegs,
432 std::set<unsigned> &InputRegs);
433
434 void FindMergedConditions(Value *Cond, MachineBasicBlock *TBB,
435 MachineBasicBlock *FBB, MachineBasicBlock *CurBB,
436 unsigned Opc);
Dan Gohmanc2277342008-10-17 21:16:08 +0000437 void EmitBranchForMergedCondition(Value *Cond, MachineBasicBlock *TBB,
438 MachineBasicBlock *FBB,
439 MachineBasicBlock *CurBB);
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000440 bool ShouldEmitAsBranches(const std::vector<CaseBlock> &Cases);
441 bool isExportableFromCurrentBlock(Value *V, const BasicBlock *FromBB);
Dan Gohmanad62f532009-04-23 23:13:24 +0000442 void CopyToExportRegsIfNeeded(Value *V);
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000443 void ExportFromCurrentBlock(Value *V);
444 void LowerCallTo(CallSite CS, SDValue Callee, bool IsTailCall,
445 MachineBasicBlock *LandingPad = NULL);
446
447private:
448 // Terminator instructions.
449 void visitRet(ReturnInst &I);
450 void visitBr(BranchInst &I);
451 void visitSwitch(SwitchInst &I);
Chris Lattnerab21db72009-10-28 00:19:10 +0000452 void visitIndirectBr(IndirectBrInst &I);
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000453 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 Gohmanae3a0be2009-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 Gohmanf0cbcd42008-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 Gohmanf0cbcd42008-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
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000532 void visitAlloca(AllocaInst &I);
533 void visitLoad(LoadInst &I);
534 void visitStore(StoreInst &I);
535 void visitPHI(PHINode &I) { } // PHI nodes are handled specially.
536 void visitCall(CallInst &I);
537 void visitInlineAsm(CallSite CS);
538 const char *visitIntrinsicCall(CallInst &I, unsigned Intrinsic);
539 void visitTargetIntrinsic(CallInst &I, unsigned Intrinsic);
540
Bill Wendlingaeb5c7b2008-09-10 00:20:20 +0000541 void visitPow(CallInst &I);
Dale Johannesen601d3c02008-09-05 01:48:15 +0000542 void visitExp2(CallInst &I);
Dale Johannesen59e577f2008-09-05 18:38:42 +0000543 void visitExp(CallInst &I);
544 void visitLog(CallInst &I);
545 void visitLog2(CallInst &I);
546 void visitLog10(CallInst &I);
Dale Johannesen601d3c02008-09-05 01:48:15 +0000547
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000548 void visitVAStart(CallInst &I);
549 void visitVAArg(VAArgInst &I);
550 void visitVAEnd(CallInst &I);
551 void visitVACopy(CallInst &I);
552
553 void visitUserOp1(Instruction &I) {
Torok Edwinc23197a2009-07-14 16:55:14 +0000554 llvm_unreachable("UserOp1 should not exist at instruction selection time!");
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000555 }
556 void visitUserOp2(Instruction &I) {
Torok Edwinc23197a2009-07-14 16:55:14 +0000557 llvm_unreachable("UserOp2 should not exist at instruction selection time!");
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000558 }
559
560 const char *implVisitBinaryAtomic(CallInst& I, ISD::NodeType Op);
Bill Wendling74c37652008-12-09 22:08:41 +0000561 const char *implVisitAluOverflow(CallInst &I, ISD::NodeType Op);
Dan Gohmanf0cbcd42008-09-03 16:12:24 +0000562};
563
564/// AddCatchInfo - Extract the personality and type infos from an eh.selector
565/// call, and add them to the specified machine basic block.
566void AddCatchInfo(CallInst &I, MachineModuleInfo *MMI,
567 MachineBasicBlock *MBB);
568
569} // end namespace llvm
570
571#endif