From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adgPz-0000ch-H7 for qemu-devel@nongnu.org; Wed, 09 Mar 2016 10:53:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adgPv-0001KF-DG for qemu-devel@nongnu.org; Wed, 09 Mar 2016 10:52:59 -0500 Received: from mail-qk0-x22e.google.com ([2607:f8b0:400d:c09::22e]:34521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adgPv-0001K4-8u for qemu-devel@nongnu.org; Wed, 09 Mar 2016 10:52:55 -0500 Received: by mail-qk0-x22e.google.com with SMTP id x1so21888019qkc.1 for ; Wed, 09 Mar 2016 07:52:54 -0800 (PST) Sender: Richard Henderson References: <87r3fjpvgx.fsf@fimbulvetr.bsc.es> From: Richard Henderson Message-ID: <56E046D3.2080709@twiddle.net> Date: Wed, 9 Mar 2016 10:52:51 -0500 MIME-Version: 1.0 In-Reply-To: <87r3fjpvgx.fsf@fimbulvetr.bsc.es> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC] [tcg] Idea on refactoring target code generation loop (gen_intermediate_code) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Paolo Bonzini , Peter Crosthwaite On 03/09/2016 09:38 AM, Lluís Vilanova wrote: > Hi, > > NOTE: I won't be throwing patches anytime soon, I just want to know if there's > interest in this for the future. > > While adding events for tracing guest instructions, I've found that the > per-target "gen_intermediate_code()" function is very similar but not exactly > the same for each of the targets. This makes architecture-agnostic features > harder to maintain across targets, specially when it comes to their relative > order. > > So, would it be worth it if I generalized part of that code into an > architecture-agnostic function that calls into target-specific hooks wherever it > needs extending? There are many ways to do it that we can discuss later. It's worth talking about, since I do believe it would make long-term maintenance across the targets easier. These "target-specific hooks" probably ought not be "hooks" in the traditional sense of attaching them to CPUState. I'd be more comfortable with a refactoring that used include files -- maybe .h or maybe .inc.c. If we do the normal sort of hook, then we've got to either expose DisasContext in places we shouldn't, or dynamically allocate it. Neither seems particularly appealing. r~