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


On Thu, Jul 2, 2009 at 12:20 AM, Jakub Jelinek<jakub@redhat.com> wrote:
> On Wed, Jul 01, 2009 at 11:07:16PM -0700, Mark Mitchell wrote:
>> Richard Guenther wrote:
>>
>> >> When using asm to change C++ symbol name, you have to mangle it
>> >> by hand. When you change the prototype of the ifunc function,
>> >> you have to mangle the symbol name again. ?Should we ask gcc
>> >> users which approach is better?
>> >
>> > No.
>>
>> Richard, I disagree with your position in this thread. ?In particular, I
>> do think that we should try to make this attribute work for C++ without
>> users having to do by-hand mangling of names. ?That's clearly the right
>> user interface; C++ programmers should never have to know about mangling.
>
> If mangling is the issue, then just allow asm and alias attribute to specify
> decl for mangling, as alternative to the current string. ?That would help
> not only using asm with ifunc attribute, but also other asms used for symbol
> redirection and the alias attribute. ?Currently in C++, if you want to have
> both foo and bar implemented by the same routine, you need to write:
>
> void
> foo (int)
> {
> }
>
> __typeof (foo) bar __attribute__((alias ("_Z3fooi")));
> __typeof (foo) baz __attribute__((alias ("_Z3fooi")));
>
> If we had:
> void
> foo (int)
> {
> }
>
> __typeof (foo) bar __attribute__((alias (mangle (foo))));
> __typeof (::foo) baz __attribute__((alias (mangle (::foo))));
>
> Or
>
> int foo (int, long);
> static int foo1 (int x, long y) { return x + y; }
> static int foo2 (int x, long y) { return x - y; }
> __typeof (foo) *foo_ifunc (void) __asm (mangle (foo))
> {
> ?if (cpuid & have_ADD)
> ? ?return foo1;
> ?return foo2;
> }
>

How do you handle

int foo (int, long);
static int foo1 (int x, long y);
static int foo2 (int x, long y);
int foo (float, long);
static int foo3 (float x, long y);
static int foo4 (float x, long y);

Which foo does __typeof (foo) refer to?


-- 
H.J.


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