From nobody Tue May 7 17:52:43 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1624170096; cv=none; d=zohomail.com; s=zohoarc; b=DbSo6GlFhzMMabKXjPYPmXNBHwCqJQGurwdgUogMubGPXqEGCp6z+OuK1IWO9Mm4SINCFHbx+LRrfKOq09by/MAfI4xU0/95PTdybRdaMn7bDeFvVFrPpkBfAs84Nbmi6psUIBH6IPSA3fti/nMTSIqrTq7tnSj/eZ0tBmsNP70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624170096; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WC4ZZt46aoWhKlwhfKzGhMWDEJXJ1wMQw+caZWV+JNY=; b=cKv07DnCUhNN1cOpTOGc4tQ5s5zs2Y0MKdGpa02xmIGgDyxxXxxhAt9k9XC9ZpfFjV+8xio6ug/bm+d2+K1IlLcszpByohiEKrwKBHcd+kFHFo8Iql5BKTf+qbPVaFbRjwdcItTH2Gc3D3fKDqroOWMn8dkjd11sQagaPtXGOpk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624170096492258.01189121259404; Sat, 19 Jun 2021 23:21:36 -0700 (PDT) Received: from localhost ([::1]:39976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luqpr-0002pp-9q for importer2@patchew.org; Sun, 20 Jun 2021 02:21:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luqoY-0000e1-W9 for qemu-devel@nongnu.org; Sun, 20 Jun 2021 02:20:15 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:40766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luqoU-0002HM-I1 for qemu-devel@nongnu.org; Sun, 20 Jun 2021 02:20:14 -0400 Received: by mail-pj1-x1034.google.com with SMTP id bb10-20020a17090b008ab029016eef083425so10191104pjb.5 for ; Sat, 19 Jun 2021 23:20:10 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id s123sm11607661pfb.78.2021.06.19.23.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Jun 2021 23:20:09 -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 :mime-version:content-transfer-encoding; bh=WC4ZZt46aoWhKlwhfKzGhMWDEJXJ1wMQw+caZWV+JNY=; b=MxhPgFM8pGjtSW93ixK11pLgnXHAiXegOok8g20xrTyOdYwTCrxhmb+P5qb34FJe+y 74iglr/fQ3OUBWfaCV9v5KEmSdEUSoenoo5crFcx8K7gX5XrwDwRy8HHSAvANCS7aO9C 13n1cSq3bEFyo4guttzCczvHs2ok9ELfyus4wAEmXvutjZQzi/p437wj6lo+0RaSFoSc rZtyVafB9jjoy6V/AcEyLslRXLpXdNJor9wCeLbrX2F9SkkjqbWyuTpUw3UvayYAmboP zt1E8c/l3GH+r0uaVTjngQXOEqCvWckofoTrxejJPXggJkjQoKqeOdi7umwPCDAAM/zJ WPKg== 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:mime-version:content-transfer-encoding; bh=WC4ZZt46aoWhKlwhfKzGhMWDEJXJ1wMQw+caZWV+JNY=; b=rhHAS2qyqmcaH1ByktlpFYNMbklPX1ot/ChSaBNL4Npgev8grwLiGkBKOwRvQv78iX biNOFf67sn6IjwIANfMiKK9suu0HtaHmRUEY/7XJZFJmqVtkoa+gNHkeGUjLeQZmuKB1 X6WKNo9Zr3OKpCk1h+Kg5/HUKMlaBJ1UHU1HoyaI8dM572OhWL1LgpxEkdq3E2cozRIz DY6bY5pxK2gY233v2BJCgUoMHVIig3oYoaa50sM80qK+1FKCb5waYFkx2O9LqWqkIo1S +9CC8QyAQDI+1bXdKAsXvFFnOk/VY5UX9QeYYHtr2xwIJYfEDrMJWc15gdBfwI3mfGzn ZrLQ== X-Gm-Message-State: AOAM533wFYDonzXsM+5uT7vo4FMO6LSi6fZRdltRJIblVq0VN0Ztnqu2 pAJfm26rkYPlkddnoQXA/QZkXP9m43u5Bg== X-Google-Smtp-Source: ABdhPJxp2v2dhCBuM5vAhizbyo8oGt6muCzyI2IAFhg59ttYJT5pr5W73kBroAJgbdC2YqmPhQP0qg== X-Received: by 2002:a17:903:228e:b029:101:af04:4e24 with SMTP id b14-20020a170903228eb0290101af044e24mr12218865plh.3.1624170009336; Sat, 19 Jun 2021 23:20:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/3] target/avr: Add DisasContextBase to DisasContext Date: Sat, 19 Jun 2021 23:20:05 -0700 Message-Id: <20210620062007.1398574-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210620062007.1398574-1-richard.henderson@linaro.org> References: <20210620062007.1398574-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mrolnik@gmail.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Migrate the bstate, tb and singlestep_enabled fields from DisasContext into the base. Signed-off-by: Richard Henderson --- target/avr/translate.c | 58 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/target/avr/translate.c b/target/avr/translate.c index 850c5941d9..20c5062730 100644 --- a/target/avr/translate.c +++ b/target/avr/translate.c @@ -80,7 +80,7 @@ typedef struct DisasContext DisasContext; =20 /* This is the state at translation time. */ struct DisasContext { - TranslationBlock *tb; + DisasContextBase base; =20 CPUAVRState *env; CPUState *cs; @@ -90,8 +90,6 @@ struct DisasContext { =20 /* Routine used to access memory */ int memidx; - int bstate; - int singlestep; =20 /* * some AVR instructions can make the following instruction to be skip= ped @@ -191,7 +189,7 @@ static bool avr_have_feature(DisasContext *ctx, int fea= ture) { if (!avr_feature(ctx->env, feature)) { gen_helper_unsupported(cpu_env); - ctx->bstate =3D DISAS_NORETURN; + ctx->base.is_jmp =3D DISAS_NORETURN; return false; } return true; @@ -1011,13 +1009,13 @@ static void gen_jmp_ez(DisasContext *ctx) { tcg_gen_deposit_tl(cpu_pc, cpu_r[30], cpu_r[31], 8, 8); tcg_gen_or_tl(cpu_pc, cpu_pc, cpu_eind); - ctx->bstate =3D DISAS_LOOKUP; + ctx->base.is_jmp =3D DISAS_LOOKUP; } =20 static void gen_jmp_z(DisasContext *ctx) { tcg_gen_deposit_tl(cpu_pc, cpu_r[30], cpu_r[31], 8, 8); - ctx->bstate =3D DISAS_LOOKUP; + ctx->base.is_jmp =3D DISAS_LOOKUP; } =20 static void gen_push_ret(DisasContext *ctx, int ret) @@ -1083,9 +1081,9 @@ static void gen_pop_ret(DisasContext *ctx, TCGv ret) =20 static void gen_goto_tb(DisasContext *ctx, int n, target_ulong dest) { - TranslationBlock *tb =3D ctx->tb; + const TranslationBlock *tb =3D ctx->base.tb; =20 - if (ctx->singlestep =3D=3D 0) { + if (!ctx->base.singlestep_enabled) { tcg_gen_goto_tb(n); tcg_gen_movi_i32(cpu_pc, dest); tcg_gen_exit_tb(tb, n); @@ -1094,7 +1092,7 @@ static void gen_goto_tb(DisasContext *ctx, int n, tar= get_ulong dest) gen_helper_debug(cpu_env); tcg_gen_exit_tb(NULL, 0); } - ctx->bstate =3D DISAS_NORETURN; + ctx->base.is_jmp =3D DISAS_NORETURN; } =20 /* @@ -1254,7 +1252,7 @@ static bool trans_RET(DisasContext *ctx, arg_RET *a) { gen_pop_ret(ctx, cpu_pc); =20 - ctx->bstate =3D DISAS_LOOKUP; + ctx->base.is_jmp =3D DISAS_LOOKUP; return true; } =20 @@ -1272,7 +1270,7 @@ static bool trans_RETI(DisasContext *ctx, arg_RETI *a) tcg_gen_movi_tl(cpu_If, 1); =20 /* Need to return to main loop to re-evaluate interrupts. */ - ctx->bstate =3D DISAS_EXIT; + ctx->base.is_jmp =3D DISAS_EXIT; return true; } =20 @@ -1484,7 +1482,7 @@ static bool trans_BRBC(DisasContext *ctx, arg_BRBC *a) gen_goto_tb(ctx, 0, ctx->npc + a->imm); gen_set_label(not_taken); =20 - ctx->bstate =3D DISAS_CHAIN; + ctx->base.is_jmp =3D DISAS_CHAIN; return true; } =20 @@ -1533,7 +1531,7 @@ static bool trans_BRBS(DisasContext *ctx, arg_BRBS *a) gen_goto_tb(ctx, 0, ctx->npc + a->imm); gen_set_label(not_taken); =20 - ctx->bstate =3D DISAS_CHAIN; + ctx->base.is_jmp =3D DISAS_CHAIN; return true; } =20 @@ -1610,7 +1608,7 @@ static TCGv gen_get_zaddr(void) */ static void gen_data_store(DisasContext *ctx, TCGv data, TCGv addr) { - if (ctx->tb->flags & TB_FLAGS_FULL_ACCESS) { + if (ctx->base.tb->flags & TB_FLAGS_FULL_ACCESS) { gen_helper_fullwr(cpu_env, data, addr); } else { tcg_gen_qemu_st8(data, addr, MMU_DATA_IDX); /* mem[addr] =3D data = */ @@ -1619,7 +1617,7 @@ static void gen_data_store(DisasContext *ctx, TCGv da= ta, TCGv addr) =20 static void gen_data_load(DisasContext *ctx, TCGv data, TCGv addr) { - if (ctx->tb->flags & TB_FLAGS_FULL_ACCESS) { + if (ctx->base.tb->flags & TB_FLAGS_FULL_ACCESS) { gen_helper_fullrd(data, cpu_env, addr); } else { tcg_gen_qemu_ld8u(data, addr, MMU_DATA_IDX); /* data =3D mem[addr]= */ @@ -2793,7 +2791,7 @@ static bool trans_BREAK(DisasContext *ctx, arg_BREAK = *a) #ifdef BREAKPOINT_ON_BREAK tcg_gen_movi_tl(cpu_pc, ctx->npc - 1); gen_helper_debug(cpu_env); - ctx->bstate =3D DISAS_EXIT; + ctx->base.is_jmp =3D DISAS_EXIT; #else /* NOP */ #endif @@ -2819,7 +2817,7 @@ static bool trans_NOP(DisasContext *ctx, arg_NOP *a) static bool trans_SLEEP(DisasContext *ctx, arg_SLEEP *a) { gen_helper_sleep(cpu_env); - ctx->bstate =3D DISAS_NORETURN; + ctx->base.is_jmp =3D DISAS_NORETURN; return true; } =20 @@ -2850,7 +2848,7 @@ static void translate(DisasContext *ctx) =20 if (!decode_insn(ctx, opcode)) { gen_helper_unsupported(cpu_env); - ctx->bstate =3D DISAS_NORETURN; + ctx->base.is_jmp =3D DISAS_NORETURN; } } =20 @@ -2903,13 +2901,15 @@ void gen_intermediate_code(CPUState *cs, Translatio= nBlock *tb, int max_insns) { CPUAVRState *env =3D cs->env_ptr; DisasContext ctx =3D { - .tb =3D tb, + .base.tb =3D tb, + .base.is_jmp =3D DISAS_NEXT, + .base.pc_first =3D tb->pc, + .base.pc_next =3D tb->pc, + .base.singlestep_enabled =3D cs->singlestep_enabled, .cs =3D cs, .env =3D env, .memidx =3D 0, - .bstate =3D DISAS_NEXT, .skip_cond =3D TCG_COND_NEVER, - .singlestep =3D cs->singlestep_enabled, }; target_ulong pc_start =3D tb->pc / 2; int num_insns =3D 0; @@ -2921,7 +2921,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb, int max_insns) */ max_insns =3D 1; } - if (ctx.singlestep) { + if (ctx.base.singlestep_enabled) { max_insns =3D 1; } =20 @@ -2946,7 +2946,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb, int max_insns) * b main - sets breakpoint at address 0x00000100 (code) * b *0x100 - sets breakpoint at address 0x00800100 (data) */ - if (unlikely(!ctx.singlestep && + if (unlikely(!ctx.base.singlestep_enabled && (cpu_breakpoint_test(cs, OFFSET_CODE + ctx.npc * 2, BP_ANY= ) || cpu_breakpoint_test(cs, OFFSET_DATA + ctx.npc * 2, BP_ANY= )))) { canonicalize_skip(&ctx); @@ -2989,11 +2989,11 @@ void gen_intermediate_code(CPUState *cs, Translatio= nBlock *tb, int max_insns) if (skip_label) { canonicalize_skip(&ctx); gen_set_label(skip_label); - if (ctx.bstate =3D=3D DISAS_NORETURN) { - ctx.bstate =3D DISAS_CHAIN; + if (ctx.base.is_jmp =3D=3D DISAS_NORETURN) { + ctx.base.is_jmp =3D DISAS_CHAIN; } } - } while (ctx.bstate =3D=3D DISAS_NEXT + } while (ctx.base.is_jmp =3D=3D DISAS_NEXT && num_insns < max_insns && (ctx.npc - pc_start) * 2 < TARGET_PAGE_SIZE - 4 && !tcg_op_buf_full()); @@ -3004,7 +3004,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb, int max_insns) =20 bool nonconst_skip =3D canonicalize_skip(&ctx); =20 - switch (ctx.bstate) { + switch (ctx.base.is_jmp) { case DISAS_NORETURN: assert(!nonconst_skip); break; @@ -3019,13 +3019,13 @@ void gen_intermediate_code(CPUState *cs, Translatio= nBlock *tb, int max_insns) tcg_gen_movi_tl(cpu_pc, ctx.npc); /* fall through */ case DISAS_LOOKUP: - if (!ctx.singlestep) { + if (!ctx.base.singlestep_enabled) { tcg_gen_lookup_and_goto_ptr(); break; } /* fall through */ case DISAS_EXIT: - if (ctx.singlestep) { + if (ctx.base.singlestep_enabled) { gen_helper_debug(cpu_env); } else { tcg_gen_exit_tb(NULL, 0); --=20 2.25.1 From nobody Tue May 7 17:52:43 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1624170183; cv=none; d=zohomail.com; s=zohoarc; b=eU9g572Vf72IRYcZsnp/p50eOegDQBuVoc19KN3fXoaalwMODjFWbdFwtLLryozfJiwXraXKrEBTMlrRIHXpSWmKaaKPvtWawcfmpFQXMwcQAuzWdo3WsVcfMWYrL2f1/P7uIwkbm2YGXA/LuhEIa2f+E2OIFkzs8T85QQAVSqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624170183; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Rdx+vNgmwrn+uNEt8j9Ac8DXUSdgEvkCxbSAocLdAWU=; b=TBX2MLQDgB8KqT1Osw/4JZplt1JHI8fn1uqycdFDDGBBCgN1aNRu6UaTmfRuzRk6caX1F59v8j0gNwJeP2kXMfCva07Xm2fpUoHZBim+wb8mU+CQrK+tQ68985ZP3tcNp3YTbZdunAQ5KHT+HyE3M5r0jTdgQ8DmiLW5cQW5Ph0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1624170183371142.87650197633388; Sat, 19 Jun 2021 23:23:03 -0700 (PDT) Received: from localhost ([::1]:45200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luqrG-0006Ih-BX for importer2@patchew.org; Sun, 20 Jun 2021 02:23:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luqoc-0000lr-3j for qemu-devel@nongnu.org; Sun, 20 Jun 2021 02:20:18 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]:39608) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luqoZ-0002Lc-TT for qemu-devel@nongnu.org; Sun, 20 Jun 2021 02:20:17 -0400 Received: by mail-pj1-x102b.google.com with SMTP id o88-20020a17090a0a61b029016eeb2adf66so10385077pjo.4 for ; Sat, 19 Jun 2021 23:20:15 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id s123sm11607661pfb.78.2021.06.19.23.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Jun 2021 23:20:09 -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 :mime-version:content-transfer-encoding; bh=Rdx+vNgmwrn+uNEt8j9Ac8DXUSdgEvkCxbSAocLdAWU=; b=hYK6U2wVoTSoOb6dPClu9T8+3kSofVXmIjZLX/MJdo1J1po0UWaFeCpKYkdA/WpTkC Zy7xnZELphYSMwYg3SSOR+4G4aI682SzR3o/4sQesq4rfFM8RLlCIPoczE6l6ZXOThwM gyebRgW7ChwnmH7FFrHsLlQcN5OFv4KuES7aQxpyD2oqR/DsThbsf+Ct9KiVjIhsHBsG VG6ACOQkFNL9icD564sxivoTzOQAjNiuqssTfgnqu/oxRCVBDU1YG1qQEJm0FsRnga0g klqSrr1Mtgl8Y9R11MFMsMPZQ2EE0DRNr1IgakEJIXP9LU+kld1eZYl6lCujJIdvIUfW FPtw== 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:mime-version:content-transfer-encoding; bh=Rdx+vNgmwrn+uNEt8j9Ac8DXUSdgEvkCxbSAocLdAWU=; b=GWACnF3uaFtX8vF9LmECWMo9EijsModx2aWq05nxId2CholeRnD1BfPiKA4GH0CIHc i+/575iVyiyrt27ooUSfZzv2c8XmLjkZXDdSx3GF+Yu5lLD5YXx8pxR2M/Ks4yQVBLCi 3VGBJEy9uh+qi+u5NkJ8fveawXsGGMTUK6P0H3oKuirGVi1vnxo44OILYJtkEd13/PcB pCCwxEfQPe4CExZpXL2aVdNb++7R/IXXc4EanefAy/zkjcZsA6aMPnunDJnOrMiK3DJB HcTD/wYiEVXlV3maa9vGeXy7t791u7kH46zXu71uLv6g+NfK0ye3VK0uvWjHOmp9HXVA eZ/A== X-Gm-Message-State: AOAM531W9/J3mMviNNep+7DQnNu8ZcFn/l5WB6CkJ13dISGqITa3cqVQ faG+neuLiMF64EhPuyyYokBWf9y2nnIuIg== X-Google-Smtp-Source: ABdhPJzBjbeQGvu9Qm43DsH6e4yTmmJJOKHMO6jmcGc6UD3HdMmVMLMOFLwUZFZEAMGTGUrfWrGVvA== X-Received: by 2002:a17:90a:3801:: with SMTP id w1mr31090574pjb.138.1624170009784; Sat, 19 Jun 2021 23:20:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/3] target/avr: Change ctx to DisasContext* in gen_intermediate_code Date: Sat, 19 Jun 2021 23:20:06 -0700 Message-Id: <20210620062007.1398574-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210620062007.1398574-1-richard.henderson@linaro.org> References: <20210620062007.1398574-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mrolnik@gmail.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Prepare for receiving it as a pointer input. Signed-off-by: Richard Henderson --- target/avr/translate.c | 84 +++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/target/avr/translate.c b/target/avr/translate.c index 20c5062730..66e9882422 100644 --- a/target/avr/translate.c +++ b/target/avr/translate.c @@ -104,7 +104,7 @@ struct DisasContext { * used in the following manner (sketch) * * TCGLabel *skip_label =3D NULL; - * if (ctx.skip_cond !=3D TCG_COND_NEVER) { + * if (ctx->skip_cond !=3D TCG_COND_NEVER) { * skip_label =3D gen_new_label(); * tcg_gen_brcond_tl(skip_cond, skip_var0, skip_var1, skip_label); * } @@ -114,7 +114,7 @@ struct DisasContext { * free_skip_var0 =3D false; * } * - * translate(&ctx); + * translate(ctx); * * if (skip_label) { * gen_set_label(skip_label); @@ -2900,7 +2900,7 @@ static bool canonicalize_skip(DisasContext *ctx) void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_ins= ns) { CPUAVRState *env =3D cs->env_ptr; - DisasContext ctx =3D { + DisasContext ctx1 =3D { .base.tb =3D tb, .base.is_jmp =3D DISAS_NEXT, .base.pc_first =3D tb->pc, @@ -2911,6 +2911,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb, int max_insns) .memidx =3D 0, .skip_cond =3D TCG_COND_NEVER, }; + DisasContext *ctx =3D &ctx1; target_ulong pc_start =3D tb->pc / 2; int num_insns =3D 0; =20 @@ -2921,23 +2922,23 @@ void gen_intermediate_code(CPUState *cs, Translatio= nBlock *tb, int max_insns) */ max_insns =3D 1; } - if (ctx.base.singlestep_enabled) { + if (ctx->base.singlestep_enabled) { max_insns =3D 1; } =20 gen_tb_start(tb); =20 - ctx.npc =3D pc_start; + ctx->npc =3D pc_start; if (tb->flags & TB_FLAGS_SKIP) { - ctx.skip_cond =3D TCG_COND_ALWAYS; - ctx.skip_var0 =3D cpu_skip; + ctx->skip_cond =3D TCG_COND_ALWAYS; + ctx->skip_var0 =3D cpu_skip; } =20 do { TCGLabel *skip_label =3D NULL; =20 /* translate current instruction */ - tcg_gen_insn_start(ctx.npc); + tcg_gen_insn_start(ctx->npc); num_insns++; =20 /* @@ -2946,65 +2947,66 @@ void gen_intermediate_code(CPUState *cs, Translatio= nBlock *tb, int max_insns) * b main - sets breakpoint at address 0x00000100 (code) * b *0x100 - sets breakpoint at address 0x00800100 (data) */ - if (unlikely(!ctx.base.singlestep_enabled && - (cpu_breakpoint_test(cs, OFFSET_CODE + ctx.npc * 2, BP_ANY= ) || - cpu_breakpoint_test(cs, OFFSET_DATA + ctx.npc * 2, BP_ANY= )))) { - canonicalize_skip(&ctx); - tcg_gen_movi_tl(cpu_pc, ctx.npc); + if (unlikely(!ctx->base.singlestep_enabled && + (cpu_breakpoint_test(cs, OFFSET_CODE + ctx->npc * 2, BP_ANY) || + cpu_breakpoint_test(cs, OFFSET_DATA + ctx->npc * 2, BP_ANY)))= ) { + canonicalize_skip(ctx); + tcg_gen_movi_tl(cpu_pc, ctx->npc); gen_helper_debug(cpu_env); goto done_generating; } =20 /* Conditionally skip the next instruction, if indicated. */ - if (ctx.skip_cond !=3D TCG_COND_NEVER) { + if (ctx->skip_cond !=3D TCG_COND_NEVER) { skip_label =3D gen_new_label(); - if (ctx.skip_var0 =3D=3D cpu_skip) { + if (ctx->skip_var0 =3D=3D cpu_skip) { /* * Copy cpu_skip so that we may zero it before the branch. * This ensures that cpu_skip is non-zero after the label * if and only if the skipped insn itself sets a skip. */ - ctx.free_skip_var0 =3D true; - ctx.skip_var0 =3D tcg_temp_new(); - tcg_gen_mov_tl(ctx.skip_var0, cpu_skip); + ctx->free_skip_var0 =3D true; + ctx->skip_var0 =3D tcg_temp_new(); + tcg_gen_mov_tl(ctx->skip_var0, cpu_skip); tcg_gen_movi_tl(cpu_skip, 0); } - if (ctx.skip_var1 =3D=3D NULL) { - tcg_gen_brcondi_tl(ctx.skip_cond, ctx.skip_var0, 0, skip_l= abel); + if (ctx->skip_var1 =3D=3D NULL) { + tcg_gen_brcondi_tl(ctx->skip_cond, ctx->skip_var0, + 0, skip_label); } else { - tcg_gen_brcond_tl(ctx.skip_cond, ctx.skip_var0, - ctx.skip_var1, skip_label); - ctx.skip_var1 =3D NULL; + tcg_gen_brcond_tl(ctx->skip_cond, ctx->skip_var0, + ctx->skip_var1, skip_label); + ctx->skip_var1 =3D NULL; } - if (ctx.free_skip_var0) { - tcg_temp_free(ctx.skip_var0); - ctx.free_skip_var0 =3D false; + if (ctx->free_skip_var0) { + tcg_temp_free(ctx->skip_var0); + ctx->free_skip_var0 =3D false; } - ctx.skip_cond =3D TCG_COND_NEVER; - ctx.skip_var0 =3D NULL; + ctx->skip_cond =3D TCG_COND_NEVER; + ctx->skip_var0 =3D NULL; } =20 - translate(&ctx); + translate(ctx); =20 if (skip_label) { - canonicalize_skip(&ctx); + canonicalize_skip(ctx); gen_set_label(skip_label); - if (ctx.base.is_jmp =3D=3D DISAS_NORETURN) { - ctx.base.is_jmp =3D DISAS_CHAIN; + if (ctx->base.is_jmp =3D=3D DISAS_NORETURN) { + ctx->base.is_jmp =3D DISAS_CHAIN; } } - } while (ctx.base.is_jmp =3D=3D DISAS_NEXT + } while (ctx->base.is_jmp =3D=3D DISAS_NEXT && num_insns < max_insns - && (ctx.npc - pc_start) * 2 < TARGET_PAGE_SIZE - 4 + && (ctx->npc - pc_start) * 2 < TARGET_PAGE_SIZE - 4 && !tcg_op_buf_full()); =20 if (tb->cflags & CF_LAST_IO) { gen_io_end(); } =20 - bool nonconst_skip =3D canonicalize_skip(&ctx); + bool nonconst_skip =3D canonicalize_skip(ctx); =20 - switch (ctx.base.is_jmp) { + switch (ctx->base.is_jmp) { case DISAS_NORETURN: assert(!nonconst_skip); break; @@ -3013,19 +3015,19 @@ void gen_intermediate_code(CPUState *cs, Translatio= nBlock *tb, int max_insns) case DISAS_CHAIN: if (!nonconst_skip) { /* Note gen_goto_tb checks singlestep. */ - gen_goto_tb(&ctx, 1, ctx.npc); + gen_goto_tb(ctx, 1, ctx->npc); break; } - tcg_gen_movi_tl(cpu_pc, ctx.npc); + tcg_gen_movi_tl(cpu_pc, ctx->npc); /* fall through */ case DISAS_LOOKUP: - if (!ctx.base.singlestep_enabled) { + if (!ctx->base.singlestep_enabled) { tcg_gen_lookup_and_goto_ptr(); break; } /* fall through */ case DISAS_EXIT: - if (ctx.base.singlestep_enabled) { + if (ctx->base.singlestep_enabled) { gen_helper_debug(cpu_env); } else { tcg_gen_exit_tb(NULL, 0); @@ -3038,7 +3040,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb, int max_insns) done_generating: gen_tb_end(tb, num_insns); =20 - tb->size =3D (ctx.npc - pc_start) * 2; + tb->size =3D (ctx->npc - pc_start) * 2; tb->icount =3D num_insns; =20 #ifdef DEBUG_DISAS --=20 2.25.1 From nobody Tue May 7 17:52:43 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1624170096; cv=none; d=zohomail.com; s=zohoarc; b=LOgIV7XgFVdDf2waqh/MtGqGTizoKHb1UOiIqzJhWrPpC1Iy12ufud/Tb/qPYUqM+V4c5ufVj50jSGyJxKhs9nvyA5R81KgMKttD0KSXheRdd6VSbtWGMOV++6k0zbGe18yYXLM0+EPvfPzDNU1T7WcUNC1PoH9f0RvvdBJSsnw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624170096; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qg7nLGJXefPL6b3exZ/dB+1f0DJPVJvddBDXPcdDQaY=; b=Ujoza5fC/1gcnKCGNyblT2vLRSlb3mA76dYwZZlP1BmfpYa9nSqV7R8ITZ3kEPQQg6uJu4lsXdwdR+iUotLC78lH+kLgietTAHXaHqCpUyqeQbKfhss/rXvEmU/ywjkIZnhsTcbCSrm7Vr2Azy5fFxEnWiXyxFK+A+fk3h7FO1I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 162417009675053.73598264578288; Sat, 19 Jun 2021 23:21:36 -0700 (PDT) Received: from localhost ([::1]:39980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luqpr-0002qA-NS for importer2@patchew.org; Sun, 20 Jun 2021 02:21:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50468) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luqoY-0000ch-4n for qemu-devel@nongnu.org; Sun, 20 Jun 2021 02:20:14 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:55943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luqoV-0002I5-N4 for qemu-devel@nongnu.org; Sun, 20 Jun 2021 02:20:13 -0400 Received: by mail-pj1-x102a.google.com with SMTP id l11so3717812pji.5 for ; Sat, 19 Jun 2021 23:20:11 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id s123sm11607661pfb.78.2021.06.19.23.20.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Jun 2021 23:20:10 -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 :mime-version:content-transfer-encoding; bh=qg7nLGJXefPL6b3exZ/dB+1f0DJPVJvddBDXPcdDQaY=; b=ht86huEz0p2QfLqvdbZdZ4gIS3eXRUK/NDCKAlLYkn6JoyMOytlON3pq9mr5+zUWpY 9GobA171AtvbsNOHLqeuQGV3m815uojVzE4harjdHdwn8NPe2MCQl6uWQnBE2swxiyTd jXyy0l8VhKCanqfAPMgJSC0beJi7YtEsSE3tGBrQkCOrYR64dBgog4AqVxZI9RNuV+XX u8LPkDEyOrURx2b0mTmBJF9LvsBMYcJ+C6VB2I5PurrKN/E0zbYeVg4EHYlAtv4KcQBv H+U/XPAjKWhyYV0bnARkE6Hk8PM9nW5VaYa8POoiK5b/oCttibZrrgRYPF5j+//IbupR /Ehg== 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:mime-version:content-transfer-encoding; bh=qg7nLGJXefPL6b3exZ/dB+1f0DJPVJvddBDXPcdDQaY=; b=ptgHcPW9DxZKJtzI2U0FnD0EKBL0JJIob8zPgMu6jCyJdIe8V9ck5BWj0jfs8sI7I2 f/xuH3hUdTaB/8EcY8mbgapCg9V52irt0dSwSDEFwglMjzbh6Eu2lCuKorkbUyGd7f0A UEPoNF3gTzBvJi3jAokgaDv30tCd1Mrg+Sp7FwgkUH4IjsjeWw1IyBehoec5x1YvR3Rv a7xCy/jnz1lXD0BkjTM0XZ246bMLRDrUT47THqwEUrlf9HAI+YCE83eefot05IjbCgbb HNvWMRBRQ4fu5WGGzgrr58JzZpf1Cx1LWPI43Frcw3Ul0HJXAc7YxuvLK3D1TQrRzS2G EeTQ== X-Gm-Message-State: AOAM533xMy/un/E+jBsdfuLQ9WlJcS8deuXBHEGQN/6ehwvOVtp8530O NlPBuMPKpAHdNU8isQXh3vjqodmOrubrIw== X-Google-Smtp-Source: ABdhPJxHsthc+ONFQ1q+sWS/c2NNIKAtzlEyVY9zGk/JQ8Q0rb2e6/hXVXzJ9VgcdlkvyUaZuypC8Q== X-Received: by 2002:a17:90a:fb95:: with SMTP id cp21mr1325159pjb.28.1624170010257; Sat, 19 Jun 2021 23:20:10 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/3] target/avr: Convert to TranslatorOps Date: Sat, 19 Jun 2021 23:20:07 -0700 Message-Id: <20210620062007.1398574-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210620062007.1398574-1-richard.henderson@linaro.org> References: <20210620062007.1398574-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mrolnik@gmail.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- target/avr/translate.c | 238 +++++++++++++++++++++++------------------ 1 file changed, 132 insertions(+), 106 deletions(-) diff --git a/target/avr/translate.c b/target/avr/translate.c index 66e9882422..72117bf3b9 100644 --- a/target/avr/translate.c +++ b/target/avr/translate.c @@ -2897,113 +2897,135 @@ static bool canonicalize_skip(DisasContext *ctx) return true; } =20 -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_ins= ns) +static void gen_breakpoint(DisasContext *ctx) { + canonicalize_skip(ctx); + tcg_gen_movi_tl(cpu_pc, ctx->npc); + gen_helper_debug(cpu_env); + ctx->base.is_jmp =3D DISAS_NORETURN; +} + +static void avr_tr_init_disas_context(DisasContextBase *dcbase, CPUState *= cs) +{ + DisasContext *ctx =3D container_of(dcbase, DisasContext, base); CPUAVRState *env =3D cs->env_ptr; - DisasContext ctx1 =3D { - .base.tb =3D tb, - .base.is_jmp =3D DISAS_NEXT, - .base.pc_first =3D tb->pc, - .base.pc_next =3D tb->pc, - .base.singlestep_enabled =3D cs->singlestep_enabled, - .cs =3D cs, - .env =3D env, - .memidx =3D 0, - .skip_cond =3D TCG_COND_NEVER, - }; - DisasContext *ctx =3D &ctx1; - target_ulong pc_start =3D tb->pc / 2; - int num_insns =3D 0; + uint32_t tb_flags =3D ctx->base.tb->flags; =20 - if (tb->flags & TB_FLAGS_FULL_ACCESS) { - /* - * This flag is set by ST/LD instruction we will regenerate it ONLY - * with mem/cpu memory access instead of mem access - */ - max_insns =3D 1; - } - if (ctx->base.singlestep_enabled) { - max_insns =3D 1; - } + ctx->cs =3D cs, + ctx->env =3D env, + ctx->memidx =3D 0, + ctx->npc =3D ctx->base.pc_first / 2; =20 - gen_tb_start(tb); - - ctx->npc =3D pc_start; - if (tb->flags & TB_FLAGS_SKIP) { + ctx->skip_cond =3D TCG_COND_NEVER; + if (tb_flags & TB_FLAGS_SKIP) { ctx->skip_cond =3D TCG_COND_ALWAYS; ctx->skip_var0 =3D cpu_skip; } =20 - do { - TCGLabel *skip_label =3D NULL; - - /* translate current instruction */ - tcg_gen_insn_start(ctx->npc); - num_insns++; - + if (tb_flags & TB_FLAGS_FULL_ACCESS) { /* - * this is due to some strange GDB behavior - * let's assume main has address 0x100 - * b main - sets breakpoint at address 0x00000100 (code) - * b *0x100 - sets breakpoint at address 0x00800100 (data) + * This flag is set by ST/LD instruction we will regenerate it ONLY + * with mem/cpu memory access instead of mem access */ - if (unlikely(!ctx->base.singlestep_enabled && - (cpu_breakpoint_test(cs, OFFSET_CODE + ctx->npc * 2, BP_ANY) || - cpu_breakpoint_test(cs, OFFSET_DATA + ctx->npc * 2, BP_ANY)))= ) { - canonicalize_skip(ctx); - tcg_gen_movi_tl(cpu_pc, ctx->npc); - gen_helper_debug(cpu_env); - goto done_generating; - } + ctx->base.max_insns =3D 1; + } + if (ctx->base.singlestep_enabled) { + ctx->base.max_insns =3D 1; + } +} =20 - /* Conditionally skip the next instruction, if indicated. */ - if (ctx->skip_cond !=3D TCG_COND_NEVER) { - skip_label =3D gen_new_label(); - if (ctx->skip_var0 =3D=3D cpu_skip) { - /* - * Copy cpu_skip so that we may zero it before the branch. - * This ensures that cpu_skip is non-zero after the label - * if and only if the skipped insn itself sets a skip. - */ - ctx->free_skip_var0 =3D true; - ctx->skip_var0 =3D tcg_temp_new(); - tcg_gen_mov_tl(ctx->skip_var0, cpu_skip); - tcg_gen_movi_tl(cpu_skip, 0); - } - if (ctx->skip_var1 =3D=3D NULL) { - tcg_gen_brcondi_tl(ctx->skip_cond, ctx->skip_var0, - 0, skip_label); - } else { - tcg_gen_brcond_tl(ctx->skip_cond, ctx->skip_var0, - ctx->skip_var1, skip_label); - ctx->skip_var1 =3D NULL; - } - if (ctx->free_skip_var0) { - tcg_temp_free(ctx->skip_var0); - ctx->free_skip_var0 =3D false; - } - ctx->skip_cond =3D TCG_COND_NEVER; - ctx->skip_var0 =3D NULL; - } +static void avr_tr_tb_start(DisasContextBase *db, CPUState *cs) +{ +} =20 - translate(ctx); +static void avr_tr_insn_start(DisasContextBase *dcbase, CPUState *cs) +{ + DisasContext *ctx =3D container_of(dcbase, DisasContext, base); =20 - if (skip_label) { - canonicalize_skip(ctx); - gen_set_label(skip_label); - if (ctx->base.is_jmp =3D=3D DISAS_NORETURN) { - ctx->base.is_jmp =3D DISAS_CHAIN; - } - } - } while (ctx->base.is_jmp =3D=3D DISAS_NEXT - && num_insns < max_insns - && (ctx->npc - pc_start) * 2 < TARGET_PAGE_SIZE - 4 - && !tcg_op_buf_full()); + tcg_gen_insn_start(ctx->npc); +} =20 - if (tb->cflags & CF_LAST_IO) { - gen_io_end(); +static bool avr_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs, + const CPUBreakpoint *bp) +{ + DisasContext *ctx =3D container_of(dcbase, DisasContext, base); + + gen_breakpoint(ctx); + return true; +} + +static void avr_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) +{ + DisasContext *ctx =3D container_of(dcbase, DisasContext, base); + TCGLabel *skip_label =3D NULL; + + /* + * This is due to some strange GDB behavior + * Let's assume main has address 0x100: + * b main - sets breakpoint at address 0x00000100 (code) + * b *0x100 - sets breakpoint at address 0x00800100 (data) + * + * The translator driver has already taken care of the code pointer. + */ + if (!ctx->base.singlestep_enabled && + cpu_breakpoint_test(cs, OFFSET_DATA + ctx->base.pc_next, BP_ANY)) { + gen_breakpoint(ctx); + return; } =20 + /* Conditionally skip the next instruction, if indicated. */ + if (ctx->skip_cond !=3D TCG_COND_NEVER) { + skip_label =3D gen_new_label(); + if (ctx->skip_var0 =3D=3D cpu_skip) { + /* + * Copy cpu_skip so that we may zero it before the branch. + * This ensures that cpu_skip is non-zero after the label + * if and only if the skipped insn itself sets a skip. + */ + ctx->free_skip_var0 =3D true; + ctx->skip_var0 =3D tcg_temp_new(); + tcg_gen_mov_tl(ctx->skip_var0, cpu_skip); + tcg_gen_movi_tl(cpu_skip, 0); + } + if (ctx->skip_var1 =3D=3D NULL) { + tcg_gen_brcondi_tl(ctx->skip_cond, ctx->skip_var0, 0, skip_lab= el); + } else { + tcg_gen_brcond_tl(ctx->skip_cond, ctx->skip_var0, + ctx->skip_var1, skip_label); + ctx->skip_var1 =3D NULL; + } + if (ctx->free_skip_var0) { + tcg_temp_free(ctx->skip_var0); + ctx->free_skip_var0 =3D false; + } + ctx->skip_cond =3D TCG_COND_NEVER; + ctx->skip_var0 =3D NULL; + } + + translate(ctx); + + ctx->base.pc_next =3D ctx->npc * 2; + + if (skip_label) { + canonicalize_skip(ctx); + gen_set_label(skip_label); + if (ctx->base.is_jmp =3D=3D DISAS_NORETURN) { + ctx->base.is_jmp =3D DISAS_CHAIN; + } + } + + if (ctx->base.is_jmp =3D=3D DISAS_NEXT) { + target_ulong page_first =3D ctx->base.pc_first & TARGET_PAGE_MASK; + + if ((ctx->base.pc_next - page_first) >=3D TARGET_PAGE_SIZE - 4) { + ctx->base.is_jmp =3D DISAS_TOO_MANY; + } + } +} + +static void avr_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) +{ + DisasContext *ctx =3D container_of(dcbase, DisasContext, base); bool nonconst_skip =3D canonicalize_skip(ctx); =20 switch (ctx->base.is_jmp) { @@ -3036,24 +3058,28 @@ void gen_intermediate_code(CPUState *cs, Translatio= nBlock *tb, int max_insns) default: g_assert_not_reached(); } +} =20 -done_generating: - gen_tb_end(tb, num_insns); +static void avr_tr_disas_log(const DisasContextBase *dcbase, CPUState *cs) +{ + qemu_log("IN: %s\n", lookup_symbol(dcbase->pc_first)); + log_target_disas(cs, dcbase->pc_first, dcbase->tb->size); +} =20 - tb->size =3D (ctx->npc - pc_start) * 2; - tb->icount =3D num_insns; +static const TranslatorOps avr_tr_ops =3D { + .init_disas_context =3D avr_tr_init_disas_context, + .tb_start =3D avr_tr_tb_start, + .insn_start =3D avr_tr_insn_start, + .breakpoint_check =3D avr_tr_breakpoint_check, + .translate_insn =3D avr_tr_translate_insn, + .tb_stop =3D avr_tr_tb_stop, + .disas_log =3D avr_tr_disas_log, +}; =20 -#ifdef DEBUG_DISAS - if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) - && qemu_log_in_addr_range(tb->pc)) { - FILE *fd; - fd =3D qemu_log_lock(); - qemu_log("IN: %s\n", lookup_symbol(tb->pc)); - log_target_disas(cs, tb->pc, tb->size); - qemu_log("\n"); - qemu_log_unlock(fd); - } -#endif +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_ins= ns) +{ + DisasContext dc; + translator_loop(&avr_tr_ops, &dc.base, cs, tb, max_insns); } =20 void restore_state_to_opc(CPUAVRState *env, TranslationBlock *tb, --=20 2.25.1