[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Reader.h
Chris Lattner
lattner at cs.uiuc.edu
Fri Jan 28 16:36:32 PST 2005
Changes in directory llvm/lib/Bytecode/Reader:
Reader.cpp updated: 1.150 -> 1.151
Reader.h updated: 1.20 -> 1.21
---
Log message:
Adjust to changes in User class and minor changes in instruction ctors.
---
Diffs of the changes: (+25 -21)
Reader.cpp | 25 ++++++++++++-------------
Reader.h | 21 +++++++++++++--------
2 files changed, 25 insertions(+), 21 deletions(-)
Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.150 llvm/lib/Bytecode/Reader/Reader.cpp:1.151
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.150 Sun Dec 19 21:23:46 2004
+++ llvm/lib/Bytecode/Reader/Reader.cpp Fri Jan 28 18:36:19 2005
@@ -32,17 +32,15 @@
using namespace llvm;
namespace {
-
-/// @brief A class for maintaining the slot number definition
-/// as a placeholder for the actual definition for forward constants defs.
-class ConstantPlaceHolder : public ConstantExpr {
- ConstantPlaceHolder(); // DO NOT IMPLEMENT
- void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT
-public:
- ConstantPlaceHolder(const Type *Ty)
- : ConstantExpr(Instruction::UserOp1, Constant::getNullValue(Ty), Ty) {}
-};
-
+ /// @brief A class for maintaining the slot number definition
+ /// as a placeholder for the actual definition for forward constants defs.
+ class ConstantPlaceHolder : public ConstantExpr {
+ ConstantPlaceHolder(); // DO NOT IMPLEMENT
+ void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT
+ public:
+ ConstantPlaceHolder(const Type *Ty)
+ : ConstantExpr(Ty, Instruction::UserOp1, 0, 0) {}
+ };
}
// Provide some details on error
@@ -671,7 +669,7 @@
error("Invalid phi node encountered!");
PHINode *PN = new PHINode(InstTy);
- PN->op_reserve(Oprnds.size());
+ PN->reserveOperandSpace(Oprnds.size());
for (unsigned i = 0, e = Oprnds.size(); i != e; i += 2)
PN->addIncoming(getValue(iType, Oprnds[i]), getBasicBlock(Oprnds[i+1]));
Result = PN;
@@ -707,7 +705,8 @@
error("Switch statement with odd number of arguments!");
SwitchInst *I = new SwitchInst(getValue(iType, Oprnds[0]),
- getBasicBlock(Oprnds[1]));
+ getBasicBlock(Oprnds[1]),
+ Oprnds.size()/2-1);
for (unsigned i = 2, e = Oprnds.size(); i != e; i += 2)
I->addCase(cast<Constant>(getValue(iType, Oprnds[i])),
getBasicBlock(Oprnds[i+1]));
Index: llvm/lib/Bytecode/Reader/Reader.h
diff -u llvm/lib/Bytecode/Reader/Reader.h:1.20 llvm/lib/Bytecode/Reader/Reader.h:1.21
--- llvm/lib/Bytecode/Reader/Reader.h:1.20 Thu Dec 9 00:19:44 2004
+++ llvm/lib/Bytecode/Reader/Reader.h Fri Jan 28 18:36:19 2005
@@ -77,18 +77,23 @@
/// constants with global variables at the end of reading the
/// globals section.
/// @brief A list of values as a User of those Values.
- struct ValueList : public User {
- ValueList() : User(Type::VoidTy, Value::ValueListVal) {}
+ class ValueList : public User {
+ std::vector<Use> Uses;
+ public:
+ ValueList() : User(Type::VoidTy, Value::ValueListVal, 0, 0) {}
// vector compatibility methods
unsigned size() const { return getNumOperands(); }
- void push_back(Value *V) { Operands.push_back(Use(V, this)); }
- Value *back() const { return Operands.back(); }
- void pop_back() { Operands.pop_back(); }
- bool empty() const { return Operands.empty(); }
- // must override this
+ void push_back(Value *V) {
+ Uses.push_back(Use(V, this));
+ OperandList = &Uses[0];
+ ++NumOperands;
+ }
+ Value *back() const { return Uses.back(); }
+ void pop_back() { Uses.pop_back(); --NumOperands; }
+ bool empty() const { return NumOperands == 0; }
virtual void print(std::ostream& os) const {
- for ( unsigned i = 0; i < size(); i++ ) {
+ for (unsigned i = 0; i < size(); ++i) {
os << i << " ";
getOperand(i)->print(os);
os << "\n";
More information about the llvm-commits
mailing list