* [lto] Possible functions for writing FIELD_DECLs
@ 2007-08-13 23:34 Jim Blandy
2007-08-15 7:03 ` Mark Mitchell
0 siblings, 1 reply; 3+ messages in thread
From: Jim Blandy @ 2007-08-13 23:34 UTC (permalink / raw)
To: Kenneth Zadeck; +Cc: gcc-patches
Here's my, um, theory as to how one might write DWARF for FIELD_DECLs
and get a reference to them for LTO's use. Kenny, I'm posting this in
hopes that you'll be able to add code to test it more quickly than I
could.
gcc/ChangeLog.lto:
2007-08-13 Jim Blandy <jimb@codesourcery.com>
* dwarf2out.c (lto_field_ref, force_field_die): New functions.
* dwarf2out.h (lto_field_ref): New declaration.
Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c (revision 127370)
+++ gcc/dwarf2out.c (working copy)
@@ -13441,6 +13441,28 @@
return type_die;
}
+/* Returns the DIE for field. A DIE will always be returned. */
+
+static dw_die_ref
+force_field_die (tree field)
+{
+ dw_die_ref decl_die;
+ decl_die = lookup_decl_die (field);
+ if (!decl_die)
+ {
+ tree decl_context = DECL_CONTEXT (field);
+ gcc_assert (decl_context && TYPE_P (decl_context));
+ force_type_die (decl_context);
+
+ /* Forcing a die for the containing type should always generate
+ a die for this field. */
+ decl_die = lookup_decl_die (field);
+ gcc_assert (decl_die);
+ }
+
+ return decl_die;
+}
+
/* Force out any required namespaces to be able to output DECL,
and return the new context_die for it, if it's changed. */
@@ -14991,6 +15013,19 @@
lto_init_ref (ref, die, DECL_CONTEXT (fn));
}
+void
+lto_field_ref (tree field,
+ lto_out_ref *ref)
+{
+ dw_die_ref die;
+
+ gcc_assert (TREE_CODE (field) == FIELD_DECL);
+ /* Generate the DIE for FIELD. */
+ die = force_field_die (field);
+ /* Construct the reference. */
+ lto_init_ref (ref, die, DECL_CONTEXT (field));
+}
+
#else
/* This should never be used, but its address is needed for comparisons. */
Index: gcc/dwarf2out.h
===================================================================
--- gcc/dwarf2out.h (revision 127370)
+++ gcc/dwarf2out.h (working copy)
@@ -66,3 +66,7 @@
/* Upon return, *REF contains a reference to FN, which must be a
FUNCTION_DECL. */
extern void lto_fn_ref (tree fn, lto_out_ref *ref);
+
+/* Upon return, *REF contains a reference to FIELD, which must be a
+ FIELD_DECL. */
+extern void lto_field_ref (tree fn, lto_out_ref *ref);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [lto] Possible functions for writing FIELD_DECLs
2007-08-13 23:34 [lto] Possible functions for writing FIELD_DECLs Jim Blandy
@ 2007-08-15 7:03 ` Mark Mitchell
2007-08-15 21:17 ` Jim Blandy
0 siblings, 1 reply; 3+ messages in thread
From: Mark Mitchell @ 2007-08-15 7:03 UTC (permalink / raw)
To: Jim Blandy; +Cc: Kenneth Zadeck, gcc-patches
Jim Blandy wrote:
> Here's my, um, theory as to how one might write DWARF for FIELD_DECLs
> and get a reference to them for LTO's use. Kenny, I'm posting this in
> hopes that you'll be able to add code to test it more quickly than I
> could.
>
> gcc/ChangeLog.lto:
> 2007-08-13 Jim Blandy <jimb@codesourcery.com>
>
> * dwarf2out.c (lto_field_ref, force_field_die): New functions.
> * dwarf2out.h (lto_field_ref): New declaration.
This looks good; please check it in. Please also do the lto/ side of
the equation; Kenny will need lto_resolve_field_ref (like
lto_resolve_fn_ref) to get the FIELD_DECL back.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [lto] Possible functions for writing FIELD_DECLs
2007-08-15 7:03 ` Mark Mitchell
@ 2007-08-15 21:17 ` Jim Blandy
0 siblings, 0 replies; 3+ messages in thread
From: Jim Blandy @ 2007-08-15 21:17 UTC (permalink / raw)
To: Mark Mitchell; +Cc: Kenneth Zadeck, gcc-patches
Mark Mitchell <mark@codesourcery.com> writes:
> Jim Blandy wrote:
>> Here's my, um, theory as to how one might write DWARF for FIELD_DECLs
>> and get a reference to them for LTO's use. Kenny, I'm posting this in
>> hopes that you'll be able to add code to test it more quickly than I
>> could.
>>
>> gcc/ChangeLog.lto:
>> 2007-08-13 Jim Blandy <jimb@codesourcery.com>
>>
>> * dwarf2out.c (lto_field_ref, force_field_die): New functions.
>> * dwarf2out.h (lto_field_ref): New declaration.
>
> This looks good; please check it in. Please also do the lto/ side of
> the equation; Kenny will need lto_resolve_field_ref (like
> lto_resolve_fn_ref) to get the FIELD_DECL back.
I've committed this; thanks.
I've posted the patch for the reading side.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-08-15 21:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-13 23:34 [lto] Possible functions for writing FIELD_DECLs Jim Blandy
2007-08-15 7:03 ` Mark Mitchell
2007-08-15 21:17 ` Jim Blandy
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).