* how to get the library DECL for a built-in function
@ 2020-12-04 23:33 Martin Sebor
2020-12-05 0:52 ` Martin Sebor
0 siblings, 1 reply; 3+ messages in thread
From: Martin Sebor @ 2020-12-04 23:33 UTC (permalink / raw)
To: gcc mailing list
I'm looking for a way to get the FUNCTION_DECL for the library
(i.e., non-built-in) form of a function given the corresponding
built-in DECL. Is there an API I can all with either the built
-in DECL or its code to get it in the middle end?
In C, what I'm looking for appears to be DECL_CHAIN(decl), at
least for the example I looked at. I.e., the library libdecl
for a corresponding __bultin_xxx DECL is DECL_CHAIN (DECL).
But in C++, it looks like it's the other way around and it's
the built-in decl that's the DECL_CHAIN(DECL) for the built-in
DECL, and AFAIK there's no good way to get from the latter to
the former.
Thanks
Martin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: how to get the library DECL for a built-in function
2020-12-04 23:33 how to get the library DECL for a built-in function Martin Sebor
@ 2020-12-05 0:52 ` Martin Sebor
2020-12-07 7:20 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Martin Sebor @ 2020-12-05 0:52 UTC (permalink / raw)
To: gcc mailing list
On 12/4/20 4:33 PM, Martin Sebor wrote:
> I'm looking for a way to get the FUNCTION_DECL for the library
> (i.e., non-built-in) form of a function given the corresponding
> built-in DECL. Is there an API I can all with either the built
> -in DECL or its code to get it in the middle end?
>
> In C, what I'm looking for appears to be DECL_CHAIN(decl), at
> least for the example I looked at. I.e., the library libdecl
> for a corresponding __bultin_xxx DECL is DECL_CHAIN (DECL).
>
> But in C++, it looks like it's the other way around and it's
> the built-in decl that's the DECL_CHAIN(DECL) for the built-in
> DECL, and AFAIK there's no good way to get from the latter to
> the former.
To expand on this: I expected to get the library DECL for
a declared function by calling
symtab_node::get_from_asmname(libname) like for instance:
tree id = get_identifier ("free");
symtab_node *node = symtab_node::get_from_asmname (id);
but what I get back is a DECL for __builtin_free instead.
The DECL for "free" is the result of DECL_CHAIN() in C but
not in C++.
>
> Thanks
> Martin
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: how to get the library DECL for a built-in function
2020-12-05 0:52 ` Martin Sebor
@ 2020-12-07 7:20 ` Richard Biener
0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2020-12-07 7:20 UTC (permalink / raw)
To: Martin Sebor; +Cc: gcc mailing list
On Sat, Dec 5, 2020 at 1:55 AM Martin Sebor via Gcc <gcc@gcc.gnu.org> wrote:
>
> On 12/4/20 4:33 PM, Martin Sebor wrote:
> > I'm looking for a way to get the FUNCTION_DECL for the library
> > (i.e., non-built-in) form of a function given the corresponding
> > built-in DECL. Is there an API I can all with either the built
> > -in DECL or its code to get it in the middle end?
> >
> > In C, what I'm looking for appears to be DECL_CHAIN(decl), at
> > least for the example I looked at. I.e., the library libdecl
> > for a corresponding __bultin_xxx DECL is DECL_CHAIN (DECL).
> >
> > But in C++, it looks like it's the other way around and it's
> > the built-in decl that's the DECL_CHAIN(DECL) for the built-in
> > DECL, and AFAIK there's no good way to get from the latter to
> > the former.
>
> To expand on this: I expected to get the library DECL for
> a declared function by calling
> symtab_node::get_from_asmname(libname) like for instance:
>
> tree id = get_identifier ("free");
> symtab_node *node = symtab_node::get_from_asmname (id);
>
> but what I get back is a DECL for __builtin_free instead.
> The DECL for "free" is the result of DECL_CHAIN() in C but
> not in C++.
The C family FEs aggressively "merge" decls, but usually
from builtin into the user provided one. Did you see whether
node->next_sharing_asm_name get's you anywhere?
(I've always wanted to see the user provided decl prevail
in what builtin_decl_implicit returns)
DECL_CHAIN on these is purely FE local from their global
name bindings structures, we should probably clear it
somewhere (LTO doesn't write it for example).
Richard.
>
> >
> > Thanks
> > Martin
> >
> >
> >
> >
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-07 7:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04 23:33 how to get the library DECL for a built-in function Martin Sebor
2020-12-05 0:52 ` Martin Sebor
2020-12-07 7:20 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).