CPU/Recompiler: Extend sign for add/sub/cmp immediates in AArch64

This commit is contained in:
Connor McLaughlin
2019-12-05 02:02:19 +10:00
parent f3e3d9a317
commit 914abe64c1
3 changed files with 47 additions and 23 deletions

View File

@ -4,8 +4,8 @@
#include "cpu_types.h"
#include <array>
#include <tuple>
#include <optional>
#include <tuple>
namespace CPU::Recompiler {
@ -137,6 +137,26 @@ struct Value
return Value();
}
/// Returns the constant value as a signed 64-bit integer, suitable as an immediate.
s64 GetS64ConstantValue() const
{
switch (size)
{
case RegSize_8:
return static_cast<s64>(SignExtend64(Truncate8(constant_value)));
case RegSize_16:
return static_cast<s64>(SignExtend64(Truncate16(constant_value)));
case RegSize_32:
return static_cast<s64>(SignExtend64(Truncate32(constant_value)));
case RegSize_64:
default:
return static_cast<s64>(constant_value);
}
}
static Value FromHostReg(RegisterCache* regcache, HostReg reg, RegSize size)
{
return Value(regcache, reg, size, ValueFlags::Valid | ValueFlags::InHostRegister);