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

王朝other·作者佚名  2007-04-10
窄屏简体版  字體: |||超大  

在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;

};

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航