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: PATCH: Add ifunc attribute


On Fri, Jun 26, 2009 at 9:12 AM, Richard
Guenther<richard.guenther@gmail.com> wrote:
> On Fri, Jun 26, 2009 at 6:03 PM, H.J. Lu<hjl.tools@gmail.com> wrote:
>> On Fri, Jun 26, 2009 at 8:47 AM, Paolo Bonzini<bonzini@gnu.org> wrote:
>>>> How do you propose to support C++?
>>>
>>> Why wouldn't Roland's proposal work with C++?
>>>
>>
>> I am not sure it will work for C++, especially for
>> member functions.
>
> asm() with a properly mangled name should work.
>
> Richard.

Here is a C++ example.  Option 3 works nicely.

---
class ifunc
{
private:
  int foo1 (int);
  int foo2 (float);

public:
  int foo (int);
  int foo (float);
  int bar (int);
  int bar (float);
};

int
__attribute__ ((ifunc))
ifunc::foo (int)
{
  return &ifunc::foo1;
}

int
__attribute__ ((ifunc))
ifunc::foo (float)
{
  return &ifunc::foo2;
}

int
ifunc::bar (int x)
{
  return foo (x);
}

int
ifunc::bar (float x)
{
  return foo (x);
}
---

How do you make it to work with other options?

-- 
H.J.


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