mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-04 05:31:51 +00:00
Sign-extend integer constants from original type size to 64 bits!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3958 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e9cb735131
commit
1c10f17552
@ -373,11 +373,15 @@ ChooseRegOrImmed(Value* val,
|
||||
else if (CPV->getType()->isSigned())
|
||||
intValue = cast<ConstantSInt>(CPV)->getValue();
|
||||
else
|
||||
{
|
||||
assert(CPV->getType()->isUnsigned() && "Not pointer, bool, or integer?");
|
||||
uint64_t V = cast<ConstantUInt>(CPV)->getValue();
|
||||
if (V >= INT64_MAX) return MachineOperand::MO_VirtualRegister;
|
||||
intValue = (int64_t) V;
|
||||
{ // get the int value and sign-extend if original was less than 64 bits
|
||||
intValue = (int64_t) cast<ConstantUInt>(CPV)->getValue();
|
||||
switch(CPV->getType()->getPrimitiveID())
|
||||
{
|
||||
case Type::UByteTyID: intValue = (int64_t) (int8_t) intValue; break;
|
||||
case Type::UShortTyID: intValue = (int64_t) (short) intValue; break;
|
||||
case Type::UIntTyID: intValue = (int64_t) (int) intValue; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
return ChooseRegOrImmed(intValue, CPV->getType()->isSigned(),
|
||||
|
@ -373,11 +373,15 @@ ChooseRegOrImmed(Value* val,
|
||||
else if (CPV->getType()->isSigned())
|
||||
intValue = cast<ConstantSInt>(CPV)->getValue();
|
||||
else
|
||||
{
|
||||
assert(CPV->getType()->isUnsigned() && "Not pointer, bool, or integer?");
|
||||
uint64_t V = cast<ConstantUInt>(CPV)->getValue();
|
||||
if (V >= INT64_MAX) return MachineOperand::MO_VirtualRegister;
|
||||
intValue = (int64_t) V;
|
||||
{ // get the int value and sign-extend if original was less than 64 bits
|
||||
intValue = (int64_t) cast<ConstantUInt>(CPV)->getValue();
|
||||
switch(CPV->getType()->getPrimitiveID())
|
||||
{
|
||||
case Type::UByteTyID: intValue = (int64_t) (int8_t) intValue; break;
|
||||
case Type::UShortTyID: intValue = (int64_t) (short) intValue; break;
|
||||
case Type::UIntTyID: intValue = (int64_t) (int) intValue; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
return ChooseRegOrImmed(intValue, CPV->getType()->isSigned(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user