Re: [Qemu-devel] [PATCH 1/3] target/s390x: convert to DisasJumpType

2018-02-19 Thread Richard Henderson
On 02/16/2018 03:40 PM, Emilio G. Cota wrote:
> The only non-trivial modification is the use of DISAS_TOO_MANY
> in the same way is used by the generic translation loop.
> 
> Signed-off-by: Emilio G. Cota 
> ---
>  target/s390x/translate.c | 1267 
> +++---
>  1 file changed, 632 insertions(+), 635 deletions(-)

Reviewed-by: Richard Henderson 


r~



Re: [Qemu-devel] [PATCH 1/3] target/s390x: convert to DisasJumpType

2018-02-19 Thread David Hildenbrand
>  switch (status) {
> -case EXIT_GOTO_TB:
> -case EXIT_NORETURN:
> +case DISAS_GOTO_TB:
> +case DISAS_NORETURN:
>  break;
> -case EXIT_PC_STALE:
> -case EXIT_PC_STALE_NOCHAIN:
> +case DISAS_TOO_MANY:
> +case DISAS_PC_STALE:
> +case DISAS_PC_STALE_NOCHAIN:
>  update_psw_addr(&dc);


Not sure if this is really the right thing to do for DISAS_TOO_MANY but
it seems to work for now :)

>  /* FALLTHRU */
> -case EXIT_PC_UPDATED:
> +case DISAS_PC_UPDATED:
>  /* Next TB starts off with CC_OP_DYNAMIC, so make sure the
> cc op type is in env */
>  update_cc_op(&dc);
>  /* FALLTHRU */
> -case EXIT_PC_CC_UPDATED:
> +case DISAS_PC_CC_UPDATED:
>  /* Exit the TB, either by raising a debug exception or by return.  */
>  if (do_debug) {
>  gen_exception(EXCP_DEBUG);
> -} else if (use_exit_tb(&dc) || status == EXIT_PC_STALE_NOCHAIN) {
> +} else if (use_exit_tb(&dc) || status == DISAS_PC_STALE_NOCHAIN) {
>  tcg_gen_exit_tb(0);
>  } else {
>  tcg_gen_lookup_and_goto_ptr();
> 

Reviewed-by: David Hildenbrand 

-- 

Thanks,

David / dhildenb



[Qemu-devel] [PATCH 1/3] target/s390x: convert to DisasJumpType

2018-02-16 Thread Emilio G. Cota
The only non-trivial modification is the use of DISAS_TOO_MANY
in the same way is used by the generic translation loop.

Signed-off-by: Emilio G. Cota 
---
 target/s390x/translate.c | 1267 +++---
 1 file changed, 632 insertions(+), 635 deletions(-)

diff --git a/target/s390x/translate.c b/target/s390x/translate.c
index b470d69..5346791 100644
--- a/target/s390x/translate.c
+++ b/target/s390x/translate.c
@@ -42,6 +42,7 @@
 #include "exec/helper-gen.h"
 
 #include "trace-tcg.h"
+#include "exec/translator.h"
 #include "exec/log.h"
 
 
@@ -73,9 +74,6 @@ typedef struct {
 } u;
 } DisasCompare;
 
-/* is_jmp field values */
-#define DISAS_EXCP DISAS_TARGET_0
-
 #ifdef DEBUG_INLINE_BRANCHES
 static uint64_t inline_branch_hit[CC_OP_MAX];
 static uint64_t inline_branch_miss[CC_OP_MAX];
@@ -1087,26 +1085,24 @@ typedef struct {
 #define SPEC_r2_f12816
 
 /* Return values from translate_one, indicating the state of the TB.  */
-typedef enum {
-/* Continue the TB.  */
-NO_EXIT,
-/* We have emitted one or more goto_tb.  No fixup required.  */
-EXIT_GOTO_TB,
-/* We are not using a goto_tb (for whatever reason), but have updated
-   the PC (for whatever reason), so there's no need to do it again on
-   exiting the TB.  */
-EXIT_PC_UPDATED,
-/* We have updated the PC and CC values.  */
-EXIT_PC_CC_UPDATED,
-/* We are exiting the TB, but have neither emitted a goto_tb, nor
-   updated the PC for the next instruction to be executed.  */
-EXIT_PC_STALE,
-/* We are exiting the TB to the main loop.  */
-EXIT_PC_STALE_NOCHAIN,
-/* We are ending the TB with a noreturn function call, e.g. longjmp.
-   No following code will be executed.  */
-EXIT_NORETURN,
-} ExitStatus;
+
+/* We are not using a goto_tb (for whatever reason), but have updated
+   the PC (for whatever reason), so there's no need to do it again on
+   exiting the TB.  */
+#define DISAS_PC_UPDATEDDISAS_TARGET_0
+
+/* We have emitted one or more goto_tb.  No fixup required.  */
+#define DISAS_GOTO_TB   DISAS_TARGET_1
+
+/* We have updated the PC and CC values.  */
+#define DISAS_PC_CC_UPDATED DISAS_TARGET_2
+
+/* We are exiting the TB, but have neither emitted a goto_tb, nor
+   updated the PC for the next instruction to be executed.  */
+#define DISAS_PC_STALE  DISAS_TARGET_3
+
+/* We are exiting the TB to the main loop.  */
+#define DISAS_PC_STALE_NOCHAIN  DISAS_TARGET_4
 
 struct DisasInsn {
 unsigned opc:16;
@@ -1121,7 +1117,7 @@ struct DisasInsn {
 void (*help_prep)(DisasContext *, DisasFields *, DisasOps *);
 void (*help_wout)(DisasContext *, DisasFields *, DisasOps *);
 void (*help_cout)(DisasContext *, DisasOps *);
-ExitStatus (*help_op)(DisasContext *, DisasOps *);
+DisasJumpType (*help_op)(DisasContext *, DisasOps *);
 
 uint64_t data;
 };
@@ -1143,11 +1139,11 @@ static void help_l2_shift(DisasContext *s, DisasFields 
*f,
 }
 }
 
-static ExitStatus help_goto_direct(DisasContext *s, uint64_t dest)
+static DisasJumpType help_goto_direct(DisasContext *s, uint64_t dest)
 {
 if (dest == s->next_pc) {
 per_branch(s, true);
-return NO_EXIT;
+return DISAS_NEXT;
 }
 if (use_goto_tb(s, dest)) {
 update_cc_op(s);
@@ -1155,31 +1151,31 @@ static ExitStatus help_goto_direct(DisasContext *s, 
uint64_t dest)
 tcg_gen_goto_tb(0);
 tcg_gen_movi_i64(psw_addr, dest);
 tcg_gen_exit_tb((uintptr_t)s->tb);
-return EXIT_GOTO_TB;
+return DISAS_GOTO_TB;
 } else {
 tcg_gen_movi_i64(psw_addr, dest);
 per_branch(s, false);
-return EXIT_PC_UPDATED;
+return DISAS_PC_UPDATED;
 }
 }
 
-static ExitStatus help_branch(DisasContext *s, DisasCompare *c,
-  bool is_imm, int imm, TCGv_i64 cdest)
+static DisasJumpType help_branch(DisasContext *s, DisasCompare *c,
+ bool is_imm, int imm, TCGv_i64 cdest)
 {
-ExitStatus ret;
+DisasJumpType ret;
 uint64_t dest = s->pc + 2 * imm;
 TCGLabel *lab;
 
 /* Take care of the special cases first.  */
 if (c->cond == TCG_COND_NEVER) {
-ret = NO_EXIT;
+ret = DISAS_NEXT;
 goto egress;
 }
 if (is_imm) {
 if (dest == s->next_pc) {
 /* Branch to next.  */
 per_branch(s, true);
-ret = NO_EXIT;
+ret = DISAS_NEXT;
 goto egress;
 }
 if (c->cond == TCG_COND_ALWAYS) {
@@ -1189,13 +1185,13 @@ static ExitStatus help_branch(DisasContext *s, 
DisasCompare *c,
 } else {
 if (!cdest) {
 /* E.g. bcr %r0 -> no branch.  */
-ret = NO_EXIT;
+ret = DISAS_NEXT;
 goto egress;
 }
 if (c->cond == TCG_COND_ALWAYS) {
 tcg_gen_mov_i64(psw_addr, cdest);
 per_branch(s, false);
-ret = EXIT_PC