summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Sparc
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-10-13 00:04:26 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-10-13 00:04:26 +0000
commitea31dc707f5646ebdadbc13da0b50b8615fad1ae (patch)
tree38d8a93d8442776cbb7fd82a453b61f70af64e4f /llvm/lib/Target/Sparc
parent4ef6cce821d7f29b61991f1b19c62e7cb282d4da (diff)
downloadbcm5719-llvm-ea31dc707f5646ebdadbc13da0b50b8615fad1ae.tar.gz
bcm5719-llvm-ea31dc707f5646ebdadbc13da0b50b8615fad1ae.zip
Make sure to handle small negative values hiding as large unsigned longs --
this is a common case created by the front-end. llvm-svn: 4127
Diffstat (limited to 'llvm/lib/Target/Sparc')
-rw-r--r--llvm/lib/Target/Sparc/SparcInstrInfo.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Target/Sparc/SparcInstrInfo.cpp b/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
index 993f2a2ffa1..148b76ef5a0 100644
--- a/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
+++ b/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
@@ -266,7 +266,7 @@ CreateIntSetInstruction(const TargetMachine& target,
// Entry == 0 ==> no immediate constant field exists at all.
// Entry > 0 ==> abs(immediate constant) <= Entry
//
-vector<unsigned int> MaxConstantsTable(Instruction::NumOtherOps);
+vector<int> MaxConstantsTable(Instruction::NumOtherOps);
static int
MaxConstantForInstr(unsigned llvmOpCode)
@@ -343,13 +343,14 @@ UltraSparcInstrInfo::ConstantMayNotFitInImmedField(const Constant* CV,
return false;
if (const ConstantUInt* U = dyn_cast<ConstantUInt>(CV))
- return (U->getValue() > MaxConstantsTable[I->getOpcode()]);
+ /* Large unsigned longs may really just be small negative signed longs */
+ return (labs((int64_t) U->getValue()) > MaxConstantsTable[I->getOpcode()]);
if (const ConstantSInt* S = dyn_cast<ConstantSInt>(CV))
- return (labs(S->getValue()) > (int) MaxConstantsTable[I->getOpcode()]);
+ return (labs(S->getValue()) > MaxConstantsTable[I->getOpcode()]);
if (isa<ConstantBool>(CV))
- return (1U > MaxConstantsTable[I->getOpcode()]);
+ return (1 > MaxConstantsTable[I->getOpcode()]);
return true;
}
@@ -380,6 +381,11 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(const TargetMachine& target,
//
const Type* valType = val->getType();
+ // Unfortunate special case: a ConstantPointerRef is just a
+ // reference to GlobalValue.
+ if (isa<ConstantPointerRef>(val))
+ val = cast<ConstantPointerRef>(val)->getValue();
+
if (isa<GlobalValue>(val))
{
TmpInstruction* tmpReg =
OpenPOWER on IntegriCloud