From nobody Thu Nov 13 12:02:49 2025 Delivered-To: importer@patchew.org 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+importer=patchew.org@nongnu.org; helo=lists.gnu.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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1579821989; cv=none; d=zohomail.com; s=zohoarc; b=erJ1q4vVmFaSVB7HgvZnKk6VOhbG36rGXmNs5y+owONgmLGnpMWpkZ11GBEBAqWiK8bEp6VwfgRHqYsYd6Xs8tQHG9OQmITC51Y5872LozfAZMLJVnGTyr6xpIYofLLnn+igPjRQeIuR5x18ZaAz+xNrctav3zcOZacYuwT5h40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579821989; 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=WXgtgFjEX2QCToUnHwizHlyfzg0a8KnJcrxsk37lyNA=; b=isHlrIMAhJG4rChxD/IQp/UOl5Ye7u5iigN2pkZQUWSeK/2qLPgcNHW8oq7tMFIX+dUGSyq2woD7t9MyF046sMS9x3ZA/DVgSXOX+gTruQCDR5M7tDnHZMRKDwpAxcsJh5WO6J53XPPW/evGJDGofAQWySnwPquOVrphAF8XSl4= 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+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579821989395415.11251892028054; Thu, 23 Jan 2020 15:26:29 -0800 (PST) Received: from localhost ([::1]:35388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iulro-0005Fh-8N for importer@patchew.org; Thu, 23 Jan 2020 18:26:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52381) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iuloV-00008U-Ms for qemu-devel@nongnu.org; Thu, 23 Jan 2020 18:23:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iuloT-0007hB-Mn for qemu-devel@nongnu.org; Thu, 23 Jan 2020 18:23:03 -0500 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:34079) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iuloT-0007gT-Ec for qemu-devel@nongnu.org; Thu, 23 Jan 2020 18:23:01 -0500 Received: by mail-pj1-x1030.google.com with SMTP id f2so83832pjq.1 for ; Thu, 23 Jan 2020 15:23:01 -0800 (PST) Received: from localhost.localdomain (rrcs-173-198-77-92.west.biz.rr.com. [173.198.77.92]) by smtp.gmail.com with ESMTPSA id z5sm4136008pfq.3.2020.01.23.15.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 15:22:59 -0800 (PST) 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=WXgtgFjEX2QCToUnHwizHlyfzg0a8KnJcrxsk37lyNA=; b=xjEJYwugtSXtucWFqdJPttgsIfgM//HpqyMyaygToNjiVsWi8pkruwOmgQTV1rkgH/ rPUqM3B+ZhkIQ6PuyymJ7rzhV8C5HO+iv5KhIXQLAxC4NhMGod9OZHn5IX2L2mGpzBSL l86fUU1f4Xejc6jAeS8QhJkTYKsKjJY2q0kCCNk3zwHDcRNerfhj9RPzhalpHmqjaYGw 4iI7mbHUwoPcqG14rld6o6iY9yNpT+HzWFyPB8Z4wOfBZ0Kma13Fhi8sCHg4U62mjWHt 5/hdRJOPYDZfe5qcwCtztNBuA9TXHMFKlXxV9/ApHrXvMtijC8r5ZOsRAarhM/GvWo57 0HuQ== 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=WXgtgFjEX2QCToUnHwizHlyfzg0a8KnJcrxsk37lyNA=; b=XMHAI06Urmz7MTZDckklccm9jg03Sw1F/ICjLJJ8BKfMnAmEbwMEO2hOmh9qeSo/BD 7ZB4ZA3P5pM8BJRCISw5T17n8p630wY/UsOBAIax5m9MYsNKnSghmVtsBCXxq48aeBjW MnKzUm1VocczZy9Vw7N+GOW+Xsf12Cj2Bw/gvrVM9OE0yd16DDDcw0pWub6j9n5qro1e 7fsgI6E/aTInKnWgvZOnakTCDCV1FacvmGCA7xmYlYAGuZ9kamzvgCV57MKZkNKBH43w x6J5HL/KhZrQvA85Z/dU8NVGG9jBonpWabK7sTFYKTeUSV2UYauT/oeEVXoNFrYvdCS0 GDtw== X-Gm-Message-State: APjAAAU+gcnF2jcQ13xWRfxTeobezAmA1iY3UFrVWLteyp4dQANsHI8u IKFs+961iP5243hHLgd8XDIlTrvR364= X-Google-Smtp-Source: APXvYqxnY2aDwz+XQwTzxP/lNPPoCkLXYBslv15jwY70KXBrp6BLiEvCVHBCOf+TKXWG9w8cj5yLKQ== X-Received: by 2002:a17:902:848f:: with SMTP id c15mr568382plo.182.1579821779928; Thu, 23 Jan 2020 15:22:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/5] target/s390x: Move DisasFields into DisasContext Date: Thu, 23 Jan 2020 13:22:47 -1000 Message-Id: <20200123232248.1800-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200123232248.1800-1-richard.henderson@linaro.org> References: <20200123232248.1800-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1030 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: thuth@redhat.com, cohuck@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" I believe that the separate allocation of DisasFields from DisasContext was meant to limit the places from which we could access fields. But that plan did not go unchanged, and since DisasContext contains a pointer to fields, the substructure is accessible everywhere. By allocating the substructure with DisasContext, we improve the locality of the accesses by avoiding one level of pointer chasing. In addition, we avoid a dangling pointer to stack allocated memory, diagnosed by static checkers. Launchpad: https://bugs.launchpad.net/bugs/1661815 Signed-off-by: Richard Henderson Reviewed-by: Thomas Huth --- target/s390x/translate.c | 22 +++++++++--------- target/s390x/translate_vx.inc.c | 40 ++++++++++++++++----------------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 51a1d865c0..3674fee10c 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -139,7 +139,7 @@ struct DisasFields { struct DisasContext { DisasContextBase base; const DisasInsn *insn; - DisasFields *fields; + DisasFields fields; uint64_t ex_value; /* * During translate_one(), pc_tmp is used to determine the instruction @@ -1094,14 +1094,14 @@ typedef enum { =20 static bool have_field1(const DisasContext *s, enum DisasFieldIndexO c) { - return (s->fields->presentO >> c) & 1; + return (s->fields.presentO >> c) & 1; } =20 static int get_field1(const DisasContext *s, enum DisasFieldIndexO o, enum DisasFieldIndexC c) { assert(have_field1(s, o)); - return s->fields->c[c]; + return s->fields.c[c]; } =20 /* Describe the layout of each field in each format. */ @@ -3763,7 +3763,7 @@ static DisasJumpType op_risbg(DisasContext *s, DisasO= ps *o) int pos, len, rot; =20 /* Adjust the arguments for the specific insn. */ - switch (s->fields->op2) { + switch (s->fields.op2) { case 0x55: /* risbg */ case 0x59: /* risbgn */ i3 &=3D 63; @@ -3804,7 +3804,7 @@ static DisasJumpType op_risbg(DisasContext *s, DisasO= ps *o) len =3D i4 - i3 + 1; pos =3D 63 - i4; rot =3D i5 & 63; - if (s->fields->op2 =3D=3D 0x5d) { + if (s->fields.op2 =3D=3D 0x5d) { pos +=3D 32; } =20 @@ -3873,7 +3873,7 @@ static DisasJumpType op_rosbg(DisasContext *s, DisasO= ps *o) tcg_gen_rotli_i64(o->in2, o->in2, i5); =20 /* Operate. */ - switch (s->fields->op2) { + switch (s->fields.op2) { case 0x55: /* AND */ tcg_gen_ori_i64(o->in2, o->in2, ~mask); tcg_gen_and_i64(o->out, o->out, o->in2); @@ -4489,7 +4489,7 @@ static DisasJumpType op_stnosm(DisasContext *s, Disas= Ops *o) tcg_gen_qemu_st8(t, o->addr1, get_mem_index(s)); tcg_temp_free_i64(t); =20 - if (s->fields->op =3D=3D 0xac) { + if (s->fields.op =3D=3D 0xac) { tcg_gen_andi_i64(psw_mask, psw_mask, (i2 << 56) | 0x00ffffffffffffffull); } else { @@ -6000,7 +6000,7 @@ static void in2_i2_32u_shl(DisasContext *s, DisasOps = *o) #ifndef CONFIG_USER_ONLY static void in2_insn(DisasContext *s, DisasOps *o) { - o->in2 =3D tcg_const_i64(s->fields->raw_insn); + o->in2 =3D tcg_const_i64(s->fields.raw_insn); } #define SPEC_in2_insn 0 #endif @@ -6299,15 +6299,13 @@ static DisasJumpType translate_one(CPUS390XState *e= nv, DisasContext *s) { const DisasInsn *insn; DisasJumpType ret =3D DISAS_NEXT; - DisasFields f; DisasOps o =3D {}; =20 /* Search for the insn in the table. */ - insn =3D extract_insn(env, s, &f); + insn =3D extract_insn(env, s, &s->fields); =20 /* Set up the strutures we use to communicate with the helpers. */ s->insn =3D insn; - s->fields =3D &f; =20 /* Emit insn_start now that we know the ILEN. */ tcg_gen_insn_start(s->base.pc_next, s->cc_op, s->ilen); @@ -6315,7 +6313,7 @@ static DisasJumpType translate_one(CPUS390XState *env= , DisasContext *s) /* Not found means unimplemented/illegal opcode. */ if (insn =3D=3D NULL) { qemu_log_mask(LOG_UNIMP, "unimplemented opcode 0x%02x%02x\n", - f.op, f.op2); + s->fields.op, s->fields.op2); gen_illegal_opcode(s); return DISAS_NORETURN; } diff --git a/target/s390x/translate_vx.inc.c b/target/s390x/translate_vx.in= c.c index e1a2d25c2f..24558cce80 100644 --- a/target/s390x/translate_vx.inc.c +++ b/target/s390x/translate_vx.inc.c @@ -732,7 +732,7 @@ static DisasJumpType op_vmr(DisasContext *s, DisasOps *= o) } =20 tmp =3D tcg_temp_new_i64(); - if (s->fields->op2 =3D=3D 0x61) { + if (s->fields.op2 =3D=3D 0x61) { /* iterate backwards to avoid overwriting data we might need later= */ for (dst_idx =3D NUM_VEC_ELEMENTS(es) - 1; dst_idx >=3D 0; dst_idx= --) { src_idx =3D dst_idx / 2; @@ -796,7 +796,7 @@ static DisasJumpType op_vpk(DisasContext *s, DisasOps *= o) return DISAS_NORETURN; } =20 - switch (s->fields->op2) { + switch (s->fields.op2) { case 0x97: if (get_field(s, m5) & 0x1) { gen_gvec_3_ptr(v1, v2, v3, cpu_env, 0, vpks_cc[es - 1]); @@ -1038,7 +1038,7 @@ static DisasJumpType op_vstl(DisasContext *s, DisasOp= s *o) =20 static DisasJumpType op_vup(DisasContext *s, DisasOps *o) { - const bool logical =3D s->fields->op2 =3D=3D 0xd4 || s->fields->op2 = =3D=3D 0xd5; + const bool logical =3D s->fields.op2 =3D=3D 0xd4 || s->fields.op2 =3D= =3D 0xd5; const uint8_t v1 =3D get_field(s, v1); const uint8_t v2 =3D get_field(s, v2); const uint8_t src_es =3D get_field(s, m3); @@ -1052,7 +1052,7 @@ static DisasJumpType op_vup(DisasContext *s, DisasOps= *o) } =20 tmp =3D tcg_temp_new_i64(); - if (s->fields->op2 =3D=3D 0xd7 || s->fields->op2 =3D=3D 0xd5) { + if (s->fields.op2 =3D=3D 0xd7 || s->fields.op2 =3D=3D 0xd5) { /* iterate backwards to avoid overwriting data we might need later= */ for (dst_idx =3D NUM_VEC_ELEMENTS(dst_es) - 1; dst_idx >=3D 0; dst= _idx--) { src_idx =3D dst_idx; @@ -1389,7 +1389,7 @@ static DisasJumpType op_vec(DisasContext *s, DisasOps= *o) gen_program_exception(s, PGM_SPECIFICATION); return DISAS_NORETURN; } - if (s->fields->op2 =3D=3D 0xdb) { + if (s->fields.op2 =3D=3D 0xdb) { es |=3D MO_SIGN; } =20 @@ -1567,7 +1567,7 @@ static DisasJumpType op_vmx(DisasContext *s, DisasOps= *o) return DISAS_NORETURN; } =20 - switch (s->fields->op2) { + switch (s->fields.op2) { case 0xff: gen_gvec_fn_3(smax, es, v1, v2, v3); break; @@ -1677,7 +1677,7 @@ static DisasJumpType op_vma(DisasContext *s, DisasOps= *o) return DISAS_NORETURN; } =20 - switch (s->fields->op2) { + switch (s->fields.op2) { case 0xaa: fn =3D &g_vmal[es]; break; @@ -1764,7 +1764,7 @@ static DisasJumpType op_vm(DisasContext *s, DisasOps = *o) return DISAS_NORETURN; } =20 - switch (s->fields->op2) { + switch (s->fields.op2) { case 0xa2: gen_gvec_fn_3(mul, es, get_field(s, v1), get_field(s, v2), get_field(s, v3)); @@ -1967,7 +1967,7 @@ static DisasJumpType op_vesv(DisasContext *s, DisasOp= s *o) return DISAS_NORETURN; } =20 - switch (s->fields->op2) { + switch (s->fields.op2) { case 0x70: gen_gvec_fn_3(shlv, es, v1, v2, v3); break; @@ -1998,7 +1998,7 @@ static DisasJumpType op_ves(DisasContext *s, DisasOps= *o) } =20 if (likely(!get_field(s, b2))) { - switch (s->fields->op2) { + switch (s->fields.op2) { case 0x30: gen_gvec_fn_2i(shli, es, v1, v3, d2); break; @@ -2015,7 +2015,7 @@ static DisasJumpType op_ves(DisasContext *s, DisasOps= *o) shift =3D tcg_temp_new_i32(); tcg_gen_extrl_i64_i32(shift, o->addr1); tcg_gen_andi_i32(shift, shift, NUM_VEC_ELEMENT_BITS(es) - 1); - switch (s->fields->op2) { + switch (s->fields.op2) { case 0x30: gen_gvec_fn_2s(shls, es, v1, v3, shift); break; @@ -2038,7 +2038,7 @@ static DisasJumpType op_vsl(DisasContext *s, DisasOps= *o) TCGv_i64 shift =3D tcg_temp_new_i64(); =20 read_vec_element_i64(shift, get_field(s, v3), 7, ES_8); - if (s->fields->op2 =3D=3D 0x74) { + if (s->fields.op2 =3D=3D 0x74) { tcg_gen_andi_i64(shift, shift, 0x7); } else { tcg_gen_andi_i64(shift, shift, 0x78); @@ -2084,7 +2084,7 @@ static DisasJumpType op_vsra(DisasContext *s, DisasOp= s *o) TCGv_i64 shift =3D tcg_temp_new_i64(); =20 read_vec_element_i64(shift, get_field(s, v3), 7, ES_8); - if (s->fields->op2 =3D=3D 0x7e) { + if (s->fields.op2 =3D=3D 0x7e) { tcg_gen_andi_i64(shift, shift, 0x7); } else { tcg_gen_andi_i64(shift, shift, 0x78); @@ -2101,7 +2101,7 @@ static DisasJumpType op_vsrl(DisasContext *s, DisasOp= s *o) TCGv_i64 shift =3D tcg_temp_new_i64(); =20 read_vec_element_i64(shift, get_field(s, v3), 7, ES_8); - if (s->fields->op2 =3D=3D 0x7c) { + if (s->fields.op2 =3D=3D 0x7c) { tcg_gen_andi_i64(shift, shift, 0x7); } else { tcg_gen_andi_i64(shift, shift, 0x78); @@ -2524,7 +2524,7 @@ static DisasJumpType op_vfa(DisasContext *s, DisasOps= *o) return DISAS_NORETURN; } =20 - switch (s->fields->op2) { + switch (s->fields.op2) { case 0xe3: fn =3D se ? gen_helper_gvec_vfa64s : gen_helper_gvec_vfa64; break; @@ -2555,7 +2555,7 @@ static DisasJumpType op_wfc(DisasContext *s, DisasOps= *o) return DISAS_NORETURN; } =20 - if (s->fields->op2 =3D=3D 0xcb) { + if (s->fields.op2 =3D=3D 0xcb) { gen_gvec_2_ptr(get_field(s, v1), get_field(s, v2), cpu_env, 0, gen_helper_gvec_wfc64); } else { @@ -2581,7 +2581,7 @@ static DisasJumpType op_vfc(DisasContext *s, DisasOps= *o) } =20 if (cs) { - switch (s->fields->op2) { + switch (s->fields.op2) { case 0xe8: fn =3D se ? gen_helper_gvec_vfce64s_cc : gen_helper_gvec_vfce6= 4_cc; break; @@ -2595,7 +2595,7 @@ static DisasJumpType op_vfc(DisasContext *s, DisasOps= *o) g_assert_not_reached(); } } else { - switch (s->fields->op2) { + switch (s->fields.op2) { case 0xe8: fn =3D se ? gen_helper_gvec_vfce64s : gen_helper_gvec_vfce64; break; @@ -2630,7 +2630,7 @@ static DisasJumpType op_vcdg(DisasContext *s, DisasOp= s *o) return DISAS_NORETURN; } =20 - switch (s->fields->op2) { + switch (s->fields.op2) { case 0xc3: fn =3D se ? gen_helper_gvec_vcdg64s : gen_helper_gvec_vcdg64; break; @@ -2688,7 +2688,7 @@ static DisasJumpType op_vfma(DisasContext *s, DisasOp= s *o) return DISAS_NORETURN; } =20 - if (s->fields->op2 =3D=3D 0x8f) { + if (s->fields.op2 =3D=3D 0x8f) { fn =3D se ? gen_helper_gvec_vfma64s : gen_helper_gvec_vfma64; } else { fn =3D se ? gen_helper_gvec_vfms64s : gen_helper_gvec_vfms64; --=20 2.20.1