Received: from eggs.gnu.org ([2001:4830:134:3::10]:48042) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLdei-00053f-CP for qemu-devel@nongnu.org; Tue, 19 Jan 2016 16:17:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aLded-0006qo-8F for qemu-devel@nongnu.org; Tue, 19 Jan 2016 16:17:36 -0500 Received: from roura.ac.upc.edu ([147.83.33.10]:50660 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aLdec-0006qF-SA for qemu-devel@nongnu.org; Tue, 19 Jan 2016 16:17:31 -0500 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <145287209895.25408.12995870835200275306.stgit@localhost> <145287210479.25408.17499099590726683703.stgit@localhost> <56993854.1030802@twiddle.net> <87egdi1u1y.fsf@fimbulvetr.bsc.es> <569955F4.4000607@twiddle.net> <87pox1xmwv.fsf@fimbulvetr.bsc.es> <20160119170029.GS29396@toto> Date: Tue, 19 Jan 2016 22:17:25 +0100 In-Reply-To: <20160119170029.GS29396@toto> (Edgar E. Iglesias's message of "Tue, 19 Jan 2016 18:00:29 +0100") Message-ID: <871t9d9sm2.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v1 1/2] tcg: Add support for constant value promises List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Edgar E. Iglesias" Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, Richard Henderson Edgar E Iglesias writes: > On Sat, Jan 16, 2016 at 09:57:36PM +0100, Llu=C3=ADs Vilanova wrote: >> Richard Henderson writes: >>=20 >> > On 01/15/2016 12:12 PM, Llu=C3=ADs Vilanova wrote: >> >> Richard Henderson writes: >> >>=20 >> >>> On 01/15/2016 07:35 AM, Llu=C3=ADs Vilanova wrote: >> >>>> +TCGv_i64 tcg_promise_i64(TCGv_promise_i64 *promise) >> >>>> +{ >> >>>> + int pi =3D tcg_ctx.gen_next_parm_idx; >> >>>> + *promise =3D (TCGv_promise_i64)&tcg_ctx.gen_opparam_buf[pi]; >> >>>> + return tcg_const_i64(0xdeadcafe); >> >>>> +} >> >>=20 >> >>> This doesn't work for a 32-bit host. The constant may be split acro= ss two >> >>> different parameter indices, and you don't know exactly where the se= cond will be. >> >>=20 >> >>> Because of that, I think this is over-engineered, and really prefer = the simpler >> >>> interface that Edgar posted last week. >> >>=20 >> >> In this case, 'tcg_set_promise_i64' sets the two arguments accordingl= y on 32-bit >> >> targets. Both solutions depend on TCG internals (in this specific cas= e the >> >> implementation of 'tcg_gen_movi_i64'), but now it's all implemented i= nside TCG. >> >>=20 >> >> Alternatively, promises could use the longer route of recording the o= pcode index >> >> (as Edgar did AFAIR), and retrieve the argument pointer from there. S= till, for >> >> 32-bit targets we have to assume the two immediate moves are gonna ge= nerate two >> >> consecutive opcodes. >>=20 >> > Your solution also doesn't help Edgar, since he's interested in modify= ing an >> > argument to the insn_start opcode, not modifying a literal constant in= a move. >>=20 >> I wasn't aware of that. If the idea was to use this for more than immedi= ates >> stored in TCGv values, I see two options. First, modify the necessary op= codes to >> use a TCGv argument instead of an immediate. Second, generalize this pat= ch to >> to select any opcode argument. >>=20 >> An example of the generalization when used to reimplement icount: >>=20 >> // insn count placeholder >> TCGv_i32 imm =3D tcg_const_i32(0xcafecafe); >> // insn count promise >> TCGv_promise_i32 imm_promise =3D tcg_promise_i32( >> 1, // how many opcodes to go "backwards" >> 1); // what argument to modify on that opcode >> // operate with imm >> ... >> // resolve value >> tcg_set_promise_i32(imm_promise, insn_count); >>=20 >> The question still stands on how to cleanly handle promises for opcodes = like a >> 64-bit mov on a 32-bit host (it's generated as two opcodes). Using this >> interface would still be cleaner than directly manipulating the low-leve= l TCG >> arrays, and makes it easier to adopt it in future changes. >>=20 > Thanks Lluis and Richard, > I'll stay with my version for the first try at the ARM load/store fault > reporting. If something better comes along that works for me, I'm happy > to change. > Richard if you want to take the patches through your tree feel free to > do so. Otherwise, I'll post them again with more context and try through > the ARM queue. My offer still stands. If the generalized interface seems adequate (specific opcode argument to set the promise for), it's a rather simple change on the series. Cheers, Lluis