emit_x64: Port to new register allocator interface

This commit is contained in:
MerryMage 2017-02-24 21:25:31 +00:00
parent f883bad2cc
commit 08a467bf9a
3 changed files with 796 additions and 833 deletions

File diff suppressed because it is too large Load diff

View file

@ -56,9 +56,9 @@ static void EmitMove(BlockOfCode* code, HostLoc to, HostLoc from) {
} else if (HostLocIsGPR(to) && HostLocIsGPR(from)) {
code->mov(HostLocToReg64(to), HostLocToReg64(from));
} else if (HostLocIsXMM(to) && HostLocIsGPR(from)) {
ASSERT_MSG(false, "TODO");
code->movq(HostLocToXmm(to), HostLocToReg64(from));
} else if (HostLocIsGPR(to) && HostLocIsXMM(from)) {
ASSERT_MSG(false, "TODO");
code->movq(HostLocToReg64(to), HostLocToXmm(from));
} else if (HostLocIsXMM(to) && HostLocIsSpill(from)) {
code->movsd(HostLocToXmm(to), SpillToOpArg(from));
} else if (HostLocIsSpill(to) && HostLocIsXMM(from)) {
@ -82,6 +82,10 @@ static void EmitExchange(BlockOfCode* code, HostLoc a, HostLoc b) {
}
}
bool Argument::GetImmediateU1() const {
return value.GetU1();
}
u8 Argument::GetImmediateU8() const {
u64 imm = ImmediateToU64(value);
ASSERT(imm < 0x100);

View file

@ -76,6 +76,7 @@ public:
return value.IsImmediate();
}
bool GetImmediateU1() const;
u8 GetImmediateU8() const;
u16 GetImmediateU16() const;
u32 GetImmediateU32() const;
@ -113,6 +114,9 @@ public:
arg.allocated = true;
return HostLocToXmm(UseHostLocReg(arg.value, any_xmm));
}
OpArg UseOpArg(Argument& arg) {
return UseGpr(arg);
}
void Use(Argument& arg, HostLoc host_loc) {
ASSERT(!arg.allocated);
arg.allocated = true;
@ -135,12 +139,9 @@ public:
UseScratchHostLocReg(arg.value, {host_loc});
}
void DefineValue(IR::Inst* inst, const Xbyak::Reg64& reg) {
HostLoc hostloc = static_cast<HostLoc>(reg.getIdx() + static_cast<size_t>(HostLoc::RAX));
DefineValue(inst, hostloc);
}
void DefineValue(IR::Inst* inst, const Xbyak::Xmm& reg) {
HostLoc hostloc = static_cast<HostLoc>(reg.getIdx() + static_cast<size_t>(HostLoc::XMM0));
void DefineValue(IR::Inst* inst, const Xbyak::Reg& reg) {
ASSERT(reg.getKind() == Xbyak::Operand::XMM || reg.getKind() == Xbyak::Operand::REG);
HostLoc hostloc = static_cast<HostLoc>(reg.getIdx() + static_cast<size_t>(reg.getKind() == Xbyak::Operand::XMM ? HostLoc::XMM0 : HostLoc::RAX));
DefineValue(inst, hostloc);
}
void DefineValue(IR::Inst* inst, Argument& arg) {