diff mbox

[RFC,v1,27/29] target-arc: LP

Message ID 1473373930-31547-28-git-send-email-mrolnik@gmail.com
State New
Headers show

Commit Message

Michael Rolnik Sept. 8, 2016, 10:32 p.m. UTC
Signed-off-by: Michael Rolnik <mrolnik@gmail.com>
---
 target-arc/helper.h         |  1 +
 target-arc/op_helper.c      |  5 ++++-
 target-arc/translate-inst.c | 40 ++++++++++++++++++++++++++++++++++++++++
 target-arc/translate-inst.h |  2 ++
 4 files changed, 47 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/target-arc/helper.h b/target-arc/helper.h
index abfd0d2..ef5c12e 100644
--- a/target-arc/helper.h
+++ b/target-arc/helper.h
@@ -25,4 +25,5 @@  DEF_HELPER_2(lr, tl, env, i32)
 DEF_HELPER_2(sr, void, i32, i32)
 DEF_HELPER_1(halt, void, env)
 DEF_HELPER_1(rtie, void, env)
+DEF_HELPER_1(flush, void, env)
 
diff --git a/target-arc/op_helper.c b/target-arc/op_helper.c
index a3f6a46..61e790e 100644
--- a/target-arc/op_helper.c
+++ b/target-arc/op_helper.c
@@ -437,4 +437,7 @@  void helper_rtie(CPUARCState *env)
     }
 }
 
-
+void helper_flush(CPUARCState *env)
+{
+    tb_flush((CPUState *)arc_env_get_cpu(env));
+}
diff --git a/target-arc/translate-inst.c b/target-arc/translate-inst.c
index 743f2be..87940ed 100644
--- a/target-arc/translate-inst.c
+++ b/target-arc/translate-inst.c
@@ -2813,3 +2813,43 @@  int arc_gen_RTIE(DisasCtxt *ctx)
     return  BS_BRANCH;
 }
 
+/*
+    LPcc
+*/
+int arc_gen_LPcc(DisasCtxt *ctx, TCGv rd, unsigned Q)
+{
+    TCGLabel *label_done = gen_new_label();
+    TCGv t0 = tcg_const_local_i32(ctx->npc);
+
+    /*
+        if cc is false, pc will be updated here
+        pc = pcl + rd
+    */
+    tcg_gen_shli_tl(cpu_pc, rd, 1);
+    tcg_gen_addi_tl(cpu_pc, cpu_pc, ctx->pcl);
+
+    /*
+        if cc is false we will jump to done label
+    */
+    arc_gen_jump_ifnot(ctx, Q, label_done);
+
+    /*
+        cc is true
+    */
+    tcg_gen_movi_tl(t0, ctx->lpe);
+
+    tcg_gen_movi_tl(cpu_lps, ctx->npc);
+    tcg_gen_mov_tl(cpu_lpe, cpu_pc);
+    tcg_gen_movi_tl(cpu_pc, ctx->npc);
+
+    tcg_gen_brcond_tl(TCG_COND_EQ, t0, cpu_lpe, label_done);
+
+    gen_helper_flush(cpu_env);
+
+gen_set_label(label_done);
+
+    tcg_temp_free_i32(t0);
+
+    return  BS_BRANCH;
+}
+
diff --git a/target-arc/translate-inst.h b/target-arc/translate-inst.h
index 8bbac4f..7ea20a0 100644
--- a/target-arc/translate-inst.h
+++ b/target-arc/translate-inst.h
@@ -171,3 +171,5 @@  int arc_gen_TRAP(DisasCtxt *c, TCGv src1);
 
 int arc_gen_RTIE(DisasCtxt *c);
 
+int arc_gen_LPcc(DisasCtxt *ctx, TCGv Rd, unsigned Q);
+