From nobody Tue Feb 10 20:48:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504808498423850.1702001708154; Thu, 7 Sep 2017 11:21:38 -0700 (PDT) Received: from localhost ([::1]:41660 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq1Qn-0004da-CV for importer@patchew.org; Thu, 07 Sep 2017 14:21:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dq1P2-0003IT-LV for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:19:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dq1Ox-0007ZJ-1G for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:19:48 -0400 Received: from mail-pg0-x229.google.com ([2607:f8b0:400e:c05::229]:37144) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dq1Ow-0007Yk-PA for qemu-devel@nongnu.org; Thu, 07 Sep 2017 14:19:42 -0400 Received: by mail-pg0-x229.google.com with SMTP id d8so854103pgt.4 for ; Thu, 07 Sep 2017 11:19:42 -0700 (PDT) Received: from pike.twiddle.net (97-126-108-236.tukw.qwest.net. [97.126.108.236]) by smtp.gmail.com with ESMTPSA id s68sm412051pfd.72.2017.09.07.11.19.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Sep 2017 11:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=U8G7jLxyl2fvoViYLUQ2i9RVyDuMQWVbBH5sbJtd/IU=; b=M+2Y06aG+zPRTd2Ca7H8mLcR8oIi/Fx3oM/mCx/OPmkPLHPMSuImh+yEpiraPa/YEr 4uzPHJtOkOJoKVmKIjGeRQvLB7YEZbr0QbNz+UnozkYZ1dlO+WM/gMtREsjb0UXFVv7q S5j1SYCFGYB5wgb0NEChE+8XMZcW1HBdpZ1uU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=U8G7jLxyl2fvoViYLUQ2i9RVyDuMQWVbBH5sbJtd/IU=; b=gOTLxCRoPBKolWl7qsM+LqjNSfTw+MiCDGH0LSEVvUxHJAm6yg7NaqiaanSXjNP3hV 3bV2oEe8ZgtB0DC7G6z9OD6ACpGxkiVw9+4U02Sa7ewzHnF3FoJwCQEKwWGc8Iwa1yZZ M+1j7+tu/lysJE11Ag9lqZsb6ZIqbCv7eVqOh3OnOzgYx+bwI73jvGiC2H60ptF0mHip +cXRWg3LCPt8ljFOOk2ucFe/X4NmTFIc6fXb+OAgwzBf6/J15zDU8wt10fn+BjZo01Hv t/p9pcK0umn/+O+p5k7GuPsRPrlr35j9Xgc6RUNjnrK5g3uX+PA7hGI5SJh9mwlmcveM FZ1w== X-Gm-Message-State: AHPjjUixJGR/RdL/+5CtwPh/j1FGmxNBrUcD7JbpTZf1xipXDpWRZsWj nKux+xaudtbw3T3d7JjZAw== X-Google-Smtp-Source: ADKCNb6FEF6AAWGG/eBy3uKjOFYA+RDuQsvHhc8vteQylc1i/kucUo9rC+AE1AhjU6xXOJzx3HMJ4g== X-Received: by 10.99.4.8 with SMTP id 8mr216134pge.123.1504808381470; Thu, 07 Sep 2017 11:19:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 7 Sep 2017 11:19:35 -0700 Message-Id: <20170907181938.3948-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170907181938.3948-1-richard.henderson@linaro.org> References: <20170907181938.3948-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::229 Subject: [Qemu-devel] [PULL 1/4] target/alpha: Convert to DisasJumpType X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson Signed-off-by: Richard Henderson --- target/alpha/translate.c | 132 ++++++++++++++++++++-----------------------= ---- 1 file changed, 55 insertions(+), 77 deletions(-) diff --git a/target/alpha/translate.c b/target/alpha/translate.c index f465752208..a75bf5dd90 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -25,11 +25,10 @@ #include "exec/exec-all.h" #include "tcg-op.h" #include "exec/cpu_ldst.h" - #include "exec/helper-proto.h" #include "exec/helper-gen.h" - #include "trace-tcg.h" +#include "exec/translator.h" #include "exec/log.h" =20 =20 @@ -73,32 +72,12 @@ struct DisasContext { bool singlestep_enabled; }; =20 -/* Return values from translate_one, indicating the state of the TB. - Note that zero indicates that we are not exiting the TB. */ - -typedef enum { - 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, - EXIT_PC_UPDATED_NOCHAIN, - - /* 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 due to page crossing or space constraints. */ - EXIT_FALLTHRU, - - /* We are ending the TB with a noreturn function call, e.g. longjmp. - No following code will be executed. */ - EXIT_NORETURN, -} ExitStatus; +/* Target-specific return values from translate_one, indicating the + state of the TB. Note that DISAS_NEXT indicates that we are not + exiting the TB. */ +#define DISAS_PC_UPDATED_NOCHAIN DISAS_TARGET_0 +#define DISAS_PC_UPDATED DISAS_TARGET_1 +#define DISAS_PC_STALE DISAS_TARGET_2 =20 /* global register indexes */ static TCGv_env cpu_env; @@ -301,14 +280,14 @@ static void gen_excp_1(int exception, int error_code) tcg_temp_free_i32(tmp1); } =20 -static ExitStatus gen_excp(DisasContext *ctx, int exception, int error_cod= e) +static DisasJumpType gen_excp(DisasContext *ctx, int exception, int error_= code) { tcg_gen_movi_i64(cpu_pc, ctx->pc); gen_excp_1(exception, error_code); - return EXIT_NORETURN; + return DISAS_NORETURN; } =20 -static inline ExitStatus gen_invalid(DisasContext *ctx) +static inline DisasJumpType gen_invalid(DisasContext *ctx) { return gen_excp(ctx, EXCP_OPCDEC, 0); } @@ -434,9 +413,9 @@ static inline void gen_store_mem(DisasContext *ctx, tcg_temp_free(tmp); } =20 -static ExitStatus gen_store_conditional(DisasContext *ctx, int ra, int rb, - int32_t disp16, int mem_idx, - TCGMemOp op) +static DisasJumpType gen_store_conditional(DisasContext *ctx, int ra, int = rb, + int32_t disp16, int mem_idx, + TCGMemOp op) { TCGLabel *lab_fail, *lab_done; TCGv addr, val; @@ -468,7 +447,7 @@ static ExitStatus gen_store_conditional(DisasContext *c= tx, int ra, int rb, =20 gen_set_label(lab_done); tcg_gen_movi_i64(cpu_lock_addr, -1); - return NO_EXIT; + return DISAS_NEXT; } =20 static bool in_superpage(DisasContext *ctx, int64_t addr) @@ -507,7 +486,7 @@ static bool use_goto_tb(DisasContext *ctx, uint64_t des= t) #endif } =20 -static ExitStatus gen_bdirect(DisasContext *ctx, int ra, int32_t disp) +static DisasJumpType gen_bdirect(DisasContext *ctx, int ra, int32_t disp) { uint64_t dest =3D ctx->pc + (disp << 2); =20 @@ -522,15 +501,15 @@ static ExitStatus gen_bdirect(DisasContext *ctx, int = ra, int32_t disp) tcg_gen_goto_tb(0); tcg_gen_movi_i64(cpu_pc, dest); tcg_gen_exit_tb((uintptr_t)ctx->tb); - return EXIT_GOTO_TB; + return DISAS_NORETURN; } else { tcg_gen_movi_i64(cpu_pc, dest); - return EXIT_PC_UPDATED; + return DISAS_PC_UPDATED; } } =20 -static ExitStatus gen_bcond_internal(DisasContext *ctx, TCGCond cond, - TCGv cmp, int32_t disp) +static DisasJumpType gen_bcond_internal(DisasContext *ctx, TCGCond cond, + TCGv cmp, int32_t disp) { uint64_t dest =3D ctx->pc + (disp << 2); TCGLabel *lab_true =3D gen_new_label(); @@ -547,7 +526,7 @@ static ExitStatus gen_bcond_internal(DisasContext *ctx,= TCGCond cond, tcg_gen_movi_i64(cpu_pc, dest); tcg_gen_exit_tb((uintptr_t)ctx->tb + 1); =20 - return EXIT_GOTO_TB; + return DISAS_NORETURN; } else { TCGv_i64 z =3D tcg_const_i64(0); TCGv_i64 d =3D tcg_const_i64(dest); @@ -558,16 +537,16 @@ static ExitStatus gen_bcond_internal(DisasContext *ct= x, TCGCond cond, tcg_temp_free_i64(z); tcg_temp_free_i64(d); tcg_temp_free_i64(p); - return EXIT_PC_UPDATED; + return DISAS_PC_UPDATED; } } =20 -static ExitStatus gen_bcond(DisasContext *ctx, TCGCond cond, int ra, - int32_t disp, int mask) +static DisasJumpType gen_bcond(DisasContext *ctx, TCGCond cond, int ra, + int32_t disp, int mask) { if (mask) { TCGv tmp =3D tcg_temp_new(); - ExitStatus ret; + DisasJumpType ret; =20 tcg_gen_andi_i64(tmp, load_gpr(ctx, ra), 1); ret =3D gen_bcond_internal(ctx, cond, tmp, disp); @@ -609,11 +588,11 @@ static void gen_fold_mzero(TCGCond cond, TCGv dest, T= CGv src) } } =20 -static ExitStatus gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, - int32_t disp) +static DisasJumpType gen_fbcond(DisasContext *ctx, TCGCond cond, int ra, + int32_t disp) { TCGv cmp_tmp =3D tcg_temp_new(); - ExitStatus ret; + DisasJumpType ret; =20 gen_fold_mzero(cond, cmp_tmp, load_fpr(ctx, ra)); ret =3D gen_bcond_internal(ctx, cond, cmp_tmp, disp); @@ -1159,7 +1138,7 @@ static void gen_rx(DisasContext *ctx, int ra, int set) tcg_temp_free(tmp); } =20 -static ExitStatus gen_call_pal(DisasContext *ctx, int palcode) +static DisasJumpType gen_call_pal(DisasContext *ctx, int palcode) { /* We're emulating OSF/1 PALcode. Many of these are trivial access to internal cpu registers. */ @@ -1185,7 +1164,7 @@ static ExitStatus gen_call_pal(DisasContext *ctx, int= palcode) palcode &=3D 0xbf; goto do_call_pal; } - return NO_EXIT; + return DISAS_NEXT; } =20 #ifndef CONFIG_USER_ONLY @@ -1232,7 +1211,7 @@ static ExitStatus gen_call_pal(DisasContext *ctx, int= palcode) =20 /* Allow interrupts to be recognized right away. */ tcg_gen_movi_i64(cpu_pc, ctx->pc); - return EXIT_PC_UPDATED_NOCHAIN; + return DISAS_PC_UPDATED_NOCHAIN; =20 case 0x36: /* RDPS */ @@ -1270,7 +1249,7 @@ static ExitStatus gen_call_pal(DisasContext *ctx, int= palcode) palcode &=3D 0x3f; goto do_call_pal; } - return NO_EXIT; + return DISAS_NEXT; } #endif return gen_invalid(ctx); @@ -1307,10 +1286,10 @@ static ExitStatus gen_call_pal(DisasContext *ctx, i= nt palcode) tcg_gen_goto_tb(0); tcg_gen_movi_i64(cpu_pc, entry); tcg_gen_exit_tb((uintptr_t)ctx->tb); - return EXIT_GOTO_TB; + return DISAS_NORETURN; } else { tcg_gen_movi_i64(cpu_pc, entry); - return EXIT_PC_UPDATED; + return DISAS_PC_UPDATED; } } #endif @@ -1344,7 +1323,7 @@ static int cpu_pr_data(int pr) return 0; } =20 -static ExitStatus gen_mfpr(DisasContext *ctx, TCGv va, int regno) +static DisasJumpType gen_mfpr(DisasContext *ctx, TCGv va, int regno) { void (*helper)(TCGv); int data; @@ -1366,7 +1345,7 @@ static ExitStatus gen_mfpr(DisasContext *ctx, TCGv va= , int regno) gen_io_start(); helper(va); gen_io_end(); - return EXIT_PC_STALE; + return DISAS_PC_STALE; } else { helper(va); } @@ -1393,10 +1372,10 @@ static ExitStatus gen_mfpr(DisasContext *ctx, TCGv = va, int regno) break; } =20 - return NO_EXIT; + return DISAS_NEXT; } =20 -static ExitStatus gen_mtpr(DisasContext *ctx, TCGv vb, int regno) +static DisasJumpType gen_mtpr(DisasContext *ctx, TCGv vb, int regno) { int data; =20 @@ -1424,7 +1403,7 @@ static ExitStatus gen_mtpr(DisasContext *ctx, TCGv vb= , int regno) case 252: /* HALT */ gen_helper_halt(vb); - return EXIT_PC_STALE; + return DISAS_PC_STALE; =20 case 251: /* ALARM */ @@ -1438,7 +1417,7 @@ static ExitStatus gen_mtpr(DisasContext *ctx, TCGv vb= , int regno) that ended with a CALL_PAL. Since the base register usually on= ly changes during boot, flushing everything works well. */ gen_helper_tb_flush(cpu_env); - return EXIT_PC_STALE; + return DISAS_PC_STALE; =20 case 32 ... 39: /* Accessing the "non-shadow" general registers. */ @@ -1467,7 +1446,7 @@ static ExitStatus gen_mtpr(DisasContext *ctx, TCGv vb= , int regno) break; } =20 - return NO_EXIT; + return DISAS_NEXT; } #endif /* !USER_ONLY*/ =20 @@ -1499,7 +1478,7 @@ static ExitStatus gen_mtpr(DisasContext *ctx, TCGv vb= , int regno) } \ } while (0) =20 -static ExitStatus translate_one(DisasContext *ctx, uint32_t insn) +static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn) { int32_t disp21, disp16, disp12 __attribute__((unused)); uint16_t fn11; @@ -1507,7 +1486,7 @@ static ExitStatus translate_one(DisasContext *ctx, ui= nt32_t insn) bool islit, real_islit; TCGv va, vb, vc, tmp, tmp2; TCGv_i32 t32; - ExitStatus ret; + DisasJumpType ret; =20 /* Decode all instruction fields */ opc =3D extract32(insn, 26, 6); @@ -1530,7 +1509,7 @@ static ExitStatus translate_one(DisasContext *ctx, ui= nt32_t insn) lit =3D 0; } =20 - ret =3D NO_EXIT; + ret =3D DISAS_NEXT; switch (opc) { case 0x00: /* CALL_PAL */ @@ -2432,7 +2411,7 @@ static ExitStatus translate_one(DisasContext *ctx, ui= nt32_t insn) gen_io_start(); gen_helper_load_pcc(va, cpu_env); gen_io_end(); - ret =3D EXIT_PC_STALE; + ret =3D DISAS_PC_STALE; } else { gen_helper_load_pcc(va, cpu_env); } @@ -2480,7 +2459,7 @@ static ExitStatus translate_one(DisasContext *ctx, ui= nt32_t insn) if (ra !=3D 31) { tcg_gen_movi_i64(ctx->ir[ra], ctx->pc); } - ret =3D EXIT_PC_UPDATED; + ret =3D DISAS_PC_UPDATED; break; =20 case 0x1B: @@ -2738,7 +2717,7 @@ static ExitStatus translate_one(DisasContext *ctx, ui= nt32_t insn) tcg_temp_free(tmp); tcg_gen_andi_i64(cpu_pc, vb, ~3); /* Allow interrupts to be recognized right away. */ - ret =3D EXIT_PC_UPDATED_NOCHAIN; + ret =3D DISAS_PC_UPDATED_NOCHAIN; break; #else goto invalid_opc; @@ -2959,7 +2938,7 @@ void gen_intermediate_code(CPUState *cs, struct Trans= lationBlock *tb) target_ulong pc_start; target_ulong pc_mask; uint32_t insn; - ExitStatus ret; + DisasJumpType ret; int num_insns; int max_insns; =20 @@ -3040,41 +3019,40 @@ void gen_intermediate_code(CPUState *cs, struct Tra= nslationBlock *tb) =20 /* If we reach a page boundary, are single stepping, or exhaust instruction count, stop generation. */ - if (ret =3D=3D NO_EXIT + if (ret =3D=3D DISAS_NEXT && ((ctx.pc & pc_mask) =3D=3D 0 || tcg_op_buf_full() || num_insns >=3D max_insns || singlestep || ctx.singlestep_enabled)) { - ret =3D EXIT_FALLTHRU; + ret =3D DISAS_TOO_MANY; } - } while (ret =3D=3D NO_EXIT); + } while (ret =3D=3D DISAS_NEXT); =20 if (tb->cflags & CF_LAST_IO) { gen_io_end(); } =20 switch (ret) { - case EXIT_GOTO_TB: - case EXIT_NORETURN: + case DISAS_NORETURN: break; - case EXIT_FALLTHRU: + case DISAS_TOO_MANY: if (use_goto_tb(&ctx, ctx.pc)) { tcg_gen_goto_tb(0); tcg_gen_movi_i64(cpu_pc, ctx.pc); tcg_gen_exit_tb((uintptr_t)ctx.tb); } /* FALLTHRU */ - case EXIT_PC_STALE: + case DISAS_PC_STALE: tcg_gen_movi_i64(cpu_pc, ctx.pc); /* FALLTHRU */ - case EXIT_PC_UPDATED: + case DISAS_PC_UPDATED: if (!use_exit_tb(&ctx)) { tcg_gen_lookup_and_goto_ptr(cpu_pc); break; } /* FALLTHRU */ - case EXIT_PC_UPDATED_NOCHAIN: + case DISAS_PC_UPDATED_NOCHAIN: if (ctx.singlestep_enabled) { gen_excp_1(EXCP_DEBUG, 0); } else { --=20 2.13.5