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

相关文章

Springboot中分析SQL性能的两种方式详解

《Springboot中分析SQL性能的两种方式详解》文章介绍了SQL性能分析的两种方式:MyBatis-Plus性能分析插件和p6spy框架,MyBatis-Plus插件配置简单,适用于开发和测试环... 目录SQL性能分析的两种方式:功能介绍实现方式:实现步骤:SQL性能分析的两种方式:功能介绍记录

Python itertools中accumulate函数用法及使用运用详细讲解

《Pythonitertools中accumulate函数用法及使用运用详细讲解》:本文主要介绍Python的itertools库中的accumulate函数,该函数可以计算累积和或通过指定函数... 目录1.1前言:1.2定义:1.3衍生用法:1.3Leetcode的实际运用:总结 1.1前言:本文将详

最长公共子序列问题的深度分析与Java实现方式

《最长公共子序列问题的深度分析与Java实现方式》本文详细介绍了最长公共子序列(LCS)问题,包括其概念、暴力解法、动态规划解法,并提供了Java代码实现,暴力解法虽然简单,但在大数据处理中效率较低,... 目录最长公共子序列问题概述问题理解与示例分析暴力解法思路与示例代码动态规划解法DP 表的构建与意义动

轻松上手MYSQL之JSON函数实现高效数据查询与操作

《轻松上手MYSQL之JSON函数实现高效数据查询与操作》:本文主要介绍轻松上手MYSQL之JSON函数实现高效数据查询与操作的相关资料,MySQL提供了多个JSON函数,用于处理和查询JSON数... 目录一、jsON_EXTRACT 提取指定数据二、JSON_UNQUOTE 取消双引号三、JSON_KE

MySQL数据库函数之JSON_EXTRACT示例代码

《MySQL数据库函数之JSON_EXTRACT示例代码》:本文主要介绍MySQL数据库函数之JSON_EXTRACT的相关资料,JSON_EXTRACT()函数用于从JSON文档中提取值,支持对... 目录前言基本语法路径表达式示例示例 1: 提取简单值示例 2: 提取嵌套值示例 3: 提取数组中的值注意

C#使用DeepSeek API实现自然语言处理,文本分类和情感分析

《C#使用DeepSeekAPI实现自然语言处理,文本分类和情感分析》在C#中使用DeepSeekAPI可以实现多种功能,例如自然语言处理、文本分类、情感分析等,本文主要为大家介绍了具体实现步骤,... 目录准备工作文本生成文本分类问答系统代码生成翻译功能文本摘要文本校对图像描述生成总结在C#中使用Deep

Linux编译器--gcc/g++使用方式

《Linux编译器--gcc/g++使用方式》文章主要介绍了C/C++程序的编译过程,包括预编译、编译、汇编和链接四个阶段,并详细解释了每个阶段的作用和具体操作,同时,还介绍了调试和发布版本的概念... 目录一、预编译指令1.1预处理功能1.2指令1.3问题扩展二、编译(生成汇编)三、汇编(生成二进制机器语

Java function函数式接口的使用方法与实例

《Javafunction函数式接口的使用方法与实例》:本文主要介绍Javafunction函数式接口的使用方法与实例,函数式接口如一支未完成的诗篇,用Lambda表达式作韵脚,将代码的机械美感... 目录引言-当代码遇见诗性一、函数式接口的生物学解构1.1 函数式接口的基因密码1.2 六大核心接口的形态学

Redis主从/哨兵机制原理分析

《Redis主从/哨兵机制原理分析》本文介绍了Redis的主从复制和哨兵机制,主从复制实现了数据的热备份和负载均衡,而哨兵机制可以监控Redis集群,实现自动故障转移,哨兵机制通过监控、下线、选举和故... 目录一、主从复制1.1 什么是主从复制1.2 主从复制的作用1.3 主从复制原理1.3.1 全量复制

Redis主从复制的原理分析

《Redis主从复制的原理分析》Redis主从复制通过将数据镜像到多个从节点,实现高可用性和扩展性,主从复制包括初次全量同步和增量同步两个阶段,为优化复制性能,可以采用AOF持久化、调整复制超时时间、... 目录Redis主从复制的原理主从复制概述配置主从复制数据同步过程复制一致性与延迟故障转移机制监控与维