gcc研究笔记(一)tree是什么

原文地址如下:

http://dev.csdn.net/author/Goncely/9d069b6715d044498304e90d8ed24eab.html

在gcc中,几乎所有的东西都是用树结构串起来的,从而形成所谓的general tree。tree可以看作是指向树节点的指针,所有的树节点都有一个共同的基类:tree_common。

在gcc中,几乎所有的东西都是用树结构串起来的,从而形成所谓的general tree。tree可以看作是指向树节点的指针,所有的树节点都有一个共同的基类:tree_common。

在文件coretypes.h中,tree的定义如下:
#ifndef USED_FOR_TARGET
...
typedef union tree_node *tree;
...
#else
...
#define tree union _dont_use_tree_here_ *
...
#endif
可见,当 USED_FOR_TARGET宏未被定义的时候,tree是指向联合类型 tree_node的指针类型;否则,tree是一个定义为 union _dont_use_tree_here_ *的宏。
在tree.h中,可以找到union tree_node的定义:
union tree_node
{
struct tree_common common;
struct tree_int_cst int_cst;
struct tree_real_cst real_cst;
struct tree_vector vector;
struct tree_string string;
struct tree_complex complex;
struct tree_identifier identifier;
struct tree_decl_minimal decl_minimal;
struct tree_decl_common decl_common;
struct tree_decl_with_rtl decl_with_rtl;
struct tree_decl_non_common decl_non_common;
struct tree_parm_decl parm_decl;
struct tree_decl_with_vis decl_with_vis;
struct tree_var_decl var_decl;
struct tree_field_decl field_decl;
struct tree_label_decl label_decl;
struct tree_result_decl result_decl;
struct tree_const_decl const_decl;
struct tree_type_decl type_decl;
struct tree_function_decl function_decl;
struct tree_type type;
struct tree_list list;
struct tree_vec vec;
struct tree_exp exp;
struct tree_ssa_name ssa_name;
struct tree_phi_node phi;
struct tree_block block;
struct tree_binfo binfo;
struct tree_statement_list stmt_list;
struct tree_value_handle value_handle;
struct tree_constructor constructor;
struct tree_memory_tag mtag;
struct tree_struct_field_tag sft;
struct tree_omp_clause omp_clause;
};

同样,tree_common的定义也在tree.h中:
struct tree_common
{
tree chain;
tree type;
union tree_ann_d *ann;
ENUM_BITFIELD(tree_code) code : 8;
unsigned side_effects_flag : 1;
unsigned constant_flag : 1;
unsigned addressable_flag : 1;
unsigned volatile_flag : 1;
unsigned readonly_flag : 1;
unsigned unsigned_flag : 1;
unsigned asm_written_flag: 1;
unsigned nowarning_flag : 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 invariant_flag : 1;
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 visited : 1;
};

Technorati :

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值