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

相关文章

基于Go语言实现Base62编码的三种方式以及对比分析

《基于Go语言实现Base62编码的三种方式以及对比分析》Base62编码是一种在字符编码中使用62个字符的编码方式,在计算机科学中,,Go语言是一种静态类型、编译型语言,它由Google开发并开源,... 目录一、标准库现状与解决方案1. 标准库对比表2. 解决方案完整实现代码(含边界处理)二、关键实现细

PostgreSQL 序列(Sequence) 与 Oracle 序列对比差异分析

《PostgreSQL序列(Sequence)与Oracle序列对比差异分析》PostgreSQL和Oracle都提供了序列(Sequence)功能,但在实现细节和使用方式上存在一些重要差异,... 目录PostgreSQL 序列(Sequence) 与 oracle 序列对比一 基本语法对比1.1 创建序

Kotlin运算符重载函数及作用场景

《Kotlin运算符重载函数及作用场景》在Kotlin里,运算符重载函数允许为自定义类型重新定义现有的运算符(如+-…)行为,从而让自定义类型能像内置类型那样使用运算符,本文给大家介绍Kotlin运算... 目录基本语法作用场景类对象数据类型接口注意事项在 Kotlin 里,运算符重载函数允许为自定义类型重

慢sql提前分析预警和动态sql替换-Mybatis-SQL

《慢sql提前分析预警和动态sql替换-Mybatis-SQL》为防止慢SQL问题而开发的MyBatis组件,该组件能够在开发、测试阶段自动分析SQL语句,并在出现慢SQL问题时通过Ducc配置实现动... 目录背景解决思路开源方案调研设计方案详细设计使用方法1、引入依赖jar包2、配置组件XML3、核心配

Java NoClassDefFoundError运行时错误分析解决

《JavaNoClassDefFoundError运行时错误分析解决》在Java开发中,NoClassDefFoundError是一种常见的运行时错误,它通常表明Java虚拟机在尝试加载一个类时未能... 目录前言一、问题分析二、报错原因三、解决思路检查类路径配置检查依赖库检查类文件调试类加载器问题四、常见

Pandas中统计汇总可视化函数plot()的使用

《Pandas中统计汇总可视化函数plot()的使用》Pandas提供了许多强大的数据处理和分析功能,其中plot()函数就是其可视化功能的一个重要组成部分,本文主要介绍了Pandas中统计汇总可视化... 目录一、plot()函数简介二、plot()函数的基本用法三、plot()函数的参数详解四、使用pl

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、程序