summaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-29 00:36:19 +0000
committerChris Lattner <sabre@nondot.org>2005-01-29 00:36:19 +0000
commitcad28bd3a059f25aef7edc35bf2454f21000ae85 (patch)
tree631d3ce0ee1a2a71080223ba6af75c48c7332788 /lib/Bytecode
parentce1df9e9e8eafd732dc5c23b9cf273491f91fba1 (diff)
downloadllvm-cad28bd3a059f25aef7edc35bf2454f21000ae85.tar.gz
llvm-cad28bd3a059f25aef7edc35bf2454f21000ae85.tar.bz2
llvm-cad28bd3a059f25aef7edc35bf2454f21000ae85.tar.xz
Adjust to changes in User class and minor changes in instruction ctors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19894 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Reader/Reader.cpp25
-rw-r--r--lib/Bytecode/Reader/Reader.h21
2 files changed, 25 insertions, 21 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index e9b18e0cea..a36aa99509 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -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 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
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 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
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]));
diff --git a/lib/Bytecode/Reader/Reader.h b/lib/Bytecode/Reader/Reader.h
index 06e021d482..c63fcc7e22 100644
--- a/lib/Bytecode/Reader/Reader.h
+++ b/lib/Bytecode/Reader/Reader.h
@@ -77,18 +77,23 @@ public:
/// 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";