From 8234b04143f13fba33103f7a5e6dffe5545da04a Mon Sep 17 00:00:00 2001 From: "Vikram S. Adve" Date: Sat, 15 Dec 2001 00:33:36 +0000 Subject: [PATCH] Remove int hack to allow unsigned numbers greater than 2^63 - 1... llvm-svn: 1483 --- llvm/lib/Target/Sparc/SparcInstrInfo.cpp | 41 ++++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Target/Sparc/SparcInstrInfo.cpp b/llvm/lib/Target/Sparc/SparcInstrInfo.cpp index 13e6f5421976..99bb14d12ed2 100644 --- a/llvm/lib/Target/Sparc/SparcInstrInfo.cpp +++ b/llvm/lib/Target/Sparc/SparcInstrInfo.cpp @@ -26,7 +26,7 @@ static inline MachineInstr* -CreateIntSetInstruction(int64_t C, bool isSigned, Value* dest, +CreateIntSetInstruction(int64_t C, Value* dest, vector& tempVec) { MachineInstr* minstr; @@ -43,12 +43,33 @@ CreateIntSetInstruction(int64_t C, bool isSigned, Value* dest, /*isdef*/ true); minstr->SetMachineOperand(2, MachineOperand::MO_VirtualRegister,dest); } - if (isSigned) + else { minstr = new MachineInstr(SETSW); minstr->SetMachineOperand(0, MachineOperand::MO_SignExtendedImmed, C); minstr->SetMachineOperand(1, MachineOperand::MO_VirtualRegister, dest); } + + return minstr; +} + +static inline MachineInstr* +CreateUIntSetInstruction(uint64_t C, Value* dest, + vector& tempVec) +{ + MachineInstr* minstr; + if (C > (unsigned int) ~0) + { // C does not fit in 32 bits + TmpInstruction* tmpReg = + new TmpInstruction(Instruction::UserOp1, Type::IntTy, NULL, NULL); + tempVec.push_back(tmpReg); + + minstr = new MachineInstr(SETX); + minstr->SetMachineOperand(0, MachineOperand::MO_SignExtendedImmed, C); + minstr->SetMachineOperand(1, MachineOperand::MO_VirtualRegister, tmpReg, + /*isdef*/ true); + minstr->SetMachineOperand(2, MachineOperand::MO_VirtualRegister,dest); + } else { minstr = new MachineInstr(SETUW); @@ -105,10 +126,18 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(Value* val, if (valType->isIntegral() || valType == Type::BoolTy) { - bool isValidConstant; - int64_t C = GetConstantValueAsSignedInt(val, isValidConstant); - assert(isValidConstant && "Unrecognized constant"); - minstr = CreateIntSetInstruction(C, valType->isSigned(), dest, tempVec); + if (ConstantUInt* uval = dyn_cast(val)) + { + uint64_t C = uval->getValue(); + minstr = CreateUIntSetInstruction(C, dest, tempVec); + } + else + { + bool isValidConstant; + int64_t C = GetConstantValueAsSignedInt(val, isValidConstant); + assert(isValidConstant && "Unrecognized constant"); + minstr = CreateIntSetInstruction(C, dest, tempVec); + } minstrVec.push_back(minstr); } else