Skip to content

Commit

Permalink
Backend\X64: r10 and r11 should be caller-saved.
Browse files Browse the repository at this point in the history
  • Loading branch information
fleroviux committed May 5, 2021
1 parent 6e1ddb9 commit 538a60f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/backend/x86_64/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,8 @@ void X64Backend::Run(Memory& memory, State& state, IREmitter const& emitter, boo
code.push(rdx);
code.push(r8);
code.push(r9);
code.push(r10);
code.push(r11);

code.sub(rsp, 0x28);
code.mov(edx, address_reg);
Expand All @@ -710,6 +712,8 @@ void X64Backend::Run(Memory& memory, State& state, IREmitter const& emitter, boo
code.call(rax);
code.add(rsp, 0x28);

code.pop(r11);
code.pop(r10);
code.pop(r9);
code.pop(r8);
code.pop(rdx);
Expand Down
10 changes: 8 additions & 2 deletions src/backend/x86_64/register_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ namespace backend {
X64RegisterAllocator::X64RegisterAllocator(IREmitter const& emitter, Xbyak::CodeGenerator& code)
: emitter(emitter)
, code(code) {
// rax and rcx are statically allocated
Xbyak::Reg32 regs[] = {
// ecx,
edx,
ebx,
esi,
Expand Down Expand Up @@ -123,7 +123,13 @@ void X64RegisterAllocator::ExpireVariables(int location) {
}

auto X64RegisterAllocator::IsCallerSaved(Xbyak::Reg32 reg) -> bool {
return reg == eax || reg == ecx || reg == edx || reg == r8d || reg == r9d;
return reg == eax ||
reg == ecx ||
reg == edx ||
reg == r8d ||
reg == r9d ||
reg == r10d ||
reg == r11d;
}

} // namespace lunatic::backend
Expand Down

0 comments on commit 538a60f

Please sign in to comment.