From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JzbzS-0003Ub-6c for qemu-devel@nongnu.org; Fri, 23 May 2008 14:27:42 -0400 Received: from [199.232.76.173] (port=50289 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JzbzQ-0003Rj-RV for qemu-devel@nongnu.org; Fri, 23 May 2008 14:27:40 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:41952) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JzbzQ-0007sw-FO for qemu-devel@nongnu.org; Fri, 23 May 2008 14:27:40 -0400 Message-ID: <48370C99.70708@bellard.org> Date: Fri, 23 May 2008 20:27:37 +0200 From: Fabrice Bellard MIME-Version: 1.0 Subject: Re: [Qemu-devel] [4544] added tcg_temp_free() and improved the handling of constants References: <200805231903.35923.paul@codesourcery.com> In-Reply-To: <200805231903.35923.paul@codesourcery.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paul Brook I will update the TCG documentation soon to explain it and other modifications I am about to do. In short, tcg_const() is now exactly equivalent to a temporary, hence it should be freed. Freeing temporaries is useful to reduce translation time and memory usage. However it has little consequences on the quality of the generated code. Fabrice. Paul Brook wrote: >> added tcg_temp_free() and improved the handling of constants > > Should the return value of tcg_const_i32 et. al. be considered immutable, or > is it ok to use it as a temporary? > > e.g.: > > static TCGv do_frob(TCGv base, int addend) > { > TCGv tmp = tcg_const_i32(addend); > tcg_gen_helper_frob(tmp, tmp, base) > return tmp; > } > > or should this be written as: > > static TCGv do_frob(TCGv base, int addend) > { > TCGv tmp = tcg_temp_new(TCG_TYPE_I32); > tcg_gen_movi_i32(tmp, addend); > tcg_gen_helper_frob(tmp, tmp, base) > return tmp; > } > > Currently it's fairly hard to enforce this restriction automatically, but we > need to decide whether it's a feature or a bug. > > Paul >