[llvm-commits] CVS: llvm/lib/Target/Sparc/EmitAssembly.cpp SparcInstrInfo.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jul 23 10:23:40 PDT 2003
Changes in directory llvm/lib/Target/Sparc:
EmitAssembly.cpp updated: 1.82 -> 1.83
SparcInstrInfo.cpp updated: 1.49 -> 1.50
---
Log message:
Simplify code by using ConstantInt::getRawValue instead of checking to see
whether the constant is signed or unsigned, then casting
---
Diffs of the changes:
Index: llvm/lib/Target/Sparc/EmitAssembly.cpp
diff -u llvm/lib/Target/Sparc/EmitAssembly.cpp:1.82 llvm/lib/Target/Sparc/EmitAssembly.cpp:1.83
--- llvm/lib/Target/Sparc/EmitAssembly.cpp:1.82 Mon Jul 14 12:17:50 2003
+++ llvm/lib/Target/Sparc/EmitAssembly.cpp Wed Jul 23 10:22:19 2003
@@ -585,9 +585,7 @@
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 += "\\\"";
Index: llvm/lib/Target/Sparc/SparcInstrInfo.cpp
diff -u llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.49 llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.50
--- llvm/lib/Target/Sparc/SparcInstrInfo.cpp:1.49 Thu Jul 10 14:48:19 2003
+++ llvm/lib/Target/Sparc/SparcInstrInfo.cpp Wed Jul 23 10:22:19 2003
@@ -43,10 +43,8 @@
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 @@
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;
}
More information about the llvm-commits
mailing list