diff options
author | Chris Lattner <sabre@nondot.org> | 2003-07-23 15:22:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-07-23 15:22:26 +0000 |
commit | 6077c3195f74b27b75ed3e9df3af7a13798b437f (patch) | |
tree | 48a5a2e54b7d1a5762d782e838db817d8a2e78ca /llvm/lib/Target/X86/InstSelectSimple.cpp | |
parent | 79f22fe02fe354c50fc4d6a1c08a894fdd847dba (diff) | |
download | bcm5719-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/X86/InstSelectSimple.cpp')
-rw-r--r-- | llvm/lib/Target/X86/InstSelectSimple.cpp | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/llvm/lib/Target/X86/InstSelectSimple.cpp b/llvm/lib/Target/X86/InstSelectSimple.cpp index ec8313eda42..1562c8483d8 100644 --- a/llvm/lib/Target/X86/InstSelectSimple.cpp +++ b/llvm/lib/Target/X86/InstSelectSimple.cpp @@ -343,12 +343,7 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB, 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 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB, 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 @@ bool ISel::EmitComparisonGetSignedness(unsigned OpNum, Value *Op0, Value *Op1) { // 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 @@ void ISel::emitSimpleBinaryOperation(MachineBasicBlock *BB, 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 @@ void ISel::visitMallocInst(MallocInst &I) { unsigned Op1Reg = getReg(I.getOperand(0)); MachineBasicBlock::iterator MBBI = BB->end(); doMultiply(BB, MBBI, Arg, Type::UIntTy, Op0Reg, Op1Reg); - - } std::vector<ValueRecord> Args; |