}
void init(Value *Ptr, const std::vector<Value*> &Idx);
void init(Value *Ptr, Value *Idx0, Value *Idx1);
+ void init(Value *Ptr, Value *Idx);
public:
/// Constructors - Create a getelementptr instruction with a base pointer an
/// list of indices. The first ctor can optionally insert before an existing
GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
const std::string &Name, BasicBlock *InsertAtEnd);
- /// Constructors - These two constructors are convenience methods because two
- /// index getelementptr instructions are so common.
+ /// Constructors - These two constructors are convenience methods because one
+ /// and two index getelementptr instructions are so common.
+ GetElementPtrInst(Value *Ptr, Value *Idx,
+ const std::string &Name = "", Instruction *InsertBefore =0);
+ GetElementPtrInst(Value *Ptr, Value *Idx,
+ const std::string &Name, BasicBlock *InsertAtEnd);
GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1,
const std::string &Name = "", Instruction *InsertBefore =0);
GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1,
bool AllowStructLeaf = false);
static const Type *getIndexedType(const Type *Ptr, Value *Idx0, Value *Idx1,
bool AllowStructLeaf = false);
+ static const Type *getIndexedType(const Type *Ptr, Value *Idx);
inline op_iterator idx_begin() { return op_begin()+1; }
inline const_op_iterator idx_begin() const { return op_begin()+1; }
//===----------------------------------------------------------------------===//
/// CallInst - This class represents a function call, abstracting a target
-/// machine's calling convention.
+/// machine's calling convention. This class uses low bit of the SubClassData
+/// field to indicate whether or not this is a tail call. The rest of the bits
+/// hold the calling convention of the call.
///
class CallInst : public Instruction {
CallInst(const CallInst &CI);
virtual CallInst *clone() const;
bool mayWriteToMemory() const { return true; }
+ bool isTailCall() const { return SubclassData & 1; }
+ void setTailCall(bool isTailCall = true) {
+ SubclassData = (SubclassData & ~1) | unsigned(isTailCall);
+ }
+
+ /// getCallingConv/setCallingConv - Get or set the calling convention of this
+ /// function call.
+ unsigned getCallingConv() const { return SubclassData >> 1; }
+ void setCallingConv(unsigned CC) {
+ SubclassData = (SubclassData & 1) | (CC << 1);
+ }
+
/// getCalledFunction - Return the function being called by this instruction
/// if it is a direct call. If it is a call through a function pointer,
/// return null.
Function *getCalledFunction() const {
- return (Function*)dyn_cast<Function>(getOperand(0));
+ return static_cast<Function*>(dyn_cast<Function>(getOperand(0)));
}
// getCalledValue - Get a pointer to a method that is invoked by this inst.
// successor.
inline ConstantInt *getSuccessorValue(unsigned idx) const {
assert(idx < getNumSuccessors() && "Successor # out of range!");
- return (ConstantInt*)getOperand(idx*2);
+ return reinterpret_cast<ConstantInt*>(getOperand(idx*2));
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
//===----------------------------------------------------------------------===//
//===---------------------------------------------------------------------------
-/// InvokeInst - Invoke instruction
+
+/// InvokeInst - Invoke instruction. The SubclassData field is used to hold the
+/// calling convention of the call.
///
class InvokeInst : public TerminatorInst {
InvokeInst(const InvokeInst &BI);
bool mayWriteToMemory() const { return true; }
+ /// getCallingConv/setCallingConv - Get or set the calling convention of this
+ /// function call.
+ unsigned getCallingConv() const { return SubclassData; }
+ void setCallingConv(unsigned CC) {
+ SubclassData = CC;
+ }
+
/// getCalledFunction - Return the function called, or null if this is an
/// indirect function invocation.
///