This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] 1/3 Add new builtin __builtin_flush_icache().

Mark Mitchell wrote:
Paolo Bonzini wrote:
1) Rename the new builtin to __builtin_clear_cache (char *beg , char
*end), and have it call the function in libgcc if there is not an
inline expansion for it?
(And use libgcc's prototype). This would be the cleanest.

This, plus, try to see how __clear_cache could use the definition of the

Paolo, I didn't quite follow your suggestion. So, I'm not sure if I'm agreeing or disagreeing. :-)

Anyhow, here's my suggestion.

1. The builtin should be:

__builtin___clear_cache (char *beg, char *end)

following the standard convention that the builtin for X is __builtin_X.

2. The default implementation of the builtin should be to call
__clear_cache.  That means that users can call __builtin_clear_cache
from their code, on all platforms.

I agree and had arrived at the same conclusion for your first two points.
3. Targets which can do something clever can implement the builtin as
they please and can define CLEAR_INSN_CACHE(BEG, END) to expand to
__builtin_clear_cache(BEG, END).  On such targets, then, __clear_cache
in libgcc will call the builtin, which we can be assured will not
recursively expand to __clear_cache.

My current idea for this can, I think,,be best expressed by looking at the proposed code for libgcc:

__clear_cache (char *beg, char *end)
 if (__builtin_clear_cache_inline_p())
   __builtin___clear_cache (beg, end);
     CLEAR_INSN_CACHE (beg, end);
#endif /* CLEAR_INSN_CACHE */

No changes to any existing CLEAR_INSN_CACHE definitions are needed. There is a new target hook that determines the value of __builtin_clear_cache_inline_p(). I chose to do it this way because I think it would be impossible to reliably determine if the __builtin___clear_cache would expand in-line without such a predicate.

A revised patch is in the works.

David Daney

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]