[llvm-commits] [llvm] r49590 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h lib/VMCore/Instructions.cpp
Gabor Greif
ggreif at gmail.com
Sat Apr 12 14:47:02 PDT 2008
Author: ggreif
Date: Sat Apr 12 16:47:02 2008
New Revision: 49590
URL: http://llvm.org/viewvc/llvm-project?rev=49590&view=rev
Log:
switch over InvokeInst
Modified:
llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp
Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49590&r1=49589&r2=49590&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Sat Apr 12 16:47:02 2008
@@ -945,13 +945,7 @@
/// @brief Construct a CallInst from a range of arguments
template<typename InputIterator>
CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &Name = "", Instruction *InsertBefore = 0);/*
- : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
- ->getElementType())->getReturnType(),
- Instruction::Call, 0, 0, InsertBefore) {
- init(Func, ArgBegin, ArgEnd, Name,
- typename std::iterator_traits<InputIterator>::iterator_category());
- }*/
+ const std::string &Name = "", Instruction *InsertBefore);
/// Construct a CallInst given a range of arguments. InputIterator
/// must be a random-access iterator pointing to contiguous storage
@@ -962,20 +956,13 @@
template<typename InputIterator>
inline CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &Name, BasicBlock *InsertAtEnd);
- /*
- : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
- ->getElementType())->getReturnType(),
- Instruction::Call, 0, 0, InsertAtEnd) {
- init(Func, ArgBegin, ArgEnd, Name,
- typename std::iterator_traits<InputIterator>::iterator_category());
- }*/
- CallInst(Value *F, Value *Actual, const std::string& Name = "",
- Instruction *InsertBefore = 0);
+ CallInst(Value *F, Value *Actual, const std::string& Name,
+ Instruction *InsertBefore);
CallInst(Value *F, Value *Actual, const std::string& Name,
BasicBlock *InsertAtEnd);
- explicit CallInst(Value *F, const std::string &Name = "",
- Instruction *InsertBefore = 0);
+ explicit CallInst(Value *F, const std::string &Name,
+ Instruction *InsertBefore);
CallInst(Value *F, const std::string &Name, BasicBlock *InsertAtEnd);
public:
template<typename InputIterator>
@@ -1699,14 +1686,6 @@
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
- /* Value *getOperand(unsigned i) const {
- assert(i < getNumOperands() && "getOperand() out of range!");
- return OperandList[i];
- }
- void setOperand(unsigned i, Value *Val) {
- assert(i < getNumOperands() && "setOperand() out of range!");
- OperandList[i] = Val;
- }*/
virtual BranchInst *clone() const;
@@ -1940,15 +1919,16 @@
///
/// @brief Construct an InvokeInst from a range of arguments
template<typename InputIterator>
- InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
- InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &Name = "", Instruction *InsertBefore = 0)
+ inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
+ InputIterator ArgBegin, InputIterator ArgEnd,
+ unsigned Values,
+ const std::string &Name, Instruction *InsertBefore);/*
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
- Instruction::Invoke, 0, 0, InsertBefore) {
+ Instruction::Invoke, 0, Values, InsertBefore) {
init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name,
typename std::iterator_traits<InputIterator>::iterator_category());
- }
+ }*/
/// Construct an InvokeInst given a range of arguments.
/// InputIterator must be a random-access iterator pointing to
@@ -1958,33 +1938,41 @@
///
/// @brief Construct an InvokeInst from a range of arguments
template<typename InputIterator>
- InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
+ inline InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
- const std::string &Name, BasicBlock *InsertAtEnd)
+ unsigned Values,
+ const std::string &Name, BasicBlock *InsertAtEnd);/*
: TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
->getElementType())->getReturnType(),
- Instruction::Invoke, 0, 0, InsertAtEnd) {
+ Instruction::Invoke, 0, Values, InsertAtEnd) {
init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name,
typename std::iterator_traits<InputIterator>::iterator_category());
- }
+ }*/
public:
template<typename InputIterator>
static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &Name = "", Instruction *InsertBefore = 0) {
- return new(ArgEnd - ArgBegin + 3) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, InsertBefore);
+ unsigned Values(ArgEnd - ArgBegin + 3);
+ return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
+ Values, Name, InsertBefore);
}
template<typename InputIterator>
static InvokeInst *Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
InputIterator ArgBegin, InputIterator ArgEnd,
const std::string &Name, BasicBlock *InsertAtEnd) {
- return new(ArgEnd - ArgBegin + 3) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name, InsertAtEnd);
+ unsigned Values(ArgEnd - ArgBegin + 3);
+ return new(Values) InvokeInst(Func, IfNormal, IfException, ArgBegin, ArgEnd,
+ Values, Name, InsertAtEnd);
}
~InvokeInst();
virtual InvokeInst *clone() const;
+ /// Provide fast operand accessors
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+
/// getCallingConv/setCallingConv - Get or set the calling convention of this
/// function call.
unsigned getCallingConv() const { return SubclassData; }
@@ -2087,6 +2075,38 @@
virtual void setSuccessorV(unsigned idx, BasicBlock *B);
};
+template <>
+struct OperandTraits<InvokeInst> : VariadicOperandTraits<3> {
+};
+
+template<typename InputIterator>
+InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
+ InputIterator ArgBegin, InputIterator ArgEnd,
+ unsigned Values,
+ const std::string &Name, Instruction *InsertBefore)
+ : TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
+ ->getElementType())->getReturnType(),
+ Instruction::Invoke,
+ OperandTraits<InvokeInst>::op_end(this) - Values,
+ Values, InsertBefore) {
+ init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name,
+ typename std::iterator_traits<InputIterator>::iterator_category());
+}
+template<typename InputIterator>
+InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException,
+ InputIterator ArgBegin, InputIterator ArgEnd,
+ unsigned Values,
+ const std::string &Name, BasicBlock *InsertAtEnd)
+ : TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
+ ->getElementType())->getReturnType(),
+ Instruction::Invoke,
+ OperandTraits<InvokeInst>::op_end(this) - Values,
+ Values, InsertAtEnd) {
+ init(Func, IfNormal, IfException, ArgBegin, ArgEnd, Name,
+ typename std::iterator_traits<InputIterator>::iterator_category());
+}
+
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(InvokeInst, Value)
//===----------------------------------------------------------------------===//
// UnwindInst Class
Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49590&r1=49589&r2=49590&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Sat Apr 12 16:47:02 2008
@@ -247,7 +247,7 @@
}
void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
- NumOperands = NumParams+1;
+ assert(NumOperands == NumParams+1 && "NumOperands not set up?");
Use *OL = OperandList;
OL[0].init(Func, this);
@@ -267,7 +267,7 @@
}
void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) {
- NumOperands = 3;
+ assert(NumOperands == 3 && "NumOperands not set up?");
Use *OL = OperandList;
OL[0].init(Func, this);
OL[1].init(Actual1, this);
@@ -289,7 +289,7 @@
}
void CallInst::init(Value *Func, Value *Actual) {
- NumOperands = 2;
+ assert(NumOperands == 2 && "NumOperands not set up?");
Use *OL = OperandList;
OL[0].init(Func, this);
OL[1].init(Actual, this);
@@ -307,7 +307,7 @@
}
void CallInst::init(Value *Func) {
- NumOperands = 1;
+ assert(NumOperands == 1 && "NumOperands not set up?");
Use *OL = OperandList;
OL[0].init(Func, this);
@@ -401,8 +401,8 @@
void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
Value* const *Args, unsigned NumArgs) {
- NumOperands = 3+NumArgs;
- Use *OL = OperandList = allocHangoffUses(3+NumArgs);
+ assert(NumOperands == 3+NumArgs && "NumOperands not set up?");
+ Use *OL = OperandList;
OL[0].init(Fn, this);
OL[1].init(IfNormal, this);
OL[2].init(IfException, this);
@@ -425,7 +425,8 @@
InvokeInst::InvokeInst(const InvokeInst &II)
: TerminatorInst(II.getType(), Instruction::Invoke,
- allocHangoffUses(II.getNumOperands()), II.getNumOperands()) {
+ OperandTraits<InvokeInst>::op_end(this) - II.getNumOperands(),
+ II.getNumOperands()) {
setParamAttrs(II.getParamAttrs());
SubclassData = II.SubclassData;
Use *OL = OperandList, *InOL = II.OperandList;
More information about the llvm-commits
mailing list