Skip to content

Commit

Permalink
Aarch64: Combine put_list + deallocate
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorng committed Dec 19, 2023
1 parent 2123d6f commit 7df94e3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
50 changes: 50 additions & 0 deletions erts/emulator/beam/jit/arm/instr_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,56 @@ void BeamModuleAssembler::emit_put_list(const ArgSource &Hd,
flush_var(dst);
}

void BeamModuleAssembler::emit_put_list_deallocate(const ArgSource &Hd,
const ArgSource &Tl,
const ArgRegister &Dst,
const ArgWord &Deallocate) {
Sint dealloc = Deallocate.get() * sizeof(Eterm);
arm::Gp hd_reg, tl_reg;
auto dst = init_destination(Dst, TMP3);

ASSERT(dealloc <= 1023);

if (Hd.isYRegister() && !Tl.isYRegister() && dealloc > 0) {
auto hd_index = Hd.as<ArgYRegister>().get();

if (hd_index == 0) {
arm::Mem mem = getArgRef(Hd);
mem = arm::Mem(E).post(dealloc);
hd_reg = TMP1;
a.ldr(hd_reg, mem);
tl_reg = load_source(Tl, TMP2).reg;
dealloc = 0;
}
} else if (!Hd.isYRegister() && Tl.isYRegister() && dealloc > 0) {
auto tl_index = Tl.as<ArgYRegister>().get();

if (tl_index == 0) {
arm::Mem mem = getArgRef(Tl);
mem = arm::Mem(E).post(dealloc);
tl_reg = TMP2;
a.ldr(tl_reg, mem);
hd_reg = load_source(Hd, TMP1).reg;
dealloc = 0;
}
}

if (!hd_reg.isValid()) {
auto [hd, tl] = load_sources(Hd, TMP1, Tl, TMP2);
hd_reg = hd.reg;
tl_reg = tl.reg;
}

a.stp(hd_reg, tl_reg, arm::Mem(HTOP).post(sizeof(Eterm[2])));
a.sub(dst.reg, HTOP, imm(sizeof(Eterm[2]) - TAG_PRIMARY_LIST));

flush_var(dst);

if (dealloc > 0) {
add(E, E, Deallocate.get() * sizeof(Eterm));
}
}

void BeamModuleAssembler::emit_put_list2(const ArgSource &Hd1,
const ArgSource &Hd2,
const ArgSource &Tl,
Expand Down
4 changes: 4 additions & 0 deletions erts/emulator/beam/jit/arm/ops.tab
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@ put_list Hd1=y Tl Dst | put_list Hd2=y Dst2 Dst3 |
consecutive_words(Hd1, Hd2) =>
put_list2 Hd1 Hd2 Tl Dst

put_list Hd Tl Dst | deallocate N =>
put_list_deallocate Hd Tl Dst N

put_list_deallocate s s d t
put_list s s d
put_list2 s s s d

Expand Down

0 comments on commit 7df94e3

Please sign in to comment.