[a64] Remove `VOne` constant in favor of `FMOV`

This commit is contained in:
Wunkolo 2024-05-27 13:13:17 -07:00
parent 3b1a696dd6
commit cba92a2e6e
3 changed files with 4 additions and 6 deletions

View File

@ -689,7 +689,6 @@ void A64Emitter::MovMem64(const oaknut::XRegSp& addr, intptr_t offset,
static const vec128_t v_consts[] = { static const vec128_t v_consts[] = {
/* VZero */ vec128f(0.0f), /* VZero */ vec128f(0.0f),
/* VOne */ vec128f(1.0f),
/* VOnePD */ vec128d(1.0), /* VOnePD */ vec128d(1.0),
/* VNegativeOne */ vec128f(-1.0f, -1.0f, -1.0f, -1.0f), /* VNegativeOne */ vec128f(-1.0f, -1.0f, -1.0f, -1.0f),
/* VFFFF */ /* VFFFF */

View File

@ -47,7 +47,6 @@ enum RegisterFlags {
enum VConst { enum VConst {
VZero = 0, VZero = 0,
VOne,
VOnePD, VOnePD,
VNegativeOne, VNegativeOne,
VFFFF, VFFFF,
@ -201,12 +200,12 @@ class A64Emitter : public oaknut::CodeBlock, public oaknut::CodeGenerator {
void ReloadMembase(); void ReloadMembase();
// Moves a 64bit immediate into memory. // Moves a 64bit immediate into memory.
bool ConstantFitsIn32Reg(uint64_t v); static bool ConstantFitsIn32Reg(uint64_t v);
void MovMem64(const oaknut::XRegSp& addr, intptr_t offset, uint64_t v); void MovMem64(const oaknut::XRegSp& addr, intptr_t offset, uint64_t v);
std::byte* GetVConstPtr() const; std::byte* GetVConstPtr() const;
std::byte* GetVConstPtr(VConst id) const; std::byte* GetVConstPtr(VConst id) const;
constexpr uintptr_t GetVConstOffset(VConst id) const { static constexpr uintptr_t GetVConstOffset(VConst id){
return sizeof(vec128_t) * id; return sizeof(vec128_t) * id;
} }
void LoadConstantV(oaknut::QReg dest, float v); void LoadConstantV(oaknut::QReg dest, float v);

View File

@ -1746,7 +1746,7 @@ struct UNPACK : Sequence<UNPACK, I<OPCODE_UNPACK, V128Op, V128Op>> {
if (i.src1.is_constant) { if (i.src1.is_constant) {
if (i.src1.value->IsConstantZero()) { if (i.src1.value->IsConstantZero()) {
e.LDR(i.dest.reg(), VConstData, e.GetVConstOffset(VOne)); e.FMOV(i.dest.reg().S4(), FImm8(0, 7, 0));
return; return;
} }
src = i.dest; src = i.dest;
@ -1759,7 +1759,7 @@ struct UNPACK : Sequence<UNPACK, I<OPCODE_UNPACK, V128Op, V128Op>> {
e.LDR(Q1, VConstData, e.GetVConstOffset(VUnpackD3DCOLOR)); e.LDR(Q1, VConstData, e.GetVConstOffset(VUnpackD3DCOLOR));
e.TBL(i.dest.reg().B16(), oaknut::List{src.B16()}, Q1.B16()); e.TBL(i.dest.reg().B16(), oaknut::List{src.B16()}, Q1.B16());
// Add 1.0f to each. // Add 1.0f to each.
e.LDR(Q1, VConstData, e.GetVConstOffset(VOne)); e.FMOV(Q1.S4(), FImm8(0, 7, 0));
e.EOR(i.dest.reg().B16(), i.dest.reg().B16(), Q1.B16()); e.EOR(i.dest.reg().B16(), i.dest.reg().B16(), Q1.B16());
// To convert to 0 to 1, games multiply by 0x47008081 and add 0xC7008081. // To convert to 0 to 1, games multiply by 0x47008081 and add 0xC7008081.
} }