[llvm-commits] [llvm] r128708 - in /llvm/trunk: include/llvm/Instructions.h lib/VMCore/Instructions.cpp
Jay Foad
jay.foad at gmail.com
Fri Apr 1 01:00:58 PDT 2011
Author: foad
Date: Fri Apr 1 03:00:58 2011
New Revision: 128708
URL: http://llvm.org/viewvc/llvm-project?rev=128708&view=rev
Log:
Various Instructions' resizeOperands() methods are only used to grow the
list of operands. Simplify and rename them accordingly.
Modified:
llvm/trunk/include/llvm/Instructions.h
llvm/trunk/lib/VMCore/Instructions.cpp
Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=128708&r1=128707&r2=128708&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Fri Apr 1 03:00:58 2011
@@ -1910,7 +1910,7 @@
"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 @@
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
private:
- void resizeOperands(unsigned NumOperands);
+ void growOperands();
};
template <>
@@ -2152,7 +2152,7 @@
// 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 @@
// 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);
Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=128708&r1=128707&r2=128708&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Fri Apr 1 03:00:58 2011
@@ -131,26 +131,14 @@
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 @@
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 @@
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 @@
}
-/// 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 @@
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;
More information about the llvm-commits
mailing list