summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2011-04-01 08:00:58 +0000
committerJay Foad <jay.foad@gmail.com>2011-04-01 08:00:58 +0000
commite98f29df8b0505063348a31a26cd47275cd524ae (patch)
tree39842d7c45c7cddd9ca14236bfc294a95eab5002
parenta6a992a6627f911cc14ec7c82a3028dc96dd9a14 (diff)
downloadbcm5719-llvm-e98f29df8b0505063348a31a26cd47275cd524ae.tar.gz
bcm5719-llvm-e98f29df8b0505063348a31a26cd47275cd524ae.zip
Various Instructions' resizeOperands() methods are only used to grow the
list of operands. Simplify and rename them accordingly. llvm-svn: 128708
-rw-r--r--llvm/include/llvm/Instructions.h8
-rw-r--r--llvm/lib/VMCore/Instructions.cpp70
2 files changed, 20 insertions, 58 deletions
diff --git a/llvm/include/llvm/Instructions.h b/llvm/include/llvm/Instructions.h
index 24b59e481ca..f14893ad28f 100644
--- a/llvm/include/llvm/Instructions.h
+++ b/llvm/include/llvm/Instructions.h
@@ -1910,7 +1910,7 @@ public:
"All operands to PHI node must be the same type as the PHI node!");
unsigned OpNo = NumOperands;
if (OpNo+2 > ReservedSpace)
- resizeOperands(0); // Get more space!
+ growOperands(); // Get more space!
// Initialize some new operands.
NumOperands = OpNo+2;
OperandList[OpNo] = V;
@@ -1960,7 +1960,7 @@ public:
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
- void resizeOperands(unsigned NumOperands);
+ void growOperands();
};
template <>
@@ -2152,7 +2152,7 @@ class SwitchInst : public TerminatorInst {
// Operand[2n+1] = BasicBlock to go to on match
SwitchInst(const SwitchInst &SI);
void init(Value *Value, BasicBlock *Default, unsigned NumReserved);
- void resizeOperands(unsigned No);
+ void growOperands();
// allocate space for exactly zero operands
void *operator new(size_t s) {
return User::operator new(s, 0);
@@ -2304,7 +2304,7 @@ class IndirectBrInst : public TerminatorInst {
// Operand[2n+1] = BasicBlock to go to on match
IndirectBrInst(const IndirectBrInst &IBI);
void init(Value *Address, unsigned NumDests);
- void resizeOperands(unsigned No);
+ void growOperands();
// allocate space for exactly zero operands
void *operator new(size_t s) {
return User::operator new(s, 0);
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 622edde5124..33dfcc032af 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -131,26 +131,14 @@ Value *PHINode::removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty) {
return Removed;
}
-/// resizeOperands - resize operands - This adjusts the length of the operands
-/// list according to the following behavior:
-/// 1. If NumOps == 0, grow the operand list in response to a push_back style
-/// of operation. This grows the number of ops by 1.5 times.
-/// 2. If NumOps > NumOperands, reserve space for NumOps operands.
-/// 3. If NumOps == NumOperands, trim the reserved space.
+/// growOperands - grow operands - This grows the operand list in response
+/// to a push_back style of operation. This grows the number of ops by 1.5
+/// times.
///
-void PHINode::resizeOperands(unsigned NumOps) {
+void PHINode::growOperands() {
unsigned e = getNumOperands();
- if (NumOps == 0) {
- NumOps = e*3/2;
- if (NumOps < 4) NumOps = 4; // 4 op PHI nodes are VERY common.
- } else if (NumOps*2 > NumOperands) {
- // No resize needed.
- if (ReservedSpace >= NumOps) return;
- } else if (NumOps == NumOperands) {
- if (ReservedSpace == NumOps) return;
- } else {
- return;
- }
+ unsigned NumOps = e*3/2;
+ if (NumOps < 4) NumOps = 4; // 4 op PHI nodes are VERY common.
ReservedSpace = NumOps;
Use *OldOps = OperandList;
@@ -2998,7 +2986,7 @@ SwitchInst::~SwitchInst() {
void SwitchInst::addCase(ConstantInt *OnVal, BasicBlock *Dest) {
unsigned OpNo = NumOperands;
if (OpNo+2 > ReservedSpace)
- resizeOperands(0); // Get more space!
+ growOperands(); // Get more space!
// Initialize some new operands.
assert(OpNo+1 < ReservedSpace && "Growing didn't work!");
NumOperands = OpNo+2;
@@ -3029,25 +3017,12 @@ void SwitchInst::removeCase(unsigned idx) {
NumOperands = NumOps-2;
}
-/// resizeOperands - resize operands - This adjusts the length of the operands
-/// list according to the following behavior:
-/// 1. If NumOps == 0, grow the operand list in response to a push_back style
-/// of operation. This grows the number of ops by 3 times.
-/// 2. If NumOps > NumOperands, reserve space for NumOps operands.
-/// 3. If NumOps == NumOperands, trim the reserved space.
+/// growOperands - grow operands - This grows the operand list in response
+/// to a push_back style of operation. This grows the number of ops by 3 times.
///
-void SwitchInst::resizeOperands(unsigned NumOps) {
+void SwitchInst::growOperands() {
unsigned e = getNumOperands();
- if (NumOps == 0) {
- NumOps = e*3;
- } else if (NumOps*2 > NumOperands) {
- // No resize needed.
- if (ReservedSpace >= NumOps) return;
- } else if (NumOps == NumOperands) {
- if (ReservedSpace == NumOps) return;
- } else {
- return;
- }
+ unsigned NumOps = e*3;
ReservedSpace = NumOps;
Use *NewOps = allocHungoffUses(NumOps);
@@ -3085,25 +3060,12 @@ void IndirectBrInst::init(Value *Address, unsigned NumDests) {
}
-/// resizeOperands - resize operands - This adjusts the length of the operands
-/// list according to the following behavior:
-/// 1. If NumOps == 0, grow the operand list in response to a push_back style
-/// of operation. This grows the number of ops by 2 times.
-/// 2. If NumOps > NumOperands, reserve space for NumOps operands.
-/// 3. If NumOps == NumOperands, trim the reserved space.
+/// growOperands - grow operands - This grows the operand list in response
+/// to a push_back style of operation. This grows the number of ops by 2 times.
///
-void IndirectBrInst::resizeOperands(unsigned NumOps) {
+void IndirectBrInst::growOperands() {
unsigned e = getNumOperands();
- if (NumOps == 0) {
- NumOps = e*2;
- } else if (NumOps*2 > NumOperands) {
- // No resize needed.
- if (ReservedSpace >= NumOps) return;
- } else if (NumOps == NumOperands) {
- if (ReservedSpace == NumOps) return;
- } else {
- return;
- }
+ unsigned NumOps = e*2;
ReservedSpace = NumOps;
Use *NewOps = allocHungoffUses(NumOps);
@@ -3147,7 +3109,7 @@ IndirectBrInst::~IndirectBrInst() {
void IndirectBrInst::addDestination(BasicBlock *DestBB) {
unsigned OpNo = NumOperands;
if (OpNo+1 > ReservedSpace)
- resizeOperands(0); // Get more space!
+ growOperands(); // Get more space!
// Initialize some new operands.
assert(OpNo < ReservedSpace && "Growing didn't work!");
NumOperands = OpNo+1;
OpenPOWER on IntegriCloud