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标准库常见错误分析和解决办法

《Go标准库常见错误分析和解决办法》Go语言的标准库为开发者提供了丰富且高效的工具,涵盖了从网络编程到文件操作等各个方面,然而,标准库虽好,使用不当却可能适得其反,正所谓工欲善其事,必先利其器,本文将... 目录1. 使用了错误的time.Duration2. time.After导致的内存泄漏3. jsO

Kotlin 作用域函数apply、let、run、with、also使用指南

《Kotlin作用域函数apply、let、run、with、also使用指南》在Kotlin开发中,作用域函数(ScopeFunctions)是一组能让代码更简洁、更函数式的高阶函数,本文将... 目录一、引言:为什么需要作用域函数?二、作用域函China编程数详解1. apply:对象配置的 “流式构建器”最

Spring事务中@Transactional注解不生效的原因分析与解决

《Spring事务中@Transactional注解不生效的原因分析与解决》在Spring框架中,@Transactional注解是管理数据库事务的核心方式,本文将深入分析事务自调用的底层原理,解释为... 目录1. 引言2. 事务自调用问题重现2.1 示例代码2.2 问题现象3. 为什么事务自调用会失效3

Mysql删除几亿条数据表中的部分数据的方法实现

《Mysql删除几亿条数据表中的部分数据的方法实现》在MySQL中删除一个大表中的数据时,需要特别注意操作的性能和对系统的影响,本文主要介绍了Mysql删除几亿条数据表中的部分数据的方法实现,具有一定... 目录1、需求2、方案1. 使用 DELETE 语句分批删除2. 使用 INPLACE ALTER T

找不到Anaconda prompt终端的原因分析及解决方案

《找不到Anacondaprompt终端的原因分析及解决方案》因为anaconda还没有初始化,在安装anaconda的过程中,有一行是否要添加anaconda到菜单目录中,由于没有勾选,导致没有菜... 目录问题原因问http://www.chinasem.cn题解决安装了 Anaconda 却找不到 An

Spring定时任务只执行一次的原因分析与解决方案

《Spring定时任务只执行一次的原因分析与解决方案》在使用Spring的@Scheduled定时任务时,你是否遇到过任务只执行一次,后续不再触发的情况?这种情况可能由多种原因导致,如未启用调度、线程... 目录1. 问题背景2. Spring定时任务的基本用法3. 为什么定时任务只执行一次?3.1 未启用

Android Kotlin 高阶函数详解及其在协程中的应用小结

《AndroidKotlin高阶函数详解及其在协程中的应用小结》高阶函数是Kotlin中的一个重要特性,它能够将函数作为一等公民(First-ClassCitizen),使得代码更加简洁、灵活和可... 目录1. 引言2. 什么是高阶函数?3. 高阶函数的基础用法3.1 传递函数作为参数3.2 Lambda

C++中::SHCreateDirectoryEx函数使用方法

《C++中::SHCreateDirectoryEx函数使用方法》::SHCreateDirectoryEx用于创建多级目录,类似于mkdir-p命令,本文主要介绍了C++中::SHCreateDir... 目录1. 函数原型与依赖项2. 基本使用示例示例 1:创建单层目录示例 2:创建多级目录3. 关键注

C++ 各种map特点对比分析

《C++各种map特点对比分析》文章比较了C++中不同类型的map(如std::map,std::unordered_map,std::multimap,std::unordered_multima... 目录特点比较C++ 示例代码 ​​​​​​代码解释特点比较1. std::map底层实现:基于红黑

C++中函数模板与类模板的简单使用及区别介绍

《C++中函数模板与类模板的简单使用及区别介绍》这篇文章介绍了C++中的模板机制,包括函数模板和类模板的概念、语法和实际应用,函数模板通过类型参数实现泛型操作,而类模板允许创建可处理多种数据类型的类,... 目录一、函数模板定义语法真实示例二、类模板三、关键区别四、注意事项 ‌在C++中,模板是实现泛型编程