reg_alloc: Handle XMM registers in LoadImmediate

This commit is contained in:
MerryMage 2017-08-16 23:11:05 +01:00
parent 993e142c6b
commit 1613846ab0

View file

@ -398,8 +398,8 @@ void RegAlloc::DefineValueImpl(IR::Inst* def_inst, const IR::Value& use_inst) {
HostLoc RegAlloc::LoadImmediate(IR::Value imm, HostLoc host_loc) { HostLoc RegAlloc::LoadImmediate(IR::Value imm, HostLoc host_loc) {
ASSERT_MSG(imm.IsImmediate(), "imm is not an immediate"); ASSERT_MSG(imm.IsImmediate(), "imm is not an immediate");
if (HostLocIsGPR(host_loc)) {
Xbyak::Reg64 reg = HostLocToReg64(host_loc); Xbyak::Reg64 reg = HostLocToReg64(host_loc);
u64 imm_value = ImmediateToU64(imm); u64 imm_value = ImmediateToU64(imm);
if (imm_value == 0) if (imm_value == 0)
code->xor_(reg.cvt32(), reg.cvt32()); code->xor_(reg.cvt32(), reg.cvt32());
@ -408,6 +408,19 @@ HostLoc RegAlloc::LoadImmediate(IR::Value imm, HostLoc host_loc) {
return host_loc; return host_loc;
} }
if (HostLocIsXMM(host_loc)) {
Xbyak::Xmm reg = HostLocToXmm(host_loc);
u64 imm_value = ImmediateToU64(imm);
if (imm_value == 0)
code->pxor(reg, reg);
else
code->movdqa(reg, code->MConst(imm_value)); // TODO: movaps/movapd more appropriate sometimes
return host_loc;
}
UNREACHABLE();
}
void RegAlloc::Move(HostLoc to, HostLoc from) { void RegAlloc::Move(HostLoc to, HostLoc from) {
ASSERT(LocInfo(to).IsEmpty() && !LocInfo(from).IsLocked()); ASSERT(LocInfo(to).IsEmpty() && !LocInfo(from).IsLocked());