diff options
author | Daniel Berlin <dberlin@dberlin.org> | 2005-07-08 23:37:11 +0000 |
---|---|---|
committer | Daniel Berlin <dberlin@gcc.gnu.org> | 2005-07-08 23:37:11 +0000 |
commit | 820cc88fbd53803f1b57374bfc78e628c6879fc0 (patch) | |
tree | e8e5667e9ce5aa5fc7514d5caa37a74c88e3f391 /gcc/doc/c-tree.texi | |
parent | c249f608702bff661796e3c188a848601cb4861c (diff) | |
download | gcc-820cc88fbd53803f1b57374bfc78e628c6879fc0.zip gcc-820cc88fbd53803f1b57374bfc78e628c6879fc0.tar.gz gcc-820cc88fbd53803f1b57374bfc78e628c6879fc0.tar.bz2 |
Makefile.in (TREE_H): Add treestruct.def.
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* Makefile.in (TREE_H): Add treestruct.def.
(c-decl.o): Add pointer-set.h
* c-decl.c (diagnose_mismatched_decls): Don't attempt to look at
visibility on regular DECL's.
(merge_decls): Fix the copying of decl nodes of various types for
the new structures. Don't update RTL, section name, weak status,
etc, on DECL's without RTL.
(grokdeclarator): DECL_ARG_TYPE_AS_WRITTEN is gone.
Don't check volatile on non-variable types.
(store_parm_decls_oldstyle): Use pointer_set instead of DECL_WEAK
to check whether we have seen arguments.
* c-objc-common.c (c_tree_printer): Reverse order of tests so that
flag is checked before field (flag is common, field is not).
* dwarf2out.c (decl_ultimate_origin): Only DECL's with
TS_DECL_COMMON could have an origin.
(add_location_or_const_value_attribute): Don't check section name
on non-var/function decls.
(dwarf2out_var_location): Reverse order of tests.
* emit-rtl.c (set_reg_attrs_for_parm): DECL_CHECK is dead, replace
with DECL_WRTL_CHECK.
* expmed.c (make_tree): rtl is now in decl_with_rtl.
* fold-const.c (fold_binary): Don't check weakness on
non-var/function decls.
(tree_expr_nonzero_p): Ditto.
(fold_checksum_tree): Use tree_decl_extra as sizeof
buffer.
* ggc-page.c (extra_order_size_table): Add sizes for
tree_decl_non_common, tree_parm_decl, tree_var_decl, and
tree_field_decl.
* gimplify.c (gimplify_bind_expr): Only set
DECL_SEEN_IN_BIND_EXPR_P on VAR_DECL.
* integrate.c (copy_decl_for_inlining): Don't set RTL on decl's
without RTL.
* langhooks-def.h (LANG_HOOK_INIT_TS): New.
* langhooks.h (init_ts). New langhook.
* passes.c (rest_of_decl_compilation): Reverse order of tests.
* print-tree.c (print_node): Update to only print fields that
exist in the structures the passed decl has.
* toplev.c (wrapup_global_declarations): Don't reset
DECL_DEFER_OUTPUT on DECL's that don't contain it.
* tree-browser.c (browse_tree): DECL_ARG_TYPE_AS_WRITTEN removed.
* tree-inline.c (remap_decl): Ditto.
* tree-outof-ssa.c (create_temp): Reverse order of tests.
* tree-pretty-print.c (print_declaration): Don't print
DECL_REGISTER on things that don't contain it.
* tree-vrp.c (expr_computes_nonzero): Don't check weakness on
non-var/function decls.
* tree.c (tree_contains_struct): New structure.
(init_priority_for_decl): New hashtable.
(tree_int_map): New structure.
(tree_int_map_eq): New function.
(tree_int_map_marked_p): Ditto.
(tree_int_map_hash): Ditto.
(tree_map): Move to tree.h.
(tree_map_eq): Externalize.
(tree_map_hash): Ditto.
(tree_map_marked_p): Ditto.
(init_ttree): Set up tree_contains_struct and call langhook.
(decl_assembler_name): Use DECL_NON_COMMON_CHECK..
(tree_code_size): Update for new structures.
(tree_node_structure): Update for new structures.
(make_node_stat): Don't try to set DECL_IN_SYSTEM_HEADER on decls
without the field.
(copy_node_stat): Copy init priority.
(build_decl_stat): Ditto for visibility.
(ts_enum_names): New.
(tree_contains_struct_check_failed): New function.
(decl_init_priority_lookup): Ditto.
(decl_init_priority_insert): Ditto.
* treestruct.def: New file.
* tree.h (CODE_CONTAINS_STRUCT): New macro.
(CONTAINS_STRUCT_CHECK): Ditto.
(tree_contains_struct_check_failed): New prototype.
(DECL_CHECK): Removed.
(DECL_MINIMAL_CHECK): New.
(DECL_COMMON_CHECK): Ditto.
(DECL_WRTL_CHECK): Ditto.
(DECL_NON_COMMON_CHECK): Ditto.
(DECL_WITH_VIS_CHECK): Ditto.
(VAR_OR_FUNCTION_DECL_P): Ditto
(struct tree_decl_minimal): New structure.
(struct tree_decl_common): Ditto.
(struct tree_decl_with_rtl): Ditto.
(struct tree_decl_with_vis): Ditto.
(struct tree_decl_non_common): Ditto.
(struct tree_field_decl): Ditto.
(struct tree_parm_decl): Ditto.
(struct tree_var_decl): Ditto.
(struct tree_function_decl): Ditto.
(struct tree_const_decl): Ditto.
(struct tree_result_decl): Ditto.
(union tree_node): Add new structures.
* var-tracking.c (track_expr_p): Reverse order of tests.
* doc/c-tree.texi: Add documentation on DECL node internal structure.
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* utils.c (create_param_decl): DECL_ARG_TYPE_AS_WRITTEN is
removed.
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* Make-lang.in: Add gt-cp-lang.h.
(cp-lang.o): Ditto.
* class.c (create_vtable_ptr): Stop setting DECL_ASSEMBLER_NAME on
the field.
* config-lang.in: Add cp-lang.c to gtfiles.
* cp-lang.c: Include hashtab.h.
(cp_init_ts): New function.
(LANG_HOOK_INIT_TS): Use macro.
(decl_shadowed_for_var_lookup): New function.
(decl_shadowed_for_var_insert): Ditto.
* cp-tree.h (THUNK_FUNCTION_CHECK): Use decl_common.
(NON_THUNK_FUNCTION_CHECK): Ditto.
(DECL_NAMESPACE_ASSOCIATIONS): Use decl_non_common.
(DECL_INIT_PRIORITY): Ditto.
(DECL_HAS_SHADOWED_FOR_VAR_P): Ditto.
(DECL_SHADOWED_FOR_VAR): Use hashtable.
(SET_DECL_SHADOWED_FOR_VAR): Ditto.
* decl.c (duplicate_decls): Update for new/updated structures.
(poplevel): Use SET_DECL_SHADOWED_FOR_VAR.
* decl2.c (start_static_initialization_or_destruction): Deal with
priority.
* pt.c (tsubst_decl): Check TS_DECL_WRTL before doing
SET_DECL_RTL.
* tree.c (handle_init_priority_attribute): Handle priority.
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* objc-act.c (objc_push_parm): DECL_ARG_TYPE_AS_WRITTEN is
removed.
* objc-act.h (KEYWORD_ARG_NAME): Use decl_non_common.
(KEYWORD_KEY_NAME): Use decl_minimal.
(METHOD_SEL_NAME): Ditto..
(METHOD_SEL_ARGS): Use decl_non_common.
(METHOD_ADD_ARGS): Ditto.
(METHOD_ADD_ARGS_ELLIPSIS_P): Use decl_common.
(METHOD_DEFINITION): Ditto.
(METHOD_ENCODING): Ditto.
* objc-lang.c: (objc_init_ts): New function.
2005-07-08 Daniel Berlin <dberlin@dberlin.org>
* trans-decl.c (create_function_arglist): DECL_ARG_TYPE_AS_WRITTEN
is removed.
From-SVN: r101799
Diffstat (limited to 'gcc/doc/c-tree.texi')
-rw-r--r-- | gcc/doc/c-tree.texi | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/gcc/doc/c-tree.texi b/gcc/doc/c-tree.texi index 196aa56..fc00d82 100644 --- a/gcc/doc/c-tree.texi +++ b/gcc/doc/c-tree.texi @@ -847,6 +847,15 @@ internal representation, except for declarations of functions (represented by @code{FUNCTION_DECL} nodes), which are described in @ref{Functions}. +@menu +* Working with declarations:: Macros and functions that work on +declarations. +* Internal structure:: How declaration nodes are represented. +@end menu + +@node Working with declarations +@subsection Working with declarations + Some macros can be used with any kind of declaration. These include: @ftable @code @item DECL_NAME @@ -991,6 +1000,179 @@ Back ends can safely ignore these nodes. @end table +@node Internal structure +@subsection Internal structure + +@code{DECL} nodes are represented internally as a hierarchy of +structures. + +@menu +* Current structure hierarchy:: The current DECL node structure +hierarchy. +* Adding new DECL node types:: How to add a new DECL node to a +frontend. +@end menu + +@node Current structure hierarchy +@subsubsection Current structure hierarchy + +@table @code + +@item struct tree_decl_minimal +This is the minimal structure to inherit from in order for common +@code{DECL} macros to work. The fields it contains are a unique ID, +source location, context, and name. + +@item struct tree_decl_common +This structure inherits from @code{struct tree_decl_minimal}. It +contains fields that most @code{DECL} nodes need, such as a field to +store alignment, machine mode, size, and attributes. + +@item struct tree_field_decl +This structure inherits from @code{struct tree_decl_common}. It is +used to represent @code{FIELD_DECL}. + +@item struct tree_label_decl +This structure inherits from @code{struct tree_decl_common}. It is +used to represent @code{LABEL_DECL}. + +@item struct tree_translation_unit_decl +This structure inherits from @code{struct tree_decl_common}. It is +used to represent @code{TRANSLATION_UNIT_DECL}. + +@item struct tree_decl_with_rtl +This structure inherits from @code{struct tree_decl_common}. It +contains a field to store the low-level RTL associated with a +@code{DECL} node. + +@item struct tree_result_decl +This structure inherits from @code{struct tree_decl_with_rtl}. It is +used to represent @code{RESULT_DECL}. + +@item struct tree_const_decl +This structure inherits from @code{struct tree_decl_with_rtl}. It is +used to represent @code{CONST_DECL}. + +@item struct tree_parm_decl +This structure inherits from @code{struct tree_decl_with_rtl}. It is +used to represent @code{PARM_DECL}. + +@item struct tree_decl_with_vis +This structure inherits from @code{struct tree_decl_with_rtl}. It +contains fields necessary to store visibility information, as well as +a section name and assembler name. + +@item struct tree_var_decl +This structure inherits from @code{struct tree_decl_with_vis}. It is +used to represent @code{VAR_DECL}. + +@item struct tree_function_decl +This structure inherits from @code{struct tree_decl_with_vis}. It is +used to represent @code{FUNCTION_DECL}. + +@end table +@node Adding new DECL node types +@subsubsection Adding new DECL node types + +Adding a new @code{DECL} tree consists of the following steps + +@table @asis + +@item Add a new tree code for the @code{DECL} node +For language specific @code{DECL} nodes, there is a @file{.def} file +in each frontend directory where the tree code should be added. +For @code{DECL} nodes that are part of the middle-end, the code should +be added to @file{tree.def}. + +@item Create a new structure type for the @code{DECL} node +These structures should inherit from one of the existing structures in +the language hierarchy by using that structure as the first member. + +@smallexample +struct tree_foo_decl +@{ + struct tree_decl_with_vis common; +@} +@end smallexample + +Would create a structure name @code{tree_foo_decl} that inherits from +@code{struct tree_decl_with_vis}. + +For language specific @code{DECL} nodes, this new structure type +should go in the appropriate @file{.h} file. +For @code{DECL} nodes that are part of the middle-end, the structure +type should go in @file{tree.h}. + +@item Add a member to the tree structure enumerator for the node +For garbage collection and dynamic checking purposes, each @code{DECL} +node structure type is required to have a unique enumerator value +specified with it. +For language specific @code{DECL} nodes, this new enumerator value +should go in the approriate @file{.def} file. +For @code{DECL} nodes that are part of the middle-end, the enumerator +values are specified in @file{treestruct.def}. + +@item Update @code{union tree_node} +In order to make your new structure type usable, it must be added to +@code{union tree_node}. +For language specific @code{DECL} nodes, a new entry should be added +to the approriate @file{.h} file of the form +@smallexample + struct tree_foo_decl GTY ((tag ("TS_VAR_DECL"))) foo_decl; +@end smallexample +For @code{DECL} nodes that are part of the middle-end, the additional +member goes directly into @code{union tree_node} in @file{tree.h}. + +@item Update dynamic checking info +In order to be able to check whether accessing a named portion of +@code{union tree_node} is legal, and whether a certain @code{DECL} node +contains one of the enumerated @code{DECL} node structures in the +hierarchy, a simple lookup table is used. +This lookup table needs to be kept up to date with the tree structure +hierarchy, or else checking and containment macros will fail +inapproriately. + +For language specific @code{DECL} nodes, their is an @code{init_ts} +function in an approriate @file{.c} file, which initializes the lookup +table. +Code setting up the table for new @code{DECL} nodes should be added +there. +For each @code{DECL} tree code and enumerator value representing a +member of the inheritance hierarchy, the table should contain 1 if +that tree code inherits (directly or indirectly) from that member. +Thus, a @code{FOO_DECL} node derived from @code{struct decl_with_rtl}, +and enumerator value @code{TS_FOO_DECL}, would be set up as follows +@smallexample +tree_contains_struct[FOO_DECL][TS_FOO_DECL] = 1; +tree_contains_struct[FOO_DECL][TS_DECL_WRTL] = 1; +tree_contains_struct[FOO_DECL][TS_DECL_COMMON] = 1; +tree_contains_struct[FOO_DECL][TS_DECL_MINIMAL] = 1; +@end smallexample + +For @code{DECL} nodes that are part of the middle-end, the setup code +goes into @file{tree.c}. + +@item Add macros to access any new fields and flags + +Each added field or flag should have a macro that is used to access +it, that performs approriate checking to ensure only the right type of +@code{DECL} nodes access the field. + +These macros generally take the following form +@smallexample +#define FOO_DECL_FIELDNAME(NODE) FOO_DECL_CHECK(NODE)->foo_decl.fieldname +@end smallexample +However, if the structure is simply a base class for further +structures, something like the following should be used +@smallexample +#define BASE_STRUCT_CHECK(T) CONTAINS_STRUCT_CHECK(T, TS_BASE_STRUCT) +#define BASE_STRUCT_FIELDNAME(NODE) \ + (BASE_STRUCT_CHECK(NODE)->base_struct.fieldname +@end smallexample + +@end table + + @c --------------------------------------------------------------------- @c Functions @c --------------------------------------------------------------------- |