From patchwork Tue Jun 29 18:54:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 468336 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp5253714jao; Tue, 29 Jun 2021 12:30:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwO3Sc5izPwOYTWt3daPuhd8I6GVXw3qTrJBA64HbW8NfZlNfF294P7xV6BOpGVN5c6pqXE X-Received: by 2002:a25:6c43:: with SMTP id h64mr40446887ybc.348.1624995040520; Tue, 29 Jun 2021 12:30:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624995040; cv=none; d=google.com; s=arc-20160816; b=N2lSRE89JfOCLt6Rrw4ARxftMUmy+QEDG7ZajXeTAyfUs65KYD3IzfCDOxcCooq4ac WV6W6wl8mrLyQNrsOPmgmvr+R9/9BYmxi6nkIR8neUQF6E4aGTuOLoKVjvCV1jwYlLqw mhVp6XuJ6nN1pSArII8M1uIifzYP30+/jecQI1lPTKc0WFiqb4E1v95unLFlRJ9P1Rf/ TMHCEr9xG4WJu8sMimTBTtGHkVke9eHm4e7XG1erpgQPE0NPX5c/LW9KT7+OWVtB+BmD z+I78wob9+euKkESuG9lDObFEO/KIisiTFcHESYo2MriJu2p45qbmEB/3TE5523Nb0Pt /A8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=fGRHMcrVsTBuc+poYCILKBwWahcIDUOmxH2NMmMtJuY=; b=TaqJkyBofk0IgZM9gscqz4OhQreI9oEg6eA2yPvVp+Cz5gyU7c+5w20A3JOp+xJff4 F4jrx0ZcdD5kyxByGCVmpwcxDjPwcFEtBZ7iTN1JlxB3ZxeKpDYClo+b1hpiETDCQ/30 tM9L8Ci0Yq5anv8oTY0bV01p8SlKJ3XE/K6S4CciB1kOirtbltJxgDELfUihicj3ET9C Xb4zXo6tKH+hjH3lOgxYuFe7FetR6veAVW+Uiiq2u+tfHin+i5GUYFdMRfg0H1FqqDgi qWpXvj0XSs+FoxQR8gXijDOFYT5ubfrAKkcey+k3IANOAvKV9UGn3ajpOXT/gSdDWMNS kyyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TUXp0LSR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u8si17461123ybb.267.2021.06.29.12.30.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jun 2021 12:30:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TUXp0LSR; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyJRP-00021G-TY for patch@linaro.org; Tue, 29 Jun 2021 15:30:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyItC-000850-Sw for qemu-devel@nongnu.org; Tue, 29 Jun 2021 14:55:18 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:40468) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyIt1-0000sk-42 for qemu-devel@nongnu.org; Tue, 29 Jun 2021 14:55:18 -0400 Received: by mail-pg1-x52b.google.com with SMTP id g22so1096429pgl.7 for ; Tue, 29 Jun 2021 11:55:03 -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=fGRHMcrVsTBuc+poYCILKBwWahcIDUOmxH2NMmMtJuY=; b=TUXp0LSR2d53p7lKsVXDg1/Zpoc0eovkepHahcioGYO82QqrvTMw9hYQ1JAH0kmxJT HmfE19G+fU6lQIBkd9pk9nt5NbM7hBjC3SZ4j31qMQ2T3xMCFRyTMThTXR4pLF50KoeE Fb0uuSsOkG1/3EmZAbDCsxYUySJ21WEbxg6H6qfWbhiH3GDIuTChUXVEQ5W3LIXkrjM3 Wn6Q11DpkGPW1ULZqjZDaRAOLCYYdTzUzIxkV6IIA3AEn/1vVP1/ZWMcHdby1mPk7xjE 84VvMo1IJ3SG5TH6cvHrr/gf7rZWO3SkecMCtzwjAPq4R+ggfQvMRjikpfnVQFEWsXnT l/8w== 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=fGRHMcrVsTBuc+poYCILKBwWahcIDUOmxH2NMmMtJuY=; b=DhD1uK2yisnqrHSKpGYeuwtABxEalNpXOm1vhSJVWI8BjCPlZf+xYMfPIOJe/Xo48c t42olibj0JMrknxDgkIwp22JI5uwqbUWwXeByIxkLcvBJ4pGNMVGf+iILv2kLW44oIMK ssZpNceCjgRdJBm8mWND4/8lYwDms8GW5niuCLkMv4ETUIpBeGyZk6sNuXT3wWvTdOtA PDgkhQCRTlBJSovE337KFldkHclFb8ukmSh0G8jilkpIXPA11xtbDVoM43yQoYdWOugT 03SajkLMWxtG8Q1AQ676ykbSyApQYZeRY+NZPpAOgRmmVPIfHFDHPg0pYTf4EcanFZAf Pb2g== X-Gm-Message-State: AOAM531grAPw9/ptu7mlq03Ail8/6DB6pnGf82VGpdmEY3+ZoBMopiiJ xdRICjdPuXH/6mU5DI2Zd9HgZVI7FX1yDg== X-Received: by 2002:a63:9256:: with SMTP id s22mr26210553pgn.166.1624992902433; Tue, 29 Jun 2021 11:55:02 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id j2sm18811253pfb.53.2021.06.29.11.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jun 2021 11:55:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 11/63] target/avr: Change ctx to DisasContext* in gen_intermediate_code Date: Tue, 29 Jun 2021 11:54:03 -0700 Message-Id: <20210629185455.3131172-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210629185455.3131172-1-richard.henderson@linaro.org> References: <20210629185455.3131172-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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: Michael Rolnik , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Prepare for receiving it as a pointer input. Tested-by: Michael Rolnik Reviewed-by: Michael Rolnik Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/avr/translate.c | 84 +++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 41 deletions(-) -- 2.25.1 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 = NULL; - * if (ctx.skip_cond != TCG_COND_NEVER) { + * if (ctx->skip_cond != TCG_COND_NEVER) { * skip_label = gen_new_label(); * tcg_gen_brcond_tl(skip_cond, skip_var0, skip_var1, skip_label); * } @@ -114,7 +114,7 @@ struct DisasContext { * free_skip_var0 = 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_insns) { CPUAVRState *env = cs->env_ptr; - DisasContext ctx = { + DisasContext ctx1 = { .base.tb = tb, .base.is_jmp = DISAS_NEXT, .base.pc_first = tb->pc, @@ -2911,6 +2911,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) .memidx = 0, .skip_cond = TCG_COND_NEVER, }; + DisasContext *ctx = &ctx1; target_ulong pc_start = tb->pc / 2; int num_insns = 0; @@ -2921,23 +2922,23 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns) */ max_insns = 1; } - if (ctx.base.singlestep_enabled) { + if (ctx->base.singlestep_enabled) { max_insns = 1; } gen_tb_start(tb); - ctx.npc = pc_start; + ctx->npc = pc_start; if (tb->flags & TB_FLAGS_SKIP) { - ctx.skip_cond = TCG_COND_ALWAYS; - ctx.skip_var0 = cpu_skip; + ctx->skip_cond = TCG_COND_ALWAYS; + ctx->skip_var0 = cpu_skip; } do { TCGLabel *skip_label = NULL; /* translate current instruction */ - tcg_gen_insn_start(ctx.npc); + tcg_gen_insn_start(ctx->npc); num_insns++; /* @@ -2946,65 +2947,66 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *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; } /* Conditionally skip the next instruction, if indicated. */ - if (ctx.skip_cond != TCG_COND_NEVER) { + if (ctx->skip_cond != TCG_COND_NEVER) { skip_label = gen_new_label(); - if (ctx.skip_var0 == cpu_skip) { + if (ctx->skip_var0 == 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 = true; - ctx.skip_var0 = tcg_temp_new(); - tcg_gen_mov_tl(ctx.skip_var0, cpu_skip); + ctx->free_skip_var0 = true; + ctx->skip_var0 = tcg_temp_new(); + tcg_gen_mov_tl(ctx->skip_var0, cpu_skip); tcg_gen_movi_tl(cpu_skip, 0); } - if (ctx.skip_var1 == NULL) { - tcg_gen_brcondi_tl(ctx.skip_cond, ctx.skip_var0, 0, skip_label); + if (ctx->skip_var1 == 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 = NULL; + tcg_gen_brcond_tl(ctx->skip_cond, ctx->skip_var0, + ctx->skip_var1, skip_label); + ctx->skip_var1 = NULL; } - if (ctx.free_skip_var0) { - tcg_temp_free(ctx.skip_var0); - ctx.free_skip_var0 = false; + if (ctx->free_skip_var0) { + tcg_temp_free(ctx->skip_var0); + ctx->free_skip_var0 = false; } - ctx.skip_cond = TCG_COND_NEVER; - ctx.skip_var0 = NULL; + ctx->skip_cond = TCG_COND_NEVER; + ctx->skip_var0 = NULL; } - translate(&ctx); + translate(ctx); if (skip_label) { - canonicalize_skip(&ctx); + canonicalize_skip(ctx); gen_set_label(skip_label); - if (ctx.base.is_jmp == DISAS_NORETURN) { - ctx.base.is_jmp = DISAS_CHAIN; + if (ctx->base.is_jmp == DISAS_NORETURN) { + ctx->base.is_jmp = DISAS_CHAIN; } } - } while (ctx.base.is_jmp == DISAS_NEXT + } while (ctx->base.is_jmp == 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()); if (tb->cflags & CF_LAST_IO) { gen_io_end(); } - bool nonconst_skip = canonicalize_skip(&ctx); + bool nonconst_skip = canonicalize_skip(ctx); - 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, TranslationBlock *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, TranslationBlock *tb, int max_insns) done_generating: gen_tb_end(tb, num_insns); - tb->size = (ctx.npc - pc_start) * 2; + tb->size = (ctx->npc - pc_start) * 2; tb->icount = num_insns; #ifdef DEBUG_DISAS