第一部分输入的:
;; Call subroutine returning no value.
(define_insn "call"
[(call (match_operand:QI 0 "indirect_operand" "m")
(match_operand:SI 1 "general_operand" "g"))]
;; Operand 1 not really used on the m68000.
""
"*
{
if (GET_CODE (operands[0]) == MEM
&& ! CONSTANT_ADDRESS_P (XEXP (operands[0], 0)))
{
operands[0] = XEXP (operands[0], 0);
return \"call %*%0\";
}
else
return \"call %0\";
}")
;; Call subroutine, returning value in operand 0
;; (which must be a hard register).
(define_insn "call_value"
[(set (match_operand 0 "" "=rf")
(call (match_operand:QI 1 "indirect_operand" "m")
(match_operand:SI 2 "general_operand" "g")))]
;; Operand 2 not really used on the m68000.
""
"*
{
if (GET_CODE (operands[1]) == MEM
&& ! CONSTANT_ADDRESS_P (XEXP (operands[1], 0)))
{
operands[1] = XEXP (operands[1], 0);
output_asm_insn (\"call %*%1\", operands);
}
else
output_asm_insn (\"call %1\", operands);
if (GET_MODE (operands[0]) == DFmode
|| GET_MODE (operands[0]) == SFmode)
{
/* fp_pop_level++; */
/* pop if reg dead */
if (!FP_REG_P (operands[0]))
abort ();
if (top_dead_p (insn))
{
POP_ONE_FP;
}
}
RET;
}")
(define_insn "nop"
[(const_int 0)]
""
"nop")
第二部分是生成的:
rtx
gen_call (operand0, operand1)
在编译gcc的时候先生成可执行文件genemit,然后再由genemit和i386.md生成insn-emit.c文件。
也就是在编译之前没有insn-*文件,编译之后就有了insn-*文件。
那么hello.s文件和i386.md就没有关系了,和insn-* 文件有关。
还是把main函数列出来:
int
main (argc, argv)
int argc;
char **argv;
{
rtx desc;
FILE *infile;
extern rtx read_rtx ();
register int c;
obstack_init (rtl_obstack);
if (argc <= 1)
fatal ("No input file name.");
infile = fopen (argv[1], "r");
if (infile == 0)
{
perror (argv[1]);
exit (FATAL_EXIT_CODE);
}
init_rtl ();
/* Assign sequential codes to all entries in the machine description
in parallel with the tables in insn-output.c. */
insn_code_number = 0;
printf ("/* Generated automatically by the program `genemit'\n\
from the machine description file `md'. */\n\n");
printf ("#include \"config.h\"\n");
printf ("#include \"rtl.h\"\n");
printf ("#include \"expr.h\"\n");
printf ("#include \"real.h\"\n");
printf ("#include \"insn-config.h\"\n\n");
printf ("#include \"insn-flags.h\"\n\n");
printf ("extern char *insn_operand_constraint[][MAX_RECOG_OPERANDS];\n\n");
printf ("extern rtx recog_operand[];\n");
printf ("#define operands emit_operand\n\n");
printf ("#define FAIL do { end_sequence (); return 0;} while (0)\n\n");
printf ("#define DONE goto _done\n\n");
/* Read the machine description. */
while (1)
{
c = read_skip_spaces (infile);
if (c == EOF)
break;
ungetc (c, infile);
desc = read_rtx (infile);
if (GET_CODE (desc) == DEFINE_INSN)
{
gen_insn (desc);
++insn_code_number;
}
if (GET_CODE (desc) == DEFINE_EXPAND)
{
gen_expand (desc);
++insn_code_number;
}
if (GET_CODE (desc) == DEFINE_PEEPHOLE)
{
++insn_code_number;
}
}
fflush (stdout);
exit (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
}