From patchwork Wed Sep 6 16:05:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111818 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1131093qge; Wed, 6 Sep 2017 09:17:40 -0700 (PDT) X-Received: by 10.200.3.195 with SMTP id z3mr4605115qtg.259.1504714660799; Wed, 06 Sep 2017 09:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504714660; cv=none; d=google.com; s=arc-20160816; b=qJk2KtJkS3sFQ3P1ERGupXs4/f73j70PF5I4yfP996aUUDWnYl8IVPJ+ISeS5oEeut dgxISUpNWiF+Weqp1F5rQKR6V8pJHMnF6L8HasyDBVNbNBGXZuFoCrdXBJqeeUcxHp+8 Ed/2xNJr0zLy6pzuMb+d39TJBfcjRHhjz9fbXvj/HrzcHhBKaqoMtjMrb+sJldUNjGoc DRHhb+xwX47guBVdfEtXnjzyv5yZd5bZWANnXvLBZsXD2dN0WxdL3PdWTvKO9WXJWbe6 1PGj41uvWx9BlCOWz4Nmp96QCDcZD4Nh4JUcEwUkmyqYBWZZk306wrp+fxlSJiSXF2jh cCJw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=4K6BNYHQcpNHFmj0sguQnGWsFAoO7efRcTcbeP5LdLw=; b=gP7eb77tMxoMGgdIny/QpW3p9lsc0WXQx3Npbt1kvMRwj9Zg23r/QqHiV4ykjtOfOm tdHpiBd4OHa9X8s0PtxeovK7I7U/N/WZCqelklAIZRsN9MzsasxqG1puFJ48GLWM2uqF dB47wZWRG44A6tE8LoqkZLuOhuRuo4g5/d+5Gs7aSHX0FHlLj+ygh7/CjFqkT/vnVe3E mTXAVPKm0ZSX1E0q0SUMpd5HEUCOjsBRHrv/Ge5QW/js45SgfSiyez7sV4zRwA8xoBEG Wb8jcAdKQoZuvweSj+L4mjCndjirgRMUj0OHK32Y7bYgU4MHeKT2E+EoywNLgVXeSV+m 0QwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i9pEc6uj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r45si221641qte.269.2017.09.06.09.17.40 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 06 Sep 2017 09:17:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=i9pEc6uj; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpd1G-000136-5r for patch@linaro.org; Wed, 06 Sep 2017 12:17:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcqa-0008W7-J3 for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpcqZ-0002BM-7u for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:36 -0400 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:33132) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpcqY-0002A9-Vs for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:35 -0400 Received: by mail-pf0-x22c.google.com with SMTP id y68so13495970pfd.0 for ; Wed, 06 Sep 2017 09:06:34 -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=4K6BNYHQcpNHFmj0sguQnGWsFAoO7efRcTcbeP5LdLw=; b=i9pEc6ujcmxqGr4fwFoufTuOdzbBcEzFM3rz1/cKLG0CVnxt+DNkKuaFUt6CAMZCmi Dy7xn4zZT8EAVzwdp3nZpFboe2P2v9/jutXOm8QFkOds8sIk6IHgsSlGLgw8+qongvrK 07ABZdNGFlWkZYOxbf6Fcw6uwlWsHzOJIUnWw= 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=4K6BNYHQcpNHFmj0sguQnGWsFAoO7efRcTcbeP5LdLw=; b=TNqTv4F13O0ZQijkOFpVFtcIJDHIv+6bn2e2ky8uCWH9myzL3WwYaasAhIgctzwAzF VnsKtZuyYHpcJ1Ke9SBE/9oRFnfBxt7+FKNM+GSu9bNkJN8bTnYPb2jgdERapn8MOv09 dfAIkR4P98emTf6j5sQ3qLWP+25sKBO5EgPtxx3kbeVFWdtwWqAbqhYvJuOcDCNGy+PS H6w11+K2ddnVbs+N80vWlwvoNJdiFiPEmXEUQ00harLkxL4vgWebOuZydgl7b40txgzb 0s7s7ooZP+d0Ebs7p32kM4RJ3aIZPJcugxuEFAi29h2WSM/ZEuxfFyA69qgwy2Ko4ua/ REZQ== X-Gm-Message-State: AHPjjUiHvbMDKlewk2TUtbrfRxoedOPJvvFaE2nn+zwzBCvMWzLLDBmH +k3OMTGm3BIEI8eOn5kCAw== X-Google-Smtp-Source: ADKCNb7Q7cJhbqusd6W9F1bdFca+Brk1NhcAZOwH0jzxCwvoH8VZULjGDOutbjELIgd4naZ0/bw9CQ== X-Received: by 10.99.0.73 with SMTP id 70mr8193748pga.289.1504713993772; Wed, 06 Sep 2017 09:06:33 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-108-236.tukw.qwest.net. [97.126.108.236]) by smtp.gmail.com with ESMTPSA id t65sm262863pfk.59.2017.09.06.09.06.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 09:06:32 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Sep 2017 09:05:54 -0700 Message-Id: <20170906160612.22769-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170906160612.22769-1-richard.henderson@linaro.org> References: <20170906160612.22769-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22c Subject: [Qemu-devel] [PULL 14/32] target/i386: [tcg] Port to generic translation framework 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, =?utf-8?q?Llu=C3=ADs_Vilanova?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Lluís Vilanova Signed-off-by: Lluís Vilanova Reviewed-by: Richard Henderson Reviewed-by: Emilio G. Cota Tested-by: Emilio G. Cota Message-Id: <150002267714.22386.5095442346868988808.stgit@frigg.lan> Signed-off-by: Richard Henderson --- target/i386/translate.c | 106 +++++++++--------------------------------------- 1 file changed, 19 insertions(+), 87 deletions(-) -- 2.13.5 diff --git a/target/i386/translate.c b/target/i386/translate.c index ad4b2735f4..de0c989763 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8450,6 +8450,10 @@ static int i386_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu, return max_insns; } +static void i386_tr_tb_start(DisasContextBase *db, CPUState *cpu) +{ +} + static void i386_tr_insn_start(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc = container_of(dcbase, DisasContext, base); @@ -8469,7 +8473,7 @@ static bool i386_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, /* The address covered by the breakpoint must be included in [tb->pc, tb->pc + tb->size) in order to for it to be properly cleared -- thus we increment the PC here so that - the logic setting tb->size below does the right thing. */ + the generic logic setting tb->size later does the right thing. */ dc->base.pc_next += 1; return true; } else { @@ -8533,94 +8537,22 @@ static void i386_tr_disas_log(const DisasContextBase *dcbase, log_target_disas(cpu, dc->base.pc_first, dc->base.tb->size, disas_flags); } -/* generate intermediate code for basic block 'tb'. */ -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) -{ - DisasContext dc1, *dc = &dc1; - int num_insns; - int max_insns; - - /* generate intermediate code */ - dc->base.singlestep_enabled = cs->singlestep_enabled; - dc->base.tb = tb; - dc->base.is_jmp = DISAS_NEXT; - dc->base.pc_first = tb->pc; - dc->base.pc_next = dc->base.pc_first; - - max_insns = tb->cflags & CF_COUNT_MASK; - if (max_insns == 0) { - max_insns = CF_COUNT_MASK; - } - if (max_insns > TCG_MAX_INSNS) { - max_insns = TCG_MAX_INSNS; - } - max_insns = i386_tr_init_disas_context(&dc->base, cs, max_insns); - - num_insns = 0; - gen_tb_start(tb); - for(;;) { - i386_tr_insn_start(&dc->base, cs); - num_insns++; - - if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) { - CPUBreakpoint *bp; - QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { - if (bp->pc == dc->base.pc_next) { - if (i386_tr_breakpoint_check(&dc->base, cs, bp)) { - break; - } - } - } - - if (dc->base.is_jmp == DISAS_NORETURN) { - break; - } - } - - if (num_insns == max_insns && (tb->cflags & CF_LAST_IO)) { - gen_io_start(); - } - - i386_tr_translate_insn(&dc->base, cs); - /* stop translation if indicated */ - if (dc->base.is_jmp) { - break; - } - /* if single step mode, we generate only one instruction and - generate an exception */ - if (dc->base.singlestep_enabled) { - dc->base.is_jmp = DISAS_TOO_MANY; - break; - } - /* if too long translation, stop generation too */ - if (tcg_op_buf_full() || - num_insns >= max_insns) { - dc->base.is_jmp = DISAS_TOO_MANY; - break; - } - if (singlestep) { - dc->base.is_jmp = DISAS_TOO_MANY; - break; - } - } - i386_tr_tb_stop(&dc->base, cs); - if (tb->cflags & CF_LAST_IO) - gen_io_end(); - gen_tb_end(tb, num_insns); +static const TranslatorOps i386_tr_ops = { + .init_disas_context = i386_tr_init_disas_context, + .tb_start = i386_tr_tb_start, + .insn_start = i386_tr_insn_start, + .breakpoint_check = i386_tr_breakpoint_check, + .translate_insn = i386_tr_translate_insn, + .tb_stop = i386_tr_tb_stop, + .disas_log = i386_tr_disas_log, +}; - tb->size = dc->base.pc_next - dc->base.pc_first; - tb->icount = num_insns; +/* generate intermediate code for basic block 'tb'. */ +void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb) +{ + DisasContext dc; -#ifdef DEBUG_DISAS - if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM) - && qemu_log_in_addr_range(dc->base.pc_first)) { - qemu_log_lock(); - qemu_log("----------------\n"); - i386_tr_disas_log(&dc->base, cs); - qemu_log("\n"); - qemu_log_unlock(); - } -#endif + translator_loop(&i386_tr_ops, &dc.base, cpu, tb); } void restore_state_to_opc(CPUX86State *env, TranslationBlock *tb,