gcc phi结构体

来源:互联网 发布:机器猫tv软件 编辑:程序博客网 时间:2024/06/06 19:15

gcc phi结构体

phi是gcc中重要的数据结构类型,它主要用于ssa中的别名处理,本文主要讲述它的作用,相关数据结构体和核心处理函数

1.作用
phi主要用于别名处理,对于在ssa阶段中因为分支导致不确定具体是什么数据,采用phi.
2.主要数据结构

struct GTY(()) phi_arg_d {  /* imm_use MUST be the first element in struct because we do some     pointer arithmetic with it.  See phi_arg_index_from_use.  */  struct ssa_use_operand_d imm_use;  tree def;  location_t locus;};

phi结点主要有三部分,def描述其ssa_name,表示其本身代表的数据,locus表示其位置,imm_use是一个双向链表结构,phi利用这个可以实现phi的def-use的遍历.

imm_use的结构:

typedef struct GTY(()) ssa_use_operand_d {  struct ssa_use_operand_d* GTY((skip(""))) prev;  struct ssa_use_operand_d* GTY((skip(""))) next;  /* Immediate uses for a given SSA name are maintained as a cyclic     list.  To recognize the root of this list, the location field     needs to point to the original SSA name.  Since statements and     SSA names are of different data types, we need this union.  See     the explanation in struct immediate_use_iterator_d.  */  union { gimple stmt; tree ssa_name; } GTY((skip(""))) loc;  tree *GTY((skip(""))) use;} ssa_use_operand_t;

可以把它理解为一个数据的def-use链接结构.其中use表示应用它的的tree,stmt,ssa_name表示本身的数据属性,prev,next表示双向链表.这个结构就是为了可以找到该数据def的use遍历.每个这个类型的数据其实就表示该定义数据的一个use结点.

常用的phi函数:

gimple_phi_num_args (const_gimple gs)gimple_phi_result (const_gimple gs)gimple_phi_set_result (gimple gs, tree result)gimple_phi_arg (gimple gs, unsigned index)
0 0
原创粉丝点击