Use an array instead of a fixed-length std::vector.

llvm-svn: 43467
This commit is contained in:
Dan Gohman 2007-10-29 20:24:00 +00:00
parent d9911e21df
commit 3bcd5fe9f1
1 changed files with 8 additions and 6 deletions

View File

@ -22,6 +22,7 @@
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"
#include "llvm/Support/InstVisitor.h" #include "llvm/Support/InstVisitor.h"
#include "llvm/Support/Streams.h" #include "llvm/Support/Streams.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include <algorithm> #include <algorithm>
#include <map> #include <map>
@ -75,8 +76,9 @@ public:
/// @param IE the insertelement operator to convert /// @param IE the insertelement operator to convert
void visitInsertElementInst(InsertElementInst& IE); void visitInsertElementInst(InsertElementInst& IE);
/// This function asserts if the instruction is a VectorType but /// This function asserts that the given instruction does not have
/// is not handled by another function. /// vector type. Instructions with vector type should be handled by
/// the other functions in this class.
/// ///
/// @brief Asserts if VectorType instruction is not handled elsewhere. /// @brief Asserts if VectorType instruction is not handled elsewhere.
/// @param I the unhandled instruction /// @param I the unhandled instruction
@ -214,7 +216,7 @@ void LowerPacked::visitLoadInst(LoadInst& LI)
// Make sure what we are dealing with is a vector type // Make sure what we are dealing with is a vector type
if (const VectorType* PKT = dyn_cast<VectorType>(LI.getType())) { if (const VectorType* PKT = dyn_cast<VectorType>(LI.getType())) {
// Initialization, Idx is needed for getelementptr needed later // Initialization, Idx is needed for getelementptr needed later
std::vector<Value*> Idx(2); Value *Idx[2];
Idx[0] = ConstantInt::get(Type::Int32Ty,0); Idx[0] = ConstantInt::get(Type::Int32Ty,0);
ArrayType* AT = ArrayType::get(PKT->getContainedType(0), ArrayType* AT = ArrayType::get(PKT->getContainedType(0),
@ -235,7 +237,7 @@ void LowerPacked::visitLoadInst(LoadInst& LI)
// Get the pointer // Get the pointer
Value* val = new GetElementPtrInst(array, Value* val = new GetElementPtrInst(array,
Idx.begin(), Idx.end(), Idx, array_endof(Idx),
LI.getName() + LI.getName() +
".ge." + utostr(i), ".ge." + utostr(i),
&LI); &LI);
@ -313,7 +315,7 @@ void LowerPacked::visitStoreInst(StoreInst& SI)
if (const VectorType* PKT = if (const VectorType* PKT =
dyn_cast<VectorType>(SI.getOperand(0)->getType())) { dyn_cast<VectorType>(SI.getOperand(0)->getType())) {
// We will need this for getelementptr // We will need this for getelementptr
std::vector<Value*> Idx(2); Value *Idx[2];
Idx[0] = ConstantInt::get(Type::Int32Ty,0); Idx[0] = ConstantInt::get(Type::Int32Ty,0);
ArrayType* AT = ArrayType::get(PKT->getContainedType(0), ArrayType* AT = ArrayType::get(PKT->getContainedType(0),
@ -333,7 +335,7 @@ void LowerPacked::visitStoreInst(StoreInst& SI)
// Generate the indices for getelementptr // Generate the indices for getelementptr
Idx[1] = ConstantInt::get(Type::Int32Ty,i); Idx[1] = ConstantInt::get(Type::Int32Ty,i);
Value* val = new GetElementPtrInst(array, Value* val = new GetElementPtrInst(array,
Idx.begin(), Idx.end(), Idx, array_endof(Idx),
"store.ge." + "store.ge." +
utostr(i) + ".", utostr(i) + ".",
&SI); &SI);