Kill unneccesary &*
[oota-llvm.git] / include / llvm / Support / CallSite.h
1 //===-- llvm/Support/CallSite.h - Abstract Call & Invoke instrs -*- C++ -*-===//
2 //
3 // This file defines the CallSite class, which is a handy wrapper for code that
4 // wants to treat Call and Invoke instructions in a generic way.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_SUPPORT_CALLSITE_H
9 #define LLVM_SUPPORT_CALLSITE_H
10
11 #include "llvm/Instruction.h"
12
13 class CallInst;
14 class InvokeInst;
15
16 class CallSite {
17   Instruction *I;
18 public:
19   CallSite(CallInst *CI) : I((Instruction*)CI) {}
20   CallSite(InvokeInst *II) : I((Instruction*)II) {}
21
22   /// getCalledValue - Return the pointer to function that is being called...
23   ///
24   Value *getCalledValue() const { return I->getOperand(0); }
25
26   /// getCalledFunction - Return the function being called if this is a direct
27   /// call, otherwise return null (if it's an indirect call).
28   ///
29   Function *getCalledFunction() const {
30     return dyn_cast<Function>(getCalledValue());
31   }
32
33   /// arg_iterator - The type of iterator to use when looping over actual
34   /// arguments at this call site...
35   typedef User::op_iterator arg_iterator;
36
37   /// arg_begin/arg_end - Return iterators corresponding to the actual argument
38   /// list for a call site.
39   ///
40   arg_iterator arg_begin() const {
41     if (I->getOpcode() == Instruction::Call)
42       return I->op_begin()+1; // Skip Function
43     else
44       return I->op_begin()+3; // Skip Function, BB, BB
45   }
46   arg_iterator arg_end() const { return I->op_begin(); }
47 };
48
49 #endif