public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Daney <ddaney@avtrex.com>
To: David Daney <ddaney@avtrex.com>,
		Mark Mitchell <mark@codesourcery.com>,
		Paolo Bonzini <bonzini@gnu.org>,
	gcc-patches@gcc.gnu.org, 	rsandifo@nildram.co.uk
Subject: Re: [Patch] 1/3 Add new builtin __builtin_flush_icache().
Date: Thu, 05 Jul 2007 18:23:00 -0000	[thread overview]
Message-ID: <468D35AD.90208@avtrex.com> (raw)
In-Reply-To: <87vecy3f6y.fsf@firetop.home>

Richard Sandiford wrote:
> David Daney <ddaney@avtrex.com> 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...
> 

This is the way I meant for it to be.  If 
targetm.builtin_clear_cache_inline_p() is false we just do the default 
expand to call the function in libgcc.

If we are expanding in-line, the it is an error if the arguments are not 
pointers.

The only reason it is an error is to prevent infinite recursion.  If 
that were not an issue, we could return NULL_RTX if validate_arglist failed.


>> +  /* 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.

The operands in the MIPS patch are both (match_operand:SI 0 
"general_operand").  Look at the part in mips.c where I do:

begin = force_reg(Pmode, begin);

If that is the wrong way to put something in a register I will change it.

David Daney

  reply	other threads:[~2007-07-05 18:17 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-01  5:01 David Daney
2007-07-01  5:05 ` [Patch] 2/3 MIPS support for " David Daney
2007-07-01 10:56   ` Richard Sandiford
2007-07-05  7:50     ` David Daney
2007-07-05 19:05       ` Richard Sandiford
2007-07-08 20:00         ` David Daney
2007-07-09 19:07           ` Richard Sandiford
2007-07-11  5:45             ` David Daney
2007-07-01  5:11 ` [Patch] 3/3 FFI: Use __builtin_flush_icache() to flush MIPS i-cache David Daney
2007-07-05  8:34   ` David Daney
2007-07-05 19:08     ` Richard Sandiford
2007-07-11 18:55       ` Tom Tromey
2007-07-01  8:01 ` [Patch] 1/3 Add new builtin __builtin_flush_icache() Paolo Bonzini
2007-07-01 17:51   ` Thiemo Seufer
2007-07-01 18:47   ` David Daney
2007-07-02  5:04     ` Paolo Bonzini
2007-07-03 23:55       ` Mark Mitchell
2007-07-04  7:18         ` Paolo Bonzini
2007-07-04 17:17           ` Mark Mitchell
2007-07-04 17:10         ` David Daney
2007-07-04 17:51           ` Mark Mitchell
2007-07-05  7:36             ` David Daney
2007-07-05 17:59               ` Richard Sandiford
2007-07-05 18:23                 ` David Daney [this message]
2007-07-05 19:11                   ` Richard Sandiford
2007-07-06  6:07               ` Mark Mitchell
2007-07-06  6:19                 ` David Daney
2007-07-06 16:39                   ` Mark Mitchell
2007-07-08 19:22                     ` David Daney
2007-07-09 19:04                       ` Richard Sandiford
2007-07-11  2:22                       ` Mark Mitchell
2007-07-11  4:47                         ` David Daney
2007-07-05  9:05 ` [Patch] 4/3 i386 target support for __builtin___clear_cache() David Daney
2007-07-08 20:39   ` David Daney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=468D35AD.90208@avtrex.com \
    --to=ddaney@avtrex.com \
    --cc=bonzini@gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mark@codesourcery.com \
    --cc=rsandifo@nildram.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).