[llvm-commits] [llvm] r49479 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h lib/VMCore/Instructions.cpp
Gabor Greif
ggreif at gmail.com
Thu Apr 10 05:46:24 PDT 2008
Author: ggreif
Date: Thu Apr 10 07:46:24 2008
New Revision: 49479
URL: http://llvm.org/viewvc/llvm-project?rev=49479&view=rev
Log:
ooops, forgot to check in the header..
* define VariadicOperandTraits
* ReturnInst: use VariadicOperandTraits for accessors
* ReturnInst: remove redundant constructor and Create method
* ReturnInst: init() should not allocate hung off Uses
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=49479&r1=49478&r2=49479&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Thu Apr 10 07:46:24 2008
@@ -1483,6 +1483,24 @@
};
//===----------------------------------------------------------------------===//
+// VariadicOperand Trait Class
+//===----------------------------------------------------------------------===//
+
+template <unsigned MINARITY = 0>
+struct VariadicOperandTraits {
+ static Use *op_begin(User* U) {
+ return reinterpret_cast<Use*>(U) - U->getNumOperands();
+ }
+ static Use *op_end(User* U) {
+ return reinterpret_cast<Use*>(U);
+ }
+ static unsigned operands(const User*U) {
+ return U->getNumOperands();
+ }
+ static inline void *allocate(unsigned); // FIXME
+};
+
+//===----------------------------------------------------------------------===//
// ReturnInst Class
//===----------------------------------------------------------------------===//
@@ -1511,8 +1529,8 @@
// if it was passed NULL.
explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0);
ReturnInst(Value *retVal, BasicBlock *InsertAtEnd);
- ReturnInst(Value * const* retVals, unsigned N);
- ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore);
+/* ReturnInst(Value * const* retVals, unsigned N);*/
+ ReturnInst(Value * const* retVals, unsigned N, Instruction *InsertBefore = 0);
ReturnInst(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd);
explicit ReturnInst(BasicBlock *InsertAtEnd);
public:
@@ -1522,10 +1540,10 @@
static ReturnInst* Create(Value *retVal, BasicBlock *InsertAtEnd) {
return new(!!retVal) ReturnInst(retVal, InsertAtEnd);
}
- static ReturnInst* Create(Value * const* retVals, unsigned N) {
- return new(N) ReturnInst(retVals, N);
- }
- static ReturnInst* Create(Value * const* retVals, unsigned N, Instruction *InsertBefore) {
+// static ReturnInst* Create(Value * const* retVals, unsigned N) {
+// return new(N) ReturnInst(retVals, N);
+// }
+ static ReturnInst* Create(Value * const* retVals, unsigned N, Instruction *InsertBefore = 0) {
return new(N) ReturnInst(retVals, N, InsertBefore);
}
static ReturnInst* Create(Value * const* retVals, unsigned N, BasicBlock *InsertAtEnd) {
@@ -1538,13 +1556,16 @@
virtual ReturnInst *clone() const;
+ /// Provide fast operand accessors
+ DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
+/*
Value *getOperand(unsigned n = 0) const {
if (getNumOperands() > 1)
return TerminatorInst::getOperand(n);
else
return Op<0>();
}
-
+*/
Value *getReturnValue(unsigned n = 0) const {
return getOperand(n);
}
@@ -1565,6 +1586,12 @@
virtual void setSuccessorV(unsigned idx, BasicBlock *B);
};
+template <>
+struct OperandTraits<ReturnInst> : VariadicOperandTraits<> {
+};
+
+DEFINE_TRANSPARENT_OPERAND_ACCESSORS(ReturnInst, Value)
+
//===----------------------------------------------------------------------===//
// BranchInst 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=49479&r1=49478&r2=49479&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Thu Apr 10 07:46:24 2008
@@ -524,7 +524,7 @@
Op<0>().init(V, this);
}
- Use *OL = OperandList = allocHangoffUses(NumOperands);
+ Use *OL = OperandList;
for (unsigned i = 0; i < NumOperands; ++i) {
Value *V = *retVals++;
assert(!isa<BasicBlock>(V) &&
More information about the llvm-commits
mailing list