This is the mail archive of the gcc-patches@gcc.gnu.org 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: [IFUNC] PATCH: Add an ifunc attribute


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


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