diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-12-15 00:33:36 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2001-12-15 00:33:36 +0000 |
commit | cee9d1c3fa15978cfbdba87f9ee7252db3e8ace9 (patch) | |
tree | 8a3db58cf41f6872deda44db80fc2ce5e245372c | |
parent | b15f64c353d81010ff4ac89b393fb03db5e8865f (diff) |
Remove int hack to allow unsigned numbers greater than 2^63 - 1...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1483 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/SparcV9/SparcV9InstrInfo.cpp | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index 13e6f54219..99bb14d12e 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp @@ -26,7 +26,7 @@ static inline MachineInstr* -CreateIntSetInstruction(int64_t C, bool isSigned, Value* dest, +CreateIntSetInstruction(int64_t C, Value* dest, vector<TmpInstruction*>& 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<TmpInstruction*>& 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<ConstantUInt>(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 |