This article is to explain how the following 4 Rtx are produced, and the Emit_call_1 () function.
(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)))
The following is the debug result after adding the fprintf () function.
(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
The relevant code in the Expand_call () function:
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 have been done here to record control flow
When the 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));
The Gen_call_value () function is in the insn-emit.c file and
(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)))
These 2 RTX related.
Rtx
Gen_call_value (Operand0, Operand1, Operand2)
RTX operand0;
RTX Operand1;
RTX Operand2;
{
ReturnGen_rtx(SET, Voidmode, Operand0,Gen_rtx(Call, Voidmode, Operand1, Operand2));
}
GCC source code Analysis, Expand_call () function Part IV, EMIT_CALL_1 () function