namespace llvm {
-struct BasicBlock;
+class BasicBlock;
class PointerType;
//===----------------------------------------------------------------------===//
: Instruction((static_cast<const Instruction*>(&EPI)->getType()),
GetElementPtr) {
Operands.reserve(EPI.Operands.size());
- for (unsigned i = 0, E = EPI.Operands.size(); i != E; ++i)
+ for (unsigned i = 0, E = (unsigned)EPI.Operands.size(); i != E; ++i)
Operands.push_back(Use(EPI.Operands[i], this));
}
void init(Value *Ptr, const std::vector<Value*> &Idx);
/// le, or ge.
///
class SetCondInst : public BinaryOperator {
- BinaryOps OpType;
public:
SetCondInst(BinaryOps Opcode, Value *LHS, Value *RHS,
const std::string &Name = "", Instruction *InsertBefore = 0);
virtual CallInst *clone() const;
bool mayWriteToMemory() const { return true; }
- // FIXME: These methods should be inline once we eliminate
- // ConstantPointerRefs!
- const Function *getCalledFunction() const;
- Function *getCalledFunction();
+ /// 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 dyn_cast<Function>(Operands[0]);
+ }
// getCalledValue - Get a pointer to a method that is invoked by this inst.
inline const Value *getCalledValue() const { return Operands[0]; }
/// getNumIncomingValues - Return the number of incoming edges
///
- unsigned getNumIncomingValues() const { return Operands.size()/2; }
+ unsigned getNumIncomingValues() const { return (unsigned)Operands.size()/2; }
/// getIncomingValue - Return incoming value #x
///
}
}
- void init(Value *RetVal) {
- if (RetVal) {
- assert(!isa<BasicBlock>(RetVal) &&
- "Cannot return basic block. Probably using the incorrect ctor");
- Operands.reserve(1);
- Operands.push_back(Use(RetVal, this));
- }
- }
+ void init(Value *RetVal);
public:
// ReturnInst constructors:
// ReturnInst() - 'ret void' instruction
+ // ReturnInst( null) - 'ret void' instruction
// ReturnInst(Value* X) - 'ret X' instruction
// ReturnInst( null, Inst *) - 'ret void' instruction, insert before I
// ReturnInst(Value* X, Inst *I) - 'ret X' instruction, insert before I
// ReturnInst( null, BB *B) - 'ret void' instruction, insert @ end of BB
// ReturnInst(Value* X, BB *B) - 'ret X' instruction, insert @ end of BB
+ //
+ // NOTE: If the Value* passed is of type void then the constructor behaves as
+ // if it was passed NULL.
ReturnInst(Value *RetVal = 0, Instruction *InsertBefore = 0)
: TerminatorInst(Instruction::Ret, InsertBefore) {
init(RetVal);
//
inline const Value *getCondition() const { return Operands[0]; }
inline Value *getCondition() { return Operands[0]; }
+ void setCondition(Value *V) { Operands[0] = V; }
+
inline const BasicBlock *getDefaultDest() const {
return cast<BasicBlock>(Operands[1].get());
}
/// getNumCases - return the number of 'cases' in this switch instruction.
/// Note that case #0 is always the default case.
unsigned getNumCases() const {
- return Operands.size()/2;
+ return (unsigned)Operands.size()/2;
}
/// getCaseValue - Return the specified case value. Note that case #0, the
assert(idx < getNumSuccessors() && "Successor # out of range!");
return cast<Constant>(Operands[idx*2].get());
}
- virtual unsigned getNumSuccessors() const { return Operands.size()/2; }
+ virtual unsigned getNumSuccessors() const { return (unsigned)Operands.size()/2; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const SwitchInst *) { return true; }
bool mayWriteToMemory() const { return true; }
/// getCalledFunction - Return the function called, or null if this is an
- /// indirect function invocation...
- ///
- /// FIXME: These should be inlined once we get rid of ConstantPointerRefs!
+ /// indirect function invocation.
///
- const Function *getCalledFunction() const;
- Function *getCalledFunction();
+ Function *getCalledFunction() const {
+ return dyn_cast<Function>(Operands[0]);
+ }
// getCalledValue - Get a pointer to a function that is invoked by this inst.
inline const Value *getCalledValue() const { return Operands[0]; }
/// UnwindInst - Immediately exit the current function, unwinding the stack
/// until an invoke instruction is found.
///
-struct UnwindInst : public TerminatorInst {
+class UnwindInst : public TerminatorInst {
+public:
UnwindInst(Instruction *InsertBefore = 0)
: TerminatorInst(Instruction::Unwind, InsertBefore) {
}
/// presence of this instruction indicates some higher level knowledge that the
/// end of the block cannot be reached.
///
-struct UnreachableInst : public TerminatorInst {
+class UnreachableInst : public TerminatorInst {
+public:
UnreachableInst(Instruction *InsertBefore = 0)
: TerminatorInst(Instruction::Unreachable, InsertBefore) {
}