gcc源代码分析,end_final()函数把insn转化成汇编代码
2014-01-13 18:24
615 查看
end_final()函数在toplev.c里面被调用。定义在final.c文件里。
end_final (main_input_filename);
final()函数:
void
final (first, file, write_symbols, optimize, prescan)
rtx first;
FILE *file;
enum debugger write_symbols;
int optimize;
int prescan;
{
register rtx insn;
last_ignored_compare = 0;
new_block = 1;
init_recog ();
CC_STATUS_INIT;
for (insn = NEXT_INSN (first); insn;)
insn = final_scan_insn (insn, file, write_symbols, optimize,
prescan, 0);
}
可以看出这是最后一遍处理。
final_scan_insn ( )函数关键代码:
/* Try to recognize the instruction.
If successful, verify that the operands satisfy the
constraints for the instruction. Crash if they don't,
since `reload' should have changed them so that they do. */
insn_code_number = recog_memoized (insn);
insn_extract (insn);
for (i = 0; i < insn_n_operands[insn_code_number]; i++)
{
if (GET_CODE (recog_operand[i]) == SUBREG)
recog_operand[i] = alter_subreg (recog_operand[i]);
}
/*insn_n_operands[140]=3,紧接着的insn_template[140]=0*/
template = insn_template[insn_code_number];
if (template == 0)
{
template = (*insn_outfun[insn_code_number]) (recog_operand, insn);
/* If the C code returns 0, it means that it is a jump insn
which follows a deleted test insn, and that test insn
needs to be reinserted. */
if (template == 0)
{
if (PREV_INSN (insn) != last_ignored_compare)
abort ();
new_block = 0;
return PREV_INSN (insn);
}
}
if (prescan > 0)
break;
/* Output assembler code from the template. */
output_asm_insn (template, recog_operand);
/* Mark this insn as having been output. */
INSN_DELETED_P (insn) = 1;
}
}
return NEXT_INSN (insn);
}
/*template = (*insn_outfun[140]) (recog_operand, insn);
/*template = output_140 (recog_operand, insn);
recog_operand[]数组是比较重要的数组,和insn_extract()函数产生,用于output_asm_insn()函数,还有这里的(*insn_outfun[insn_code_number])函数。
end_final (main_input_filename);
final()函数:
void
final (first, file, write_symbols, optimize, prescan)
rtx first;
FILE *file;
enum debugger write_symbols;
int optimize;
int prescan;
{
register rtx insn;
last_ignored_compare = 0;
new_block = 1;
init_recog ();
CC_STATUS_INIT;
for (insn = NEXT_INSN (first); insn;)
insn = final_scan_insn (insn, file, write_symbols, optimize,
prescan, 0);
}
可以看出这是最后一遍处理。
final_scan_insn ( )函数关键代码:
/* Try to recognize the instruction.
If successful, verify that the operands satisfy the
constraints for the instruction. Crash if they don't,
since `reload' should have changed them so that they do. */
insn_code_number = recog_memoized (insn);
insn_extract (insn);
for (i = 0; i < insn_n_operands[insn_code_number]; i++)
{
if (GET_CODE (recog_operand[i]) == SUBREG)
recog_operand[i] = alter_subreg (recog_operand[i]);
}
/*insn_n_operands[140]=3,紧接着的insn_template[140]=0*/
template = insn_template[insn_code_number];
if (template == 0)
{
template = (*insn_outfun[insn_code_number]) (recog_operand, insn);
/* If the C code returns 0, it means that it is a jump insn
which follows a deleted test insn, and that test insn
needs to be reinserted. */
if (template == 0)
{
if (PREV_INSN (insn) != last_ignored_compare)
abort ();
new_block = 0;
return PREV_INSN (insn);
}
}
if (prescan > 0)
break;
/* Output assembler code from the template. */
output_asm_insn (template, recog_operand);
/* Mark this insn as having been output. */
INSN_DELETED_P (insn) = 1;
}
}
return NEXT_INSN (insn);
}
/*template = (*insn_outfun[140]) (recog_operand, insn);
/*template = output_140 (recog_operand, insn);
recog_operand[]数组是比较重要的数组,和insn_extract()函数产生,用于output_asm_insn()函数,还有这里的(*insn_outfun[insn_code_number])函数。
相关文章推荐
- gcc源代码分析,insn_extract()函数和recog_operand[]数组的关系
- gcc源代码分析gen_push_operand ()函数和emit_move_insn ()函数
- gcc源代码分析emit_call_insn()函数
- gcc源代码分析,debug_tree()函数的利用
- 函数调用汇编代码分析
- GCC Coverage代码分析-GCC插桩前后汇编代码对比分析
- Gcc源代码分析,insn和rtx的关系
- 反汇编时的函数识别及各函数调用约定的汇编代码分析
- 函数调用过程-汇编代码分析
- gcc源代码分析,get_parm_info ()函数分析
- GCC Coverage代码分析-GCC插桩前后汇编代码对比分析
- 汇编代码分析----函数的调用堆栈过程(进程内核栈的切换过程)
- gcc源代码分析,expand_call()函数第三部分
- gcc源代码分析,expand_call ()函数分析第五部分,store_one_arg ()函数
- linux 内核源代码情景分析——linux 内核源码中的汇编语言代码
- gcc源代码分析之gen_call_value()函数
- gcc源代码分析,build_pointer_type ()函数分析
- gcc源代码分析,finish_decl ()函数和rest_of_decl_compilation ()函数分析
- gcc源代码分析,finish_decl ()函数和push_parm_decl ()函数分析
- MDK main()函数执行前汇编代码分析