From patchwork Wed Sep 6 16:05:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111809 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1121317qge; Wed, 6 Sep 2017 09:11:22 -0700 (PDT) X-Received: by 10.55.25.150 with SMTP id 22mr4345154qkz.91.1504714282187; Wed, 06 Sep 2017 09:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504714282; cv=none; d=google.com; s=arc-20160816; b=rm8CApp1AVaYkaCYR7I5if1BJOOzHwTygWioWwgMBIzRBQj5kHlDvHwThYXlLj90sN Nf8nwlbI3pmoq+iKAwN30w35mwvoCzO0PNdhe0K2MNOvCKSuZDjFBeDwLCnCroT/YeQ4 Ujwam+9HvsIGlFgrJfGXF0bW4v6WwSueCBxRj2QO5GYi0Hb6ZzVpokBtJGJm6t4EtqVD 71p2C9nfVGPeUvagscxIdMa2Pj6wr+39ypk0JoEs2p/sNnTgtTxzCYo86rdK8HwlCKVX qRcVRW6c5zBCUVzm8FNe+tPFp6srq6V2gST7Z7R/Ei3syYDYS1lB9aVNoXfPa/MpFoC/ Mz9Q== 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=0yLW7ctcPD/DWG7PrJMW3lLrukj18jAqXKN1J9zeHP8=; b=DFwhR0HeyGYvOuWAd96hmLod0VAxbWquzRfTRCw5Q3l6w2gYobJv3rCvAvx8Eq5lOH l+xQ+E/3lvXZSXqbzihEeGH+9Qgo6S3davEjCJt4HldAYAGgbeE4W7NGEnuIdVLXkkwZ P7z0PZZXSuTit6EeghMsgk1I8KMDqcD+nP4ix9U9e1sBf1d590pKHS+NSPT84NPF+Hsf 6vefqTr+F9V7UYgD1h4JOT3ji6upZpL2RZec4IKL2HBedVskaoCaOjHV7xrzLBZWemGg +bDePl2O/mQ6Bt8uQcfSMfVjm0lUzx7J4IWu4T4KVz1CxOZrFItjlpcE3EMKbdH4e1x9 lIug== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=j6epNIpB; 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 36si179698qto.523.2017.09.06.09.11.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 06 Sep 2017 09:11:22 -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=j6epNIpB; 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]:36974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcv9-0003ep-P0 for patch@linaro.org; Wed, 06 Sep 2017 12:11:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcqX-0008SC-7u for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpcqQ-0001p8-WD for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:33 -0400 Received: from mail-pg0-x231.google.com ([2607:f8b0:400e:c05::231]:33605) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpcqQ-0001oG-NQ for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:26 -0400 Received: by mail-pg0-x231.google.com with SMTP id t3so16078080pgt.0 for ; Wed, 06 Sep 2017 09:06:26 -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=0yLW7ctcPD/DWG7PrJMW3lLrukj18jAqXKN1J9zeHP8=; b=j6epNIpBJPws696wzHJeQSNm0013QBV4JxNZ4PSB0lTNEJGYSMq9js8R/Ski8n1ltQ ocunFyDXZLNU1I9gA7oaBbphGu3we0zmbb6FCvt5fUuYeDghQdhNGN22WEmrzGpdbFGw svh44ahdhoswWEtlZmSi22flB+6rUqT5F5vsg= 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=0yLW7ctcPD/DWG7PrJMW3lLrukj18jAqXKN1J9zeHP8=; b=lz7DLUwddkUOULRaMCMVIECUyoNGu0tQBABdDdUDTzHlav+LEZRl3Bjy3sc4ejD+sR DmdfWO04dIK4SVzXeT8iYJH9rWPTFimV3tDaysGzCT0VOBcbkqIhuqbv2e1q+AtJ0PD3 n468elWw98uzwHSjOKuQiJkkXO2C9OCbspFah9tYDxMCj0Xk8RZrgX460JdFP6gHTeQr kHN9iMc6Y52yz1BEgWA2ywRMLxLfW8AFajReV468pmvmiUkUkaRfXok+y+aBUrTq2fSW E2kDBV6ESqfp2g07RxkGp0EQvONfshYJpxmoGqcEgyNQEwFJWn9ky8DF/bKvNDuj5hZ1 ho7Q== X-Gm-Message-State: AHPjjUhxxvvKuUD5PimUK1iZa3V/deFIx6a8nR5vLHAeFxOAnho6QKND ZsGb5qrEsHWMIQSKkHQupQ== X-Google-Smtp-Source: ADKCNb4aMrf5UWcX8z4WvPP0srlrpSR5Hoi14MGmnxTRApX2oZFz4Z6bZvUKCC6N3HdLL6JfHSGu4g== X-Received: by 10.99.143.89 with SMTP id r25mr8067193pgn.224.1504713985475; Wed, 06 Sep 2017 09:06:25 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 09:06:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Sep 2017 09:05:48 -0700 Message-Id: <20170906160612.22769-9-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:c05::231 Subject: [Qemu-devel] [PULL 08/32] target/i386: [tcg] Port to init_disas_context 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 Incrementally paves the way towards using the generic instruction translation loop. Reviewed-by: Emilio G. Cota Reviewed-by: Richard Henderson Reviewed-by: Alex Benneé Signed-off-by: Lluís Vilanova Message-Id: <150002122448.22386.16854673576827449259.stgit@frigg.lan> [rth: Adjust for max_insns interface change.] Signed-off-by: Richard Henderson --- target/i386/translate.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) -- 2.13.5 diff --git a/target/i386/translate.c b/target/i386/translate.c index 3a3d91c4d7..4281e9bc56 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -8377,20 +8377,13 @@ void tcg_x86_init(void) } } -/* generate intermediate code for basic block 'tb'. */ -void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) +static int i386_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cpu, + int max_insns) { - CPUX86State *env = cs->env_ptr; - DisasContext dc1, *dc = &dc1; - uint32_t flags; - target_ulong cs_base; - int num_insns; - int max_insns; - - /* generate intermediate code */ - dc->base.pc_first = tb->pc; - cs_base = tb->cs_base; - flags = tb->flags; + DisasContext *dc = container_of(dcbase, DisasContext, base); + CPUX86State *env = cpu->env_ptr; + uint32_t flags = dc->base.tb->flags; + target_ulong cs_base = dc->base.tb->cs_base; dc->pe = (flags >> HF_PE_SHIFT) & 1; dc->code32 = (flags >> HF_CS32_SHIFT) & 1; @@ -8401,11 +8394,9 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) dc->cpl = (flags >> HF_CPL_SHIFT) & 3; dc->iopl = (flags >> IOPL_SHIFT) & 3; dc->tf = (flags >> TF_SHIFT) & 1; - dc->base.singlestep_enabled = cs->singlestep_enabled; dc->cc_op = CC_OP_DYNAMIC; dc->cc_op_dirty = false; dc->cs_base = cs_base; - dc->base.tb = tb; dc->popl_esp_hack = 0; /* select memory access functions */ dc->mem_index = 0; @@ -8423,7 +8414,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) dc->code64 = (flags >> HF_CS64_SHIFT) & 1; #endif dc->flags = flags; - dc->jmp_opt = !(dc->tf || cs->singlestep_enabled || + dc->jmp_opt = !(dc->tf || dc->base.singlestep_enabled || (flags & HF_INHIBIT_IRQ_MASK)); /* Do not optimize repz jumps at all in icount mode, because rep movsS instructions are execured with different paths @@ -8435,7 +8426,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) record/replay modes and there will always be an additional step for ecx=0 when icount is enabled. */ - dc->repz_opt = !dc->jmp_opt && !(tb->cflags & CF_USE_ICOUNT); + dc->repz_opt = !dc->jmp_opt && !(dc->base.tb->cflags & CF_USE_ICOUNT); #if 0 /* check addseg logic */ if (!dc->addseg && (dc->vm86 || !dc->pe || !dc->code32)) @@ -8455,9 +8446,24 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) cpu_ptr1 = tcg_temp_new_ptr(); cpu_cc_srcT = tcg_temp_local_new(); + return max_insns; +} + +/* generate intermediate code for basic block 'tb'. */ +void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) +{ + CPUX86State *env = cs->env_ptr; + 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; - num_insns = 0; + max_insns = tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; @@ -8465,7 +8471,9 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) 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(;;) { tcg_gen_insn_start(dc->base.pc_next, dc->cc_op); @@ -8498,7 +8506,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) the flag and abort the translation to give the irqs a change to be happen */ if (dc->tf || dc->base.singlestep_enabled || - (flags & HF_INHIBIT_IRQ_MASK)) { + (dc->base.tb->flags & HF_INHIBIT_IRQ_MASK)) { gen_jmp_im(dc->base.pc_next - dc->cs_base); gen_eob(dc); break;