[llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp LevelRaise.cpp TransformInternals.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Sep 10 20:22:15 PDT 2002
Changes in directory llvm/lib/Transforms:
ExprTypeConvert.cpp updated: 1.56 -> 1.57
LevelRaise.cpp updated: 1.69 -> 1.70
TransformInternals.cpp updated: 1.28 -> 1.29
---
Log message:
- Change getelementptr instruction to use long indexes instead of uint
indexes for sequential types.
---
Diffs of the changes:
Index: llvm/lib/Transforms/ExprTypeConvert.cpp
diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.56 llvm/lib/Transforms/ExprTypeConvert.cpp:1.57
--- llvm/lib/Transforms/ExprTypeConvert.cpp:1.56 Tue Sep 10 17:52:51 2002
+++ llvm/lib/Transforms/ExprTypeConvert.cpp Tue Sep 10 20:21:23 2002
@@ -233,8 +233,8 @@
const Type *BaseType = GEP->getPointerOperand()->getType();
const Type *ElTy = 0;
- while (!Indices.empty() && isa<ConstantUInt>(Indices.back()) &&
- cast<ConstantUInt>(Indices.back())->getValue() == 0) {
+ while (!Indices.empty() &&
+ Indices.back() == Constant::getNullValue(Indices.back()->getType())){
Indices.pop_back();
ElTy = GetElementPtrInst::getIndexedType(BaseType, Indices, true);
if (ElTy == PVTy)
@@ -245,11 +245,11 @@
if (ElTy) break; // Found a number of zeros we can strip off!
// Otherwise, we can convert a GEP from one form to the other iff the
- // current gep is of the form 'getelementptr sbyte*, unsigned N
+ // current gep is of the form 'getelementptr sbyte*, long N
// and we could convert this to an appropriate GEP for the new type.
//
if (GEP->getNumOperands() == 2 &&
- GEP->getOperand(1)->getType() == Type::UIntTy &&
+ GEP->getOperand(1)->getType() == Type::LongTy &&
GEP->getType() == PointerType::get(Type::SByteTy)) {
// Do not Check to see if our incoming pointer can be converted
@@ -272,12 +272,12 @@
}
// Otherwise, it could be that we have something like this:
- // getelementptr [[sbyte] *] * %reg115, uint %reg138 ; [sbyte]**
+ // getelementptr [[sbyte] *] * %reg115, long %reg138 ; [sbyte]**
// and want to convert it into something like this:
- // getelemenptr [[int] *] * %reg115, uint %reg138 ; [int]**
+ // getelemenptr [[int] *] * %reg115, long %reg138 ; [int]**
//
if (GEP->getNumOperands() == 2 &&
- GEP->getOperand(1)->getType() == Type::UIntTy &&
+ GEP->getOperand(1)->getType() == Type::LongTy &&
TD.getTypeSize(PTy->getElementType()) ==
TD.getTypeSize(GEP->getType()->getElementType())) {
const PointerType *NewSrcTy = PointerType::get(PVTy);
@@ -425,21 +425,20 @@
const Type *BaseType = GEP->getPointerOperand()->getType();
const Type *PVTy = cast<PointerType>(Ty)->getElementType();
Res = 0;
- while (!Indices.empty() && isa<ConstantUInt>(Indices.back()) &&
- cast<ConstantUInt>(Indices.back())->getValue() == 0) {
+ while (!Indices.empty() &&
+ Indices.back() == Constant::getNullValue(Indices.back()->getType())){
Indices.pop_back();
if (GetElementPtrInst::getIndexedType(BaseType, Indices, true) == PVTy) {
- if (Indices.size() == 0) {
- Res = new CastInst(GEP->getPointerOperand(), BaseType); // NOOP
- } else {
+ if (Indices.size() == 0)
+ Res = new CastInst(GEP->getPointerOperand(), BaseType); // NOOP CAST
+ else
Res = new GetElementPtrInst(GEP->getPointerOperand(), Indices, Name);
- }
break;
}
}
if (Res == 0 && GEP->getNumOperands() == 2 &&
- GEP->getOperand(1)->getType() == Type::UIntTy &&
+ GEP->getOperand(1)->getType() == Type::LongTy &&
GEP->getType() == PointerType::get(Type::SByteTy)) {
// Otherwise, we can convert a GEP from one form to the other iff the
@@ -749,7 +748,7 @@
//
if (DataSize != 1) {
TempScale = BinaryOperator::create(Instruction::Mul, Index,
- ConstantUInt::get(Type::UIntTy,
+ ConstantSInt::get(Type::LongTy,
DataSize));
Index = TempScale;
}
@@ -952,7 +951,7 @@
if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) {
std::vector<Value*> Indices;
- Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ Indices.push_back(ConstantSInt::get(Type::LongTy, 0));
unsigned Offset = 0; // No offset, get first leaf.
LoadedTy = getStructOffsetType(CT, Offset, Indices, false);
@@ -988,7 +987,7 @@
const StructType *SElTy = cast<StructType>(ElTy);
std::vector<Value*> Indices;
- Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ Indices.push_back(Constant::getNullValue(Type::LongTy));
unsigned Offset = 0;
const Type *Ty = getStructOffsetType(ElTy, Offset, Indices, false);
@@ -1017,7 +1016,7 @@
if (isa<StructType>(ValTy)) {
std::vector<Value*> Indices;
- Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ Indices.push_back(Constant::getNullValue(Type::LongTy));
unsigned Offset = 0;
ValTy = getStructOffsetType(ValTy, Offset, Indices, false);
@@ -1049,7 +1048,7 @@
if (DataSize != 1) {
// Insert a multiply of the old element type is not a unit size...
Index = BinaryOperator::create(Instruction::Mul, Index,
- ConstantUInt::get(Type::UIntTy, DataSize),
+ ConstantSInt::get(Type::LongTy, DataSize),
"scale", It);
}
Index: llvm/lib/Transforms/LevelRaise.cpp
diff -u llvm/lib/Transforms/LevelRaise.cpp:1.69 llvm/lib/Transforms/LevelRaise.cpp:1.70
--- llvm/lib/Transforms/LevelRaise.cpp:1.69 Tue Sep 10 12:02:54 2002
+++ llvm/lib/Transforms/LevelRaise.cpp Tue Sep 10 20:21:23 2002
@@ -323,7 +323,7 @@
// Build the index vector, full of all zeros
std::vector<Value*> Indices;
- Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ Indices.push_back(ConstantSInt::get(Type::LongTy, 0));
while (CurCTy && !isa<PointerType>(CurCTy)) {
if (const StructType *CurSTy = dyn_cast<StructType>(CurCTy)) {
// Check for a zero element struct type... if we have one, bail.
@@ -338,7 +338,7 @@
}
// Insert a zero to index through this type...
- Indices.push_back(ConstantUInt::get(CurCTy->getIndexType(), 0));
+ Indices.push_back(Constant::getNullValue(CurCTy->getIndexType()));
// Did we find what we're looking for?
if (ElTy->isLosslesslyConvertableTo(DestPointedTy)) break;
Index: llvm/lib/Transforms/TransformInternals.cpp
diff -u llvm/lib/Transforms/TransformInternals.cpp:1.28 llvm/lib/Transforms/TransformInternals.cpp:1.29
--- llvm/lib/Transforms/TransformInternals.cpp:1.28 Tue Sep 10 12:02:55 2002
+++ llvm/lib/Transforms/TransformInternals.cpp Tue Sep 10 20:21:23 2002
@@ -66,7 +66,7 @@
NextType = ATy->getElementType();
unsigned ChildSize = TD.getTypeSize(NextType);
- Indices.push_back(ConstantUInt::get(Type::UIntTy, Offset/ChildSize));
+ Indices.push_back(ConstantSInt::get(Type::LongTy, Offset/ChildSize));
ThisOffset = (Offset/ChildSize)*ChildSize;
} else {
Offset = 0; // Return the offset that we were able to acheive
@@ -141,13 +141,13 @@
if (BI) { // Generate code?
BasicBlock *BB = (*BI)->getParent();
- if (Expr.Var->getType() != Type::UIntTy)
- Expr.Var = new CastInst(Expr.Var, Type::UIntTy,
+ if (Expr.Var->getType() != Type::LongTy)
+ Expr.Var = new CastInst(Expr.Var, Type::LongTy,
Expr.Var->getName()+"-idxcast", *BI);
if (ScaleAmt && ScaleAmt != 1) {
// If we have to scale up our index, do so now
- Value *ScaleAmtVal = ConstantUInt::get(Type::UIntTy,
+ Value *ScaleAmtVal = ConstantSInt::get(Type::LongTy,
(unsigned)ScaleAmt);
Expr.Var = BinaryOperator::create(Instruction::Mul, Expr.Var,
ScaleAmtVal,
@@ -155,7 +155,7 @@
}
if (Index) { // Add an offset to the index
- Value *IndexAmt = ConstantUInt::get(Type::UIntTy, (unsigned)Index);
+ Value *IndexAmt = ConstantSInt::get(Type::LongTy, (unsigned)Index);
Expr.Var = BinaryOperator::create(Instruction::Add, Expr.Var,
IndexAmt,
Expr.Var->getName()+"-offset",
@@ -168,14 +168,14 @@
} else if (Offset >= (int)ElSize || -Offset >= (int)ElSize) {
// Calculate the index that we are entering into the array cell with
unsigned Index = Offset/ElSize;
- Indices.push_back(ConstantUInt::get(Type::UIntTy, Index));
+ Indices.push_back(ConstantSInt::get(Type::LongTy, Index));
Offset -= (int)(Index*ElSize); // Consume part of the offset
} else if (isa<ArrayType>(CompTy) || Indices.empty()) {
// Must be indexing a small amount into the first cell of the array
// Just index into element zero of the array here.
//
- Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+ Indices.push_back(ConstantSInt::get(Type::LongTy, 0));
} else {
return 0; // Hrm. wierd, can't handle this case. Bail
}
More information about the llvm-commits
mailing list