[llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp Type.cpp iMemory.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Apr 4 20:32:19 PDT 2004
Changes in directory llvm/lib/VMCore:
ConstantFolding.cpp updated: 1.55 -> 1.56
Type.cpp updated: 1.98 -> 1.99
iMemory.cpp updated: 1.35 -> 1.36
---
Log message:
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.
---
Diffs of the changes: (+14 -10)
Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.55 llvm/lib/VMCore/ConstantFolding.cpp:1.56
--- llvm/lib/VMCore/ConstantFolding.cpp:1.55 Thu Mar 11 23:53:32 2004
+++ llvm/lib/VMCore/ConstantFolding.cpp Sun Apr 4 20:30:19 2004
@@ -608,10 +608,10 @@
if (!isa<ConstantInt>(C1) || !isa<ConstantInt>(C2))
return -2; // don't know!
- // Ok, we have two differing integer indices. Convert them to
- // be the same type. Long is always big enough, so we use it.
- C1 = ConstantExpr::getCast(C1, Type::LongTy);
- C2 = ConstantExpr::getCast(C2, Type::LongTy);
+ // Ok, we have two differing integer indices. Sign extend them to be the same
+ // type. Long is always big enough, so we use it.
+ C1 = ConstantExpr::getSignExtend(C1, Type::LongTy);
+ C2 = ConstantExpr::getSignExtend(C2, Type::LongTy);
if (C1 == C2) return 0; // Are they just differing types?
// If they are really different, now that they are the same type, then we
Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.98 llvm/lib/VMCore/Type.cpp:1.99
--- llvm/lib/VMCore/Type.cpp:1.98 Sun Mar 28 18:17:20 2004
+++ llvm/lib/VMCore/Type.cpp Sun Apr 4 20:30:19 2004
@@ -295,8 +295,9 @@
bool StructType::indexValid(const Value *V) const {
// Structure indexes require unsigned integer constants.
- if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V))
- return CU->getValue() < ContainedTys.size();
+ if (V->getType() == Type::UIntTy)
+ if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V))
+ return CU->getValue() < ContainedTys.size();
return false;
}
@@ -304,10 +305,8 @@
// element. For a structure type, this must be a constant value...
//
const Type *StructType::getTypeAtIndex(const Value *V) const {
- assert(isa<Constant>(V) && "Structure index must be a constant!!");
+ assert(indexValid(V) && "Invalid structure index!");
unsigned Idx = cast<ConstantUInt>(V)->getValue();
- assert(Idx < ContainedTys.size() && "Structure index out of range!");
- assert(indexValid(V) && "Invalid structure index!"); // Duplicate check
return ContainedTys[Idx];
}
Index: llvm/lib/VMCore/iMemory.cpp
diff -u llvm/lib/VMCore/iMemory.cpp:1.35 llvm/lib/VMCore/iMemory.cpp:1.36
--- llvm/lib/VMCore/iMemory.cpp:1.35 Thu Mar 11 17:53:51 2004
+++ llvm/lib/VMCore/iMemory.cpp Sun Apr 4 20:30:19 2004
@@ -137,7 +137,12 @@
if (!isa<PointerType>(Ptr)) return 0; // Type isn't a pointer type!
// Handle the special case of the empty set index set...
- if (Idx.empty()) return cast<PointerType>(Ptr)->getElementType();
+ if (Idx.empty())
+ if (AllowCompositeLeaf ||
+ cast<PointerType>(Ptr)->getElementType()->isFirstClassType())
+ return cast<PointerType>(Ptr)->getElementType();
+ else
+ return 0;
unsigned CurIdx = 0;
while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) {
More information about the llvm-commits
mailing list