ctrump/analyzer/cfg.c File Reference

CFGを作る コードからロード、ストアを抜き出す SSA解析する. More...

#include "ctrump/analyzer/cfg.h"
#include "ctrump/common/bitmap.h"
#include "ctrump/common/varray.h"
#include "ctrump/common/uthash.h"
#include "ctrump/common/intmap.h"
#include "ctrump/common/abort.h"
#include "ctrump/ast/ast.h"
#include "ctrump/analyzer/peel.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <assert.h>

Include dependency graph for cfg.c:

Go to the source code of this file.

Data Structures

struct  partial_bb_expr
 partial_bb が保持するexpr More...
struct  pending_chain
 あとで更新するポインタのリスト More...
struct  ordered_load_store_node
 順序付けられたロードストア More...
struct  partial_bb
 解析途中のBB More...
struct  partial_var_info
 解析途中の変数 More...
struct  label_table
 検索用ラベルテーブル More...
struct  build_cfg_env
 build_cfgするのに必要な情報 More...
struct  flow_env
 フローの状態 More...

Defines

#define zero_bmp   ctrump_bmp_zero
#define HASH_FIND_SYM(head, findptr, out)   HASH_FIND(hh,head,findptr,sizeof(struct ctrump_symbol*),out)
#define REDUC_CASE_LHS(ecode, rcode, r)
#define CHECK_ERROR(e)   {int r = (e); if (r < 0) return r;}
#define ALLOC_BB_VEC(aname, numname, vaname)
#define COPY_VEC(aname, numname, vaname)

Enumerations

enum  partial_bb_expr_code { BB_EXPR }
enum  load_store_t { INIT, LOAD, STORE }

Functions

static struct partial_bbnew_bb (struct build_cfg_env *env, struct ctrump_loop_cfg_info *loop)
 新しくpartial_bbを作る
static void append_succs_maybe (struct partial_bb *bb,struct partial_bb *next, struct build_cfg_env *env)
 bb の後続ブロックにnextを追加する uhrechableなBB(NULL)に対しては何もしない
static void append_succs (struct partial_bb *bb, struct partial_bb *next, struct build_cfg_env *env)
 bb の後続ブロックにnextを追加する nextの先行ブロックにbbを追加する
static void build_cfg_expr_maybe (struct ctrump_expr *e, struct ctrump_stmt *at, struct build_cfg_env *env, struct ctrump_loop_cfg_info *cur_loop, struct partial_bb **current_bb_ptr)
 式のCFGを作る
static void build_cfg_expr (struct ctrump_expr *e, struct ctrump_stmt *at, struct build_cfg_env *env, struct ctrump_loop_cfg_info *cur_loop, struct partial_bb **current_bb_ptr)
 式のCFGを作る
static void build_cfg_initializer (struct ctrump_initializer *init, struct ctrump_stmt *stmt, struct build_cfg_env *env, struct ctrump_loop_cfg_info *cur_loop, struct partial_bb **current_bb_ptr)
 初期化子のCFGを作る
static void build_cfg_initializer_list (struct ctrump_initializer_list *list, struct ctrump_stmt *stmt, struct build_cfg_env *env, struct ctrump_loop_cfg_info *cur_loop, struct partial_bb **current_bb_ptr)
 初期化子リストのCFGを作る
static void delete_table (struct label_table *table)
 ラベルテーブルを削除
static int build_label_table (struct label_table **table, const struct ctrump_compound_stmt *stmts, struct build_cfg_env *env)
 ラベルテーブルをつくる
static int build_label_ref (struct label_table *table, const struct ctrump_compound_stmt *stmt, struct build_cfg_env *env)
 参照されてるラベルを調べる
static int check_label_use (struct build_cfg_env *env, const struct ctrump_compound_stmt *stmts)
 ラベルテーブルを作る
static void build_cfg_logical_expr (struct ctrump_expr *lhs, struct ctrump_expr *rhs, struct ctrump_stmt *at, struct build_cfg_env *env, struct ctrump_loop_cfg_info *cur_loop, struct partial_bb **current_bb_ptr)
 論理式に対してCFGを作る これ以後もAST式の構造は変化しないが、 論理式の中身は別のBBに保持される点に注意
static void build_cfg_trinary_cond_expr (struct ctrump_expr *cond, struct ctrump_expr *then_, struct ctrump_expr *else_, struct ctrump_stmt *at, struct build_cfg_env *env, struct ctrump_loop_cfg_info *cur_loop, struct partial_bb **current_bb_ptr)
 条件式に対してCFGを作る
static void build_cfg_cond_expr (struct ctrump_expr *e, struct ctrump_stmt *at, struct build_cfg_env *env, struct ctrump_loop_cfg_info *cur_loop, struct partial_bb **current_bb_ptr)
 式に含まれる論理式に対するCFGを作る 論理式以外は何もしない
static void append_pending (struct build_cfg_env *env, struct partial_bb *bb, struct ctrump_bb **resolve_ptr)
 あとで更新するctrump_bbへのポインタを追加する
static struct partial_bbget_id_bb (struct build_cfg_env *env, struct ctrump_stmt *stmt, struct ctrump_loop_cfg_info *cur_loop)
 idで示す文を先頭に持つBBを取得 無ければ作る
static struct partial_bbget_id_bb_maybe (struct build_cfg_env *env, struct ctrump_stmt *stmt, struct ctrump_loop_cfg_info *loop, struct partial_bb *return_to_bb)
 idで示す文を先頭に持つBBを取得 無ければ作る stmt が NULL なら次の文は存在しない(return_toへ飛ぶ)
static int build_cfg_stmt (struct ctrump_stmt *stmt, struct ctrump_stmt *next_stmt,struct build_cfg_env *env, const struct flow_env *flow_env, struct partial_bb **current_bb_ptr)
 文のCFGを作る
static int build_cfg_compound (const struct ctrump_compound_stmt *stmts, struct build_cfg_env *env, const struct flow_env *flow_env, struct partial_bb **current_bb_ptr, struct ctrump_stmt *next_block_stmt)
 複合文に対するCFGを作る
static int dfs_order (struct partial_bb *start, struct build_cfg_env *env, int num_bb, ctrump_bitmap_t bb_bitmap)
 CFGを深さ優先探索で辿った順の配列をつくり、 bb->dfs_order を設定する.
static struct partial_bbnca (struct partial_bb *x, struct partial_bb *y)
 最近共通祖先(Nearest Common Ancestor)を求める
static void build_dom (struct build_cfg_env *env, int num_bb)
 支配木を作る
static void find_df (struct build_cfg_env *env, int num_bb)
 支配辺境を求める domtree -> dominance frontier
static int insert_phi (struct partial_bb **bbs, int num_bb, struct partial_var_info *var_info, int num_var_info, int id, ctrump_bitmap_t tmp_bitmap, struct ctrump_mempool *cfg_alloc)
 φを挿入する.
static struct ctrump_pdg_nodealloc_pdg_node (struct ctrump_varray *pdg_node_list, struct ctrump_mempool *alloc, struct ctrump_stmt *at, int *id, enum ctrump_pdg_node_code code)
 PDGノードを割り当てる.
static int recog_reductive (struct ctrump_expr *e, struct ctrump_var *v, int is_float, enum ctrump_reductive_expr_code *ret_code, struct ctrump_expr **ret_expr)
 縮約演算を識別する
static struct ctrump_pdg_nodessa_node_store_expr (enum ctrump_expr_code op_code, struct ctrump_var *var, struct ctrump_expr *store_val, struct ctrump_varray *pdg_node_list, struct ctrump_pdg_node *old_val, struct ctrump_stmt *at, struct ctrump_mempool *alloc, int *id)
 ストア演算の処理
static int assign_pdg_node_bb (struct ctrump_varray *pdg_node_list, struct partial_bb *bb, struct partial_var_info *var_info, int num_var_info, int id, struct ctrump_mempool *cfg_alloc)
 各式にPDGを割り当てる
static int assign_pdg_node (struct ctrump_varray *pdg_node_list, struct partial_bb *entry, struct partial_var_info *var_info, int num_var_info, int id, struct ctrump_mempool *cfg_alloc)
 各式にPDGを割り当てる
static int extract_load_store_expr_rval (struct ctrump_expr *e, struct ctrump_stmt *at, struct partial_bb *bb, struct ctrump_intmap *var_info_map, struct ctrump_build_cfg_error *error, struct ctrump_mempool *cfg_alloc, struct ctrump_mempool *tmp_alloc)
 右辺値からロードストアを抜き出す
static struct ctrump_subscriptappend_nd_subscript (struct ctrump_varray *subscripts, struct ctrump_varray *nd_subscripts, struct ctrump_subscript *s, struct ctrump_texpr *load_data_texpr, struct ctrump_expr *subscript, struct ctrump_mempool *cfg_alloc)
 配列アクセスの解析
static struct ctrump_subscriptappend_record_member_ref (struct ctrump_varray *subscripts, struct ctrump_varray *nd_subscripts, struct ctrump_subscript *s, struct ctrump_member_ref *ref, struct ctrump_texpr *load_data_type, int is_pointer, struct ctrump_mempool *cfg_alloc)
 メンバアクセスの解析
static int recog_array_access (struct ctrump_expr **ret_array, struct ctrump_subscript **ret_vec, int *num_ret, struct ctrump_expr *access_expr, struct partial_bb *bb, struct ctrump_intmap *var_info_map, struct ctrump_build_cfg_error *error, struct ctrump_stmt *at, struct ctrump_mempool *cfg_alloc, struct ctrump_mempool *tmp_alloc)
 配列アクセスの解析
static void append_ordered_memop (struct ctrump_varray *memop, enum ctrump_load_store_t load_store, int idx, struct ctrump_mempool *tmp_alloc)
 順序付きメモリ操作の追加
static int append_memory_store (struct ctrump_varray *store, struct ctrump_varray *ordered, struct partial_bb *bb, struct ctrump_intmap *var_info_map, struct ctrump_build_cfg_error *error, struct ctrump_stmt *at_stmt, enum ctrump_expr_code store_op, struct ctrump_expr *dest_expr, struct ctrump_expr *val, int flags, struct ctrump_mempool *cfg_alloc, struct ctrump_mempool *tmp_alloc)
 メモリへのストアを追加
static void add_var_loadstore (struct partial_bb *bb, enum load_store_t code, int op_idx, int var_idx, struct ctrump_mempool *tmp_alloc)
 メモリへのロードストアを追加
static void add_var_store (struct partial_bb *bb, struct partial_var_info *vi, struct ctrump_varray *stores, struct ctrump_stmt *at, struct ctrump_var *var, struct ctrump_expr *var_ref_expr, struct ctrump_expr *val_expr, struct ctrump_pdg_node *pdg, enum ctrump_expr_code store_op, int flags, struct ctrump_mempool *tmp_alloc, enum load_store_t store_code)
 メモリへのストアを追加
static int extract_load_store_assign (enum ctrump_expr_code store_op, struct ctrump_expr *lhs, struct ctrump_expr *val_expr, struct ctrump_stmt *at, struct partial_bb *bb, struct ctrump_intmap *var_info_map, struct ctrump_build_cfg_error *error, struct ctrump_mempool *cfg_alloc, struct ctrump_mempool *tmp_alloc)
 代入式からロードストアを抜き出す
static int append_memory_load (struct ctrump_varray *aload, struct ctrump_varray *ordered, struct partial_bb *bb, struct ctrump_intmap *var_info_map, struct ctrump_build_cfg_error *error, struct ctrump_stmt *at_stmt, struct ctrump_expr *load_expr, struct ctrump_mempool *cfg_alloc, struct ctrump_mempool *tmp_alloc)
 メモリロードを追加
static int extract_load_store_initializer (struct ctrump_initializer *initializer, struct ctrump_stmt *at, struct partial_bb *bb, struct ctrump_intmap *var_info_map, struct ctrump_build_cfg_error *error, struct ctrump_mempool *cfg_alloc, struct ctrump_mempool *tmp_alloc)
 初期化子からロードストアを抜き出す
static int extract_load_store_initializer_list (struct ctrump_initializer_list *init_list, struct ctrump_stmt *at, struct partial_bb *bb, struct ctrump_intmap *var_info_map, struct ctrump_build_cfg_error *error, struct ctrump_mempool *cfg_alloc, struct ctrump_mempool *tmp_alloc)
 初期化リストからロードストアを抜き出す
static int extract_load_store (struct partial_bb *bb, struct ctrump_intmap *var_info_map, struct ctrump_build_cfg_error *error, struct ctrump_mempool *cfg_alloc, struct ctrump_mempool *tmp_alloc)
 BBからロードストアを抜き出す.
static void assign_var_info_expr (struct ctrump_varray *info, struct ctrump_intmap *info_map, struct ctrump_expr *e, int num_bb, struct ctrump_mempool *tmp_alloc)
 変数アクセスを抜き出して変数情報を割り当てる
static void assign_var_info_initializer (struct ctrump_varray *var_info_vec, struct ctrump_intmap *var_info_map, struct ctrump_initializer *initializer, int num_bb, struct ctrump_mempool *tmp_alloc)
 初期化子から変数アクセスを抜き出す
static void assign_var_info_initializer_list (struct ctrump_varray *var_info_vec, struct ctrump_intmap *var_info_map, struct ctrump_initializer_list *inits, int num_bb, struct ctrump_mempool *tmp_alloc)
 初期化子リストから変数アクセスを抜き出す
static int assign_var_info (struct partial_bb **bb_vec, int num_bb, struct ctrump_varray *var_info_vec, struct ctrump_intmap *var_info_map, struct ctrump_mempool *tmp_alloc)
 プログラムから変数アクセスを探して必要な情報を割り当てる
static void calc_df (struct partial_bb **dfs_order, int num_bb, struct ctrump_intmap *varinfo_map, int num_var_info, ctrump_bitmap_t tmp_bitmap)
 支配辺境を計算する
static void resolve_bb_vec (struct ctrump_bb **bb_vec, struct ctrump_varray *partial_vec, struct ctrump_bb **basic_blocks)
 partial_bbへのポインタをctrump_bbへのポインタに変換する
static int build_cfg (struct ctrump_cfg *ret, struct ctrump_intmap *var_info_map, struct ctrump_mempool *cfg_pool, struct ctrump_mempool *varmap_pool, const struct ctrump_compound_stmt *stmts, struct build_cfg_env *env)
 CFGを作る.
static int build_cfg_loop (struct ctrump_stmt *body, struct ctrump_expr *exit_cond, struct partial_bb *cond_bb_enter, struct partial_bb *cond_bb_exit, struct partial_bb *return_bb, struct partial_bb *continue_bb_enter, struct partial_bb *continue_bb_exit, struct ctrump_stmt *next_stmt, struct ctrump_loop_cfg_info *loop, struct build_cfg_env *env, struct ctrump_loop_cfg_info *outer_loop, struct partial_bb **current_bb_ptr)
 body ループのCFGを作る
static int build_cfg_for (struct ctrump_loop_cfg_info **loop_ret, struct ctrump_expr *cond, struct ctrump_expr *iter, struct ctrump_stmt *body, struct ctrump_stmt *next_stmt, struct build_cfg_env *env, const struct flow_env *flow_env, struct partial_bb **current_bb_ptr)
 for ループのCFGを作る
static int build_cfg_while (struct ctrump_loop_cfg_info **loop_ret, struct ctrump_expr *cond, struct ctrump_stmt *body, struct ctrump_stmt *next_stmt, struct build_cfg_env *env, const struct flow_env *flow_env, struct partial_bb **current_bb_ptr)
 whileループのCFGを作る
static int build_cfg_do_while (struct ctrump_expr *cond, struct ctrump_stmt *body, struct ctrump_stmt *next_stmt, struct build_cfg_env *env, const struct flow_env *flow_env, struct partial_bb **current_bb_ptr)
 do-whileループのCFGを作る
static void build_cfg_decl (struct ctrump_stmt *stmt, struct ctrump_decl *decl, struct build_cfg_env *env, struct ctrump_loop_cfg_info *cur_loop, struct partial_bb **current_bb_ptr)
 宣言のCFGを作る
int ctrump_build_cfg (struct ctrump_cfg *ret, struct ctrump_intmap *var_info_map, struct ctrump_build_cfg_error *error, const struct ctrump_fundef *def, struct ctrump_mempool *cfg_pool, struct ctrump_mempool *varmap_pool, int num_ast, int id_begin)
 CFGを作る.


Detailed Description

CFGを作る コードからロード、ストアを抜き出す SSA解析する.

Note:
unrechableな部分があったり、gotoがあったりするケースに あまり対応できていない
_maybe が付く関数は、unrechableなBBに対しては 何もする必要が無いことを意図している(が、あまりうまく動いていない)

Definition in file cfg.c.


Define Documentation

#define ALLOC_BB_VEC ( aname,
numname,
vaname   ) 

Value:

b->aname = ctrump_mempool_alloc(env->cfg_pool, sizeof(struct ctrump_bb*)*pb->vaname.nelem); \
        b->numname = pb->vaname.nelem;

Referenced by build_cfg().

#define CHECK_ERROR (  )     {int r = (e); if (r < 0) return r;}

#define COPY_VEC ( aname,
numname,
vaname   ) 

Value:

b->aname = ctrump_varray_copy(&pb->vaname, env->cfg_pool);      \
        b->numname = pb->vaname.nelem;

Referenced by build_cfg().

#define HASH_FIND_SYM ( head,
findptr,
out   )     HASH_FIND(hh,head,findptr,sizeof(struct ctrump_symbol*),out)

Definition at line 191 of file cfg.c.

Referenced by build_cfg_stmt(), build_label_ref(), and build_label_table().

#define REDUC_CASE_LHS ( ecode,
rcode,
 ) 

Value:

case ecode:                         \
                *ret_code = rcode;              \
                *ret_expr = r;                  \
                return 1;

Referenced by recog_reductive().

#define zero_bmp   ctrump_bmp_zero


Enumeration Type Documentation

Enumerator:
INIT 
LOAD 
STORE 

Definition at line 81 of file cfg.c.

Enumerator:
BB_EXPR 

Definition at line 57 of file cfg.c.


Function Documentation

static void add_var_loadstore ( struct partial_bb bb,
enum load_store_t  code,
int  op_idx,
int  var_idx,
struct ctrump_mempool tmp_alloc 
) [static]

static void add_var_store ( struct partial_bb bb,
struct partial_var_info vi,
struct ctrump_varray stores,
struct ctrump_stmt at,
struct ctrump_var var,
struct ctrump_expr var_ref_expr,
struct ctrump_expr val_expr,
struct ctrump_pdg_node pdg,
enum ctrump_expr_code  store_op,
int  flags,
struct ctrump_mempool tmp_alloc,
enum load_store_t  store_code 
) [static]

static struct ctrump_pdg_node* alloc_pdg_node ( struct ctrump_varray pdg_node_list,
struct ctrump_mempool alloc,
struct ctrump_stmt at,
int *  id,
enum ctrump_pdg_node_code  code 
) [static, read]

PDGノードを割り当てる.

Definition at line 915 of file cfg.c.

References ctrump_pdg_node::at, ctrump_pdg_node::code, ctrump_mempool_alloc, ctrump_pdg_node::id, and VA_PUSH.

Referenced by assign_pdg_node(), assign_pdg_node_bb(), and ssa_node_store_expr().

static int append_memory_load ( struct ctrump_varray aload,
struct ctrump_varray ordered,
struct partial_bb bb,
struct ctrump_intmap var_info_map,
struct ctrump_build_cfg_error error,
struct ctrump_stmt at_stmt,
struct ctrump_expr load_expr,
struct ctrump_mempool cfg_alloc,
struct ctrump_mempool tmp_alloc 
) [static]

static int append_memory_store ( struct ctrump_varray store,
struct ctrump_varray ordered,
struct partial_bb bb,
struct ctrump_intmap var_info_map,
struct ctrump_build_cfg_error error,
struct ctrump_stmt at_stmt,
enum ctrump_expr_code  store_op,
struct ctrump_expr dest_expr,
struct ctrump_expr val,
int  flags,
struct ctrump_mempool cfg_alloc,
struct ctrump_mempool tmp_alloc 
) [static]

static struct ctrump_subscript* append_nd_subscript ( struct ctrump_varray subscripts,
struct ctrump_varray nd_subscripts,
struct ctrump_subscript s,
struct ctrump_texpr load_data_texpr,
struct ctrump_expr subscript,
struct ctrump_mempool cfg_alloc 
) [static, read]

static void append_ordered_memop ( struct ctrump_varray memop,
enum ctrump_load_store_t  load_store,
int  idx,
struct ctrump_mempool tmp_alloc 
) [static]

順序付きメモリ操作の追加

Definition at line 1575 of file cfg.c.

References ctrump_ordered_memory_load_store_node::code, ctrump_ordered_memory_load_store_node::op_index, VA_LAST_PTR, and VA_NEWELEM_P.

Referenced by append_memory_load(), and append_memory_store().

static void append_pending ( struct build_cfg_env env,
struct partial_bb bb,
struct ctrump_bb **  resolve_ptr 
) [static]

あとで更新するctrump_bbへのポインタを追加する

partial_bb はあとでctrump_bbに変換されるが、 解析途中は、ctrump_bbが存在していない。

解析途中にctrump_bbへのポインタを設定することが必要になった場合(ループなど) その時点では、ctrump_bbが存在しないため、あとで設定する必要がでてくる。

そういう時は、partial_bb の resolve_pending に設定したいポインタのポインタ を繋いでおくと、partial_bb → ctrump_bbへの変換時に、 resolve_pending へ繋いでおいたポインタは、変換後のctrump_bbを指すように 更新される

Definition at line 515 of file cfg.c.

References pending_chain::chain, ctrump_mempool_alloc, partial_bb::resolve_pending, pending_chain::resolve_ptr, and build_cfg_env::tmp_alloc.

Referenced by build_cfg_loop().

static struct ctrump_subscript* append_record_member_ref ( struct ctrump_varray subscripts,
struct ctrump_varray nd_subscripts,
struct ctrump_subscript s,
struct ctrump_member_ref ref,
struct ctrump_texpr load_data_type,
int  is_pointer,
struct ctrump_mempool cfg_alloc 
) [static, read]

static void append_succs ( struct partial_bb bb,
struct partial_bb next,
struct build_cfg_env env 
) [static]

bb の後続ブロックにnextを追加する nextの先行ブロックにbbを追加する

Definition at line 549 of file cfg.c.

References build_cfg_env::tmp_alloc, and VA_PUSH_P.

Referenced by append_succs_maybe(), build_cfg_for(), build_cfg_logical_expr(), build_cfg_loop(), build_cfg_stmt(), and build_cfg_trinary_cond_expr().

static void append_succs_maybe ( struct partial_bb bb,
struct partial_bb next,
struct build_cfg_env env 
) [static]

bb の後続ブロックにnextを追加する uhrechableなBB(NULL)に対しては何もしない

Definition at line 563 of file cfg.c.

References append_succs().

Referenced by build_cfg(), build_cfg_do_while(), build_cfg_loop(), and build_cfg_stmt().

static int assign_pdg_node ( struct ctrump_varray pdg_node_list,
struct partial_bb entry,
struct partial_var_info var_info,
int  num_var_info,
int  id,
struct ctrump_mempool cfg_alloc 
) [static]

static int assign_pdg_node_bb ( struct ctrump_varray pdg_node_list,
struct partial_bb bb,
struct partial_var_info var_info,
int  num_var_info,
int  id,
struct ctrump_mempool cfg_alloc 
) [static]

static int assign_var_info ( struct partial_bb **  bb_vec,
int  num_bb,
struct ctrump_varray var_info_vec,
struct ctrump_intmap var_info_map,
struct ctrump_mempool tmp_alloc 
) [static]

プログラムから変数アクセスを探して必要な情報を割り当てる

Returns:
number of var info

Definition at line 2291 of file cfg.c.

References assign_var_info_expr(), partial_bb::bb, BB_EXPR, partial_bb_expr::code, ctrump_varray::nelem, and partial_bb_expr::u.

Referenced by build_cfg().

static void assign_var_info_expr ( struct ctrump_varray info,
struct ctrump_intmap info_map,
struct ctrump_expr e,
int  num_bb,
struct ctrump_mempool tmp_alloc 
) [static]

変数アクセスを抜き出して変数情報を割り当てる

Definition at line 2114 of file cfg.c.

References ctrump_call_expr::args, ctrump_expr::arr_ref, ctrump_arr_ref_expr::array, ctrump_expr::binary, ctrump_expr::call, ctrump_expr::cast, ctrump_expr::code, ctrump_cond_expr::cond, ctrump_expr::cond, CTRUMP_CASE_BIN_ARITH_EXPR, CTRUMP_CASE_BIN_EQ_EXPR, CTRUMP_CASE_BIN_LOG_EXPR, CTRUMP_CASE_BIN_OP_ASSIGN_EXPR, CTRUMP_CASE_CONSTANT_TERM, CTRUMP_EXPR_ARRREF, CTRUMP_EXPR_BIN_ASSIGN, CTRUMP_EXPR_BIN_COMMA, CTRUMP_EXPR_CALL, CTRUMP_EXPR_CAST, CTRUMP_EXPR_CONDITIONAL, CTRUMP_EXPR_EMPTY, CTRUMP_EXPR_IMPLICIT_CAST, CTRUMP_EXPR_INITIALIZER, CTRUMP_EXPR_IVTMP, CTRUMP_EXPR_MACRO_EXPAND, CTRUMP_EXPR_MEMBER_REF, CTRUMP_EXPR_PAREN, CTRUMP_EXPR_PTR_MEMBER_REF, CTRUMP_EXPR_TEXT, CTRUMP_EXPR_UNA_ADDR, CTRUMP_EXPR_UNA_BCMPL, CTRUMP_EXPR_UNA_LNEG, CTRUMP_EXPR_UNA_NEG, CTRUMP_EXPR_UNA_POS, CTRUMP_EXPR_UNA_POST_DEC, CTRUMP_EXPR_UNA_POST_INC, CTRUMP_EXPR_UNA_PRE_DEC, CTRUMP_EXPR_UNA_PRE_INC, CTRUMP_EXPR_UNA_PTRREF, CTRUMP_EXPR_VARREF, ctrump_fixme, ctrump_intmap_lookup_add(), ctrump_unreachable, ctrump_paren_expr::expr, ctrump_unary_expr::expr, ctrump_implicit_cast_expr::expr, ctrump_cast_expr::expr, ctrump_call_expr::func_expr, ctrump_var::id, ctrump_expr::implicit_cast, ctrump_cfg_var_info::index, ctrump_binary_expr::lhs, ctrump_expr::member_ref, partial_var_info::modified_at, ctrump_varray::nelem, ctrump_call_expr::num_args, ctrump_member_ref::obj_expr, ctrump_expr::paren, partial_var_info::result, ctrump_binary_expr::rhs, ctrump_arr_ref_expr::subscript, ctrump_expr::u, ctrump_expr::unary, VA_LAST_PTR, VA_NEWELEM_P, ctrump_intmap_bucket::val, ctrump_cfg_var_info::var, ctrump_varref_expr::var, ctrump_expr::varref, and zero_bmp.

Referenced by assign_var_info(), assign_var_info_initializer(), and assign_var_info_initializer_list().

static void assign_var_info_initializer ( struct ctrump_varray var_info_vec,
struct ctrump_intmap var_info_map,
struct ctrump_initializer initializer,
int  num_bb,
struct ctrump_mempool tmp_alloc 
) [static]

static void assign_var_info_initializer_list ( struct ctrump_varray var_info_vec,
struct ctrump_intmap var_info_map,
struct ctrump_initializer_list inits,
int  num_bb,
struct ctrump_mempool tmp_alloc 
) [static]

static int build_cfg ( struct ctrump_cfg ret,
struct ctrump_intmap var_info_map,
struct ctrump_mempool cfg_pool,
struct ctrump_mempool varmap_pool,
const struct ctrump_compound_stmt stmts,
struct build_cfg_env env 
) [static]

CFGを作る.

Definition at line 2379 of file cfg.c.

References ctrump_cfg::addressed, ALLOC_BB_VEC, append_succs_maybe(), assign_pdg_node(), assign_var_info(), ctrump_cfg::basic_blocks, build_cfg_env::basic_blocks, partial_bb::bb, BB_EXPR, build_cfg_env::bb_id, flow_env::break_to, build_cfg_compound(), build_dom(), calc_df(), build_cfg_env::cfg_pool, pending_chain::chain, partial_bb::children, partial_bb_expr::code, flow_env::continue_to, COPY_VEC, ctrump_bitmap_set(), ctrump_intmap_init_pool(), ctrump_intmap_iterator_begin(), ctrump_intmap_iterator_next(), ctrump_intmap_resize_pool(), ctrump_mempool_alloc, CTRUMP_STOR_CLASS_ARGMENT, CTRUMP_STOR_CLASS_AUTO, CTRUMP_STOR_CLASS_AUTO_UNSPECIFIED, ctrump_varray_discard(), ctrump_varray_init(), ctrump_varray_init_pool(), ctrump_bb::dfs, build_cfg_env::dfs_order, dfs_order(), ctrump_bb::dom_children, ctrump_varray::elements, build_cfg_env::error, partial_bb_expr::expr, ctrump_bb::exprs, extract_load_store(), find_df(), partial_bb::flags, ctrump_bb::flags, ctrump_cfg::global, ctrump_cfg::head, partial_bb::id, ctrump_bb::id, ctrump_bb::id_in_cfg, insert_phi(), ctrump_bb::kill, partial_bb::kill, ctrump_bb::live, partial_bb::live, ctrump_bb::loop_belong_to, partial_bb::loop_cfg, flow_env::loop_cfg, partial_var_info::map_val, ctrump_phi_node::merge_at, ctrump_varray::nelem, new_bb(), build_cfg_env::next_id, ctrump_cfg::num_bb, ctrump_bb::num_exprs, partial_bb::num_phi, ctrump_bb::num_phi, ctrump_bb::num_var, ctrump_cfg::num_var, partial_bb::phi_inserted, partial_bb::phi_nodes, ctrump_bb::phi_nodes, ctrump_bb::preds, resolve_bb_vec(), partial_bb::resolve_pending, pending_chain::resolve_ptr, partial_var_info::result, flow_env::return_to, ctrump_var::stor_class, ctrump_bb::succs, ctrump_cfg::tail, build_cfg_env::tmp_alloc, partial_bb_expr::u, ctrump_bb::use, partial_bb::use, VA_ELEM, ctrump_intmap_bucket::val, ctrump_cfg_var_info::var, OffloadSpe::var, ctrump_cfg::var_info, and zero_bmp.

Referenced by ctrump_build_cfg().

static int build_cfg_compound ( const struct ctrump_compound_stmt stmts,
struct build_cfg_env env,
const struct flow_env flow_env,
struct partial_bb **  current_bb_ptr,
struct ctrump_stmt next_block_stmt 
) [static]

複合文に対するCFGを作る

Definition at line 663 of file cfg.c.

References build_cfg_stmt(), ctrump_compound_stmt::items, and ctrump_compound_stmt::num_item.

Referenced by build_cfg(), and build_cfg_stmt().

static void build_cfg_cond_expr ( struct ctrump_expr e,
struct ctrump_stmt at,
struct build_cfg_env env,
struct ctrump_loop_cfg_info cur_loop,
struct partial_bb **  current_bb_ptr 
) [static]

式に含まれる論理式に対するCFGを作る 論理式以外は何もしない

Definition at line 395 of file cfg.c.

References ctrump_call_expr::args, ctrump_expr::arr_ref, ctrump_arr_ref_expr::array, ctrump_expr::binary, build_cfg_initializer_list(), build_cfg_logical_expr(), build_cfg_trinary_cond_expr(), ctrump_expr::call, ctrump_expr::cast, ctrump_expr::code, ctrump_cond_expr::cond, ctrump_expr::cond, CTRUMP_CASE_ALL_UNARY_EXPR, CTRUMP_CASE_BIN_ARITH_EXPR, CTRUMP_CASE_BIN_EQ_EXPR, CTRUMP_CASE_BIN_LOG_EXPR, CTRUMP_CASE_BIN_OP_ASSIGN_EXPR, CTRUMP_CASE_CONSTANT_TERM, CTRUMP_EXPR_ARRREF, CTRUMP_EXPR_BIN_ASSIGN, CTRUMP_EXPR_BIN_COMMA, CTRUMP_EXPR_CALL, CTRUMP_EXPR_CAST, CTRUMP_EXPR_CONDITIONAL, CTRUMP_EXPR_EMPTY, CTRUMP_EXPR_IMPLICIT_CAST, CTRUMP_EXPR_INITIALIZER, CTRUMP_EXPR_IVTMP, CTRUMP_EXPR_MACRO_EXPAND, CTRUMP_EXPR_MEMBER_REF, CTRUMP_EXPR_PAREN, CTRUMP_EXPR_PTR_MEMBER_REF, CTRUMP_EXPR_TEXT, CTRUMP_EXPR_VARREF, ctrump_unreachable, ctrump_cond_expr::else_, ctrump_macro_expand_expr::expanded, ctrump_implicit_cast_expr::expr, ctrump_cast_expr::expr, ctrump_paren_expr::expr, ctrump_unary_expr::expr, ctrump_call_expr::func_expr, ctrump_expr::implicit_cast, ctrump_initializer_expr::initializer, ctrump_expr::initializer, ctrump_binary_expr::lhs, ctrump_expr::macro_expand, ctrump_expr::member_ref, ctrump_call_expr::num_args, ctrump_member_ref::obj_expr, ctrump_expr::paren, ctrump_binary_expr::rhs, ctrump_arr_ref_expr::subscript, ctrump_cond_expr::then_, ctrump_expr::u, and ctrump_expr::unary.

Referenced by build_cfg_expr().

static void build_cfg_decl ( struct ctrump_stmt stmt,
struct ctrump_decl decl,
struct build_cfg_env env,
struct ctrump_loop_cfg_info cur_loop,
struct partial_bb **  current_bb_ptr 
) [static]

宣言のCFGを作る

Definition at line 2863 of file cfg.c.

References build_cfg_initializer(), ctrump_decl::decls, ctrump_decl_with_init::initializer, and ctrump_decl::num_decls.

Referenced by build_cfg_stmt().

static int build_cfg_do_while ( struct ctrump_expr cond,
struct ctrump_stmt body,
struct ctrump_stmt next_stmt,
struct build_cfg_env env,
const struct flow_env flow_env,
struct partial_bb **  current_bb_ptr 
) [static]

static void build_cfg_expr ( struct ctrump_expr e,
struct ctrump_stmt at,
struct build_cfg_env env,
struct ctrump_loop_cfg_info cur_loop,
struct partial_bb **  current_bb_ptr 
) [static]

static void build_cfg_expr_maybe ( struct ctrump_expr e,
struct ctrump_stmt at,
struct build_cfg_env env,
struct ctrump_loop_cfg_info cur_loop,
struct partial_bb **  current_bb_ptr 
) [static]

式のCFGを作る

Note:
unrechableなBB(NULL)に対しては何もしない

Definition at line 532 of file cfg.c.

References build_cfg_expr().

Referenced by build_cfg_do_while(), build_cfg_initializer(), build_cfg_initializer_list(), and build_cfg_stmt().

static int build_cfg_for ( struct ctrump_loop_cfg_info **  loop_ret,
struct ctrump_expr cond,
struct ctrump_expr iter,
struct ctrump_stmt body,
struct ctrump_stmt next_stmt,
struct build_cfg_env env,
const struct flow_env flow_env,
struct partial_bb **  current_bb_ptr 
) [static]

for ループのCFGを作る

Definition at line 2688 of file cfg.c.

References append_succs(), build_cfg_expr(), build_cfg_loop(), build_cfg_env::cfg_pool, ctrump_mempool_alloc, flow_env::loop_cfg, new_bb(), and flow_env::return_to.

Referenced by build_cfg_stmt().

static void build_cfg_initializer ( struct ctrump_initializer init,
struct ctrump_stmt stmt,
struct build_cfg_env env,
struct ctrump_loop_cfg_info loop,
struct partial_bb **  current_bb_ptr 
) [static]

static void build_cfg_initializer_list ( struct ctrump_initializer_list list,
struct ctrump_stmt stmt,
struct build_cfg_env env,
struct ctrump_loop_cfg_info loop,
struct partial_bb **  current_bb_ptr 
) [static]

static void build_cfg_logical_expr ( struct ctrump_expr lhs,
struct ctrump_expr rhs,
struct ctrump_stmt at,
struct build_cfg_env env,
struct ctrump_loop_cfg_info cur_loop,
struct partial_bb **  current_bb_ptr 
) [static]

論理式に対してCFGを作る これ以後もAST式の構造は変化しないが、 論理式の中身は別のBBに保持される点に注意

a + (b && c); xxyy は、式としては構文解析後から変わらず↓こういう形になるが、 (+ a (&& b c)) xxyy

BBとしては、

bb0 : (+ a (&& b bb1 : c)) bb2 : xxyy

となる

Definition at line 332 of file cfg.c.

References append_succs(), build_cfg_expr(), and new_bb().

Referenced by build_cfg_cond_expr().

static int build_cfg_loop ( struct ctrump_stmt body,
struct ctrump_expr exit_cond,
struct partial_bb cond_bb_enter,
struct partial_bb cond_bb_exit,
struct partial_bb return_bb,
struct partial_bb continue_bb_enter,
struct partial_bb continue_bb_exit,
struct ctrump_stmt next_stmt,
struct ctrump_loop_cfg_info loop,
struct build_cfg_env env,
struct ctrump_loop_cfg_info outer_loop,
struct partial_bb **  current_bb_ptr 
) [static]

body ループのCFGを作る

Parameters:
exit_cond ループのbody(条件式除く)
cond_bb_enter 条件式の入り口
cond_bb_exit 条件式の出口
return_bb returnで抜ける先
continue_bb_enter continueした先の式の入り口
continue_bb_exit continueした先の式の出口
next_stmt 次の文
loop 今のループの情報
env 
outer_loop 外側のループ
current_bb_ptr 今いるbasic blockへのポインタのポインタ
Note:
continue_bb_exit -> cond_bb_enter へのフローはこの関数の外で繋いでおくこと

Definition at line 2615 of file cfg.c.

References append_pending(), append_succs(), append_succs_maybe(), ctrump_loop_cfg_info::body_start_bb, ctrump_loop_cfg_info::break_bb, flow_env::break_to, build_cfg_stmt(), ctrump_loop_cfg_info::cond_bb, flow_env::continue_to, CTRUMP_BB_LOOP_ENTRY, ctrump_loop_cfg_info::exit_cond, partial_bb::flags, get_id_bb_maybe(), ctrump_loop_cfg_info::id, flow_env::loop_cfg, ctrump_loop_cfg_info::loop_pred, new_bb(), build_cfg_env::next_id, and flow_env::return_to.

Referenced by build_cfg_for(), and build_cfg_while().

static int build_cfg_stmt ( struct ctrump_stmt stmt,
struct ctrump_stmt next_stmt,
struct build_cfg_env env,
const struct flow_env flow_env,
struct partial_bb **  current_bb_ptr 
) [static]

文のCFGを作る

Definition at line 2880 of file cfg.c.

References append_succs(), append_succs_maybe(), BMP_P, ctrump_for_decl_stmt::body, ctrump_do_while_stmt::body, ctrump_while_stmt::body, ctrump_for_stmt::body, ctrump_if_stmt::body, flow_env::break_to, build_cfg_compound(), build_cfg_decl(), build_cfg_do_while(), build_cfg_expr_maybe(), build_cfg_for(), build_cfg_while(), ctrump_build_cfg_error::code, ctrump_stmt::code, ctrump_stmt::compound, ctrump_for_decl_stmt::cond, ctrump_do_while_stmt::cond, ctrump_while_stmt::cond, ctrump_for_stmt::cond, ctrump_if_else_stmt::cond, ctrump_if_stmt::cond, flow_env::continue_to, CTRUMP_BUILD_CFG_ERROR_BREAK_IN_NOT_LOOP, CTRUMP_BUILD_CFG_ERROR_CONTINUE_IN_NOT_LOOP, ctrump_fixme, CTRUMP_STMT_ASM, CTRUMP_STMT_BREAK, CTRUMP_STMT_CASE, CTRUMP_STMT_COMPOUND, CTRUMP_STMT_CONTINUE, CTRUMP_STMT_DECL, CTRUMP_STMT_DEFAULT, CTRUMP_STMT_DEFINE, CTRUMP_STMT_DO_WHILE, CTRUMP_STMT_EMPTY, CTRUMP_STMT_EXPR, CTRUMP_STMT_FOR, CTRUMP_STMT_FOR_DECL, CTRUMP_STMT_GOTO, CTRUMP_STMT_IF, CTRUMP_STMT_IF_ELSE, CTRUMP_STMT_IFDEF, CTRUMP_STMT_LABELED, CTRUMP_STMT_LIST, CTRUMP_STMT_NEWLINE, CTRUMP_STMT_PRAGMA, CTRUMP_STMT_RETURN, CTRUMP_STMT_RETURN_EXPR, CTRUMP_STMT_SLAAST_COMMENT, CTRUMP_STMT_SLASLA_COMMENT, CTRUMP_STMT_SWITCH, CTRUMP_STMT_UNDEF, CTRUMP_STMT_WHILE, ctrump_unreachable, ctrump_stmt::decl, ctrump_stmt::do_while, ctrump_if_else_stmt::else_body, build_cfg_env::error, ctrump_expr_stmt::expr, ctrump_stmt::expr, ctrump_stmt::for_, ctrump_stmt::for_decl, get_id_bb(), get_id_bb_maybe(), ctrump_stmt::goto_, HASH_FIND_SYM, ctrump_stmt::id, ctrump_stmt::if_, ctrump_stmt::if_else, ctrump_for_decl_stmt::init, ctrump_for_stmt::init, ctrump_for_decl_stmt::iter, ctrump_for_stmt::iter, ctrump_goto_stmt::label, build_cfg_env::label_ref_bmp, build_cfg_env::label_table, ctrump_stmt::labeled, ctrump_for_decl_stmt::loop_cfg, ctrump_while_stmt::loop_cfg, ctrump_for_stmt::loop_cfg, flow_env::loop_cfg, ctrump_loop_cfg_info::loop_stmt, ctrump_stmt::ret_expr, flow_env::return_to, ctrump_return_expr_stmt::retval, ctrump_labeled_stmt::stmt, ctrump_build_cfg_error::stmt, label_table::stmt, ctrump_if_else_stmt::then_body, ctrump_stmt::u, and ctrump_stmt::while_.

Referenced by build_cfg_compound(), build_cfg_do_while(), and build_cfg_loop().

static void build_cfg_trinary_cond_expr ( struct ctrump_expr cond,
struct ctrump_expr then_,
struct ctrump_expr else_,
struct ctrump_stmt at,
struct build_cfg_env env,
struct ctrump_loop_cfg_info cur_loop,
struct partial_bb **  current_bb_ptr 
) [static]

条件式に対してCFGを作る

Definition at line 356 of file cfg.c.

References append_succs(), build_cfg_expr(), and new_bb().

Referenced by build_cfg_cond_expr().

static int build_cfg_while ( struct ctrump_loop_cfg_info **  loop_ret,
struct ctrump_expr cond,
struct ctrump_stmt body,
struct ctrump_stmt next_stmt,
struct build_cfg_env env,
const struct flow_env flow_env,
struct partial_bb **  current_bb_ptr 
) [static]

whileループのCFGを作る

Definition at line 2726 of file cfg.c.

References build_cfg_expr(), build_cfg_loop(), build_cfg_env::cfg_pool, ctrump_mempool_alloc, flow_env::loop_cfg, new_bb(), and flow_env::return_to.

Referenced by build_cfg_stmt().

static void build_dom ( struct build_cfg_env env,
int  num_bb 
) [static]

支配木を作る

Definition at line 773 of file cfg.c.

References partial_bb::bb, partial_bb::children, build_cfg_env::dfs_order, partial_bb::idom, nca(), build_cfg_env::tmp_alloc, VA_ELEM, and VA_PUSH_P.

Referenced by build_cfg().

static int build_label_ref ( struct label_table table,
const struct ctrump_compound_stmt stmt,
struct build_cfg_env env 
) [static]

static int build_label_table ( struct label_table **  table,
const struct ctrump_compound_stmt stmts,
struct build_cfg_env env 
) [static]

static void calc_df ( struct partial_bb **  dfs_order,
int  num_bb,
struct ctrump_intmap varinfo_map,
int  num_var_info,
ctrump_bitmap_t  tmp_bitmap 
) [static]

static int check_label_use ( struct build_cfg_env env,
const struct ctrump_compound_stmt stmts 
) [static]

ラベルテーブルを作る

Definition at line 289 of file cfg.c.

References build_label_ref(), build_label_table(), delete_table(), and build_cfg_env::label_table.

Referenced by ctrump_build_cfg().

int ctrump_build_cfg ( struct ctrump_cfg ret,
struct ctrump_intmap var_info_map,
struct ctrump_build_cfg_error error,
const struct ctrump_fundef def,
struct ctrump_mempool cfg_pool,
struct ctrump_mempool varmap_pool,
int  num_ast,
int  id_begin 
)

static void delete_table ( struct label_table table  )  [static]

ラベルテーブルを削除

Definition at line 198 of file cfg.c.

References HASH_DEL.

Referenced by build_label_table(), check_label_use(), and ctrump_build_cfg().

static int dfs_order ( struct partial_bb start,
struct build_cfg_env env,
int  num_bb,
ctrump_bitmap_t  bb_bitmap 
) [static]

CFGを深さ優先探索で辿った順の配列をつくり、 bb->dfs_order を設定する.

Definition at line 697 of file cfg.c.

References BMP_P, BMP_SET, ctrump_mempool_alloc, build_cfg_env::dfs_order, partial_bb::id, partial_bb::idom, partial_bb::order, build_cfg_env::tmp_alloc, and VA_ELEM.

Referenced by build_cfg(), and ctrump_analyze_loop().

static int extract_load_store ( struct partial_bb bb,
struct ctrump_intmap var_info_map,
struct ctrump_build_cfg_error error,
struct ctrump_mempool cfg_alloc,
struct ctrump_mempool tmp_alloc 
) [static]

BBからロードストアを抜き出す.

Definition at line 2081 of file cfg.c.

References partial_bb_expr::at, BB_EXPR, CHECK_ERROR, partial_bb_expr::code, extract_load_store_expr_rval(), and partial_bb_expr::u.

Referenced by build_cfg().

static int extract_load_store_assign ( enum ctrump_expr_code  store_op,
struct ctrump_expr lhs,
struct ctrump_expr val_expr,
struct ctrump_stmt at,
struct partial_bb bb,
struct ctrump_intmap var_info_map,
struct ctrump_build_cfg_error error,
struct ctrump_mempool cfg_alloc,
struct ctrump_mempool tmp_alloc 
) [static]

static int extract_load_store_expr_rval ( struct ctrump_expr e,
struct ctrump_stmt at,
struct partial_bb bb,
struct ctrump_intmap var_info_map,
struct ctrump_build_cfg_error error,
struct ctrump_mempool cfg_alloc,
struct ctrump_mempool tmp_alloc 
) [static]

右辺値からロードストアを抜き出す

Definition at line 1888 of file cfg.c.

References add_var_loadstore(), ctrump_var::addressed, append_memory_load(), ctrump_call_expr::args, ctrump_expr::arr_ref, ctrump_arr_ref_expr::array, ctrump_var_ref::at, ctrump_expr::binary, ctrump_expr::call, ctrump_expr::cast, CHECK_ERROR, ctrump_build_cfg_error::code, ctrump_expr::code, ctrump_cond_expr::cond, ctrump_expr::cond, ctrump_bitmap_p(), ctrump_bitmap_set(), CTRUMP_BUILD_CFG_ERROR_INVALID_ADDRESSOP, CTRUMP_CASE_BIN_LOG_EXPR, CTRUMP_CASE_BIN_OP_ASSIGN_EXPR, CTRUMP_CASE_CONSTANT_TERM, CTRUMP_EXPR_ARRREF, CTRUMP_EXPR_BIN_ADD, CTRUMP_EXPR_BIN_ASSIGN, CTRUMP_EXPR_BIN_BAND, CTRUMP_EXPR_BIN_BOR, CTRUMP_EXPR_BIN_BXOR, CTRUMP_EXPR_BIN_COMMA, CTRUMP_EXPR_BIN_DIV, CTRUMP_EXPR_BIN_EQ, CTRUMP_EXPR_BIN_GE, CTRUMP_EXPR_BIN_GT, CTRUMP_EXPR_BIN_LE, CTRUMP_EXPR_BIN_LSHIFT, CTRUMP_EXPR_BIN_LT, CTRUMP_EXPR_BIN_MOD, CTRUMP_EXPR_BIN_MUL, CTRUMP_EXPR_BIN_NE, CTRUMP_EXPR_BIN_RSHIFT, CTRUMP_EXPR_BIN_SUB, CTRUMP_EXPR_CALL, CTRUMP_EXPR_CAST, CTRUMP_EXPR_CONDITIONAL, CTRUMP_EXPR_EMPTY, CTRUMP_EXPR_IMPLICIT_CAST, CTRUMP_EXPR_INITIALIZER, CTRUMP_EXPR_IVTMP, CTRUMP_EXPR_MACRO_EXPAND, CTRUMP_EXPR_MEMBER_REF, CTRUMP_EXPR_PAREN, CTRUMP_EXPR_PTR_MEMBER_REF, CTRUMP_EXPR_TEXT, CTRUMP_EXPR_UNA_ADDR, CTRUMP_EXPR_UNA_BCMPL, CTRUMP_EXPR_UNA_LNEG, CTRUMP_EXPR_UNA_NEG, CTRUMP_EXPR_UNA_POS, CTRUMP_EXPR_UNA_POST_DEC, CTRUMP_EXPR_UNA_POST_INC, CTRUMP_EXPR_UNA_PRE_DEC, CTRUMP_EXPR_UNA_PRE_INC, CTRUMP_EXPR_UNA_PTRREF, CTRUMP_EXPR_VARREF, ctrump_fixme, ctrump_intmap_lookup(), ctrump_unreachable, ctrump_paren_expr::expr, ctrump_unary_expr::expr, ctrump_implicit_cast_expr::expr, ctrump_cast_expr::expr, extract_load_store_assign(), extract_load_store_initializer_list(), ctrump_call_expr::func_expr, ctrump_var::id, ctrump_expr::implicit_cast, ctrump_cfg_var_info::index, ctrump_initializer_expr::initializer, ctrump_expr::initializer, partial_bb::kill, ctrump_binary_expr::lhs, LOAD, ctrump_varray::nelem, ctrump_call_expr::num_args, partial_bb::ordered_mem_load_store, ctrump_expr::paren, ctrump_varref_expr::pdg, ctrump_var_ref::ref_expr, partial_var_info::result, ctrump_binary_expr::rhs, ctrump_build_cfg_error::stmt, ctrump_arr_ref_expr::subscript, ctrump_expr::u, ctrump_expr::unary, partial_bb::use, VA_LAST_PTR, VA_NEWELEM_P, ctrump_varref_expr::var, and ctrump_expr::varref.

Referenced by append_memory_load(), append_memory_store(), extract_load_store(), extract_load_store_initializer(), extract_load_store_initializer_list(), and recog_array_access().

static int extract_load_store_initializer ( struct ctrump_initializer initializer,
struct ctrump_stmt at,
struct partial_bb bb,
struct ctrump_intmap var_info_map,
struct ctrump_build_cfg_error error,
struct ctrump_mempool cfg_alloc,
struct ctrump_mempool tmp_alloc 
) [static]

static int extract_load_store_initializer_list ( struct ctrump_initializer_list init_list,
struct ctrump_stmt at,
struct partial_bb bb,
struct ctrump_intmap var_info_map,
struct ctrump_build_cfg_error error,
struct ctrump_mempool cfg_alloc,
struct ctrump_mempool tmp_alloc 
) [static]

static void find_df ( struct build_cfg_env env,
int  num_bb 
) [static]

支配辺境を求める domtree -> dominance frontier

Definition at line 811 of file cfg.c.

References partial_bb::bb, partial_bb::children, build_cfg_env::dfs_order, partial_bb::idom, ctrump_varray::nelem, build_cfg_env::tmp_alloc, VA_ELEM, and VA_PUSH_P.

Referenced by build_cfg().

static struct partial_bb* get_id_bb ( struct build_cfg_env env,
struct ctrump_stmt stmt,
struct ctrump_loop_cfg_info cur_loop 
) [static, read]

idで示す文を先頭に持つBBを取得 無ければ作る

Note:
intmapにすべき

Definition at line 613 of file cfg.c.

References ctrump_stmt::id, new_bb(), and build_cfg_env::stmt_bb_table.

Referenced by build_cfg_do_while(), build_cfg_stmt(), and get_id_bb_maybe().

static struct partial_bb* get_id_bb_maybe ( struct build_cfg_env env,
struct ctrump_stmt stmt,
struct ctrump_loop_cfg_info loop,
struct partial_bb return_to_bb 
) [static, read]

idで示す文を先頭に持つBBを取得 無ければ作る stmt が NULL なら次の文は存在しない(return_toへ飛ぶ)

Note:
intmapにすべき

Definition at line 638 of file cfg.c.

References get_id_bb().

Referenced by build_cfg_do_while(), build_cfg_loop(), and build_cfg_stmt().

static int insert_phi ( struct partial_bb **  bbs,
int  num_bb,
struct partial_var_info var_info,
int  num_var_info,
int  id,
ctrump_bitmap_t  tmp_bitmap,
struct ctrump_mempool cfg_alloc 
) [static]

static struct partial_bb* nca ( struct partial_bb x,
struct partial_bb y 
) [static, read]

最近共通祖先(Nearest Common Ancestor)を求める

Definition at line 749 of file cfg.c.

References partial_bb::idom, and partial_bb::order.

Referenced by build_dom().

static struct partial_bb * new_bb ( struct build_cfg_env env,
struct ctrump_loop_cfg_info cfg 
) [static, read]

static int recog_array_access ( struct ctrump_expr **  ret_array,
struct ctrump_subscript **  ret_vec,
int *  num_ret,
struct ctrump_expr access_expr,
struct partial_bb bb,
struct ctrump_intmap var_info_map,
struct ctrump_build_cfg_error error,
struct ctrump_stmt at,
struct ctrump_mempool cfg_alloc,
struct ctrump_mempool tmp_alloc 
) [static]

static int recog_reductive ( struct ctrump_expr e,
struct ctrump_var v,
int  is_float,
enum ctrump_reductive_expr_code ret_code,
struct ctrump_expr **  ret_expr 
) [static]

縮約演算を識別する

Definition at line 933 of file cfg.c.

References ctrump_expr::binary, ctrump_expr::code, CTRUMP_CASE_BIN_ARITH_EXPR, CTRUMP_CASE_BIN_EQ_EXPR, CTRUMP_CASE_BIN_LOG_EXPR, CTRUMP_CASE_BIN_OP_ASSIGN_EXPR, CTRUMP_CASE_CONSTANT_TERM, CTRUMP_EXPR_ARRREF, CTRUMP_EXPR_BIN_ADD, CTRUMP_EXPR_BIN_ASSIGN, CTRUMP_EXPR_BIN_BAND, CTRUMP_EXPR_BIN_BOR, CTRUMP_EXPR_BIN_BXOR, CTRUMP_EXPR_BIN_COMMA, CTRUMP_EXPR_BIN_LAND, CTRUMP_EXPR_BIN_LOR, CTRUMP_EXPR_BIN_MUL, CTRUMP_EXPR_BIN_SUB, CTRUMP_EXPR_CALL, CTRUMP_EXPR_CAST, CTRUMP_EXPR_CONDITIONAL, CTRUMP_EXPR_EMPTY, CTRUMP_EXPR_IMPLICIT_CAST, CTRUMP_EXPR_INITIALIZER, CTRUMP_EXPR_IVTMP, CTRUMP_EXPR_MACRO_EXPAND, CTRUMP_EXPR_MEMBER_REF, ctrump_expr_occur_var(), CTRUMP_EXPR_PAREN, CTRUMP_EXPR_PTR_MEMBER_REF, CTRUMP_EXPR_TEXT, CTRUMP_EXPR_UNA_ADDR, CTRUMP_EXPR_UNA_BCMPL, CTRUMP_EXPR_UNA_LNEG, CTRUMP_EXPR_UNA_NEG, CTRUMP_EXPR_UNA_POS, CTRUMP_EXPR_UNA_POST_DEC, CTRUMP_EXPR_UNA_POST_INC, CTRUMP_EXPR_UNA_PRE_DEC, CTRUMP_EXPR_UNA_PRE_INC, CTRUMP_EXPR_UNA_PTRREF, CTRUMP_EXPR_VARREF, CTRUMP_REDUCTIVE_ADD, CTRUMP_REDUCTIVE_BAND, CTRUMP_REDUCTIVE_BOR, CTRUMP_REDUCTIVE_BXOR, CTRUMP_REDUCTIVE_FADD, CTRUMP_REDUCTIVE_FMUL, CTRUMP_REDUCTIVE_FSUB, CTRUMP_REDUCTIVE_LAND, CTRUMP_REDUCTIVE_LOR, CTRUMP_REDUCTIVE_MUL, CTRUMP_REDUCTIVE_SUB, ctrump_unreachable, ctrump_macro_expand_expr::expanded, ctrump_paren_expr::expr, ctrump_binary_expr::lhs, ctrump_expr::macro_expand, ctrump_expr::paren, REDUC_CASE_LHS, ctrump_binary_expr::rhs, ctrump_expr::u, ctrump_varref_expr::var, and ctrump_expr::varref.

Referenced by ssa_node_store_expr().

static void resolve_bb_vec ( struct ctrump_bb **  bb_vec,
struct ctrump_varray partial_vec,
struct ctrump_bb **  basic_blocks 
) [static]

partial_bbへのポインタをctrump_bbへのポインタに変換する

Definition at line 2362 of file cfg.c.

References partial_bb::id, ctrump_varray::nelem, and VA_ELEM.

Referenced by build_cfg().

static struct ctrump_pdg_node* ssa_node_store_expr ( enum ctrump_expr_code  op_code,
struct ctrump_var var,
struct ctrump_expr store_val,
struct ctrump_varray pdg_node_list,
struct ctrump_pdg_node old_val,
struct ctrump_stmt at,
struct ctrump_mempool alloc,
int *  id 
) [static, read]


Generated on Tue Mar 31 20:19:24 2009 for ctrump by  doxygen 1.5.6