summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-02-13 15:31:03 -0800
committerOri Bernstein <ori@eigenstate.org>2016-02-13 15:31:03 -0800
commit56d1f1bccd4f943b43e5b8043dd63a17ceb2b2b1 (patch)
treeb6c2e0e797be2801129cd552b3cb9c0ce916e43f /6
parentef16012a85da92aa8e7fdb7890e2f7a88364c9bd (diff)
downloadmc-56d1f1bccd4f943b43e5b8043dd63a17ceb2b2b1.tar.gz
Save regs correctly around rep movs
Diffstat (limited to '6')
-rw-r--r--6/insns.def8
-rw-r--r--6/isel.c10
2 files changed, 14 insertions, 4 deletions
diff --git a/6/insns.def b/6/insns.def
index 8e716e4..bf86846 100644
--- a/6/insns.def
+++ b/6/insns.def
@@ -55,22 +55,22 @@ Insn(Irepmovsb,
"\trep movsb\n",
"\tREP; MOVSB\n",
Use(.r={Rrcx,Rrsi,Rrdi}),
- Def(None))
+ Def(.r={Rrcx,Rrsi,Rrdi}))
Insn(Irepmovsw,
"\trep movsw\n",
"\tREP; MOVSW\n",
Use(.r={Rrcx,Rrsi,Rrdi}),
- Def(None))
+ Def(.r={Rrcx,Rrsi,Rrdi}))
Insn(Irepmovsl,
"\trep movsl\n",
"\tREP; MOVSL\n",
Use(.r={Rrcx,Rrsi,Rrdi}),
- Def(None))
+ Def(.r={Rrcx,Rrsi,Rrdi}))
Insn(Irepmovsq,
"\trep movsq\n",
"\tREP; MOVSQ\n",
Use(.r={Rrcx,Rrsi,Rrdi}),
- Def(None))
+ Def(.r={Rrcx,Rrsi,Rrdi}))
Insn(Ilea,
"\tlea%2t %m,%r\n",
"\tLEA%2T %M,%R\n",
diff --git a/6/isel.c b/6/isel.c
index c47e96b..c674758 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -405,6 +405,7 @@ static const Mode szmodes[] = {
static void blit(Isel *s, Loc *to, Loc *from, size_t dstoff, size_t srcoff, size_t sz, size_t align)
{
size_t i, modesz;
+ Loc *savsi, *savdi, *savcx; /* pointers to src, dst */
Loc *sp, *dp, *len; /* pointers to src, dst */
Loc *tmp, *src, *dst; /* source memory, dst memory */
@@ -429,7 +430,13 @@ static void blit(Isel *s, Loc *to, Loc *from, size_t dstoff, size_t srcoff, size
}
}
} else {
+ savsi = locreg(ModeQ);
+ savdi = locreg(ModeQ);
+ savcx = locreg(ModeQ);
len = loclit(sz, ModeQ);
+ g(s, Imov, locphysreg(Rrsi), savsi);
+ g(s, Imov, locphysreg(Rrdi), savdi);
+ g(s, Imov, locphysreg(Rrcx), savcx);
sp = newr(s, from);
dp = newr(s, to);
@@ -446,6 +453,9 @@ static void blit(Isel *s, Loc *to, Loc *from, size_t dstoff, size_t srcoff, size
else
g(s, Imov, dp, locphysreg(Rrdi), NULL);
g(s, Irepmovsb, NULL);
+ g(s, Imov, savsi, locphysreg(Rrsi));
+ g(s, Imov, savdi, locphysreg(Rrdi));
+ g(s, Imov, savcx, locphysreg(Rrcx));
}
}