summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Sparc
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-07-23 15:22:26 +0000
committerChris Lattner <sabre@nondot.org>2003-07-23 15:22:26 +0000
commit6077c3195f74b27b75ed3e9df3af7a13798b437f (patch)
tree48a5a2e54b7d1a5762d782e838db817d8a2e78ca /llvm/lib/Target/Sparc
parent79f22fe02fe354c50fc4d6a1c08a894fdd847dba (diff)
downloadbcm5719-llvm-6077c3195f74b27b75ed3e9df3af7a13798b437f.tar.gz
bcm5719-llvm-6077c3195f74b27b75ed3e9df3af7a13798b437f.zip
Simplify code by using ConstantInt::getRawValue instead of checking to see
whether the constant is signed or unsigned, then casting llvm-svn: 7252
Diffstat (limited to 'llvm/lib/Target/Sparc')
-rw-r--r--llvm/lib/Target/Sparc/EmitAssembly.cpp4
-rw-r--r--llvm/lib/Target/Sparc/SparcInstrInfo.cpp16
2 files changed, 6 insertions, 14 deletions
diff --git a/llvm/lib/Target/Sparc/EmitAssembly.cpp b/llvm/lib/Target/Sparc/EmitAssembly.cpp
index 6080e99e73f..019d447e502 100644
--- a/llvm/lib/Target/Sparc/EmitAssembly.cpp
+++ b/llvm/lib/Target/Sparc/EmitAssembly.cpp
@@ -585,9 +585,7 @@ static string getAsCString(const ConstantArray *CVA) {
const Type *ETy = cast<ArrayType>(CVA->getType())->getElementType();
Result = "\"";
for (unsigned i = 0; i < CVA->getNumOperands(); ++i) {
- unsigned char C = (ETy == Type::SByteTy) ?
- (unsigned char)cast<ConstantSInt>(CVA->getOperand(i))->getValue() :
- (unsigned char)cast<ConstantUInt>(CVA->getOperand(i))->getValue();
+ unsigned char C = cast<ConstantInt>(CVA->getOperand(i))->getRawValue();
if (C == '"') {
Result += "\\\"";
diff --git a/llvm/lib/Target/Sparc/SparcInstrInfo.cpp b/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
index 75bea0d7774..39d6dcc6a15 100644
--- a/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
+++ b/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
@@ -43,10 +43,8 @@ GetConstantValueAsUnsignedInt(const Value *V,
if (isa<Constant>(V))
if (const ConstantBool *CB = dyn_cast<ConstantBool>(V))
return (int64_t)CB->getValue();
- else if (const ConstantSInt *CS = dyn_cast<ConstantSInt>(V))
- return (uint64_t)CS->getValue();
- else if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V))
- return CU->getValue();
+ else if (const ConstantInt *CI = dyn_cast<ConstantInt>(V))
+ return CI->getRawValue();
isValidConstant = false;
return 0;
@@ -377,15 +375,11 @@ UltraSparcInstrInfo::ConstantMayNotFitInImmedField(const Constant* CV,
if (isa<ConstantPointerNull>(CV)) // can always use %g0
return false;
- if (const ConstantUInt* U = dyn_cast<ConstantUInt>(CV))
- /* 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()) > MaxConstantsTable[I->getOpcode()]);
+ if (const ConstantInt* CI = dyn_cast<ConstantInt>(CV))
+ return labs((int64_t)CI->getRawValue()) > MaxConstantsTable[I->getOpcode()];
if (isa<ConstantBool>(CV))
- return (1 > MaxConstantsTable[I->getOpcode()]);
+ return 1 > MaxConstantsTable[I->getOpcode()];
return true;
}
OpenPOWER on IntegriCloud