[llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Printer.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jul 23 10:23:33 PDT 2003
Changes in directory llvm/lib/Target/X86:
InstSelectSimple.cpp updated: 1.114 -> 1.115
Printer.cpp updated: 1.44 -> 1.45
---
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/X86/InstSelectSimple.cpp
diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.114 llvm/lib/Target/X86/InstSelectSimple.cpp:1.115
--- llvm/lib/Target/X86/InstSelectSimple.cpp:1.114 Fri Jul 18 15:23:43 2003
+++ llvm/lib/Target/X86/InstSelectSimple.cpp Wed Jul 23 10:22:21 2003
@@ -343,12 +343,7 @@
if (Class == cLong) {
// Copy the value into the register pair.
- uint64_t Val;
- if (C->getType()->isSigned())
- Val = cast<ConstantSInt>(C)->getValue();
- else
- Val = cast<ConstantUInt>(C)->getValue();
-
+ uint64_t Val = cast<ConstantInt>(C)->getRawValue();
BMI(MBB, IP, X86::MOVir32, 1, R).addZImm(Val & 0xFFFFFFFF);
BMI(MBB, IP, X86::MOVir32, 1, R+1).addZImm(Val >> 32);
return;
@@ -362,12 +357,9 @@
if (C->getType() == Type::BoolTy) {
BMI(MBB, IP, X86::MOVir8, 1, R).addZImm(C == ConstantBool::True);
- } else if (C->getType()->isSigned()) {
- ConstantSInt *CSI = cast<ConstantSInt>(C);
- BMI(MBB, IP, IntegralOpcodeTab[Class], 1, R).addZImm(CSI->getValue());
} else {
- ConstantUInt *CUI = cast<ConstantUInt>(C);
- BMI(MBB, IP, IntegralOpcodeTab[Class], 1, R).addZImm(CUI->getValue());
+ ConstantInt *CI = cast<ConstantInt>(C);
+ BMI(MBB, IP, IntegralOpcodeTab[Class], 1, R).addZImm(CI->getRawValue());
}
} else if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
double Value = CFP->getValue();
@@ -585,11 +577,8 @@
// Special case handling of: cmp R, i
if (Class == cByte || Class == cShort || Class == cInt)
if (ConstantInt *CI = dyn_cast<ConstantInt>(Op1)) {
- uint64_t Op1v;
- if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(CI))
- Op1v = CSI->getValue();
- else
- Op1v = cast<ConstantUInt>(CI)->getValue();
+ uint64_t Op1v = cast<ConstantInt>(CI)->getRawValue();
+
// Mask off any upper bits of the constant, if there are any...
Op1v &= (1ULL << (8 << Class)) - 1;
@@ -1061,11 +1050,7 @@
assert(Class < 3 && "General code handles 64-bit integer types!");
unsigned Opcode = OpcodeTab[OperatorClass][Class];
unsigned Op0r = getReg(Op0, BB, IP);
- uint64_t Op1v;
- if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(Op1C))
- Op1v = CSI->getValue();
- else
- Op1v = cast<ConstantUInt>(Op1C)->getValue();
+ uint64_t Op1v = cast<ConstantInt>(Op1C)->getRawValue();
// Mask off any upper bits of the constant, if there are any...
Op1v &= (1ULL << (8 << Class)) - 1;
@@ -2082,8 +2067,6 @@
unsigned Op1Reg = getReg(I.getOperand(0));
MachineBasicBlock::iterator MBBI = BB->end();
doMultiply(BB, MBBI, Arg, Type::UIntTy, Op0Reg, Op1Reg);
-
-
}
std::vector<ValueRecord> Args;
Index: llvm/lib/Target/X86/Printer.cpp
diff -u llvm/lib/Target/X86/Printer.cpp:1.44 llvm/lib/Target/X86/Printer.cpp:1.45
--- llvm/lib/Target/X86/Printer.cpp:1.44 Fri Jul 11 16:57:01 2003
+++ llvm/lib/Target/X86/Printer.cpp Wed Jul 23 10:22:22 2003
@@ -293,9 +293,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 += "\\\"";
@@ -943,19 +941,14 @@
return false; // success
}
-static const Function *isConstantFunctionPointerRef (const Constant *C) {
- const ConstantPointerRef *R = dyn_cast<ConstantPointerRef>(C);
- if (R) {
- const Function *F = dyn_cast<Function>(R->getValue());
- if (F) {
+static const Function *isConstantFunctionPointerRef(const Constant *C) {
+ if (const ConstantPointerRef *R = dyn_cast<ConstantPointerRef>(C))
+ if (const Function *F = dyn_cast<Function>(R->getValue()))
return F;
- }
- }
- return NULL;
+ return 0;
}
-bool Printer::doFinalization(Module &M)
-{
+bool Printer::doFinalization(Module &M) {
// Print out module-level global variables here.
for (Module::const_giterator I = M.gbegin(), E = M.gend(); I != E; ++I) {
std::string name(getValueName(I));
@@ -989,5 +982,3 @@
MangledGlobals.clear();
return false; // success
}
-
-
More information about the llvm-commits
mailing list