gcc源代码分析,debug_tree()函数,又一利器啊

gcc源代码分析,debug_rtx()函数,利器啊

print-tree.c

#include "config.h"

#include "tree.h"

#include <stdio.h>

/* Names of tree components.

Used for printing out the tree and error messages.  */

#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,

char *tree_code_name[] = {

#include "tree.def"

};

#undef DEFTREECODE

同样的debug_tree()函数放在哪里才有用是个重要而有用的问题,

只有看完相关的代码才能知道。

我认为放到expr.c文件中比较好。

if (mode != Pmode && modifier == EXPAND_SUM)

modifier = EXPAND_NORMAL;

fprintf(stderr ,"expand_expr code = %x\n",code);

debug_tree (exp);

/* Ensure we reference a volatile object even if value is ignored.  */

if (ignore && TREE_THIS_VOLATILE (exp)

&& mode != VOIDmode && mode != BLKmode)

{

target = gen_reg_rtx (mode);

temp = expand_expr (exp, target, VOIDmode, modifier);

if (temp != target)

emit_move_insn (target, temp);

return target;

}

switch (code)
/*再这个关键的分支处,之前打印出语法树是个明智的选择*/

{

case PARM_DECL:

if (DECL_RTL (exp) == 0)

{

error_with_decl (exp, "prior parameter‘s size depends on `%s‘");

return const0_rtx;

}

case FUNCTION_DECL:

case VAR_DECL:

时间: 2024-08-03 09:52:25

gcc源代码分析,debug_tree()函数,又一利器啊的相关文章

gcc源代码分析gen_push_operand ()函数和emit_move_insn ()函数

如何生成下面红色的3个指令? 和gen_push_operand ()函数和emit_move_insn ()函数有关,他们都在expand_call()函数中被调用. 具体位置: rtx addr; #ifdef PUSH_ROUNDING if (args_addr == 0) addr = gen_push_operand (); else #endif if (GET_CODE (args_so_far) == CONST_INT) addr = memory_address (mode

gcc源代码分析,在expand_call ()函数 和expand_expr_stmt ()函数的开始处加入debug_tree ()函数

对于expand_call函数来说最主要的参数就是exp这个tree树, 打印出来之后我们终于看到了printf和Hello,world! expand_call <call_expr 840f0 type <integer_type 824d0 int permanent SI size <integer_cst 8254c literal permanent 4 align 32 size_unit 8 sep_unit 32 symtab 0 sep <integer_cst

gcc源代码分析,debug_tree()函数的利用

tree.def 中第0x3d个元素是 DEFTREECODE (CALL_EXPR, "call_expr", "e", 3) 下面是debug_tree()函数的结果,可以看出expand_expr()函数到gen_rtx()函数的调用过程! expand_expr code = 3d <call_expr 840f0 type <integer_type 824d0 int permanent SI size <integer_cst 825

gcc源代码分析,expand_call()函数和printf(&quot;Hello, world!\n&quot;);的关系

expand_call()函数在expr.c文件中. 下面是expand_call()函数的主要调试结果,记录之. 主要是加入了debug_tree()函数和debug_rtx()函数. debug_tree()函数加入到了expand_expr()函数的开始. debug_rtx()函数加入到了gen_rtx()函数的结束处. emit_call_1()函数是何时调用的也能看出.emit_call_insn()是何时调用的也能看出. 主要的调试目的是expand_call()函数是如何生成rt

gcc源代码分析,expand_call ()函数分析第五部分,store_one_arg ()函数

本文主要是分析store_one_arg ()函数和expand_expr ()的关系来说明如何处理 函数的参数.printf("Hello, world!\n");中的"Hello, world!\n"这个字符串常量的! expand_call () 函数中的相关代码: if (args[i].reg == 0 && TYPE_SIZE (TREE_TYPE (args[i].tree_value)) != 0) { fprintf(stderr,

gcc源代码分析的方法【总结】

看gcc-1.40有段时间了,14年左右看了一段时间,15年左右看了一段时间. 现在可以说基本上明白了gcc的大部分代码. 如果说能快速的明白其中的原理,总结我看代码的方法捷径我列举以下几条. 第一,gcc版本低,这是成功的前提,也是一条捷径. 第二,分析最基本的hello.c文件,就一条函数调用,但是已经足够. 第三,发现了debug_rtx ()函数和debug_tree ()函数.这两个函数可以说是看懂gcc的唯一的两把钥匙! 第四,思路正确,expand_call()如何产生各种rtx的

gcc源代码分析,build_pointer_type ()函数分析

function = build (ADDR_EXPR, build_pointer_type (TREE_TYPE (function)), function); 继续分析上篇文章的这句. /* Constructors for pointer, array and function types. (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are constructed by language-dependent code, not he

gcc源代码分析,finish_decl ()函数和push_parm_decl ()函数分析

parms: parm { push_parm_decl ($1); } /* This is what appears inside the parens in a function declarator. Is value is represented in the format that grokdeclarator expects.  */ parmlist_2:  /* empty */ { $$ = get_parm_info (0); } | parms { $$ = get_pa

gcc源代码分析,expand_call()函数第三部分

(insn_list 6 (nil)) (insn_list 2 (insn_list 6 (nil))) (sequence[ ] ) (reg:SI 0) (const_int 4) 这次是解释这5条rtx的产生过程 相关的代码片段: /* Mark all register-parms as living through the call.  */ start_sequence (); for (i = 0; i < num_actuals; i++) if (args[i].reg !=