diff options
author | Chris Lattner <sabre@nondot.org> | 2004-04-05 01:30:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-04-05 01:30:19 +0000 |
commit | 28977af72a11fcad5d1b54d7a96b3df02828f6fc (patch) | |
tree | 671a8fa4df839cb653ebd22dda8fa39639b3afa7 /lib/Transforms/ExprTypeConvert.cpp | |
parent | 830b6f98686f40f86811dceb5497433ebac385e1 (diff) |
Support getelementptr instructions which use uint's to index into structure
types and can have arbitrary 32- and 64-bit integer types indexing into
sequential types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12653 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/ExprTypeConvert.cpp')
-rw-r--r-- | lib/Transforms/ExprTypeConvert.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index b30ddf1f29..bde24f0158 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -797,10 +797,13 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty, // stream, so we have to delete it when we're done. // if (DataSize != 1) { - // FIXME, PR82 - TempScale = BinaryOperator::create(Instruction::Mul, Index, - ConstantSInt::get(Type::LongTy, - DataSize)); + Value *CST; + if (Index->getType()->isSigned()) + CST = ConstantSInt::get(Index->getType(), DataSize); + else + CST = ConstantUInt::get(Index->getType(), DataSize); + + TempScale = BinaryOperator::create(Instruction::Mul, Index, CST); Index = TempScale; } @@ -1012,8 +1015,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) { std::vector<Value*> Indices; - // FIXME, PR82 - Indices.push_back(ConstantSInt::get(Type::LongTy, 0)); + Indices.push_back(Constant::getNullValue(Type::UIntTy)); unsigned Offset = 0; // No offset, get first leaf. LoadedTy = getStructOffsetType(CT, Offset, Indices, TD, false); @@ -1049,8 +1051,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, const StructType *SElTy = cast<StructType>(ElTy); std::vector<Value*> Indices; - // FIXME, PR82 - Indices.push_back(Constant::getNullValue(Type::LongTy)); + Indices.push_back(Constant::getNullValue(Type::UIntTy)); unsigned Offset = 0; const Type *Ty = getStructOffsetType(ElTy, Offset, Indices, TD,false); @@ -1079,8 +1080,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, if (isa<StructType>(ValTy)) { std::vector<Value*> Indices; - // FIXME: PR82 - Indices.push_back(Constant::getNullValue(Type::LongTy)); + Indices.push_back(Constant::getNullValue(Type::UIntTy)); unsigned Offset = 0; ValTy = getStructOffsetType(ValTy, Offset, Indices, TD, false); @@ -1112,10 +1112,13 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, if (DataSize != 1) { // Insert a multiply of the old element type is not a unit size... - Index = BinaryOperator::create(Instruction::Mul, Index, - // FIXME: PR82 - ConstantSInt::get(Type::LongTy, DataSize), - "scale", It); + Value *CST; + if (Index->getType()->isSigned()) + CST = ConstantSInt::get(Index->getType(), DataSize); + else + CST = ConstantUInt::get(Index->getType(), DataSize); + + Index = BinaryOperator::create(Instruction::Mul, Index, CST, "scale", It); } // Perform the conversion now... |