aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-09-11 01:21:29 +0000
committerChris Lattner <sabre@nondot.org>2002-09-11 01:21:29 +0000
commit106ff4551c9c35bb6bcbdd6ca50543b100a7658e (patch)
treeecc29951a8648a0ca42426f152de89d8d6127539 /lib/Target
parent562219de55f007b0dbd3aeffad888e530a8faad4 (diff)
downloadexternal_llvm-106ff4551c9c35bb6bcbdd6ca50543b100a7658e.tar.gz
external_llvm-106ff4551c9c35bb6bcbdd6ca50543b100a7658e.tar.bz2
external_llvm-106ff4551c9c35bb6bcbdd6ca50543b100a7658e.zip
- Change getelementptr instruction to use long indexes instead of uint
indexes for sequential types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3681 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/CBackend/CBackend.cpp4
-rw-r--r--lib/Target/CBackend/Writer.cpp4
-rw-r--r--lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp16
3 files changed, 12 insertions, 12 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 941af03af2..bc3829f67c 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -916,7 +916,7 @@ void CWriter::printIndexingExpression(Value *Ptr, User::op_iterator I,
}
for (; I != E; ++I)
- if ((*I)->getType() == Type::UIntTy) {
+ if ((*I)->getType() == Type::LongTy) {
Out << "[((int) ("; // sign-extend from 32 (to 64) bits
writeOperand(*I);
Out << " * sizeof(";
@@ -925,7 +925,7 @@ void CWriter::printIndexingExpression(Value *Ptr, User::op_iterator I,
printType(cast<PointerType>(Ptr->getType())->getElementType());
Out << ")]";
} else {
- Out << ".field" << cast<ConstantUInt>(*I)->getValue();
+ Out << ".field" << cast<ConstantSInt>(*I)->getValue();
}
}
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index 941af03af2..bc3829f67c 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -916,7 +916,7 @@ void CWriter::printIndexingExpression(Value *Ptr, User::op_iterator I,
}
for (; I != E; ++I)
- if ((*I)->getType() == Type::UIntTy) {
+ if ((*I)->getType() == Type::LongTy) {
Out << "[((int) ("; // sign-extend from 32 (to 64) bits
writeOperand(*I);
Out << " * sizeof(";
@@ -925,7 +925,7 @@ void CWriter::printIndexingExpression(Value *Ptr, User::op_iterator I,
printType(cast<PointerType>(Ptr->getType())->getElementType());
Out << ")]";
} else {
- Out << ".field" << cast<ConstantUInt>(*I)->getValue();
+ Out << ".field" << cast<ConstantSInt>(*I)->getValue();
}
}
diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
index 870bbbd787..036b1a7f3f 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
@@ -113,12 +113,12 @@ static Value*
FoldGetElemChain(InstrTreeNode* ptrNode, vector<Value*>& chainIdxVec)
{
InstructionNode* gepNode = dyn_cast<InstructionNode>(ptrNode);
- if (gepNode == NULL)
- return NULL; // ptr value is not computed in this tree
-
GetElementPtrInst* gepInst =
- dyn_cast<GetElementPtrInst>(gepNode->getInstruction());
- if (gepInst == NULL) // ptr value does not come from GEP instruction
+ dyn_cast_or_null<GetElementPtrInst>(gepNode->getInstruction());
+
+ // ptr value is not computed in this tree or ptr value does not come from GEP
+ // instruction
+ if (gepInst == NULL)
return NULL;
// Return NULL if we don't fold any instructions in.
@@ -149,8 +149,8 @@ FoldGetElemChain(InstrTreeNode* ptrNode, vector<Value*>& chainIdxVec)
ptrVal = gepInst->getPointerOperand();
// Check for a leading [0] index, if any. It will be discarded later.
- ConstantUInt* CV = dyn_cast<ConstantUInt>((Value*) *firstIdx);
- hasLeadingZero = bool(CV && CV->getValue() == 0);
+ hasLeadingZero = (*firstIdx ==
+ Constant::getNullValue((*firstIdx)->getType()));
// Insert its index vector at the start, skipping any leading [0]
chainIdxVec.insert(chainIdxVec.begin(),
@@ -168,7 +168,7 @@ FoldGetElemChain(InstrTreeNode* ptrNode, vector<Value*>& chainIdxVec)
// If the first getElementPtr instruction had a leading [0], add it back.
// Note that this instruction is the *last* one successfully folded above.
if (ptrVal && hasLeadingZero)
- chainIdxVec.insert(chainIdxVec.begin(), ConstantUInt::get(Type::UIntTy,0));
+ chainIdxVec.insert(chainIdxVec.begin(), ConstantSInt::get(Type::LongTy,0));
return ptrVal;
}