首页 > 代码库 > gcc源代码分析,expand_call ()函数第四部分,emit_call_1 ()函数

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

本文是为了解释下面这4个rtx是如何产生的,和emit_call_1 ()函数有关。


(const_int 4)

(mem:QI (symbol_ref/v:SI ("printf")))

(call (mem:QI (symbol_ref/v:SI ("printf")))
   (const_int 4))

(set (reg:SI 0)
   (call (mem:QI (symbol_ref/v:SI ("printf")))
       (const_int 4)))


下面是加了fprintf()函数之后的调试结果。


(const_int 4)
emit_call_1 funexp symbol_ref
before emit_call_insn

(mem:QI (symbol_ref/v:SI ("printf")))

(call (mem:QI (symbol_ref/v:SI ("printf")))
   (const_int 4))

(set (reg:SI 0)
   (call (mem:QI (symbol_ref/v:SI ("printf")))
       (const_int 4)))
emit_call_insn
after emit_call_inst
after emit_call_1
end expand_call

expand_call ()函数中的相关代码:


  if (args_size.constant < 0)
    args_size.constant = 0;
  emit_call_1 (funexp, funtype, args_size.constant,
           FUNCTION_ARG (args_so_far, VOIDmode, void_type_node, 1),
           valreg, old_inhibit_defer_pop, use_insns);

/* ???  Nothing has been done here to record control flow
   when contained functions can do nonlocal gotos.  */




static void
emit_call_1 (funexp, funtype, stack_size, next_arg_reg, valreg, old_inhibit_defer_pop, use_insns)
     rtx funexp;
     tree funtype;
     int stack_size;
     rtx next_arg_reg;
     rtx valreg;
     int old_inhibit_defer_pop;
     rtx use_insns;
{
  rtx stack_size_rtx = gen_rtx (CONST_INT, VOIDmode, stack_size);
  rtx call_insn;

  if (valreg)
    emit_call_insn (gen_call_value (valreg,
                    gen_rtx (MEM, FUNCTION_MODE, funexp),
                    stack_size_rtx, next_arg_reg));


gen_call_value ()函数在insn-emit.c文件中和

(call (mem:QI (symbol_ref/v:SI ("printf")))
   (const_int 4))

(set (reg:SI 0)
   (call (mem:QI (symbol_ref/v:SI ("printf")))
       (const_int 4)))

这2个rtx有关。

rtx

gen_call_value (operand0, operand1, operand2)
     rtx operand0;
     rtx operand1;
     rtx operand2;
{
  return gen_rtx (SET, VOIDmode, operand0, gen_rtx (CALL, VOIDmode, operand1, operand2));
}

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