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

2024-01-02 22:58

本文主要是介绍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,"before store_one_arg \n");
    store_one_arg (&args[i], argblock, may_be_alloca);
    fprintf(stderr,"after store_one_arg \n ");
    }


下面是 store_one_arg ()函数中的相关代码:

static void
store_one_arg (arg, argblock, may_be_alloca)
     struct arg_data *arg;
     rtx argblock;
     int may_be_alloca;
{
  register tree pval = arg->tree_value;
  int used = 0;

  if (TREE_CODE (pval) == ERROR_MARK)
    return;
fprintf(stderr,"in store_one_arg debug_tree pval \n");
   debug_tree(pval); 

...

  else if (TYPE_MODE (TREE_TYPE (pval)) != BLKmode)
    {
      register int size;
      rtx tem;

      fprintf(stderr,"else if type_mode 1 \n");
      /* Argument is a scalar, not entirely passed in registers.
     (If part is passed in registers, arg->partial says how much
     and emit_push_insn will take care of putting it there.)
    
     Push it, and if its size is less than the
     amount of space allocated to it,
     also bump stack pointer by the additional space.
     Note that in C the default argument promotions
     will prevent such mismatches.  */

      size = GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (pval)));
      /* Compute how much space the push instruction will push.
     On many machines, pushing a byte will advance the stack
     pointer by a halfword.  */
#ifdef PUSH_ROUNDING
      size = PUSH_ROUNDING (size);
#endif
      used = size;

      /* Compute how much space the argument should get:
     round up to a multiple of the alignment for arguments.  */
      if (none != FUNCTION_ARG_PADDING (TYPE_MODE (TREE_TYPE (pval)), const0_rtx))
    used = (((size + PARM_BOUNDARY / BITS_PER_UNIT - 1)
         / (PARM_BOUNDARY / BITS_PER_UNIT))
        * (PARM_BOUNDARY / BITS_PER_UNIT));

      tem = arg->value;
      if (tem == 0)
    {
     fprintf(stderr,"else if type_mode 2\n");
       tem = expand_expr (pval, 0, VOIDmode, 0);
      /* ANSI doesn't require a sequence point here,
         but PCC has one, so this will avoid some problems.  */
     fprintf(stderr,"else if type_mode 3\n");
      emit_queue ();
    }

      /* Don't allow anything left on stack from computation
     of argument to alloca.  */
      if (may_be_alloca)
    do_pending_stack_adjust ();

      fprintf(stderr,"else if type_mode 4 \n");
      emit_push_insn (tem, TYPE_MODE (TREE_TYPE (pval)), 0, 0,
              arg->partial, arg->reg, used - size,
              argblock, ARGS_SIZE_RTX (arg->offset));
    }

下面是调试结果:



before store_one_arg

in store_one_arg debug_tree pval
 <nop_expr 840d8
    type <pointer_type 9117c
        type <integer_type 91130 char readonly permanent QI
            size <integer_cst 82638 literal permanent 1
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
            max <integer_cst 82620 literal permanent 127
            pointer_to_this <pointer_type 9117c>
        permanent unsigned SI
        size <integer_cst 8254c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        chain <function_type 912c0>
    literal
    arg 0 <nop_expr 840c0
        type <pointer_type 88a44 type <integer_type 825bc char>
            permanent unsigned SI size <integer_cst 8254c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
            chain <array_type 88a90>
        literal
        arg 0 <addr_expr 840a8 type <pointer_type 94f58>
            literal
            arg 0 <string_cst 84014 type <array_type 94ef4>
                static literal "Hello, world!
"
else if type_mode 1
else if type_mode 2
expand_expr code = 71
 <nop_expr 840d8
    type <pointer_type 9117c
        type <integer_type 91130 char readonly permanent QI
            size <integer_cst 82638 literal permanent 1
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
            max <integer_cst 82620 literal permanent 127
            pointer_to_this <pointer_type 9117c>
        permanent unsigned SI
        size <integer_cst 8254c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        chain <function_type 912c0>
    literal
    arg 0 <nop_expr 840c0
        type <pointer_type 88a44 type <integer_type 825bc char>
            permanent unsigned SI size <integer_cst 8254c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
            chain <array_type 88a90>
        literal
        arg 0 <addr_expr 840a8 type <pointer_type 94f58>
            literal
            arg 0 <string_cst 84014 type <array_type 94ef4>
                static literal "Hello, world!
"
expand_expr code = 71
 <nop_expr 840c0
    type <pointer_type 88a44
        type <integer_type 825bc char permanent QI
            size <integer_cst 82638 literal permanent 1
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
            max <integer_cst 82620 literal permanent 127
            pointer_to_this <pointer_type 88a44> chain <integer_type 826a8 long int>
        permanent unsigned SI
        size <integer_cst 8254c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        chain <array_type 88a90>
    literal
    arg 0 <addr_expr 840a8
        type <pointer_type 94f58 type <array_type 94ef4>
            unsigned SI size <integer_cst 8254c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
        literal
        arg 0 <string_cst 84014 type <array_type 94ef4>
            static literal "Hello, world!
"
expand_expr code = 74
 <addr_expr 840a8
    type <pointer_type 94f58
        type <array_type 94ef4 type <integer_type 825bc char>
            BLK
            size <integer_cst 94f40 literal 15
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 82638 literal permanent 1 domain <integer_type 94ea8>
            pointer_to_this <pointer_type 94f58> chain <pointer_type 94f58>
        unsigned SI
        size <integer_cst 8254c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
    literal
    arg 0 <string_cst 84014 type <array_type 94ef4>
        static literal "Hello, world!
"
expand_expr code = 26
 <string_cst 84014
    type <array_type 94ef4
        type <integer_type 825bc char permanent QI
            size <integer_cst 82638 literal permanent 1
            align 8 size_unit 8 sep_unit 8 symtab 0
            sep <integer_cst 82608 literal permanent -128 precision 8 min <integer_cst 82608 -128>
            max <integer_cst 82620 literal permanent 127
            pointer_to_this <pointer_type 88a44> chain <integer_type 826a8 long int>
        BLK
        size <integer_cst 94f40 literal 15
        align 8 size_unit 8 sep_unit 8 symtab 0 sep <integer_cst 82638 1>
        domain <integer_type 94ea8 SI
            size <integer_cst 8254c literal permanent 4
            align 32 size_unit 8 sep_unit 32 symtab 0
            sep <integer_cst 84048 literal 0 precision 32 min <integer_cst 84048 0>
            max <integer_cst 84078 literal 14
        pointer_to_this <pointer_type 94f58> chain <pointer_type 94f58>
    static literal "Hello, world!
"
output_constant_def

(symbol_ref:SI ("*LC0"))

(mem:BLK (symbol_ref:SI ("*LC0")))
this this
addr_expr
force_operand 27
end addr_expr
else if type_mode 3
else if type_mode 4
begin emit_push_insn
gen_push_operand

(pre_dec:SI (reg:SI 7))
end gen_push_operand
before emit_move_insn

(mem:SI (pre_dec:SI (reg:SI 7)))
before return emit_insn icode= 14

(set (mem:SI (pre_dec:SI (reg:SI 7)))
   (symbol_ref:SI ("*LC0")))
emit_insn
after emit_move_insn
after store_one_arg

这篇关于gcc源代码分析,expand_call ()函数分析第五部分,store_one_arg ()函数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/563888

相关文章

Python中的Walrus运算符分析示例详解

《Python中的Walrus运算符分析示例详解》Python中的Walrus运算符(:=)是Python3.8引入的一个新特性,允许在表达式中同时赋值和返回值,它的核心作用是减少重复计算,提升代码简... 目录1. 在循环中避免重复计算2. 在条件判断中同时赋值变量3. 在列表推导式或字典推导式中简化逻辑

Python的time模块一些常用功能(各种与时间相关的函数)

《Python的time模块一些常用功能(各种与时间相关的函数)》Python的time模块提供了各种与时间相关的函数,包括获取当前时间、处理时间间隔、执行时间测量等,:本文主要介绍Python的... 目录1. 获取当前时间2. 时间格式化3. 延时执行4. 时间戳运算5. 计算代码执行时间6. 转换为指

Python正则表达式语法及re模块中的常用函数详解

《Python正则表达式语法及re模块中的常用函数详解》这篇文章主要给大家介绍了关于Python正则表达式语法及re模块中常用函数的相关资料,正则表达式是一种强大的字符串处理工具,可以用于匹配、切分、... 目录概念、作用和步骤语法re模块中的常用函数总结 概念、作用和步骤概念: 本身也是一个字符串,其中

Java程序进程起来了但是不打印日志的原因分析

《Java程序进程起来了但是不打印日志的原因分析》:本文主要介绍Java程序进程起来了但是不打印日志的原因分析,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Java程序进程起来了但是不打印日志的原因1、日志配置问题2、日志文件权限问题3、日志文件路径问题4、程序

Java字符串操作技巧之语法、示例与应用场景分析

《Java字符串操作技巧之语法、示例与应用场景分析》在Java算法题和日常开发中,字符串处理是必备的核心技能,本文全面梳理Java中字符串的常用操作语法,结合代码示例、应用场景和避坑指南,可快速掌握字... 目录引言1. 基础操作1.1 创建字符串1.2 获取长度1.3 访问字符2. 字符串处理2.1 子字

一文详解如何在Python中从字符串中提取部分内容

《一文详解如何在Python中从字符串中提取部分内容》:本文主要介绍如何在Python中从字符串中提取部分内容的相关资料,包括使用正则表达式、Pyparsing库、AST(抽象语法树)、字符串操作... 目录前言解决方案方法一:使用正则表达式方法二:使用 Pyparsing方法三:使用 AST方法四:使用字

shell编程之函数与数组的使用详解

《shell编程之函数与数组的使用详解》:本文主要介绍shell编程之函数与数组的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录shell函数函数的用法俩个数求和系统资源监控并报警函数函数变量的作用范围函数的参数递归函数shell数组获取数组的长度读取某下的

MySQL高级查询之JOIN、子查询、窗口函数实际案例

《MySQL高级查询之JOIN、子查询、窗口函数实际案例》:本文主要介绍MySQL高级查询之JOIN、子查询、窗口函数实际案例的相关资料,JOIN用于多表关联查询,子查询用于数据筛选和过滤,窗口函... 目录前言1. JOIN(连接查询)1.1 内连接(INNER JOIN)1.2 左连接(LEFT JOI

MySQL中FIND_IN_SET函数与INSTR函数用法解析

《MySQL中FIND_IN_SET函数与INSTR函数用法解析》:本文主要介绍MySQL中FIND_IN_SET函数与INSTR函数用法解析,本文通过实例代码给大家介绍的非常详细,感兴趣的朋友一... 目录一、功能定义与语法1、FIND_IN_SET函数2、INSTR函数二、本质区别对比三、实际场景案例分

Python 迭代器和生成器概念及场景分析

《Python迭代器和生成器概念及场景分析》yield是Python中实现惰性计算和协程的核心工具,结合send()、throw()、close()等方法,能够构建高效、灵活的数据流和控制流模型,这... 目录迭代器的介绍自定义迭代器省略的迭代器生产器的介绍yield的普通用法yield的高级用法yidle