This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [IFUNC] PATCH: Add an ifunc attribute
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Paolo Bonzini <bonzini at gnu dot org>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, Jakub Jelinek <jakub at redhat dot com>, Richard Guenther <richard dot guenther at gmail dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 02 Jul 2009 08:50:15 -0700
- Subject: Re: [IFUNC] PATCH: Add an ifunc attribute
- References: <84fc9c000906280957r26be86d4h8130d8d0ae5455a1@mail.gmail.com> <84fc9c000906281020h6a63ed83kd109df656729229a@mail.gmail.com> <6dc9ffc80906281027u37d13ec7w931add5f095b1df9@mail.gmail.com> <84fc9c000906281113td6522cxd0f5057512874eed@mail.gmail.com> <6dc9ffc80906281208m67e7abb8q5b35b405f77e572@mail.gmail.com> <Pine.LNX.4.64.0906281928420.26388@digraph.polyomino.org.uk> <6dc9ffc80906281239u2589c6f0uc12fae2225d421db@mail.gmail.com> <84fc9c000906281240y39c679e3uc54a5eeb716fa126@mail.gmail.com> <4A4C4E94.8090705@codesourcery.com> <20090702072020.GL4462@tyan-ft48-01.lab.bos.redhat.com> <6dc9ffc80907020547w3531b29eke4cdc3275f58d51d@mail.gmail.com> <4A4CB532.4060603@gnu.org>
Paolo Bonzini wrote:
> Accept __attribute__ ((ifunc (int foo(int, long)) then. And then do
>
> typedef int foo_type (int, long);
> foo *bar (void) __attribute__ ((ifunc (foo_type foo)))
I don't object to something like this, or Jakub's "mangle" suggestion.
I agree with Jakub that if we can build something that is useful in more
contexts, that is a good thing.
I think that for C++, there are two reasonably natural ways to deal with
overloading. The first is a full declaration, just as would be required
to declare the function. This is what Paolo demonstrates above. Of
course, in the case of templates, this might be complex. For example:
mangle(template <> void S<int>::f(double))
or some such. The other would be to use the same rules that apply when
performing a cast. For example:
mangle((void (*)())f);
Here, the overloaded "f" can be resolved based on the cast-to type. A
further extension that gets you the type of the top level declaration
being declared would be useful. For example:
void f(int) attribute((asm(mangle((typeof)g))));
The intent here is that we pick the "g" that matches the type of "f".
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713