Mercurial > hg > CbC > CbC_gcc
diff gcc/genpeep.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | f6334be47118 |
children | 84e7813d76e9 |
line wrap: on
line diff
--- a/gcc/genpeep.c Sun Aug 21 07:07:55 2011 +0900 +++ b/gcc/genpeep.c Fri Oct 27 22:46:09 2017 +0900 @@ -1,6 +1,5 @@ /* Generate code from machine description to perform peephole optimizations. - Copyright (C) 1987, 1989, 1992, 1997, 1998, 1999, 2000, 2003, 2004, - 2007, 2010 Free Software Foundation, Inc. + Copyright (C) 1987-2017 Free Software Foundation, Inc. This file is part of GCC. @@ -47,19 +46,14 @@ static int n_operands; -/* Peephole optimizations get insn codes just like insn patterns. - Count them so we know the code of the define_peephole we are handling. */ - -static int insn_code_number = 0; - -static void gen_peephole (rtx); static void match_rtx (rtx, struct link *, int); static void print_path (struct link *); static void print_code (RTX_CODE); static void -gen_peephole (rtx peep) +gen_peephole (md_rtx_info *info) { + rtx peep = info->def; int ninsns = XVECLEN (peep, 0); int i; @@ -72,16 +66,14 @@ if (i > 0) { printf (" do { insn = NEXT_INSN (insn);\n"); - printf (" if (insn == 0) goto L%d; }\n", - insn_code_number); + printf (" if (insn == 0) goto L%d; }\n", info->index); printf (" while (NOTE_P (insn)\n"); printf ("\t || (NONJUMP_INSN_P (insn)\n"); printf ("\t && (GET_CODE (PATTERN (insn)) == USE\n"); printf ("\t\t || GET_CODE (PATTERN (insn)) == CLOBBER)));\n"); printf (" if (LABEL_P (insn)\n\ - || BARRIER_P (insn))\n goto L%d;\n", - insn_code_number); + || BARRIER_P (insn))\n goto L%d;\n", info->index); } printf (" pat = PATTERN (insn);\n"); @@ -89,7 +81,7 @@ /* Walk the insn's pattern, remembering at all times the path down to the walking point. */ - match_rtx (XVECEXP (peep, 0, i), NULL, insn_code_number); + match_rtx (XVECEXP (peep, 0, i), NULL, info->index); } /* We get this far if the pattern matches. @@ -97,7 +89,7 @@ if (XSTR (peep, 1) && XSTR (peep, 1)[0]) printf (" if (! (%s)) goto L%d;\n", - XSTR (peep, 1), insn_code_number); + XSTR (peep, 1), info->index); /* If that matches, construct new pattern and put it in the first insn. This new pattern will never be matched. @@ -109,8 +101,7 @@ /* Record this define_peephole's insn code in the insn, as if it had been recognized to match this. */ - printf (" INSN_CODE (ins1) = %d;\n", - insn_code_number); + printf (" INSN_CODE (ins1) = %d;\n", info->index); /* Delete the remaining insns. */ if (ninsns > 1) @@ -120,7 +111,7 @@ cannot be zero. */ printf (" return NEXT_INSN (insn);\n"); - printf (" L%d:\n\n", insn_code_number); + printf (" L%d:\n\n", info->index); } static void @@ -231,10 +222,6 @@ } return; - case ADDRESS: - match_rtx (XEXP (x, 0), path, fail_label); - return; - default: break; } @@ -286,6 +273,12 @@ printf (" if (XINT (x, %d) != %d) goto L%d;\n", i, XINT (x, i), fail_label); } + else if (fmt[i] == 'r') + { + gcc_assert (i == 0); + printf (" if (REGNO (x) != %d) goto L%d;\n", + REGNO (x), fail_label); + } else if (fmt[i] == 'w') { /* Make sure that at run time `x' is the RTX we want to test. */ @@ -344,16 +337,14 @@ { const char *p1; for (p1 = GET_RTX_NAME (code); *p1; p1++) - putchar (TOUPPER(*p1)); + putchar (TOUPPER (*p1)); } -extern int main (int, char **); +extern int main (int, const char **); int -main (int argc, char **argv) +main (int argc, const char **argv) { - rtx desc; - max_opno = -1; progname = "genpeep"; @@ -367,25 +358,30 @@ printf ("#include \"config.h\"\n"); printf ("#include \"system.h\"\n"); printf ("#include \"coretypes.h\"\n"); - printf ("#include \"tm.h\"\n"); + printf ("#include \"backend.h\"\n"); + printf ("#include \"tree.h\"\n"); + printf ("#include \"rtl.h\"\n"); printf ("#include \"insn-config.h\"\n"); - printf ("#include \"rtl.h\"\n"); + printf ("#include \"alias.h\"\n"); + printf ("#include \"varasm.h\"\n"); + printf ("#include \"stor-layout.h\"\n"); + printf ("#include \"calls.h\"\n"); + printf ("#include \"memmodel.h\"\n"); printf ("#include \"tm_p.h\"\n"); printf ("#include \"regs.h\"\n"); printf ("#include \"output.h\"\n"); printf ("#include \"recog.h\"\n"); printf ("#include \"except.h\"\n"); - printf ("#include \"function.h\"\n"); printf ("#include \"diagnostic-core.h\"\n"); printf ("#include \"flags.h\"\n"); printf ("#include \"tm-constrs.h\"\n\n"); - printf ("#ifdef HAVE_peephole\n"); printf ("extern rtx peep_operand[];\n\n"); printf ("#define operands peep_operand\n\n"); - printf ("rtx\npeephole (rtx ins1)\n{\n"); - printf (" rtx insn ATTRIBUTE_UNUSED, x ATTRIBUTE_UNUSED, pat ATTRIBUTE_UNUSED;\n\n"); + printf ("rtx_insn *\npeephole (rtx_insn *ins1)\n{\n"); + printf (" rtx_insn *insn ATTRIBUTE_UNUSED;\n"); + printf (" rtx x ATTRIBUTE_UNUSED, pat ATTRIBUTE_UNUSED;\n\n"); /* Early out: no peepholes for insns followed by barriers. */ printf (" if (NEXT_INSN (ins1)\n"); @@ -394,27 +390,17 @@ /* Read the machine description. */ - while (1) - { - int line_no, rtx_number = 0; - - desc = read_md_rtx (&line_no, &rtx_number); - if (desc == NULL) + md_rtx_info info; + while (read_md_rtx (&info)) + switch (GET_CODE (info.def)) + { + case DEFINE_PEEPHOLE: + gen_peephole (&info); break; - if (GET_CODE (desc) == DEFINE_PEEPHOLE) - { - gen_peephole (desc); - insn_code_number++; - } - if (GET_CODE (desc) == DEFINE_INSN - || GET_CODE (desc) == DEFINE_EXPAND - || GET_CODE (desc) == DEFINE_SPLIT - || GET_CODE (desc) == DEFINE_PEEPHOLE2) - { - insn_code_number++; - } - } + default: + break; + } printf (" return 0;\n}\n\n"); @@ -422,7 +408,6 @@ max_opno = 1; printf ("rtx peep_operand[%d];\n", max_opno + 1); - printf ("#endif\n"); fflush (stdout); return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);