Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N80JD-0005Al-4D for qemu-devel@nongnu.org; Tue, 10 Nov 2009 18:39:35 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N80J8-00054t-CB for qemu-devel@nongnu.org; Tue, 10 Nov 2009 18:39:34 -0500 Received: from [199.232.76.173] (port=39877 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N80J8-00054e-7R for qemu-devel@nongnu.org; Tue, 10 Nov 2009 18:39:30 -0500 Received: from mx20.gnu.org ([199.232.41.8]:55746) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N80J7-0003k1-Sl for qemu-devel@nongnu.org; Tue, 10 Nov 2009 18:39:30 -0500 Received: from mail.codesourcery.com ([38.113.113.100]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N80J7-0008J8-3L for qemu-devel@nongnu.org; Tue, 10 Nov 2009 18:39:29 -0500 From: Paul Brook Subject: Re: [Qemu-devel] [PATCH 00/18] target-arm cleanup Date: Tue, 10 Nov 2009 23:39:26 +0000 References: <5b31733c0907190843k11ead885tc6b4c81b79f7257b@mail.gmail.com> <20091015174054.GZ4127@hall.aurel32.net> In-Reply-To: <20091015174054.GZ4127@hall.aurel32.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <200911102339.27007.paul@codesourcery.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Laurent Desnogues , Filip Navara , Aurelien Jarno > On the code itself, I don't really like the remaining, new_tmp(), > dead_tmp(), and even more the fact that some functions can allocate > (e.g load_reg) or free (e.g. store_reg) some TCG variables implicitely. > This is a way to make errors by reallocating or forgetting to free some > > variables, and that leads to strange code like: > | if (rn == 15) { > | tmp = new_tmp(); > | tcg_gen_movi_i32(tmp, 0); > | } else { > | tmp = load_reg(s, rn); > | } There is actually logic behind this Consider the obvious implementation of the "neg" instruction: val = load_reg(rn); tcg_gen_neg_i32(val, val); store_reg(rd, val); With the current code this is safe. However if load_reg returns cpu_R[n] instead of a temporary then the above code will incorrectly clobber the source register. My theory was that tracking down an accidental write to a source register is much harder than tracking down a mismatched temporary. Paul