diff mbox

[RFC,v1,10/29] target-arc: POP, PUSH

Message ID 1473373930-31547-11-git-send-email-mrolnik@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Rolnik Sept. 8, 2016, 10:31 p.m. UTC
Signed-off-by: Michael Rolnik <mrolnik@gmail.com>
---
 target-arc/translate-inst.c | 22 ++++++++++++++++++++++
 target-arc/translate-inst.h |  3 +++
 2 files changed, 25 insertions(+)

Comments

Richard Henderson Sept. 20, 2016, 11:57 p.m. UTC | #1
On 09/08/2016 03:31 PM, Michael Rolnik wrote:
> +    tcg_gen_subi_tl(cpu_sp, cpu_sp, 4);
> +    tcg_gen_qemu_st_tl(src1, cpu_sp, ctx->memidx, MO_UL);

You need to delay the write to the stack pointer until after the store, 
otherwise sp will have the incorrect contents if the page is not writable.


r~
diff mbox

Patch

diff --git a/target-arc/translate-inst.c b/target-arc/translate-inst.c
index 7f7e951..2a579f8 100644
--- a/target-arc/translate-inst.c
+++ b/target-arc/translate-inst.c
@@ -1147,3 +1147,25 @@  int arc_gen_NOT(DisasCtxt *ctx, TCGv dest, TCGv src1)
     return  BS_NONE;
 }
 
+/*
+    POP
+*/
+int arc_gen_POP(DisasCtxt *ctx, TCGv src1)
+{
+    tcg_gen_qemu_ld_tl(src1, cpu_sp, ctx->memidx, MO_UL);
+    tcg_gen_addi_tl(cpu_sp, cpu_sp, 4);
+
+    return BS_NONE;
+}
+
+/*
+    PUSH
+*/
+int arc_gen_PUSH(DisasCtxt *ctx, TCGv src1)
+{
+    tcg_gen_subi_tl(cpu_sp, cpu_sp, 4);
+    tcg_gen_qemu_st_tl(src1, cpu_sp, ctx->memidx, MO_UL);
+
+    return BS_NONE;
+}
+
diff --git a/target-arc/translate-inst.h b/target-arc/translate-inst.h
index 36ce19b..d088a43 100644
--- a/target-arc/translate-inst.h
+++ b/target-arc/translate-inst.h
@@ -75,3 +75,6 @@  int arc_gen_NEG(DisasCtxt *c, TCGv dest, TCGv src1);
 int arc_gen_ABS(DisasCtxt *c, TCGv dest, TCGv src1);
 int arc_gen_NOT(DisasCtxt *c, TCGv dest, TCGv src1);
 
+int arc_gen_POP(DisasCtxt *c, TCGv src1);
+int arc_gen_PUSH(DisasCtxt *c, TCGv src1);
+