From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13087 invoked by alias); 5 Jul 2007 17:59:01 -0000 Received: (qmail 13058 invoked by uid 22791); 5 Jul 2007 17:59:00 -0000 X-Spam-Check-By: sourceware.org Received: from smtp.nildram.co.uk (HELO smtp.nildram.co.uk) (195.112.4.54) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 05 Jul 2007 17:58:49 +0000 Received: from firetop.home (unknown [84.12.162.236]) by smtp.nildram.co.uk (Postfix) with ESMTP id 74DAD2BFCCF; Thu, 5 Jul 2007 18:58:43 +0100 (BST) Received: from richard by firetop.home with local (Exim 4.63) (envelope-from ) id 1I6VbJ-00070c-Ca; Thu, 05 Jul 2007 18:58:45 +0100 From: Richard Sandiford To: David Daney Mail-Followup-To: David Daney , Mark Mitchell , Paolo Bonzini , gcc-patches@gcc.gnu.org, rsandifo@nildram.co.uk Cc: Mark Mitchell , Paolo Bonzini , gcc-patches@gcc.gnu.org Subject: Re: [Patch] 1/3 Add new builtin __builtin_flush_icache(). References: <468734D3.3020908@avtrex.com> <46875F54.8070905@gnu.org> <4687F6C1.6050906@avtrex.com> <46888752.2040207@gnu.org> <468ADFB4.4060400@codesourcery.com> <468BCF25.40807@avtrex.com> <468BD6CA.8000703@codesourcery.com> <468C999B.1000102@avtrex.com> Date: Thu, 05 Jul 2007 17:59:00 -0000 In-Reply-To: <468C999B.1000102@avtrex.com> (David Daney's message of "Thu, 05 Jul 2007 00:11:23 -0700") Message-ID: <87vecy3f6y.fsf@firetop.home> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-07/txt/msg00473.txt.bz2 David Daney writes: > +/* Expand a call to _builtin___clear_cache. If the target does not > + support the operation, return NULL_RTX so it expands as a call. */ > +static rtx > +expand_builtin_clear_cache (tree exp) > +{ > + tree begin, end; > + rtx begin_rtx, end_rtx; > + > + if (!targetm.builtin_clear_cache_inline_p()) > + return NULL_RTX; > + > + /* We must not expand to a library call if > + __builtin_clear_cache_inline_p() returns true. If we did, the > + fallback library function in libgcc would expand to a call to > + _builtin___clear_cache() and we would recurse infinitely. */ > + if (!validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE)) This comment seems to belong above the earlier code. However, I'm only really replying because... > + /* Evaluate BEGIN and END. */ > + begin_rtx = expand_expr (begin, NULL_RTX, Pmode, EXPAND_NORMAL); > + begin_rtx = convert_memory_address (Pmode, begin_rtx); > + > + end_rtx = expand_expr (end, NULL_RTX, Pmode, EXPAND_NORMAL); > + end_rtx = convert_memory_address (Pmode, end_rtx); > + > +#ifdef HAVE_clear_cache > + if (HAVE_clear_cache) > + emit_insn (gen_clear_cache (begin_rtx, end_rtx)); > +#endif When I said that the switch from general_operand to pmode_register_operand would need target-independent changes, I meant it would need changes to this bit of code. I think you need to check the predicates of each clear_cache operand and force the operand into a register if it doesn't match. Something like: if (HAVE_clear_cache) { icode = CODE_FOR_clear_cache; if (!insn_data[icode].operand[0].predicate (begin_rtx, Pmode)) begin_rtx = copy_to_mode_reg (Pmode, begin_rtx); if (!insn_data[icode].operand[1].predicate (end_rtx, Pmode)) end_rtx = copy_to_mode_reg (Pmode, end_rtx); emit_insn (gen_clear_cache (begin_rtx, end_rtx)); } (It's unfortunate that this construct has to be copied so often, but that's the way it is.) As it stands, the code only seems to guarantee that the operand is an address operand, whereas the predicates in the MIPS patch claim that it will be a register. Richard