WHIRL Generator (WGEN in Open64) 笔记

WHIRL Gen 核心逻辑(Spin 2 whirl)

(就是获取spin的每个node)

gs_t 就是 spin的单个AST node

使用gs_operand(list,0)获取当前node的is_t,

使用 list = gs_operand(list,1)获取下一个node

获取node之后使用 WGEN_Expand_Top_Level_Decl (gs_t decl) 来展开莫个gs_t()

之后就是各种调用WGEN_Expand_Decl ,包括递归调用



中间可能出现:

———   Function   ——— 

WGEN_Expand_Function_Body

WGEN_Start_Function

WGEN_Handle_Named_Return_Value

Mark_Scopes_And_Labels

WGEN_Expand_Stmt

WGEN_Finish_Function

Pop_Current_Function_Decl

Push_Current_Function_Decl

——  Whirl  ——— 

WGEN_Whirlify_Decl

WGEN_Initialize_Decl

———  Thunk  ——— 

WGEN_Adjust_Thunk

WGEN_Generate_Thunk  — For adjusting return or this pointer.

———  Symtab ——— 

WN_st_idx()

ST_st_idx(const char *)  string -> str_id / saving  function name to symtab 

———  WN ——— 

WN_Set_Call_Default_Flags

WN_Set_Call_Replace_By_Jump

WN_Ldid

WN_CreateParm(Mtype_comparison (arg_mtype), arg_wn,

                           arg_ty, WN_PARM_BY_VALUE);

WN_kid = ***   Set kid of WN

WN_Create (OPR_CALL, ret_mtype, MTYPE_V, nargs)

WN_st

WN_CreateReturn

WN_Stid


——   Statement. ——— 

WGEN_Stmt_Append(wn, getsrcpos())

Mark_Scopes_And_Labels()

WGEN_Expand_Stmt

WGEN_GetLABEL

WGEN_Assembly_Alias






BT实测结果

frame #0: 0x0000000100070282 wgen`::WGEN_Expand_Decl(decl=0x0000000101800580, can_skip=YES) at wgen_decl.cxx:709

 frame #1: 0x000000010007b5dd wgen`::WGEN_Expand_Top_Level_Decl(top_level_decl=0x0000000101800580) at wgen_decl.cxx:5208

    frame #2: 0x0000000100002555 wgen`main(argc=3, argv=0x00007fff5fbffa88, envp=0x00007fff5fbffaa8) at main.c:362

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • "use strict";function _classCallCheck(e,t){if(!(e instanc...
    久些阅读 2,059评论 0 2
  • 外面全是漆黑一片,灰霭霭的云团四处游荡,阴森森的,像是要吞噬这片清冷的后夜。 “噔”,拉电灯的声音从赵瑞水家里挤进...
    待春生阅读 591评论 0 1
  • 睡过午觉,天依然很热,没有一丝风,就连苍蝇也懒得动弹。外面是白白刺眼的阳光,炙热伴随着昆虫的嗡鸣混成一片涌向每个角...
    一缕阳光yg阅读 1,150评论 24 30
  • 今天宝宝很激动,10点还不睡觉,我和宝爸两个人为了哄他睡觉两个人一起睡,可是喝完奶的他翻来覆去了一会儿,一会儿过来...
    逗逗的妈妈姚兰阅读 277评论 1 1