GCC主要数据结构之tree_base

本文介绍GCC编译器中树结构的基础定义,详细解释了树节点的类型与字段,包括整型、数组、变量声明等常见代码。此外还探讨了树节点如何通过宏进行访问。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

/*---------------------------------------------------------------------------                               Main data structures ---------------------------------------------------------------------------*/ /* A tree node can represent a data type, a variable, an expression    or a statement.  Each node has a TREE_CODE which says what kind of    thing it represents.  Some common codes are:    INTEGER_TYPE -- represents a type of integers.    ARRAY_TYPE -- represents a type of pointer.    VAR_DECL -- represents a declared variable.    INTEGER_CST -- represents a constant integer value.    PLUS_EXPR -- represents a sum (an expression).

   As for the contents of a tree node: there are some fields    that all nodes share.  Each TREE_CODE has various special-purpose    fields as well.  The fields of a node are never accessed directly,    always through accessor macros.  */

/* Every kind of tree node starts with this structure,    so all nodes have these fields.

   See the accessor macros, defined below, for documentation of the    fields, and the table below which connects the fields and the    accessor macros.  */

struct GTY(()) tree_base {   ENUM_BITFIELD(tree_code) code : 16;

  unsigned side_effects_flag : 1;   unsigned constant_flag : 1;   unsigned addressable_flag : 1;   unsigned volatile_flag : 1;   unsigned readonly_flag : 1;   unsigned asm_written_flag: 1;   unsigned nowarning_flag : 1;   unsigned visited : 1;

  unsigned used_flag : 1;   unsigned nothrow_flag : 1;   unsigned static_flag : 1;   unsigned public_flag : 1;   unsigned private_flag : 1;   unsigned protected_flag : 1;   unsigned deprecated_flag : 1;   unsigned default_def_flag : 1;

  union {     /* The bits in the following structure should only be used with        accessor macros that constrain inputs with tree checking.  */     struct {       unsigned lang_flag_0 : 1;       unsigned lang_flag_1 : 1;       unsigned lang_flag_2 : 1;       unsigned lang_flag_3 : 1;       unsigned lang_flag_4 : 1;       unsigned lang_flag_5 : 1;       unsigned lang_flag_6 : 1;       unsigned saturating_flag : 1;

      unsigned unsigned_flag : 1;       unsigned packed_flag : 1;       unsigned user_align : 1;       unsigned nameless_flag : 1;       unsigned atomic_flag : 1;       unsigned spare0 : 3;

      unsigned spare1 : 8;

      /* This field is only used with TREE_TYPE nodes; the only reason it is   present in tree_base instead of tree_type is to save space.  The size   of the field must be large enough to hold addr_space_t values.  */       unsigned address_space : 8;     } bits;

    /* The following fields are present in tree_base to save space.  The        nodes using them do not require any of the flags above and so can        make better use of the 4-byte sized word.  */

    /* The number of HOST_WIDE_INTs in an INTEGER_CST.  */     struct {       /* The number of HOST_WIDE_INTs if the INTEGER_CST is accessed in   its native precision.  */       unsigned char unextended;

      /* The number of HOST_WIDE_INTs if the INTEGER_CST is extended to   wider precisions based on its TYPE_SIGN.  */       unsigned char extended;

      /* The number of HOST_WIDE_INTs if the INTEGER_CST is accessed in   offset_int precision, with smaller integers being extended   according to their TYPE_SIGN.  This is equal to one of the two   fields above but is cached for speed.  */       unsigned char offset;     } int_length;

    /* VEC length.  This field is only used with TREE_VEC.  */     int length;

    /* SSA version number.  This field is only used with SSA_NAME.  */     unsigned int version;

    /* Internal function code.  */     enum internal_fn ifn;

    /* The following two fields are used for MEM_REF and TARGET_MEM_REF        expression trees and specify known data non-dependences.  For        two memory references in a function they are known to not        alias if dependence_info.clique are equal and dependence_info.base        are distinct.  */     struct {       unsigned short clique;       unsigned short base;     } dependence_info;   } GTY((skip(""))) u; };

(gdb) bt #0 0x005cd5ff in std::_Rb_tree_decrement(std::_Rb_tree_node_base*) () from /usr/lib/libstdc++.so.6 #1 0x080e3b15 in std::_Rb_tree_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> >::operator-- (this=0xbfbacdc4) at /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_tree.h:199 #2 0x080e3873 in std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> > >::_M_insert_unique (this=0x89b53a0, __v=...) at /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_tree.h:1179 #3 0x080e31df in std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> > >::_M_insert_unique_ (this=0x89b53a0, __position=..., __v=...) at /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_tree.h:1217 #4 0x080e2ee7 in std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, STDTM::AlarmElement, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, STDTM::AlarmElement> > >::insert (this=0x89b53a0, __position=..., __x=...) at /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_map.h:540
最新发布
06-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值