gcc/gcc/genrecog.c

2900 lines
75 KiB
C
Raw Normal View History

1991-11-24 20:57:16 +01:00
/* Generate code from machine description to recognize rtl as insns.
2000-02-26 14:55:09 +01:00
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1997, 1998,
1999, 2000, 2001, 2002 Free Software Foundation, Inc.
1991-11-24 20:57:16 +01:00
Makefile.in, [...]: replace "GNU CC" with "GCC". * Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c, bitmap.h, builtin-types.def, builtins.c, builtins.def, c-aux-info.c, c-common.c, c-common.def, c-common.h, c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c, c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in, c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c, caller-save.c, calls.c, collect2.c, collect2.h, combine.c, conditions.h, config.gcc, configure.frag, configure.in, conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c, cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h, dependence.c, df.c, df.h, diagnostic.c, diagnostic.h, doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c, dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c, emit-rtl.c, errors.c, errors.h, except.c, except.h, exgettext, explow.c, expmed.c, expr.c, expr.h, final.c, fixproto, flags.h, flow.c, fold-const.c, fp-test.c, function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp, gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c, gencheck.c, gencodes.c, genconfig.c, genemit.c, genextract.c, genflags.c, gengenrtl.c, genmultilib, genopinit.c, genoutput.c, genpeep.c, genrecog.c, gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c, ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c, graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h, gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h, gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h, hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h, integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c, libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h, machmode.def, machmode.h, main.c, mbchar.c, mbchar.h, mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk, mkmap-symver.awk, optabs.c, output.h, params.c, params.def, params.h, predict.c, predict.def, predict.h, prefix.c, prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c, read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c, regclass.c, regmove.c, regrename.c, regs.h, reload.c, reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c, rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h, sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c, sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c, ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c, stringpool.c, system.h, timevar.c, timevar.def, timevar.h, tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h, tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h, unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h, unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c, xcoffout.h: replace "GNU CC" with "GCC". From-SVN: r45105
2001-08-22 16:35:51 +02:00
This file is part of GCC.
Makefile.in, [...]: replace "GNU CC" with "GCC". * Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c, bitmap.h, builtin-types.def, builtins.c, builtins.def, c-aux-info.c, c-common.c, c-common.def, c-common.h, c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c, c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in, c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c, caller-save.c, calls.c, collect2.c, collect2.h, combine.c, conditions.h, config.gcc, configure.frag, configure.in, conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c, cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h, dependence.c, df.c, df.h, diagnostic.c, diagnostic.h, doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c, dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c, emit-rtl.c, errors.c, errors.h, except.c, except.h, exgettext, explow.c, expmed.c, expr.c, expr.h, final.c, fixproto, flags.h, flow.c, fold-const.c, fp-test.c, function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp, gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c, gencheck.c, gencodes.c, genconfig.c, genemit.c, genextract.c, genflags.c, gengenrtl.c, genmultilib, genopinit.c, genoutput.c, genpeep.c, genrecog.c, gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c, ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c, graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h, gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h, gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h, hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h, integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c, libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h, machmode.def, machmode.h, main.c, mbchar.c, mbchar.h, mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk, mkmap-symver.awk, optabs.c, output.h, params.c, params.def, params.h, predict.c, predict.def, predict.h, prefix.c, prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c, read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c, regclass.c, regmove.c, regrename.c, regs.h, reload.c, reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c, rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h, sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c, sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c, ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c, stringpool.c, system.h, timevar.c, timevar.def, timevar.h, tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h, tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h, unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h, unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c, xcoffout.h: replace "GNU CC" with "GCC". From-SVN: r45105
2001-08-22 16:35:51 +02:00
GCC is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
Makefile.in, [...]: replace "GNU CC" with "GCC". * Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c, bitmap.h, builtin-types.def, builtins.c, builtins.def, c-aux-info.c, c-common.c, c-common.def, c-common.h, c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c, c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in, c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c, caller-save.c, calls.c, collect2.c, collect2.h, combine.c, conditions.h, config.gcc, configure.frag, configure.in, conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c, cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h, dependence.c, df.c, df.h, diagnostic.c, diagnostic.h, doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c, dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c, emit-rtl.c, errors.c, errors.h, except.c, except.h, exgettext, explow.c, expmed.c, expr.c, expr.h, final.c, fixproto, flags.h, flow.c, fold-const.c, fp-test.c, function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp, gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c, gencheck.c, gencodes.c, genconfig.c, genemit.c, genextract.c, genflags.c, gengenrtl.c, genmultilib, genopinit.c, genoutput.c, genpeep.c, genrecog.c, gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c, ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c, graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h, gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h, gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h, hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h, integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c, libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h, machmode.def, machmode.h, main.c, mbchar.c, mbchar.h, mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk, mkmap-symver.awk, optabs.c, output.h, params.c, params.def, params.h, predict.c, predict.def, predict.h, prefix.c, prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c, read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c, regclass.c, regmove.c, regrename.c, regs.h, reload.c, reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c, rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h, sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c, sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c, ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c, stringpool.c, system.h, timevar.c, timevar.def, timevar.h, tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h, tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h, unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h, unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c, xcoffout.h: replace "GNU CC" with "GCC". From-SVN: r45105
2001-08-22 16:35:51 +02:00
GCC is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
Makefile.in, [...]: replace "GNU CC" with "GCC". * Makefile.in, alias.c, basic-block.h, bb-reorder.c, bitmap.c, bitmap.h, builtin-types.def, builtins.c, builtins.def, c-aux-info.c, c-common.c, c-common.def, c-common.h, c-convert.c, c-decl.c, c-dump.c, c-dump.h, c-errors.c, c-format.c, c-lang.c, c-lex.c, c-lex.h, c-parse.in, c-pragma.c, c-pragma.h, c-semantics.c, c-tree.h, c-typeck.c, caller-save.c, calls.c, collect2.c, collect2.h, combine.c, conditions.h, config.gcc, configure.frag, configure.in, conflict.c, convert.c, convert.h, cppspec.c, crtstuff.c, cse.c, cselib.c, cselib.h, dbxout.c, dbxout.h, defaults.h, dependence.c, df.c, df.h, diagnostic.c, diagnostic.h, doloop.c, dominance.c, dwarf.h, dwarf2.h, dwarf2asm.c, dwarf2asm.h, dwarf2out.c, dwarf2out.h, dwarfout.c, emit-rtl.c, errors.c, errors.h, except.c, except.h, exgettext, explow.c, expmed.c, expr.c, expr.h, final.c, fixproto, flags.h, flow.c, fold-const.c, fp-test.c, function.c, function.h, gbl-ctors.h, gcc.c, gcc.h, gcc.hlp, gccspec.c, gcov-io.h, gcse.c, genattr.c, genattrtab.c, gencheck.c, gencodes.c, genconfig.c, genemit.c, genextract.c, genflags.c, gengenrtl.c, genmultilib, genopinit.c, genoutput.c, genpeep.c, genrecog.c, gensupport.c, gensupport.h, ggc-callbacks.c, ggc-common.c, ggc-none.c, ggc-page.c, ggc-simple.c, ggc.h, global.c, graph.c, graph.h, gthr-aix.h, gthr-dce.h, gthr-posix.h, gthr-rtems.h, gthr-single.h, gthr-solaris.h, gthr-vxworks.h, gthr-win32.h, gthr.h, haifa-sched.c, halfpic.c, halfpic.h, hard-reg-set.h, hwint.h, ifcvt.c, input.h, insn-addr.h, integrate.c, integrate.h, jump.c, lcm.c, libgcc2.c, libgcc2.h, lists.c, local-alloc.c, loop.c, loop.h, machmode.def, machmode.h, main.c, mbchar.c, mbchar.h, mips-tdump.c, mips-tfile.c, mklibgcc.in, mkmap-flat.awk, mkmap-symver.awk, optabs.c, output.h, params.c, params.def, params.h, predict.c, predict.def, predict.h, prefix.c, prefix.h, print-rtl.c, print-tree.c, profile.c, protoize.c, read-rtl.c, real.c, real.h, recog.c, recog.h, reg-stack.c, regclass.c, regmove.c, regrename.c, regs.h, reload.c, reload.h, reload1.c, reorg.c, resource.c, resource.h, rtl.c, rtl.def, rtl.h, rtlanal.c, sbitmap.c, sbitmap.h, sched-deps.c, sched-ebb.c, sched-int.h, sched-rgn.c, sched-vis.c, sdbout.c, sdbout.h, sibcall.c, simplify-rtx.c, ssa-ccp.c, ssa-dce.c, ssa.c, ssa.h, stmt.c, stor-layout.c, stringpool.c, system.h, timevar.c, timevar.def, timevar.h, tlink.c, toplev.c, toplev.h, tree.c, tree.def, tree.h, tsystem.h, unroll.c, unwind-dw2-fde.c, unwind-dw2-fde.h, unwind-dw2.c, unwind-pe.h, unwind-sjlj.c, unwind.h, unwind.inc, varasm.c, varray.c, varray.h, xcoffout.c, xcoffout.h: replace "GNU CC" with "GCC". From-SVN: r45105
2001-08-22 16:35:51 +02:00
along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
/* This program is used to produce insn-recog.c, which contains a
function called `recog' plus its subroutines. These functions
contain a decision tree that recognizes whether an rtx, the
argument given to recog, is a valid instruction.
recog returns -1 if the rtx is not valid. If the rtx is valid,
recog returns a nonnegative number which is the insn code number
for the pattern that matched. This is the same as the order in the
machine description of the entry that matched. This number can be
used as an index into various insn_* tables, such as insn_template,
insn_outfun, and insn_n_operands (found in insn-output.c).
The third argument to recog is an optional pointer to an int. If
present, recog will accept a pattern if it matches except for
1991-11-24 20:57:16 +01:00
missing CLOBBER expressions at the end. In that case, the value
pointed to by the optional pointer will be set to the number of
CLOBBERs that need to be added (it should be initialized to zero by
the caller). If it is set nonzero, the caller should allocate a
PARALLEL of the appropriate size, copy the initial entries, and
call add_clobbers (found in insn-emit.c) to fill in the CLOBBERs.
1991-11-24 20:57:16 +01:00
This program also generates the function `split_insns', which
returns 0 if the rtl could not be split, or it returns the split
Delete SEQUENCE rtl usage outside of reorg and ssa passes. 2002-06-05 David S. Miller <davem@redhat.com> Delete SEQUENCE rtl usage outside of reorg and ssa passes. * rtl.h (gen_sequence, emit_insns, emit_insns_before, emit_insns_before_scope, emit_insns_after, emit_insns_after_scope): Delete declaration. * ada/misc.c (insert_code_for): Use emit_insn* instead of emit_insns_foo. * config/alpha/alpha.c (alpha_set_memflags_1): Abort on SEQUENCE. (alpha_set_memflags): Fix comment. (set_frame_related_p): Use get_insns instead of gen_sequence. * config/alpha/alpha.md (setjmp receiver splitter): Avoid emitting no insns. * config/arm/arm.c (arm_finalize_pic): Use get_insns instead of gen_sequence. (arm_gen_load_multiple, arm_gen_store_multiple): Likewise. * config/fr30/fr30.c (fr30_move_double): Likewise. * config/i386/i386.c (ix86_expand_int_movcc, ix86_expand_movstr): Likewise. * config/ia64/ia64.c (spill_restore_mem): Likewise. * config/ia64/ia64.md (conditional move spliiter): Avoid emitting no insns. * config/m32r/m32r.c (gen_split_move_double): Use get_insns instead of gen_sequence. * config/mips/mips.c (embedded_pic_fnaddr_reg): Likewise. (mips_expand_prologue, mips16_gp_pseudo_reg): Likewise. * config/sh/sh.c (sh_need_epilogue): Likewise. * config/sparc/sparc.md (current_function_calls_alloca, flat): New attributes. (setjmp pattern and split): Use them to avoid splitter which emits no RTL. * genattrtab.c (main): Emit include of function.h * config/stormy16/stormy16.c (xstormy16_split_cbranch): Use get_insns instead of gen_sequence. * config/cris/cris.c (cris_split_movdx): Likewise. * emit-rtl.c (emit_insns*): Kill. (try_split): Expect insn list instead of SEQUENCE. (make_jump_insn_raw, make_call_insn_raw): Fix comments. (emit_*insn*): Reimplement to work with INSN lists and PATTERNs. Make them abort if a SEQUENCE is given and RTL checking is enabled. (emit_*_scope): Don't forget to set scope on final insn. (gen_sequence): Move from here... * ssa.c (gen_sequence): To here as private function. * builtins.c (expand_builtin_apply_args): Use emit_insn_foo, fix comments. (expand_builtin_return, expand_builtin_mathfn): Likewise. (expand_builtin_strlen): Use get_insns instead of gen_sequence. (expand_builtin_saveregs): Use emit_insn_foo, fix comments. (expand_builtin_expect_jump): Use get_insns and fix comments. * calls.c (try_to_integrate): Use emit_insn_foo. (expand_call, emit_library_call_value_1): Likewise. * expr.c (emit_queue): Handle insn lists instead of SEQUENCE. (emit_move_insn_1): Use get_insns instead of gen_sequence. (expand_expr): Use emit_insn_foo. * cfgrtl.c (commit_one_edge_insertion): Use emit_insn_foo. * except.c (build_post_landing_pads): Likewise. * flow.c (attempt_auto_inc): Likewise. * stmt.c (expand_fixup, fixup_gotos, expand_nl_handler_label, expand_nl_goto_receivers, expand_decl_cleanup): Likewise. * function.c (fixup_var_refs_insn): Use get_insns instead of gen_sequence. (fixup_var_refs_1): Likewise and expect insn list from gen_foo. (fixup_memory_subreg): Use get_insns instead of gen_sequence. (fixup_stack_1, purge_addressof_1, expand_main_function, get_arg_pointer_save_area): Likewise. (optimize_bit_field, instantiate_virtual_regs_1, assign_parms, expand_function_end): Use emit_insn_foo. (record_insns, keep_stack_depressed): Work with insn list instead of SEQUENCE, fix comments. * ifcvt.c (noce_emit_store_flag, noce_try_store_flag, noce_try_store_flag_constants, noce_try_store_flag_inc, noce_try_store_flag_mask, noce_emit_cmove, noce_try_cmove_arith, noce_try_minmax, noce_try_abs): Use emit_insn_foo. (noce_process_if_block): Use get_insns instead of gen_sequence. * optabs.c (add_equal_note): Work with insn list, fix comments. (expand_binop): Expect insn list from GEN_FCN(), use emit_insn_foo. (expand_unop, expand_complex_abs, expand_unop_insn, expand_no_conflict_block): Likewise. (gen_move_insn): Use get_insns instead of gen_sequence. (gen_cond_trap): Likewise. * integrate.c (copy_rtx_and_substitute): Likewise. (emit_initial_value_sets): Use emit_insn_foo. * reload1.c (emit_output_reload_insns, emit_reload_insns): Likewise. (fixup_abnormal_edges): Avoid losing REG_NOTES more intelligently now that RTL generators give insn lists. * sibcall.c (replace_call_placeholder): Use emit_insn_foo. * doloop.c (doloop_modify, doloop_modify_runtime): Use get_insns instead of gen_sequence. (doloop_optimize): Work with insn lists instead of SEQUENCE rtl. * explow.c (emit_stack_save, emit_stack_restore): Use get_insns instead of gen_sequence. * loop.c (move_movables, emit_prefetch_instructions, gen_add_mult, check_dbra_loop, gen_load_of_final_value): Likewise. (loop_regs_update): Work with insn list instead of SEQUENCE rtl. (product_cheap_p): Likewise, and add commentary about RTL wastage here. * lcm.c (optimize_mode_switching): Use get_insns instead of gen_sequence. * profile.c (gen_edge_profiler): Likewise. * regmove.c (copy_src_to_dest): Likewise. * reg-stack.c (compensate_edge): Likewise and fix comment. * gcse.c (process_insert_insn): Likewise. (insert_insn_end_bb): Work with insn list instead of SEQUENCE rtl. * jump.c (delete_prior_computation): Update comment. * genemit.c (gen_expand, gen_split, main): Use get_insns instead of gen_sequence, update comments to match. * recog.c (peephole2_optimize): Work with insn lists instead of SEQUENCE rtl. * sched-vis.c (print_pattern): Abort on SEQUENCE. * unroll.c (unroll_loop, find_splittable_givs, final_giv_value): Use get_insns instead of gen_sequence. (copy_loop_body): Likewise and don't emit dummy NOTE. * genrecog.c: Don't mention SEQUENCE rtl in comments. * combine.c (try_combine): Expect insn lists from split generator. * reorg.c (relax_delay_slots): Emit SEQUENCE into insn list by hand. From-SVN: r54497
2002-06-11 14:22:48 +02:00
rtl as an INSN list.
This program also generates the function `peephole2_insns', which
returns 0 if the rtl could not be matched. If there was a match,
Delete SEQUENCE rtl usage outside of reorg and ssa passes. 2002-06-05 David S. Miller <davem@redhat.com> Delete SEQUENCE rtl usage outside of reorg and ssa passes. * rtl.h (gen_sequence, emit_insns, emit_insns_before, emit_insns_before_scope, emit_insns_after, emit_insns_after_scope): Delete declaration. * ada/misc.c (insert_code_for): Use emit_insn* instead of emit_insns_foo. * config/alpha/alpha.c (alpha_set_memflags_1): Abort on SEQUENCE. (alpha_set_memflags): Fix comment. (set_frame_related_p): Use get_insns instead of gen_sequence. * config/alpha/alpha.md (setjmp receiver splitter): Avoid emitting no insns. * config/arm/arm.c (arm_finalize_pic): Use get_insns instead of gen_sequence. (arm_gen_load_multiple, arm_gen_store_multiple): Likewise. * config/fr30/fr30.c (fr30_move_double): Likewise. * config/i386/i386.c (ix86_expand_int_movcc, ix86_expand_movstr): Likewise. * config/ia64/ia64.c (spill_restore_mem): Likewise. * config/ia64/ia64.md (conditional move spliiter): Avoid emitting no insns. * config/m32r/m32r.c (gen_split_move_double): Use get_insns instead of gen_sequence. * config/mips/mips.c (embedded_pic_fnaddr_reg): Likewise. (mips_expand_prologue, mips16_gp_pseudo_reg): Likewise. * config/sh/sh.c (sh_need_epilogue): Likewise. * config/sparc/sparc.md (current_function_calls_alloca, flat): New attributes. (setjmp pattern and split): Use them to avoid splitter which emits no RTL. * genattrtab.c (main): Emit include of function.h * config/stormy16/stormy16.c (xstormy16_split_cbranch): Use get_insns instead of gen_sequence. * config/cris/cris.c (cris_split_movdx): Likewise. * emit-rtl.c (emit_insns*): Kill. (try_split): Expect insn list instead of SEQUENCE. (make_jump_insn_raw, make_call_insn_raw): Fix comments. (emit_*insn*): Reimplement to work with INSN lists and PATTERNs. Make them abort if a SEQUENCE is given and RTL checking is enabled. (emit_*_scope): Don't forget to set scope on final insn. (gen_sequence): Move from here... * ssa.c (gen_sequence): To here as private function. * builtins.c (expand_builtin_apply_args): Use emit_insn_foo, fix comments. (expand_builtin_return, expand_builtin_mathfn): Likewise. (expand_builtin_strlen): Use get_insns instead of gen_sequence. (expand_builtin_saveregs): Use emit_insn_foo, fix comments. (expand_builtin_expect_jump): Use get_insns and fix comments. * calls.c (try_to_integrate): Use emit_insn_foo. (expand_call, emit_library_call_value_1): Likewise. * expr.c (emit_queue): Handle insn lists instead of SEQUENCE. (emit_move_insn_1): Use get_insns instead of gen_sequence. (expand_expr): Use emit_insn_foo. * cfgrtl.c (commit_one_edge_insertion): Use emit_insn_foo. * except.c (build_post_landing_pads): Likewise. * flow.c (attempt_auto_inc): Likewise. * stmt.c (expand_fixup, fixup_gotos, expand_nl_handler_label, expand_nl_goto_receivers, expand_decl_cleanup): Likewise. * function.c (fixup_var_refs_insn): Use get_insns instead of gen_sequence. (fixup_var_refs_1): Likewise and expect insn list from gen_foo. (fixup_memory_subreg): Use get_insns instead of gen_sequence. (fixup_stack_1, purge_addressof_1, expand_main_function, get_arg_pointer_save_area): Likewise. (optimize_bit_field, instantiate_virtual_regs_1, assign_parms, expand_function_end): Use emit_insn_foo. (record_insns, keep_stack_depressed): Work with insn list instead of SEQUENCE, fix comments. * ifcvt.c (noce_emit_store_flag, noce_try_store_flag, noce_try_store_flag_constants, noce_try_store_flag_inc, noce_try_store_flag_mask, noce_emit_cmove, noce_try_cmove_arith, noce_try_minmax, noce_try_abs): Use emit_insn_foo. (noce_process_if_block): Use get_insns instead of gen_sequence. * optabs.c (add_equal_note): Work with insn list, fix comments. (expand_binop): Expect insn list from GEN_FCN(), use emit_insn_foo. (expand_unop, expand_complex_abs, expand_unop_insn, expand_no_conflict_block): Likewise. (gen_move_insn): Use get_insns instead of gen_sequence. (gen_cond_trap): Likewise. * integrate.c (copy_rtx_and_substitute): Likewise. (emit_initial_value_sets): Use emit_insn_foo. * reload1.c (emit_output_reload_insns, emit_reload_insns): Likewise. (fixup_abnormal_edges): Avoid losing REG_NOTES more intelligently now that RTL generators give insn lists. * sibcall.c (replace_call_placeholder): Use emit_insn_foo. * doloop.c (doloop_modify, doloop_modify_runtime): Use get_insns instead of gen_sequence. (doloop_optimize): Work with insn lists instead of SEQUENCE rtl. * explow.c (emit_stack_save, emit_stack_restore): Use get_insns instead of gen_sequence. * loop.c (move_movables, emit_prefetch_instructions, gen_add_mult, check_dbra_loop, gen_load_of_final_value): Likewise. (loop_regs_update): Work with insn list instead of SEQUENCE rtl. (product_cheap_p): Likewise, and add commentary about RTL wastage here. * lcm.c (optimize_mode_switching): Use get_insns instead of gen_sequence. * profile.c (gen_edge_profiler): Likewise. * regmove.c (copy_src_to_dest): Likewise. * reg-stack.c (compensate_edge): Likewise and fix comment. * gcse.c (process_insert_insn): Likewise. (insert_insn_end_bb): Work with insn list instead of SEQUENCE rtl. * jump.c (delete_prior_computation): Update comment. * genemit.c (gen_expand, gen_split, main): Use get_insns instead of gen_sequence, update comments to match. * recog.c (peephole2_optimize): Work with insn lists instead of SEQUENCE rtl. * sched-vis.c (print_pattern): Abort on SEQUENCE. * unroll.c (unroll_loop, find_splittable_givs, final_giv_value): Use get_insns instead of gen_sequence. (copy_loop_body): Likewise and don't emit dummy NOTE. * genrecog.c: Don't mention SEQUENCE rtl in comments. * combine.c (try_combine): Expect insn lists from split generator. * reorg.c (relax_delay_slots): Emit SEQUENCE into insn list by hand. From-SVN: r54497
2002-06-11 14:22:48 +02:00
the new rtl is returned in an INSN list, and LAST_INSN will point
to the last recognized insn in the old sequence. */
1991-11-24 20:57:16 +01:00
#include "bconfig.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
1991-11-24 20:57:16 +01:00
#include "rtl.h"
#include "errors.h"
#include "gensupport.h"
1991-11-24 20:57:16 +01:00
#define OUTPUT_LABEL(INDENT_STRING, LABEL_NUMBER) \
printf("%sL%d: ATTRIBUTE_UNUSED_LABEL\n", (INDENT_STRING), (LABEL_NUMBER))
/* Holds an array of names indexed by insn_code_number. */
static char **insn_name_ptr = 0;
static int insn_name_ptr_size = 0;
/* A listhead of decision trees. The alternatives to a node are kept
in a doubly-linked list so we can easily add nodes to the proper
place when merging. */
struct decision_head
{
struct decision *first;
struct decision *last;
};
/* A single test. The two accept types aren't tests per-se, but
their equality (or lack thereof) does affect tree merging so
it is convenient to keep them here. */
struct decision_test
{
/* A linked list through the tests attached to a node. */
struct decision_test *next;
/* These types are roughly in the order in which we'd like to test them. */
enum decision_type
{
DT_mode, DT_code, DT_veclen,
DT_elt_zero_int, DT_elt_one_int, DT_elt_zero_wide, DT_elt_zero_wide_safe,
DT_veclen_ge, DT_dup, DT_pred, DT_c_test,
DT_accept_op, DT_accept_insn
} type;
union
{
enum machine_mode mode; /* Machine mode of node. */
RTX_CODE code; /* Code to test. */
struct
{
const char *name; /* Predicate to call. */
int index; /* Index into `preds' or -1. */
enum machine_mode mode; /* Machine mode for node. */
} pred;
const char *c_test; /* Additional test to perform. */
int veclen; /* Length of vector. */
int dup; /* Number of operand to compare against. */
HOST_WIDE_INT intval; /* Value for XINT for XWINT. */
int opno; /* Operand number matched. */
struct {
int code_number; /* Insn number matched. */
int lineno; /* Line number of the insn. */
int num_clobbers_to_add; /* Number of CLOBBERs to be added. */
} insn;
} u;
};
/* Data structure for decision tree for recognizing legitimate insns. */
1991-11-24 20:57:16 +01:00
struct decision
{
struct decision_head success; /* Nodes to test on success. */
struct decision *next; /* Node to test on failure. */
struct decision *prev; /* Node whose failure tests us. */
struct decision *afterward; /* Node to test on success,
but failure of successor nodes. */
const char *position; /* String denoting position in pattern. */
struct decision_test *tests; /* The tests for this node. */
int number; /* Node number, used for labels */
int subroutine_number; /* Number of subroutine this node starts */
int need_label; /* Label needs to be output. */
1991-11-24 20:57:16 +01:00
};
#define SUBROUTINE_THRESHOLD 100
1991-11-24 20:57:16 +01:00
static int next_subroutine_number;
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
/* We can write three types of subroutines: One for insn recognition,
one to split insns, and one for peephole-type optimizations. This
defines which type is being written. */
1991-11-24 20:57:16 +01:00
enum routine_type {
RECOG, SPLIT, PEEPHOLE2
};
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
#define IS_SPLIT(X) ((X) != RECOG)
1991-11-24 20:57:16 +01:00
/* Next available node number for tree nodes. */
1991-11-24 20:57:16 +01:00
static int next_number;
1991-11-24 20:57:16 +01:00
/* Next number to use as an insn_code. */
1991-11-24 20:57:16 +01:00
static int next_insn_code;
1991-11-24 20:57:16 +01:00
/* Similar, but counts all expressions in the MD file; used for
1996-07-04 00:07:53 +02:00
error messages. */
1991-11-24 20:57:16 +01:00
static int next_index;
1991-11-24 20:57:16 +01:00
/* Record the highest depth we ever have so we know how many variables to
allocate in each subroutine we make. */
1991-11-24 20:57:16 +01:00
static int max_depth;
/* The line number of the start of the pattern currently being processed. */
static int pattern_lineno;
/* Count of errors. */
static int error_count;
/* This table contains a list of the rtl codes that can possibly match a
predicate defined in recog.c. The function `maybe_both_true' uses it to
deduce that there are no expressions that can be matches by certain pairs
of tree nodes. Also, if a predicate can match only one code, we can
hardwire that code into the node testing the predicate. */
1991-11-24 20:57:16 +01:00
builtins.c (expand_builtin_setjmp_receiver): Const-ify. * builtins.c (expand_builtin_setjmp_receiver): Const-ify. * c-common.c (fname_var_t, c_tree_code_type, c_tree_code_length): Likewise. * c-dump.c (dump_option_value_info): Likewise. * c-format.c (format_length_info, format_char_info, format_flag_spec, format_flag_pair, format_kind_info): Likewise. * collect2.c (names): Likewise. * cppdefault.h (default_include): Likewise. * cppexp.c (suffix, vsuf_1, vsuf_2, vsuf_3): Likewise. * flow.c (life_analysis): Likewise. * gcc.c (dir_separator_str, modify_target, option_map, target_option_translations, spec_list_1, extra_specs_1, init_spec): Likewise. * gcov.c (gcov_version_string): Likewise. * genattr.c (write_units): Likewise. * genattrtab.c (make_length_attrs, write_function_unit_info): Likewise. * gengenrtl.c (rtx_definition, defs): Likewise. * genrecog.c (pred_table): Likewise. * global.c (global_alloc): Likewise. * lcm.c (optimize_mode_switching): Likewise. * local-alloc.c (find_free_reg): Likewise. * params.h (param_info): Likewise. * predict.c (predictor_info): Likewise. * protoize.c (unexpansion_struct): Likewise. * real.c (bmask): Likewise. * recog.h (insn_operand_data, insn_data): Likewise. * regclass.c (initial_fixed_regs, initial_call_used_regs): Likewise. * stmt.c (expand_nl_goto_receiver): Likewise. * toplev.c (da, debug_args, lang_opt, documented_lang_options, target_switches, target_options): Likewise. * tradcif.y (token, tokentab2, yylex): Likewise. * tree.h (attribute_spec): Likewise. * alpha.c (override_options, alpha_lookup_xfloating_lib_func): Likewise. * arc.c (arc_output_function_epilogue): Likewise. * arm.c (processors, all_cores, all_architectures, arm_override_options, isr_attribute_arg, isr_attribute_args, arm_isr_value): Likewise. * avr.c (mcu_type_s, reg_class_tab, order_regs_for_local_alloc): Likewise. * c4x.c (c4x_int_reglist): Likewise. * d30v.c (override_options): Likewise. * h8300.c (shift_insn): Likewise. * i386.c (size_cost, i386_cost, i486_cost, pentium_cost, pentiumpro_cost, k6_cost, athlon_cost, pentium4_cost, ix86_cost, ix86_expand_sse_comi, ix86_expand_sse_compare, override_options, builtin_description, bdesc_comi, bdesc_2arg, bdesc_1arg, ix86_init_mmx_sse_builtins, ix86_expand_builtin): Likewise. * i386.h (processor_costs, ix86_cost): Likewise. * m68hc11.c (m68hc11_cost, m6811_cost, m6812_cost): Likewise. * m68hc11.h (processor_costs, m68hc11_cost): Likewise. * m68k.c (codes_68881, codes_FPA): Likewise. * m88k.c (mode_from_align, max_from_align, all_from_align, best_from_align, m_options): Likewise. * m88k.h (ORDER_REGS_FOR_LOCAL_ALLOC): Likewise. * mcore.c (mode_from_align): Likewise. * mips/elf64.h (UNIQUE_SECTION): Likewise. * mips/iris6gld.h (UNIQUE_SECTION): Likewise. * mips.c (mips_sw_reg_names, mips_regno_to_class): Likewise. * mips.h (mips_regno_to_class): Likewise. * ns32k.c (scales): Likewise. * pa.c (import_string, magic_milli): Likewise. * rs6000.c (alt_reg_names, rs6000_override_options): Likewise. * sparc.c (leaf_reg_remap, sparc_override_options, reg_leaf_alloc_order, reg_nonleaf_alloc_order, reg_alloc_orders): Likewise. * sparc.h (sparc_cpu_select, leaf_reg_remap): Likewise. cp: * class.c (build_vtable_entry_ref): Const-ify. * decl.c (predefined_identifier, initialize_predefined_identifiers): Likewise. * init.c (build_new_1): Likewise. * lex.c (cplus_tree_code_type, cplus_tree_code_length, resword): Likewise. f: * bad.c (_ffebad_message_, ffebad_messages_): Const-ify. * bld.c (ffebld_arity_op_): Likewise. * bld.h (ffebld_arity_op_): Likewise. * com.c (ffecom_init_0): Likewise. * intdoc.c (_ffeintrin_name_, _ffeintrin_gen_, _ffeintrin_spec_, _ffeintrin_imp_, names, gens, imps, specs, cc_pair, cc_descriptions, cc_summaries): Likewise. * intrin.c (_ffeintrin_name_, _ffeintrin_gen_, _ffeintrin_spec_, _ffeintrin_imp_, ffeintrin_names_, ffeintrin_gens_, ffeintrin_imps_, ffeintrin_specs_): Likewise. java: * jcf-io.c (format_uint): Const-ify. * lang.c (java_tree_code_type, java_tree_code_length): Likewise. * lex.c (java_get_line_col): Likewise. * parse.y (build_incdec): Likewise. From-SVN: r46062
2001-10-07 18:51:11 +02:00
static const struct pred_table
{
builtins.c (expand_builtin_setjmp_receiver): Const-ify. * builtins.c (expand_builtin_setjmp_receiver): Const-ify. * c-common.c (fname_var_t, c_tree_code_type, c_tree_code_length): Likewise. * c-dump.c (dump_option_value_info): Likewise. * c-format.c (format_length_info, format_char_info, format_flag_spec, format_flag_pair, format_kind_info): Likewise. * collect2.c (names): Likewise. * cppdefault.h (default_include): Likewise. * cppexp.c (suffix, vsuf_1, vsuf_2, vsuf_3): Likewise. * flow.c (life_analysis): Likewise. * gcc.c (dir_separator_str, modify_target, option_map, target_option_translations, spec_list_1, extra_specs_1, init_spec): Likewise. * gcov.c (gcov_version_string): Likewise. * genattr.c (write_units): Likewise. * genattrtab.c (make_length_attrs, write_function_unit_info): Likewise. * gengenrtl.c (rtx_definition, defs): Likewise. * genrecog.c (pred_table): Likewise. * global.c (global_alloc): Likewise. * lcm.c (optimize_mode_switching): Likewise. * local-alloc.c (find_free_reg): Likewise. * params.h (param_info): Likewise. * predict.c (predictor_info): Likewise. * protoize.c (unexpansion_struct): Likewise. * real.c (bmask): Likewise. * recog.h (insn_operand_data, insn_data): Likewise. * regclass.c (initial_fixed_regs, initial_call_used_regs): Likewise. * stmt.c (expand_nl_goto_receiver): Likewise. * toplev.c (da, debug_args, lang_opt, documented_lang_options, target_switches, target_options): Likewise. * tradcif.y (token, tokentab2, yylex): Likewise. * tree.h (attribute_spec): Likewise. * alpha.c (override_options, alpha_lookup_xfloating_lib_func): Likewise. * arc.c (arc_output_function_epilogue): Likewise. * arm.c (processors, all_cores, all_architectures, arm_override_options, isr_attribute_arg, isr_attribute_args, arm_isr_value): Likewise. * avr.c (mcu_type_s, reg_class_tab, order_regs_for_local_alloc): Likewise. * c4x.c (c4x_int_reglist): Likewise. * d30v.c (override_options): Likewise. * h8300.c (shift_insn): Likewise. * i386.c (size_cost, i386_cost, i486_cost, pentium_cost, pentiumpro_cost, k6_cost, athlon_cost, pentium4_cost, ix86_cost, ix86_expand_sse_comi, ix86_expand_sse_compare, override_options, builtin_description, bdesc_comi, bdesc_2arg, bdesc_1arg, ix86_init_mmx_sse_builtins, ix86_expand_builtin): Likewise. * i386.h (processor_costs, ix86_cost): Likewise. * m68hc11.c (m68hc11_cost, m6811_cost, m6812_cost): Likewise. * m68hc11.h (processor_costs, m68hc11_cost): Likewise. * m68k.c (codes_68881, codes_FPA): Likewise. * m88k.c (mode_from_align, max_from_align, all_from_align, best_from_align, m_options): Likewise. * m88k.h (ORDER_REGS_FOR_LOCAL_ALLOC): Likewise. * mcore.c (mode_from_align): Likewise. * mips/elf64.h (UNIQUE_SECTION): Likewise. * mips/iris6gld.h (UNIQUE_SECTION): Likewise. * mips.c (mips_sw_reg_names, mips_regno_to_class): Likewise. * mips.h (mips_regno_to_class): Likewise. * ns32k.c (scales): Likewise. * pa.c (import_string, magic_milli): Likewise. * rs6000.c (alt_reg_names, rs6000_override_options): Likewise. * sparc.c (leaf_reg_remap, sparc_override_options, reg_leaf_alloc_order, reg_nonleaf_alloc_order, reg_alloc_orders): Likewise. * sparc.h (sparc_cpu_select, leaf_reg_remap): Likewise. cp: * class.c (build_vtable_entry_ref): Const-ify. * decl.c (predefined_identifier, initialize_predefined_identifiers): Likewise. * init.c (build_new_1): Likewise. * lex.c (cplus_tree_code_type, cplus_tree_code_length, resword): Likewise. f: * bad.c (_ffebad_message_, ffebad_messages_): Const-ify. * bld.c (ffebld_arity_op_): Likewise. * bld.h (ffebld_arity_op_): Likewise. * com.c (ffecom_init_0): Likewise. * intdoc.c (_ffeintrin_name_, _ffeintrin_gen_, _ffeintrin_spec_, _ffeintrin_imp_, names, gens, imps, specs, cc_pair, cc_descriptions, cc_summaries): Likewise. * intrin.c (_ffeintrin_name_, _ffeintrin_gen_, _ffeintrin_spec_, _ffeintrin_imp_, ffeintrin_names_, ffeintrin_gens_, ffeintrin_imps_, ffeintrin_specs_): Likewise. java: * jcf-io.c (format_uint): Const-ify. * lang.c (java_tree_code_type, java_tree_code_length): Likewise. * lex.c (java_get_line_col): Likewise. * parse.y (build_incdec): Likewise. From-SVN: r46062
2001-10-07 18:51:11 +02:00
const char *const name;
const RTX_CODE codes[NUM_RTX_CODE];
} preds[] = {
{"general_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
LABEL_REF, SUBREG, REG, MEM, ADDRESSOF}},
#ifdef PREDICATE_CODES
PREDICATE_CODES
#endif
{"address_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
LABEL_REF, SUBREG, REG, MEM, ADDRESSOF,
PLUS, MINUS, MULT}},
{"register_operand", {SUBREG, REG, ADDRESSOF}},
{"pmode_register_operand", {SUBREG, REG, ADDRESSOF}},
{"scratch_operand", {SCRATCH, REG}},
{"immediate_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
LABEL_REF}},
{"const_int_operand", {CONST_INT}},
{"const_double_operand", {CONST_INT, CONST_DOUBLE}},
{"nonimmediate_operand", {SUBREG, REG, MEM, ADDRESSOF}},
{"nonmemory_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
LABEL_REF, SUBREG, REG, ADDRESSOF}},
{"push_operand", {MEM}},
{"pop_operand", {MEM}},
{"memory_operand", {SUBREG, MEM}},
{"indirect_operand", {SUBREG, MEM}},
{"comparison_operator", {EQ, NE, LE, LT, GE, GT, LEU, LTU, GEU, GTU,
UNORDERED, ORDERED, UNEQ, UNGE, UNGT, UNLE,
UNLT, LTGT}},
{"mode_independent_operand", {CONST_INT, CONST_DOUBLE, CONST, SYMBOL_REF,
LABEL_REF, SUBREG, REG, MEM, ADDRESSOF}}
};
optabs.c (init_optabs): Initialize fixtab... * optabs.c (init_optabs): Initialize fixtab, fixtrunctab, floattab, and extendtab within their proper array boundaries. * emit-rtl.c (init_emit_once): Pass `const_tiny_rtx' with bounds for the entire array. * config/arm/arm.c (arm_override_options): Use ARRAY_SIZE. * config/alpha/alpha.c (alpha_lookup_xfloating_lib_func): Likewise. * config/avr/avr.c (order_regs_for_local_alloc): Likewise. * config/fr30/fr30.c (fr30_print_operand): Likewise. * config/i386/dgux.c (output_options): Likewise. * config/i386/dgux.h (ASM_FILE_START): Likewise. * config/m88k/m88k.c (output_options): Likewise. * config/m88k/m88k.h (ASM_FILE_START): Likewise. * config/mcore/mcore.c (mcore_output_inline_const_forced, layout_mcore_frame, handle_structs_in_regs): Likewise. * config/mips/mips.c (output_block_move): Likewise. * config/rs6000/rs6000.c (rs6000_override_options, rs6000_file_start): Likewise. * config/sparc/sparc.c (sparc_add_gc_roots): Likewise. * fixinc/fixfixes.c (FIX_TABLE_CT): Likewise. * fixinc/fixtests.c (TEST_TABLE_CT): Likewise. * builtins.c (expand_builtin_setjmp): Likewise. * expr.c (safe_from_p): Likewise. * flow.c (life_analysis): Likewise. * fold-const.c (size_int_type_wide): Likewise. * gcc.c (translate_options, init_spec, set_spec, main): Likewise. * genattrtab.c (make_length_attrs): Likewise. * genopinit.c (gen_insn): Likewise. * genrecog.c (NUM_KNOWN_PREDS, NUM_SPECIAL_MODE_PREDS): Likewise. * global.c (global_alloc): Likewise. * local-alloc.c (find_free_reg): Likewise. * mips-tdump.c (print_symbol): Likewise. * mips-tfile.c (parse_def, parse_input): Likewise. * reload1.c (NUM_ELIMINABLE_REGS): Likewise. * stmt.c (expand_nl_goto_receiver): Likewise. * stor-layout.c (set_sizetype): Likewise. * varasm.c (decode_reg_name): Likewise. * toplev.c (decode_f_option, decode_W_option, set_target_switch, print_switch_values): Likewise. (NUM_ELEM): Remove macro. (display_help, main): s/NUM_ELEM/ARRAY_SIZE/ From-SVN: r35949
2000-08-24 22:31:35 +02:00
#define NUM_KNOWN_PREDS ARRAY_SIZE (preds)
1991-11-24 20:57:16 +01:00
c-common.c (c_tree_code_name): Const-ification. * c-common.c (c_tree_code_name): Const-ification. * c-decl.c (c_decode_option): Likewise. * c-typeck.c (warn_for_assignment): Likewise. * collect2.c (libexts, is_ctor_dtor, main, ignore_library): Likewise. * cppinit.c (output_deps): Likewise. * dependence.c (dependence_string, direction_string): Likewise. * dwarf2out.c (output_ranges): Likewise. * fixinc/fixfixes.c (emit_gnu_type): Likewise. * fixinc/gnu-regex.c (re_error_msgid): Likewise. * gcc.c (standard_exec_prefix, standard_exec_prefix_1, standard_startfile_prefix, standard_startfile_prefix_1, standard_startfile_prefix_2, tooldir_base_prefix, standard_bindir_prefix, find_a_file): Likewise. * genattrtab.c (make_length_attrs): Likewise. * gencheck.c (tree_codes): Likewise. * genemit.c (gen_split): Likewise. * genrecog.c (special_mode_pred_table): Likewise. * graph.c (graph_ext): Likewise. * protoize (default_include): Likewise. * reload.c (reload_when_needed_name): Likewise. * sched-vis.c (visualize_stall_cycles): Likewise. * tlink.c (recompile_files): Likewise. * toplev.c (decode_g_option): Likewise. * tradcpp.c (output_deps): Likewise. * varasm.c (decode_reg_name): Likewise. * arm.c (arm_condition_codes, strings_fpa, thumb_condition_code): Const-ification. * arm.md: Likewise. * avr.c (avr_regnames, encode_section_info): Likewise. * c4x.c (float_reg_names): Likewise. * darwin.h (ASM_GLOBALIZE_LABEL): Likewise. * elfos.h (const_section): Likewise. * i386.c (ix86_comp_type_attributes): Likewise. * i386/win32.h (STRIP_NAME_ENCODING): Likewise. * ia64/aix.h (UNIQUE_SECTION): Likewise. * ia64.c (type_names): Likewise. * m68hc11.c (reg_class_names): Likewise. * m88k.c (m_options): Likewise. * mips.c (mips_output_conditional_branch, mips_unique_section): Likewise. * rs6000/sysv4.h (ASM_DECLARE_FUNCTION_NAME): Likewise. * sparc.c (sparc_flat_function_prologue, sparc_flat_function_epilogue, ultra_code_names): Likewise. * sparc.h (OVERRIDE_OPTIONS): Likewise. From-SVN: r45567
2001-09-12 19:18:03 +02:00
static const char *const special_mode_pred_table[] = {
#ifdef SPECIAL_MODE_PREDICATES
SPECIAL_MODE_PREDICATES
#endif
"pmode_register_operand"
};
optabs.c (init_optabs): Initialize fixtab... * optabs.c (init_optabs): Initialize fixtab, fixtrunctab, floattab, and extendtab within their proper array boundaries. * emit-rtl.c (init_emit_once): Pass `const_tiny_rtx' with bounds for the entire array. * config/arm/arm.c (arm_override_options): Use ARRAY_SIZE. * config/alpha/alpha.c (alpha_lookup_xfloating_lib_func): Likewise. * config/avr/avr.c (order_regs_for_local_alloc): Likewise. * config/fr30/fr30.c (fr30_print_operand): Likewise. * config/i386/dgux.c (output_options): Likewise. * config/i386/dgux.h (ASM_FILE_START): Likewise. * config/m88k/m88k.c (output_options): Likewise. * config/m88k/m88k.h (ASM_FILE_START): Likewise. * config/mcore/mcore.c (mcore_output_inline_const_forced, layout_mcore_frame, handle_structs_in_regs): Likewise. * config/mips/mips.c (output_block_move): Likewise. * config/rs6000/rs6000.c (rs6000_override_options, rs6000_file_start): Likewise. * config/sparc/sparc.c (sparc_add_gc_roots): Likewise. * fixinc/fixfixes.c (FIX_TABLE_CT): Likewise. * fixinc/fixtests.c (TEST_TABLE_CT): Likewise. * builtins.c (expand_builtin_setjmp): Likewise. * expr.c (safe_from_p): Likewise. * flow.c (life_analysis): Likewise. * fold-const.c (size_int_type_wide): Likewise. * gcc.c (translate_options, init_spec, set_spec, main): Likewise. * genattrtab.c (make_length_attrs): Likewise. * genopinit.c (gen_insn): Likewise. * genrecog.c (NUM_KNOWN_PREDS, NUM_SPECIAL_MODE_PREDS): Likewise. * global.c (global_alloc): Likewise. * local-alloc.c (find_free_reg): Likewise. * mips-tdump.c (print_symbol): Likewise. * mips-tfile.c (parse_def, parse_input): Likewise. * reload1.c (NUM_ELIMINABLE_REGS): Likewise. * stmt.c (expand_nl_goto_receiver): Likewise. * stor-layout.c (set_sizetype): Likewise. * varasm.c (decode_reg_name): Likewise. * toplev.c (decode_f_option, decode_W_option, set_target_switch, print_switch_values): Likewise. (NUM_ELEM): Remove macro. (display_help, main): s/NUM_ELEM/ARRAY_SIZE/ From-SVN: r35949
2000-08-24 22:31:35 +02:00
#define NUM_SPECIAL_MODE_PREDS ARRAY_SIZE (special_mode_pred_table)
static struct decision *new_decision
PARAMS ((const char *, struct decision_head *));
static struct decision_test *new_decision_test
PARAMS ((enum decision_type, struct decision_test ***));
static rtx find_operand
PARAMS ((rtx, int));
static rtx find_matching_operand
PARAMS ((rtx, int));
static void validate_pattern
PARAMS ((rtx, rtx, rtx, int));
static struct decision *add_to_sequence
PARAMS ((rtx, struct decision_head *, const char *, enum routine_type, int));
static int maybe_both_true_2
PARAMS ((struct decision_test *, struct decision_test *));
static int maybe_both_true_1
PARAMS ((struct decision_test *, struct decision_test *));
static int maybe_both_true
PARAMS ((struct decision *, struct decision *, int));
static int nodes_identical_1
PARAMS ((struct decision_test *, struct decision_test *));
static int nodes_identical
PARAMS ((struct decision *, struct decision *));
static void merge_accept_insn
PARAMS ((struct decision *, struct decision *));
static void merge_trees
PARAMS ((struct decision_head *, struct decision_head *));
static void factor_tests
PARAMS ((struct decision_head *));
static void simplify_tests
PARAMS ((struct decision_head *));
static int break_out_subroutines
PARAMS ((struct decision_head *, int));
static void find_afterward
PARAMS ((struct decision_head *, struct decision *));
static void change_state
PARAMS ((const char *, const char *, struct decision *, const char *));
static void print_code
PARAMS ((enum rtx_code));
static void write_afterward
PARAMS ((struct decision *, struct decision *, const char *));
static struct decision *write_switch
PARAMS ((struct decision *, int));
static void write_cond
PARAMS ((struct decision_test *, int, enum routine_type));
static void write_action
PARAMS ((struct decision *, struct decision_test *, int, int,
struct decision *, enum routine_type));
static int is_unconditional
PARAMS ((struct decision_test *, enum routine_type));
static int write_node
PARAMS ((struct decision *, int, enum routine_type));
static void write_tree_1
PARAMS ((struct decision_head *, int, enum routine_type));
static void write_tree
PARAMS ((struct decision_head *, const char *, enum routine_type, int));
static void write_subroutine
PARAMS ((struct decision_head *, enum routine_type));
static void write_subroutines
PARAMS ((struct decision_head *, enum routine_type));
static void write_header
PARAMS ((void));
static struct decision_head make_insn_sequence
PARAMS ((rtx, enum routine_type));
static void process_tree
PARAMS ((struct decision_head *, enum routine_type));
static void record_insn_name
PARAMS ((int, const char *));
static void debug_decision_0
PARAMS ((struct decision *, int, int));
static void debug_decision_1
PARAMS ((struct decision *, int));
static void debug_decision_2
PARAMS ((struct decision_test *));
extern void debug_decision
PARAMS ((struct decision *));
extern void debug_decision_list
PARAMS ((struct decision *));
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
/* Create a new node in sequence after LAST. */
static struct decision *
new_decision (position, last)
const char *position;
struct decision_head *last;
1991-11-24 20:57:16 +01:00
{
alias.c: Remove uses of "register" specifier in declarations of arguments and local... 2001-10-10 Stan Shebs <shebs@apple.com> * alias.c: Remove uses of "register" specifier in declarations of arguments and local variables. * c-common.c: Ditto. * c-convert.c: Ditto. * c-decl.c: Ditto. * c-format.c: Ditto. * c-semantics.c: Ditto. * c-typeck.c: Ditto. * caller-save.c: Ditto. * calls.c: Ditto. * cfg.c: Ditto. * cfgbuild.c: Ditto. * cfgrtl.c: Ditto. * collect2.c: Ditto. * combine.c: Ditto. * convert.c: Ditto. * cppexp.c: Ditto. * cppfiles.c: Ditto. * cse.c: Ditto. * dbxout.c: Ditto. * defaults.h: Ditto. * df.c: Ditto. * dwarf2out.c: Ditto. * dwarfout.c: Ditto. * emit-rtl.c: Ditto. * explow.c: Ditto. * expmed.c: Ditto. * expr.c: Ditto. * final.c: Ditto. * fix-header.c: Ditto. * floatlib.c: Ditto. * flow.c: Ditto. * fold-const.c: Ditto. * function.c: Ditto. * gcc.c: Ditto. * gcse.c: Ditto. * gen-protos.c: Ditto. * genattrtab.c: Ditto. * gencheck.c: Ditto. * genconfig.c: Ditto. * genemit.c: Ditto. * genextract.c: Ditto. * genflags.c: Ditto. * gengenrtl.c: Ditto. * genoutput.c: Ditto. * genpeep.c: Ditto. * genrecog.c: Ditto. * gensupport.c: Ditto. * global.c: Ditto. * gmon.c: Ditto. * graph.c: Ditto. * haifa-sched.c: Ditto. * hard-reg-set.h: Ditto. * hash.c: Ditto. * integrate.c: Ditto. * jump.c: Ditto. * lists.c: Ditto. * local-alloc.c: Ditto. * loop.c: Ditto. * mips-tdump.c: Ditto. * mips-tfile.c: Ditto. * optabs.c: Ditto. * prefix.c: Ditto. * print-rtl.c: Ditto. * read-rtl.c: Ditto. * real.c: Ditto. * recog.c: Ditto. * reg-stack.c: Ditto. * regclass.c: Ditto. * regmove.c: Ditto. * reload.c: Ditto. * reload1.c: Ditto. * reorg.c: Ditto. * resource.c: Ditto. * rtl.c: Ditto. * rtlanal.c: Ditto. * scan.c: Ditto. * sched-deps.c: Ditto. * sched-rgn.c: Ditto. * sdbout.c: Ditto. * simplify-rtx.c: Ditto. * stmt.c: Ditto. * stor-layout.c: Ditto. * toplev.c: Ditto. * tradcif.y: Ditto. * tradcpp.c: Ditto. * tree.c: Ditto. * unroll.c: Ditto. * varasm.c: Ditto. * xcoffout.c: Ditto. From-SVN: r46173
2001-10-11 05:16:15 +02:00
struct decision *new
= (struct decision *) xmalloc (sizeof (struct decision));
1991-11-24 20:57:16 +01:00
memset (new, 0, sizeof (*new));
new->success = *last;
new->position = xstrdup (position);
new->number = next_number++;
1991-11-24 20:57:16 +01:00
last->first = last->last = new;
return new;
}
/* Create a new test and link it in at PLACE. */
1991-11-24 20:57:16 +01:00
static struct decision_test *
new_decision_test (type, pplace)
enum decision_type type;
struct decision_test ***pplace;
{
struct decision_test **place = *pplace;
struct decision_test *test;
1991-11-24 20:57:16 +01:00
test = (struct decision_test *) xmalloc (sizeof (*test));
test->next = *place;
test->type = type;
*place = test;
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
place = &test->next;
*pplace = place;
1991-11-24 20:57:16 +01:00
return test;
}
/* Search for and return operand N. */
static rtx
find_operand (pattern, n)
rtx pattern;
int n;
{
const char *fmt;
RTX_CODE code;
int i, j, len;
rtx r;
code = GET_CODE (pattern);
if ((code == MATCH_SCRATCH
|| code == MATCH_INSN
|| code == MATCH_OPERAND
|| code == MATCH_OPERATOR
|| code == MATCH_PARALLEL)
&& XINT (pattern, 0) == n)
return pattern;
fmt = GET_RTX_FORMAT (code);
len = GET_RTX_LENGTH (code);
for (i = 0; i < len; i++)
{
switch (fmt[i])
{
case 'e': case 'u':
if ((r = find_operand (XEXP (pattern, i), n)) != NULL_RTX)
return r;
break;
case 'V':
if (! XVEC (pattern, i))
break;
/* FALLTHRU */
case 'E':
for (j = 0; j < XVECLEN (pattern, i); j++)
if ((r = find_operand (XVECEXP (pattern, i, j), n)) != NULL_RTX)
return r;
break;
case 'i': case 'w': case '0': case 's':
break;
default:
abort ();
}
}
return NULL;
}
/* Search for and return operand M, such that it has a matching
constraint for operand N. */
static rtx
find_matching_operand (pattern, n)
rtx pattern;
int n;
{
const char *fmt;
RTX_CODE code;
int i, j, len;
rtx r;
code = GET_CODE (pattern);
if (code == MATCH_OPERAND
&& (XSTR (pattern, 2)[0] == '0' + n
|| (XSTR (pattern, 2)[0] == '%'
&& XSTR (pattern, 2)[1] == '0' + n)))
return pattern;
fmt = GET_RTX_FORMAT (code);
len = GET_RTX_LENGTH (code);
for (i = 0; i < len; i++)
{
switch (fmt[i])
{
case 'e': case 'u':
if ((r = find_matching_operand (XEXP (pattern, i), n)))
return r;
break;
case 'V':
if (! XVEC (pattern, i))
break;
/* FALLTHRU */
case 'E':
for (j = 0; j < XVECLEN (pattern, i); j++)
if ((r = find_matching_operand (XVECEXP (pattern, i, j), n)))
return r;
break;
case 'i': case 'w': case '0': case 's':
break;
default:
abort ();
}
}
return NULL;
}
/* Check for various errors in patterns. SET is nonnull for a destination,
and is the complete set pattern. SET_CODE is '=' for normal sets, and
'+' within a context that requires in-out constraints. */
static void
validate_pattern (pattern, insn, set, set_code)
rtx pattern;
rtx insn;
rtx set;
int set_code;
{
const char *fmt;
RTX_CODE code;
size_t i, len;
int j;
code = GET_CODE (pattern);
switch (code)
{
case MATCH_SCRATCH:
return;
case MATCH_INSN:
case MATCH_OPERAND:
case MATCH_OPERATOR:
{
const char *pred_name = XSTR (pattern, 1);
int allows_non_lvalue = 1, allows_non_const = 1;
int special_mode_pred = 0;
const char *c_test;
if (GET_CODE (insn) == DEFINE_INSN)
c_test = XSTR (insn, 2);
else
c_test = XSTR (insn, 1);
if (pred_name[0] != 0)
{
for (i = 0; i < NUM_KNOWN_PREDS; i++)
if (! strcmp (preds[i].name, pred_name))
break;
if (i < NUM_KNOWN_PREDS)
{
int j;
allows_non_lvalue = allows_non_const = 0;
for (j = 0; preds[i].codes[j] != 0; j++)
{
RTX_CODE c = preds[i].codes[j];
if (c != LABEL_REF
&& c != SYMBOL_REF
&& c != CONST_INT
&& c != CONST_DOUBLE
&& c != CONST
&& c != HIGH
&& c != CONSTANT_P_RTX)
allows_non_const = 1;
if (c != REG
&& c != SUBREG
&& c != MEM
&& c != ADDRESSOF
&& c != CONCAT
&& c != PARALLEL
&& c != STRICT_LOW_PART)
allows_non_lvalue = 1;
}
}
else
{
#ifdef PREDICATE_CODES
/* If the port has a list of the predicates it uses but
omits one, warn. */
message_with_line (pattern_lineno,
"warning: `%s' not in PREDICATE_CODES",
pred_name);
#endif
}
for (i = 0; i < NUM_SPECIAL_MODE_PREDS; ++i)
if (strcmp (pred_name, special_mode_pred_table[i]) == 0)
{
special_mode_pred = 1;
break;
}
}
if (code == MATCH_OPERAND)
{
const char constraints0 = XSTR (pattern, 2)[0];
/* In DEFINE_EXPAND, DEFINE_SPLIT, and DEFINE_PEEPHOLE2, we
don't use the MATCH_OPERAND constraint, only the predicate.
This is confusing to folks doing new ports, so help them
not make the mistake. */
if (GET_CODE (insn) == DEFINE_EXPAND
|| GET_CODE (insn) == DEFINE_SPLIT
|| GET_CODE (insn) == DEFINE_PEEPHOLE2)
{
if (constraints0)
message_with_line (pattern_lineno,
"warning: constraints not supported in %s",
rtx_name[GET_CODE (insn)]);
}
/* A MATCH_OPERAND that is a SET should have an output reload. */
else if (set && constraints0)
{
if (set_code == '+')
{
if (constraints0 == '+')
;
/* If we've only got an output reload for this operand,
we'd better have a matching input operand. */
else if (constraints0 == '='
&& find_matching_operand (insn, XINT (pattern, 0)))
;
else
{
message_with_line (pattern_lineno,
"operand %d missing in-out reload",
XINT (pattern, 0));
error_count++;
}
}
else if (constraints0 != '=' && constraints0 != '+')
{
message_with_line (pattern_lineno,
"operand %d missing output reload",
XINT (pattern, 0));
error_count++;
}
}
}
/* Allowing non-lvalues in destinations -- particularly CONST_INT --
while not likely to occur at runtime, results in less efficient
code from insn-recog.c. */
if (set
&& pred_name[0] != '\0'
&& allows_non_lvalue)
{
message_with_line (pattern_lineno,
"warning: destination operand %d allows non-lvalue",
XINT (pattern, 0));
}
/* A modeless MATCH_OPERAND can be handy when we can
check for multiple modes in the c_test. In most other cases,
it is a mistake. Only DEFINE_INSN is eligible, since SPLIT
and PEEP2 can FAIL within the output pattern. Exclude
address_operand, since its mode is related to the mode of
the memory not the operand. Exclude the SET_DEST of a call
instruction, as that is a common idiom. */
if (GET_MODE (pattern) == VOIDmode
&& code == MATCH_OPERAND
&& GET_CODE (insn) == DEFINE_INSN
&& allows_non_const
&& ! special_mode_pred
&& pred_name[0] != '\0'
&& strcmp (pred_name, "address_operand") != 0
&& strstr (c_test, "operands") == NULL
&& ! (set
&& GET_CODE (set) == SET
&& GET_CODE (SET_SRC (set)) == CALL))
{
message_with_line (pattern_lineno,
"warning: operand %d missing mode?",
XINT (pattern, 0));
}
return;
}
case SET:
{
enum machine_mode dmode, smode;
rtx dest, src;
dest = SET_DEST (pattern);
src = SET_SRC (pattern);
/* STRICT_LOW_PART is a wrapper. Its argument is the real
destination, and it's mode should match the source. */
if (GET_CODE (dest) == STRICT_LOW_PART)
dest = XEXP (dest, 0);
/* Find the referant for a DUP. */
if (GET_CODE (dest) == MATCH_DUP
|| GET_CODE (dest) == MATCH_OP_DUP
|| GET_CODE (dest) == MATCH_PAR_DUP)
dest = find_operand (insn, XINT (dest, 0));
if (GET_CODE (src) == MATCH_DUP
|| GET_CODE (src) == MATCH_OP_DUP
|| GET_CODE (src) == MATCH_PAR_DUP)
src = find_operand (insn, XINT (src, 0));
dmode = GET_MODE (dest);
smode = GET_MODE (src);
/* The mode of an ADDRESS_OPERAND is the mode of the memory
reference, not the mode of the address. */
if (GET_CODE (src) == MATCH_OPERAND
&& ! strcmp (XSTR (src, 1), "address_operand"))
;
/* The operands of a SET must have the same mode unless one
is VOIDmode. */
else if (dmode != VOIDmode && smode != VOIDmode && dmode != smode)
{
message_with_line (pattern_lineno,
"mode mismatch in set: %smode vs %smode",
GET_MODE_NAME (dmode), GET_MODE_NAME (smode));
error_count++;
}
/* If only one of the operands is VOIDmode, and PC or CC0 is
not involved, it's probably a mistake. */
else if (dmode != smode
&& GET_CODE (dest) != PC
&& GET_CODE (dest) != CC0
&& GET_CODE (src) != PC
&& GET_CODE (src) != CC0
&& GET_CODE (src) != CONST_INT)
{
const char *which;
which = (dmode == VOIDmode ? "destination" : "source");
message_with_line (pattern_lineno,
"warning: %s missing a mode?", which);
}
if (dest != SET_DEST (pattern))
validate_pattern (dest, insn, pattern, '=');
validate_pattern (SET_DEST (pattern), insn, pattern, '=');
validate_pattern (SET_SRC (pattern), insn, NULL_RTX, 0);
return;
}
case CLOBBER:
validate_pattern (SET_DEST (pattern), insn, pattern, '=');
return;
case ZERO_EXTRACT:
validate_pattern (XEXP (pattern, 0), insn, set, set ? '+' : 0);
validate_pattern (XEXP (pattern, 1), insn, NULL_RTX, 0);
validate_pattern (XEXP (pattern, 2), insn, NULL_RTX, 0);
return;
case STRICT_LOW_PART:
validate_pattern (XEXP (pattern, 0), insn, set, set ? '+' : 0);
return;
case LABEL_REF:
if (GET_MODE (XEXP (pattern, 0)) != VOIDmode)
{
message_with_line (pattern_lineno,
"operand to label_ref %smode not VOIDmode",
GET_MODE_NAME (GET_MODE (XEXP (pattern, 0))));
error_count++;
}
break;
default:
break;
}
fmt = GET_RTX_FORMAT (code);
len = GET_RTX_LENGTH (code);
for (i = 0; i < len; i++)
{
switch (fmt[i])
{
case 'e': case 'u':
validate_pattern (XEXP (pattern, i), insn, NULL_RTX, 0);
break;
case 'E':
for (j = 0; j < XVECLEN (pattern, i); j++)
validate_pattern (XVECEXP (pattern, i, j), insn, NULL_RTX, 0);
break;
case 'i': case 'w': case '0': case 's':
break;
default:
abort ();
}
}
}
/* Create a chain of nodes to verify that an rtl expression matches
PATTERN.
1991-11-24 20:57:16 +01:00
LAST is a pointer to the listhead in the previous node in the chain (or
in the calling function, for the first node).
1991-11-24 20:57:16 +01:00
POSITION is the string representing the current position in the insn.
1991-11-24 20:57:16 +01:00
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
INSN_TYPE is the type of insn for which we are emitting code.
A pointer to the final node in the chain is returned. */
1991-11-24 20:57:16 +01:00
static struct decision *
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
add_to_sequence (pattern, last, position, insn_type, top)
1991-11-24 20:57:16 +01:00
rtx pattern;
struct decision_head *last;
const char *position;
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
enum routine_type insn_type;
int top;
1991-11-24 20:57:16 +01:00
{
RTX_CODE code;
struct decision *this, *sub;
struct decision_test *test;
struct decision_test **place;
char *subpos;
alias.c: Remove uses of "register" specifier in declarations of arguments and local... 2001-10-10 Stan Shebs <shebs@apple.com> * alias.c: Remove uses of "register" specifier in declarations of arguments and local variables. * c-common.c: Ditto. * c-convert.c: Ditto. * c-decl.c: Ditto. * c-format.c: Ditto. * c-semantics.c: Ditto. * c-typeck.c: Ditto. * caller-save.c: Ditto. * calls.c: Ditto. * cfg.c: Ditto. * cfgbuild.c: Ditto. * cfgrtl.c: Ditto. * collect2.c: Ditto. * combine.c: Ditto. * convert.c: Ditto. * cppexp.c: Ditto. * cppfiles.c: Ditto. * cse.c: Ditto. * dbxout.c: Ditto. * defaults.h: Ditto. * df.c: Ditto. * dwarf2out.c: Ditto. * dwarfout.c: Ditto. * emit-rtl.c: Ditto. * explow.c: Ditto. * expmed.c: Ditto. * expr.c: Ditto. * final.c: Ditto. * fix-header.c: Ditto. * floatlib.c: Ditto. * flow.c: Ditto. * fold-const.c: Ditto. * function.c: Ditto. * gcc.c: Ditto. * gcse.c: Ditto. * gen-protos.c: Ditto. * genattrtab.c: Ditto. * gencheck.c: Ditto. * genconfig.c: Ditto. * genemit.c: Ditto. * genextract.c: Ditto. * genflags.c: Ditto. * gengenrtl.c: Ditto. * genoutput.c: Ditto. * genpeep.c: Ditto. * genrecog.c: Ditto. * gensupport.c: Ditto. * global.c: Ditto. * gmon.c: Ditto. * graph.c: Ditto. * haifa-sched.c: Ditto. * hard-reg-set.h: Ditto. * hash.c: Ditto. * integrate.c: Ditto. * jump.c: Ditto. * lists.c: Ditto. * local-alloc.c: Ditto. * loop.c: Ditto. * mips-tdump.c: Ditto. * mips-tfile.c: Ditto. * optabs.c: Ditto. * prefix.c: Ditto. * print-rtl.c: Ditto. * read-rtl.c: Ditto. * real.c: Ditto. * recog.c: Ditto. * reg-stack.c: Ditto. * regclass.c: Ditto. * regmove.c: Ditto. * reload.c: Ditto. * reload1.c: Ditto. * reorg.c: Ditto. * resource.c: Ditto. * rtl.c: Ditto. * rtlanal.c: Ditto. * scan.c: Ditto. * sched-deps.c: Ditto. * sched-rgn.c: Ditto. * sdbout.c: Ditto. * simplify-rtx.c: Ditto. * stmt.c: Ditto. * stor-layout.c: Ditto. * toplev.c: Ditto. * tradcif.y: Ditto. * tradcpp.c: Ditto. * tree.c: Ditto. * unroll.c: Ditto. * varasm.c: Ditto. * xcoffout.c: Ditto. From-SVN: r46173
2001-10-11 05:16:15 +02:00
size_t i;
const char *fmt;
int depth = strlen (position);
1991-11-24 20:57:16 +01:00
int len;
enum machine_mode mode;
1991-11-24 20:57:16 +01:00
if (depth > max_depth)
max_depth = depth;
aclocal.m4 (libiberty_AC_FUNC_C_ALLOCA): New. libiberty: * aclocal.m4 (libiberty_AC_FUNC_C_ALLOCA): New. * configure.in: Replace all alloca logic with a simple use of the above new macro. * config.table: Kill *-*-beos* entry. * config/mh-beos: Delete. * configure, config.in: Regenerate. * Makefile.in (ALLOCA, HFILES): Kill. (REQUIRED_OFILES): Add alloca.o. (alloca.o): Depend on libiberty.h. (argv.o): Don't depend on alloca-conf.h. * alloca-conf.h: Delete. * alloca.c: Include libiberty.h. Kill all #ifdef emacs blocks. Provide the C alloca unconditionally. Use PTR where appropriate. Make i00afunc static. * argv.c: Don't include alloca-conf.h. include: * libiberty.h: Prototype C_alloca; define alloca to either __builtin_alloca or C_alloca as appropriate. gcc: * aclocal.m4 (AM_GNU_GETTEXT): Don't AC_REQUIRE AC_FUNC_ALLOCA. * configure, config.in: Regenerate. * config.gcc: Remove references to deleted files. * genattr.c, genattrtab.c, genextract.c, genoutput.c, genrecog.c, rtl.c: Do not use alloca anywhere. * Makefile.in, build-make, system.h, config/x-interix, config/x-svr4, config/xm-interix.h, config/xm-openbsd.h, config/alpha/xm-alpha.h, config/alpha/xm-vms.h, config/arc/xm-arc.h, config/arm/xm-arm.h, config/d30v/xm-d30v.h, config/dsp16xx/xm-dsp16xx.h, config/h8300/xm-h8300.h, config/i370/x-oe, config/i370/xm-linux.h, config/i386/x-aix, config/i386/x-beos, config/i386/x-ncr3000, config/i386/x-sco5, config/i386/xm-dgux.h, config/i860/x-sysv4, config/i960/xm-i960.h, config/m32r/xm-m32r.h, config/m68k/x-crds, config/m68k/x-dpx2, config/m68k/x-hp320, config/m68k/x-hp320g, config/m69k/x-mot3300, config/m68k/x-mot3300-gas, config/m68k/xm-amix.h, config/m68k/xm-hp320.h, config/m68k/xm-m68kv.h, config/m68k/xm-mot3300.h, config/m88k/x-dolph, config/m88k/x-sysv4, config/m88k/x-tekXD88, config/m88k/xm-m88k.h, config/mcore/xm-mcore.h, config/mips/x-iris, config/mips/x-iris3, config/mips/x-sni-svr4, config/mips/x-sysv, config/mips/xm-iris6.h, config/mips/xm-mips.h, config/mips/xm-nws3250v4.h, config/pa/x-hpux, config/pa/x-pa-mpeix, config/pa/xm-pa.h, config/pa/xm-pa64hpux.h, config/pa/xm-pahpux.h, config/pa/xm-papro.h, config/romp/xm-romp.h, config/rs6000/x-aix31, config/rs6000/x-aix41, config/rs6000/x-beos, config/rs6000/x-lynx, config/rs6000/x-mach, config/rs6000/x-rs6000, config/rs6000/x-sysv4, config/rs6000/xm-rs6000.h, config/rs6000/xm-sysv4.h, config/sh/xm-sh.h, config/sparc/x-sysv4, config/sparc/xm-linux.h, config/sparc/xm-pbd.h, config/sparc/xm-sparc.h, config/vax/xm-vms.h: Eradicate all references to alloca and related stuff. * config/xm-alloca.h, config/clipper/x-clix, config/i386/xm-sysv4.h, config/i860/x-fx2800, config/i860/x-sysv3, config/m88k/x-sysv3, config/sparc/xm-sol2.h, config/we32k/x-we32k: Delete (contained only alloca related hacks). * config/i386/xm-beos.h, config/rs6000/xm-beos.h: Just define USE_C_ALLOCA. From-SVN: r40259
2001-03-06 10:52:35 +01:00
subpos = (char *) xmalloc (depth + 2);
strcpy (subpos, position);
subpos[depth + 1] = 0;
1991-11-24 20:57:16 +01:00
sub = this = new_decision (position, last);
place = &this->tests;
1991-11-24 20:57:16 +01:00
restart:
mode = GET_MODE (pattern);
code = GET_CODE (pattern);
1991-11-24 20:57:16 +01:00
switch (code)
{
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
case PARALLEL:
/* Toplevel peephole pattern. */
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
if (insn_type == PEEPHOLE2 && top)
{
/* We don't need the node we just created -- unlink it. */
last->first = last->last = NULL;
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
for (i = 0; i < (size_t) XVECLEN (pattern, 0); i++)
{
/* Which insn we're looking at is represented by A-Z. We don't
ever use 'A', however; it is always implied. */
subpos[depth] = (i > 0 ? 'A' + i : 0);
sub = add_to_sequence (XVECEXP (pattern, 0, i),
last, subpos, insn_type, 0);
last = &sub->success;
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
}
aclocal.m4 (libiberty_AC_FUNC_C_ALLOCA): New. libiberty: * aclocal.m4 (libiberty_AC_FUNC_C_ALLOCA): New. * configure.in: Replace all alloca logic with a simple use of the above new macro. * config.table: Kill *-*-beos* entry. * config/mh-beos: Delete. * configure, config.in: Regenerate. * Makefile.in (ALLOCA, HFILES): Kill. (REQUIRED_OFILES): Add alloca.o. (alloca.o): Depend on libiberty.h. (argv.o): Don't depend on alloca-conf.h. * alloca-conf.h: Delete. * alloca.c: Include libiberty.h. Kill all #ifdef emacs blocks. Provide the C alloca unconditionally. Use PTR where appropriate. Make i00afunc static. * argv.c: Don't include alloca-conf.h. include: * libiberty.h: Prototype C_alloca; define alloca to either __builtin_alloca or C_alloca as appropriate. gcc: * aclocal.m4 (AM_GNU_GETTEXT): Don't AC_REQUIRE AC_FUNC_ALLOCA. * configure, config.in: Regenerate. * config.gcc: Remove references to deleted files. * genattr.c, genattrtab.c, genextract.c, genoutput.c, genrecog.c, rtl.c: Do not use alloca anywhere. * Makefile.in, build-make, system.h, config/x-interix, config/x-svr4, config/xm-interix.h, config/xm-openbsd.h, config/alpha/xm-alpha.h, config/alpha/xm-vms.h, config/arc/xm-arc.h, config/arm/xm-arm.h, config/d30v/xm-d30v.h, config/dsp16xx/xm-dsp16xx.h, config/h8300/xm-h8300.h, config/i370/x-oe, config/i370/xm-linux.h, config/i386/x-aix, config/i386/x-beos, config/i386/x-ncr3000, config/i386/x-sco5, config/i386/xm-dgux.h, config/i860/x-sysv4, config/i960/xm-i960.h, config/m32r/xm-m32r.h, config/m68k/x-crds, config/m68k/x-dpx2, config/m68k/x-hp320, config/m68k/x-hp320g, config/m69k/x-mot3300, config/m68k/x-mot3300-gas, config/m68k/xm-amix.h, config/m68k/xm-hp320.h, config/m68k/xm-m68kv.h, config/m68k/xm-mot3300.h, config/m88k/x-dolph, config/m88k/x-sysv4, config/m88k/x-tekXD88, config/m88k/xm-m88k.h, config/mcore/xm-mcore.h, config/mips/x-iris, config/mips/x-iris3, config/mips/x-sni-svr4, config/mips/x-sysv, config/mips/xm-iris6.h, config/mips/xm-mips.h, config/mips/xm-nws3250v4.h, config/pa/x-hpux, config/pa/x-pa-mpeix, config/pa/xm-pa.h, config/pa/xm-pa64hpux.h, config/pa/xm-pahpux.h, config/pa/xm-papro.h, config/romp/xm-romp.h, config/rs6000/x-aix31, config/rs6000/x-aix41, config/rs6000/x-beos, config/rs6000/x-lynx, config/rs6000/x-mach, config/rs6000/x-rs6000, config/rs6000/x-sysv4, config/rs6000/xm-rs6000.h, config/rs6000/xm-sysv4.h, config/sh/xm-sh.h, config/sparc/x-sysv4, config/sparc/xm-linux.h, config/sparc/xm-pbd.h, config/sparc/xm-sparc.h, config/vax/xm-vms.h: Eradicate all references to alloca and related stuff. * config/xm-alloca.h, config/clipper/x-clix, config/i386/xm-sysv4.h, config/i860/x-fx2800, config/i860/x-sysv3, config/m88k/x-sysv3, config/sparc/xm-sol2.h, config/we32k/x-we32k: Delete (contained only alloca related hacks). * config/i386/xm-beos.h, config/rs6000/xm-beos.h: Just define USE_C_ALLOCA. From-SVN: r40259
2001-03-06 10:52:35 +01:00
goto ret;
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
}
/* Else nothing special. */
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
break;
case MATCH_PARALLEL:
/* The explicit patterns within a match_parallel enforce a minimum
length on the vector. The match_parallel predicate may allow
for more elements. We do need to check for this minimum here
or the code generated to match the internals may reference data
beyond the end of the vector. */
test = new_decision_test (DT_veclen_ge, &place);
test->u.veclen = XVECLEN (pattern, 2);
/* FALLTHRU */
1991-11-24 20:57:16 +01:00
case MATCH_OPERAND:
case MATCH_SCRATCH:
case MATCH_OPERATOR:
case MATCH_INSN:
{
const char *pred_name;
RTX_CODE was_code = code;
int allows_const_int = 1;
if (code == MATCH_SCRATCH)
{
pred_name = "scratch_operand";
code = UNKNOWN;
}
else
{
pred_name = XSTR (pattern, 1);
if (code == MATCH_PARALLEL)
code = PARALLEL;
else
code = UNKNOWN;
}
if (pred_name[0] != 0)
{
test = new_decision_test (DT_pred, &place);
test->u.pred.name = pred_name;
test->u.pred.mode = mode;
/* See if we know about this predicate and save its number.
If we do, and it only accepts one code, note that fact.
If we know that the predicate does not allow CONST_INT,
we know that the only way the predicate can match is if
the modes match (here we use the kludge of relying on the
fact that "address_operand" accepts CONST_INT; otherwise,
it would have to be a special case), so we can test the
mode (but we need not). This fact should considerably
simplify the generated code. */
for (i = 0; i < NUM_KNOWN_PREDS; i++)
if (! strcmp (preds[i].name, pred_name))
break;
if (i < NUM_KNOWN_PREDS)
{
int j;
test->u.pred.index = i;
if (preds[i].codes[1] == 0 && code == UNKNOWN)
code = preds[i].codes[0];
allows_const_int = 0;
for (j = 0; preds[i].codes[j] != 0; j++)
if (preds[i].codes[j] == CONST_INT)
{
allows_const_int = 1;
break;
}
}
else
test->u.pred.index = -1;
}
/* Can't enforce a mode if we allow const_int. */
if (allows_const_int)
mode = VOIDmode;
/* Accept the operand, ie. record it in `operands'. */
test = new_decision_test (DT_accept_op, &place);
test->u.opno = XINT (pattern, 0);
if (was_code == MATCH_OPERATOR || was_code == MATCH_PARALLEL)
{
char base = (was_code == MATCH_OPERATOR ? '0' : 'a');
for (i = 0; i < (size_t) XVECLEN (pattern, 2); i++)
{
subpos[depth] = i + base;
sub = add_to_sequence (XVECEXP (pattern, 2, i),
&sub->success, subpos, insn_type, 0);
}
}
goto fini;
}
1991-11-24 20:57:16 +01:00
case MATCH_OP_DUP:
code = UNKNOWN;
test = new_decision_test (DT_dup, &place);
test->u.dup = XINT (pattern, 0);
test = new_decision_test (DT_accept_op, &place);
test->u.opno = XINT (pattern, 0);
Warning fixes: * Makefile.in (sched.o): Depend on recog.h. * alias.c (REG_BASE_VALUE): Cast the result of REGNO() macro to (unsigned) when comparing against one. (find_base_value): Likewise. (record_base_value): Cast variable `regno' to (unsigned) when comparing against one. Cast the result of REGNO() macro to (unsigned) when comparing against one. (memrefs_conflict_p): Change type of variables `r_x' and `r_y' to unsigned. (init_alias_analysis): Add unsigned variable `ui'. Use it as loop variable where an unsigned index is needed. * caller-save.c (init_caller_save): Cast `-1' to (enum insn_code) before comparing against one. * collect2.c: Add prototypes for functions `error', `fatal' and `fatal_perror'. Make these functions take variable arguments instead of faking it with a fixed number of args. (write_c_file_stat): Cast the argument of ctype macro to (unsigned char). * combine.c (can_combine_p): Mark parameter `pred' with ATTRIBUTE_UNUSED. (find_split_point): Cast variable `src' to (unsigned HOST_WIDE_INT) when comparing against one. HOST_WIDE_INT) when comparing against one. (simplify_rtx): Cast 1 to (unsigned HOST_WIDE_INT) in shift. (simplify_logical): Likewise. (force_to_mode): Cast result of INTVAL() macro to (unsigned HOST_WIDE_INT) when comparing against one. Cast 1 to (unsigned HOST_WIDE_INT) in shift. (simplify_and_const_int): Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (merge_outer_ops): Cast variable const0 to `unsigned HOST_WIDE_INT' when comparing against the result of GET_MODE_MASK() macro. (simplify_comparison): Likewise for variable `c0'. Cast variable `const_op' to `unsigned HOST_WIDE_INT' when comparing against one. Cast `1' to `unsigned HOST_WIDE_INT' in shift. Cast the result of `GET_MODE_MASK()/2' to `HOST_WIDE_INT' when comparing against one. Cast `1' to `unsigned HOST_WIDE_INT' in shift. Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (distribute_notes): Wrap variable `cc0_setter' in macro `HAVE_cc0'. config/mips/mips.c (gen_int_relational): Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (output_block_move): Cast `sizeof' expression to (int) when comparing against one. (function_arg): Cast BITS_PER_WORD to `unsigned' when comparing against one. (save_restore_insns): Cast `base_offset' to `long' to match format specifier in fprintf. * config/mips/mips.h (Pmode): Cast the result of `Pmode' macro to `enum machine_mode'. * flow.c (life_analysis_1): Remove unused variable `insn'. * gcc.c (translate_options): Move variables `j' and `k' into the scope in which they are used. Change their types to `size_t'. (set_spec): Cast the argument of ctype macro to `unsigned char'. (read_specs): Likewise. (process_command): Cast `sizeof' to (int) when comparing against one. (do_spec_1): Cast the argument of ctype macro to `unsigned char'. (handle_braces): Cast both sides of `==' expression to `long' to ensure sign matching. (main): Cast variable `i' to `int' when comparing against one. * gcov-io.h (__fetch_long): Change type of parameter `bytes' from int to size_t. Cast variable `i' to size_t when comparing against one. * genattrtab.c (convert_set_attr_alternative): Remove unused parameter `insn_code'. All callers changed. (convert_set_attr): Likewise. * genrecog.c (add_to_sequence): Cast result of XVECLEN() macro to size_t when comparing against one. Likewise for variable `len'. * global.c (global_alloc): Cast variable `max_regno' to size_t when comparing against one. Likewise for variable `max_allocno'. * jump.c (sets_cc0_p): Mark parameter `x' with ATTRIBUTE_UNUSED. * local-alloc.c (validate_equiv_mem_from_store): Mark parameter `set' with ATTRIBUTE_UNUSED. (find_free_reg): Cast `sizeof' expression to (int) when comparing against one. * loop.c (count_loop_regs_set): Remove unused variable `dest'. (strength_reduce): Mark parameter `bct_p' with ATTRIBUTE_UNUSED. (get_condition): Cast variable `const_val' to `unsigned HOST_WIDE_INT' when comparing against one. Cast unsigned expression to HOST_WIDE_INT when comparing against one. (insert_loop_mem): Mark parameter `data' with ATTRIBUTE_UNUSED. (load_mems_and_recount_loop_regs_set): Cast variable `nregs' to `unsigned' when comparing against one. * protoize.c (is_id_char): Change type of parameter `ch' to unsigned char. (munge_compile_params): Cast argument of ctype macro to (const unsigned char). (process_aux_info_file): Cast variable `aux_info_size' to int when comparing against one. (forward_to_next_token_char): Cast argument of ctype macro to `const unsigned char'. (edit_formals_lists): Likewise. (find_rightmost_formals_list): Likewise. (add_local_decl): Likewise. (add_global_decls): Likewise. (edit_fn_definition): Likewise. (do_cleaning): Likewise. (scan_for_missed_items): Likewise. (edit_file): Cast variable `orig_size' to (int) when comparing against one. (main): Cast argument of ctype macro to `const unsigned char'. * recog.c (const_int_operand): Mark parameter `mode' with ATTRIBUTE_UNUSED. * regclass.c (record_reg_classes): Change type of variable `c' to `unsigned char'. Cast `char' array index to `unsigned char'. * reload.c (push_secondary_reload): Cast argument to REG_CLASS_FROM_LETTER() macro to `unsigned char'. * reload1.c (calculate_needs): Cast `char' array index to `unsigned char'. (set_label_offsets): Change type of variable `i' to unsigned int. Cast result of XVECLEN() macro to unsigned when comparing against one. (mark_not_eliminable): Change type of variable `i' to unsigned. (order_regs_for_reload): Likewise. Cast `max_regno' to unsigned when comparing against one. (reload_as_needed): Cast macro NUM_ELIMINABLE_REGS to (int) when comparing against one. (choose_reload_regs): Hide unused label `fail'. (reload_cse_simplify_operands): Cast `char' array index to `unsigned char'. (reload_combine_note_store): Mark parameter `set' with ATTRIBUTE_UNUSED. Cast UNITS_PER_WORD to unsigned when comparing against one. (reload_cse_move2add): Remove unused variable `src2'. * sched.c: Include recog.h. (sched_note_set): Remove unused parameter `b'. All callers changed. (split_hard_reg_notes): Likewise for parameter `orig_insn'. (blockage_range): Cast result of UNIT_BLOCKED() macro to (int) when comparing against one. * stupid.c (stupid_find_reg): Mark parameter `changes_size' with ATTRIBUTE_UNUSED. Cast `sizeof' expression to (int) when comparing against one. * unroll.c (precondition_loop_p): Remove unused parameter `loop_end'. All callers changed. From-SVN: r23079
1998-10-14 11:02:55 +02:00
for (i = 0; i < (size_t) XVECLEN (pattern, 1); i++)
1991-11-24 20:57:16 +01:00
{
subpos[depth] = i + '0';
sub = add_to_sequence (XVECEXP (pattern, 1, i),
&sub->success, subpos, insn_type, 0);
1991-11-24 20:57:16 +01:00
}
goto fini;
1991-11-24 20:57:16 +01:00
case MATCH_DUP:
case MATCH_PAR_DUP:
code = UNKNOWN;
test = new_decision_test (DT_dup, &place);
test->u.dup = XINT (pattern, 0);
goto fini;
1991-11-24 20:57:16 +01:00
case ADDRESS:
pattern = XEXP (pattern, 0);
goto restart;
default:
break;
1991-11-24 20:57:16 +01:00
}
fmt = GET_RTX_FORMAT (code);
len = GET_RTX_LENGTH (code);
/* Do tests against the current node first. */
Warning fixes: * Makefile.in (sched.o): Depend on recog.h. * alias.c (REG_BASE_VALUE): Cast the result of REGNO() macro to (unsigned) when comparing against one. (find_base_value): Likewise. (record_base_value): Cast variable `regno' to (unsigned) when comparing against one. Cast the result of REGNO() macro to (unsigned) when comparing against one. (memrefs_conflict_p): Change type of variables `r_x' and `r_y' to unsigned. (init_alias_analysis): Add unsigned variable `ui'. Use it as loop variable where an unsigned index is needed. * caller-save.c (init_caller_save): Cast `-1' to (enum insn_code) before comparing against one. * collect2.c: Add prototypes for functions `error', `fatal' and `fatal_perror'. Make these functions take variable arguments instead of faking it with a fixed number of args. (write_c_file_stat): Cast the argument of ctype macro to (unsigned char). * combine.c (can_combine_p): Mark parameter `pred' with ATTRIBUTE_UNUSED. (find_split_point): Cast variable `src' to (unsigned HOST_WIDE_INT) when comparing against one. HOST_WIDE_INT) when comparing against one. (simplify_rtx): Cast 1 to (unsigned HOST_WIDE_INT) in shift. (simplify_logical): Likewise. (force_to_mode): Cast result of INTVAL() macro to (unsigned HOST_WIDE_INT) when comparing against one. Cast 1 to (unsigned HOST_WIDE_INT) in shift. (simplify_and_const_int): Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (merge_outer_ops): Cast variable const0 to `unsigned HOST_WIDE_INT' when comparing against the result of GET_MODE_MASK() macro. (simplify_comparison): Likewise for variable `c0'. Cast variable `const_op' to `unsigned HOST_WIDE_INT' when comparing against one. Cast `1' to `unsigned HOST_WIDE_INT' in shift. Cast the result of `GET_MODE_MASK()/2' to `HOST_WIDE_INT' when comparing against one. Cast `1' to `unsigned HOST_WIDE_INT' in shift. Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (distribute_notes): Wrap variable `cc0_setter' in macro `HAVE_cc0'. config/mips/mips.c (gen_int_relational): Cast result of INTVAL() macro to `unsigned HOST_WIDE_INT' when comparing against one. (output_block_move): Cast `sizeof' expression to (int) when comparing against one. (function_arg): Cast BITS_PER_WORD to `unsigned' when comparing against one. (save_restore_insns): Cast `base_offset' to `long' to match format specifier in fprintf. * config/mips/mips.h (Pmode): Cast the result of `Pmode' macro to `enum machine_mode'. * flow.c (life_analysis_1): Remove unused variable `insn'. * gcc.c (translate_options): Move variables `j' and `k' into the scope in which they are used. Change their types to `size_t'. (set_spec): Cast the argument of ctype macro to `unsigned char'. (read_specs): Likewise. (process_command): Cast `sizeof' to (int) when comparing against one. (do_spec_1): Cast the argument of ctype macro to `unsigned char'. (handle_braces): Cast both sides of `==' expression to `long' to ensure sign matching. (main): Cast variable `i' to `int' when comparing against one. * gcov-io.h (__fetch_long): Change type of parameter `bytes' from int to size_t. Cast variable `i' to size_t when comparing against one. * genattrtab.c (convert_set_attr_alternative): Remove unused parameter `insn_code'. All callers changed. (convert_set_attr): Likewise. * genrecog.c (add_to_sequence): Cast result of XVECLEN() macro to size_t when comparing against one. Likewise for variable `len'. * global.c (global_alloc): Cast variable `max_regno' to size_t when comparing against one. Likewise for variable `max_allocno'. * jump.c (sets_cc0_p): Mark parameter `x' with ATTRIBUTE_UNUSED. * local-alloc.c (validate_equiv_mem_from_store): Mark parameter `set' with ATTRIBUTE_UNUSED. (find_free_reg): Cast `sizeof' expression to (int) when comparing against one. * loop.c (count_loop_regs_set): Remove unused variable `dest'. (strength_reduce): Mark parameter `bct_p' with ATTRIBUTE_UNUSED. (get_condition): Cast variable `const_val' to `unsigned HOST_WIDE_INT' when comparing against one. Cast unsigned expression to HOST_WIDE_INT when comparing against one. (insert_loop_mem): Mark parameter `data' with ATTRIBUTE_UNUSED. (load_mems_and_recount_loop_regs_set): Cast variable `nregs' to `unsigned' when comparing against one. * protoize.c (is_id_char): Change type of parameter `ch' to unsigned char. (munge_compile_params): Cast argument of ctype macro to (const unsigned char). (process_aux_info_file): Cast variable `aux_info_size' to int when comparing against one. (forward_to_next_token_char): Cast argument of ctype macro to `const unsigned char'. (edit_formals_lists): Likewise. (find_rightmost_formals_list): Likewise. (add_local_decl): Likewise. (add_global_decls): Likewise. (edit_fn_definition): Likewise. (do_cleaning): Likewise. (scan_for_missed_items): Likewise. (edit_file): Cast variable `orig_size' to (int) when comparing against one. (main): Cast argument of ctype macro to `const unsigned char'. * recog.c (const_int_operand): Mark parameter `mode' with ATTRIBUTE_UNUSED. * regclass.c (record_reg_classes): Change type of variable `c' to `unsigned char'. Cast `char' array index to `unsigned char'. * reload.c (push_secondary_reload): Cast argument to REG_CLASS_FROM_LETTER() macro to `unsigned char'. * reload1.c (calculate_needs): Cast `char' array index to `unsigned char'. (set_label_offsets): Change type of variable `i' to unsigned int. Cast result of XVECLEN() macro to unsigned when comparing against one. (mark_not_eliminable): Change type of variable `i' to unsigned. (order_regs_for_reload): Likewise. Cast `max_regno' to unsigned when comparing against one. (reload_as_needed): Cast macro NUM_ELIMINABLE_REGS to (int) when comparing against one. (choose_reload_regs): Hide unused label `fail'. (reload_cse_simplify_operands): Cast `char' array index to `unsigned char'. (reload_combine_note_store): Mark parameter `set' with ATTRIBUTE_UNUSED. Cast UNITS_PER_WORD to unsigned when comparing against one. (reload_cse_move2add): Remove unused variable `src2'. * sched.c: Include recog.h. (sched_note_set): Remove unused parameter `b'. All callers changed. (split_hard_reg_notes): Likewise for parameter `orig_insn'. (blockage_range): Cast result of UNIT_BLOCKED() macro to (int) when comparing against one. * stupid.c (stupid_find_reg): Mark parameter `changes_size' with ATTRIBUTE_UNUSED. Cast `sizeof' expression to (int) when comparing against one. * unroll.c (precondition_loop_p): Remove unused parameter `loop_end'. All callers changed. From-SVN: r23079
1998-10-14 11:02:55 +02:00
for (i = 0; i < (size_t) len; i++)
1991-11-24 20:57:16 +01:00
{
if (fmt[i] == 'i')
1991-11-24 20:57:16 +01:00
{
if (i == 0)
{
test = new_decision_test (DT_elt_zero_int, &place);
test->u.intval = XINT (pattern, i);
}
else if (i == 1)
{
test = new_decision_test (DT_elt_one_int, &place);
test->u.intval = XINT (pattern, i);
}
else
abort ();
1991-11-24 20:57:16 +01:00
}
else if (fmt[i] == 'w')
1992-07-06 22:02:55 +02:00
{
/* If this value actually fits in an int, we can use a switch
statement here, so indicate that. */
enum decision_type type
= ((int) XWINT (pattern, i) == XWINT (pattern, i))
? DT_elt_zero_wide_safe : DT_elt_zero_wide;
if (i != 0)
abort ();
test = new_decision_test (type, &place);
test->u.intval = XWINT (pattern, i);
1992-07-06 22:02:55 +02:00
}
1991-11-24 20:57:16 +01:00
else if (fmt[i] == 'E')
{
if (i != 0)
abort ();
test = new_decision_test (DT_veclen, &place);
test->u.veclen = XVECLEN (pattern, i);
}
}
/* Now test our sub-patterns. */
for (i = 0; i < (size_t) len; i++)
{
switch (fmt[i])
{
case 'e': case 'u':
subpos[depth] = '0' + i;
sub = add_to_sequence (XEXP (pattern, i), &sub->success,
subpos, insn_type, 0);
break;
case 'E':
{
alias.c: Remove uses of "register" specifier in declarations of arguments and local... 2001-10-10 Stan Shebs <shebs@apple.com> * alias.c: Remove uses of "register" specifier in declarations of arguments and local variables. * c-common.c: Ditto. * c-convert.c: Ditto. * c-decl.c: Ditto. * c-format.c: Ditto. * c-semantics.c: Ditto. * c-typeck.c: Ditto. * caller-save.c: Ditto. * calls.c: Ditto. * cfg.c: Ditto. * cfgbuild.c: Ditto. * cfgrtl.c: Ditto. * collect2.c: Ditto. * combine.c: Ditto. * convert.c: Ditto. * cppexp.c: Ditto. * cppfiles.c: Ditto. * cse.c: Ditto. * dbxout.c: Ditto. * defaults.h: Ditto. * df.c: Ditto. * dwarf2out.c: Ditto. * dwarfout.c: Ditto. * emit-rtl.c: Ditto. * explow.c: Ditto. * expmed.c: Ditto. * expr.c: Ditto. * final.c: Ditto. * fix-header.c: Ditto. * floatlib.c: Ditto. * flow.c: Ditto. * fold-const.c: Ditto. * function.c: Ditto. * gcc.c: Ditto. * gcse.c: Ditto. * gen-protos.c: Ditto. * genattrtab.c: Ditto. * gencheck.c: Ditto. * genconfig.c: Ditto. * genemit.c: Ditto. * genextract.c: Ditto. * genflags.c: Ditto. * gengenrtl.c: Ditto. * genoutput.c: Ditto. * genpeep.c: Ditto. * genrecog.c: Ditto. * gensupport.c: Ditto. * global.c: Ditto. * gmon.c: Ditto. * graph.c: Ditto. * haifa-sched.c: Ditto. * hard-reg-set.h: Ditto. * hash.c: Ditto. * integrate.c: Ditto. * jump.c: Ditto. * lists.c: Ditto. * local-alloc.c: Ditto. * loop.c: Ditto. * mips-tdump.c: Ditto. * mips-tfile.c: Ditto. * optabs.c: Ditto. * prefix.c: Ditto. * print-rtl.c: Ditto. * read-rtl.c: Ditto. * real.c: Ditto. * recog.c: Ditto. * reg-stack.c: Ditto. * regclass.c: Ditto. * regmove.c: Ditto. * reload.c: Ditto. * reload1.c: Ditto. * reorg.c: Ditto. * resource.c: Ditto. * rtl.c: Ditto. * rtlanal.c: Ditto. * scan.c: Ditto. * sched-deps.c: Ditto. * sched-rgn.c: Ditto. * sdbout.c: Ditto. * simplify-rtx.c: Ditto. * stmt.c: Ditto. * stor-layout.c: Ditto. * toplev.c: Ditto. * tradcif.y: Ditto. * tradcpp.c: Ditto. * tree.c: Ditto. * unroll.c: Ditto. * varasm.c: Ditto. * xcoffout.c: Ditto. From-SVN: r46173
2001-10-11 05:16:15 +02:00
int j;
for (j = 0; j < XVECLEN (pattern, i); j++)
{
subpos[depth] = 'a' + j;
sub = add_to_sequence (XVECEXP (pattern, i, j),
&sub->success, subpos, insn_type, 0);
}
break;
}
case 'i': case 'w':
/* Handled above. */
break;
case '0':
break;
default:
abort ();
}
}
fini:
/* Insert nodes testing mode and code, if they're still relevant,
before any of the nodes we may have added above. */
if (code != UNKNOWN)
{
place = &this->tests;
test = new_decision_test (DT_code, &place);
test->u.code = code;
}
if (mode != VOIDmode)
{
place = &this->tests;
test = new_decision_test (DT_mode, &place);
test->u.mode = mode;
}
/* If we didn't insert any tests or accept nodes, hork. */
if (this->tests == NULL)
abort ();
aclocal.m4 (libiberty_AC_FUNC_C_ALLOCA): New. libiberty: * aclocal.m4 (libiberty_AC_FUNC_C_ALLOCA): New. * configure.in: Replace all alloca logic with a simple use of the above new macro. * config.table: Kill *-*-beos* entry. * config/mh-beos: Delete. * configure, config.in: Regenerate. * Makefile.in (ALLOCA, HFILES): Kill. (REQUIRED_OFILES): Add alloca.o. (alloca.o): Depend on libiberty.h. (argv.o): Don't depend on alloca-conf.h. * alloca-conf.h: Delete. * alloca.c: Include libiberty.h. Kill all #ifdef emacs blocks. Provide the C alloca unconditionally. Use PTR where appropriate. Make i00afunc static. * argv.c: Don't include alloca-conf.h. include: * libiberty.h: Prototype C_alloca; define alloca to either __builtin_alloca or C_alloca as appropriate. gcc: * aclocal.m4 (AM_GNU_GETTEXT): Don't AC_REQUIRE AC_FUNC_ALLOCA. * configure, config.in: Regenerate. * config.gcc: Remove references to deleted files. * genattr.c, genattrtab.c, genextract.c, genoutput.c, genrecog.c, rtl.c: Do not use alloca anywhere. * Makefile.in, build-make, system.h, config/x-interix, config/x-svr4, config/xm-interix.h, config/xm-openbsd.h, config/alpha/xm-alpha.h, config/alpha/xm-vms.h, config/arc/xm-arc.h, config/arm/xm-arm.h, config/d30v/xm-d30v.h, config/dsp16xx/xm-dsp16xx.h, config/h8300/xm-h8300.h, config/i370/x-oe, config/i370/xm-linux.h, config/i386/x-aix, config/i386/x-beos, config/i386/x-ncr3000, config/i386/x-sco5, config/i386/xm-dgux.h, config/i860/x-sysv4, config/i960/xm-i960.h, config/m32r/xm-m32r.h, config/m68k/x-crds, config/m68k/x-dpx2, config/m68k/x-hp320, config/m68k/x-hp320g, config/m69k/x-mot3300, config/m68k/x-mot3300-gas, config/m68k/xm-amix.h, config/m68k/xm-hp320.h, config/m68k/xm-m68kv.h, config/m68k/xm-mot3300.h, config/m88k/x-dolph, config/m88k/x-sysv4, config/m88k/x-tekXD88, config/m88k/xm-m88k.h, config/mcore/xm-mcore.h, config/mips/x-iris, config/mips/x-iris3, config/mips/x-sni-svr4, config/mips/x-sysv, config/mips/xm-iris6.h, config/mips/xm-mips.h, config/mips/xm-nws3250v4.h, config/pa/x-hpux, config/pa/x-pa-mpeix, config/pa/xm-pa.h, config/pa/xm-pa64hpux.h, config/pa/xm-pahpux.h, config/pa/xm-papro.h, config/romp/xm-romp.h, config/rs6000/x-aix31, config/rs6000/x-aix41, config/rs6000/x-beos, config/rs6000/x-lynx, config/rs6000/x-mach, config/rs6000/x-rs6000, config/rs6000/x-sysv4, config/rs6000/xm-rs6000.h, config/rs6000/xm-sysv4.h, config/sh/xm-sh.h, config/sparc/x-sysv4, config/sparc/xm-linux.h, config/sparc/xm-pbd.h, config/sparc/xm-sparc.h, config/vax/xm-vms.h: Eradicate all references to alloca and related stuff. * config/xm-alloca.h, config/clipper/x-clix, config/i386/xm-sysv4.h, config/i860/x-fx2800, config/i860/x-sysv3, config/m88k/x-sysv3, config/sparc/xm-sol2.h, config/we32k/x-we32k: Delete (contained only alloca related hacks). * config/i386/xm-beos.h, config/rs6000/xm-beos.h: Just define USE_C_ALLOCA. From-SVN: r40259
2001-03-06 10:52:35 +01:00
ret:
free (subpos);
return sub;
}
/* A subroutine of maybe_both_true; examines only one test.
Returns > 0 for "definitely both true" and < 0 for "maybe both true". */
static int
maybe_both_true_2 (d1, d2)
struct decision_test *d1, *d2;
{
if (d1->type == d2->type)
{
switch (d1->type)
{
case DT_mode:
return d1->u.mode == d2->u.mode;
case DT_code:
return d1->u.code == d2->u.code;
case DT_veclen:
return d1->u.veclen == d2->u.veclen;
case DT_elt_zero_int:
case DT_elt_one_int:
case DT_elt_zero_wide:
case DT_elt_zero_wide_safe:
return d1->u.intval == d2->u.intval;
default:
break;
}
}
/* If either has a predicate that we know something about, set
things up so that D1 is the one that always has a known
predicate. Then see if they have any codes in common. */
if (d1->type == DT_pred || d2->type == DT_pred)
{
if (d2->type == DT_pred)
{
struct decision_test *tmp;
tmp = d1, d1 = d2, d2 = tmp;
}
/* If D2 tests a mode, see if it matches D1. */
if (d1->u.pred.mode != VOIDmode)
{
if (d2->type == DT_mode)
{
if (d1->u.pred.mode != d2->u.mode
/* The mode of an address_operand predicate is the
mode of the memory, not the operand. It can only
be used for testing the predicate, so we must
ignore it here. */
&& strcmp (d1->u.pred.name, "address_operand") != 0)
return 0;
}
/* Don't check two predicate modes here, because if both predicates
accept CONST_INT, then both can still be true even if the modes
are different. If they don't accept CONST_INT, there will be a
separate DT_mode that will make maybe_both_true_1 return 0. */
}
if (d1->u.pred.index >= 0)
{
/* If D2 tests a code, see if it is in the list of valid
codes for D1's predicate. */
if (d2->type == DT_code)
{
const RTX_CODE *c = &preds[d1->u.pred.index].codes[0];
while (*c != 0)
{
if (*c == d2->u.code)
break;
++c;
}
if (*c == 0)
return 0;
}
/* Otherwise see if the predicates have any codes in common. */
else if (d2->type == DT_pred && d2->u.pred.index >= 0)
1991-11-24 20:57:16 +01:00
{
const RTX_CODE *c1 = &preds[d1->u.pred.index].codes[0];
int common = 0;
while (*c1 != 0 && !common)
{
const RTX_CODE *c2 = &preds[d2->u.pred.index].codes[0];
while (*c2 != 0 && !common)
{
common = (*c1 == *c2);
++c2;
}
++c1;
}
if (!common)
return 0;
1991-11-24 20:57:16 +01:00
}
}
}
/* Tests vs veclen may be known when strict equality is involved. */
if (d1->type == DT_veclen && d2->type == DT_veclen_ge)
return d1->u.veclen >= d2->u.veclen;
if (d1->type == DT_veclen_ge && d2->type == DT_veclen)
return d2->u.veclen >= d1->u.veclen;
return -1;
1991-11-24 20:57:16 +01:00
}
/* A subroutine of maybe_both_true; examines all the tests for a given node.
Returns > 0 for "definitely both true" and < 0 for "maybe both true". */
static int
maybe_both_true_1 (d1, d2)
struct decision_test *d1, *d2;
{
struct decision_test *t1, *t2;
/* A match_operand with no predicate can match anything. Recognize
this by the existence of a lone DT_accept_op test. */
if (d1->type == DT_accept_op || d2->type == DT_accept_op)
return 1;
/* Eliminate pairs of tests while they can exactly match. */
while (d1 && d2 && d1->type == d2->type)
{
if (maybe_both_true_2 (d1, d2) == 0)
return 0;
d1 = d1->next, d2 = d2->next;
}
/* After that, consider all pairs. */
for (t1 = d1; t1 ; t1 = t1->next)
for (t2 = d2; t2 ; t2 = t2->next)
if (maybe_both_true_2 (t1, t2) == 0)
return 0;
return -1;
}
/* Return 0 if we can prove that there is no RTL that can match both
D1 and D2. Otherwise, return 1 (it may be that there is an RTL that
can match both or just that we couldn't prove there wasn't such an RTL).
1991-11-24 20:57:16 +01:00
TOPLEVEL is nonzero if we are to only look at the top level and not
recursively descend. */
1991-11-24 20:57:16 +01:00
static int
maybe_both_true (d1, d2, toplevel)
struct decision *d1, *d2;
int toplevel;
1991-11-24 20:57:16 +01:00
{
struct decision *p1, *p2;
int cmp;
/* Don't compare strings on the different positions in insn. Doing so
is incorrect and results in false matches from constructs like
[(set (subreg:HI (match_operand:SI "register_operand" "r") 0)
(subreg:HI (match_operand:SI "register_operand" "r") 0))]
vs
[(set (match_operand:HI "register_operand" "r")
(match_operand:HI "register_operand" "r"))]
If we are presented with such, we are recursing through the remainder
of a node's success nodes (from the loop at the end of this function).
Skip forward until we come to a position that matches.
Due to the way position strings are constructed, we know that iterating
forward from the lexically lower position (e.g. "00") will run into
the lexically higher position (e.g. "1") and not the other way around.
This saves a bit of effort. */
cmp = strcmp (d1->position, d2->position);
if (cmp != 0)
{
if (toplevel)
abort ();
/* If the d2->position was lexically lower, swap. */
if (cmp > 0)
1999-09-22 08:53:35 +02:00
p1 = d1, d1 = d2, d2 = p1;
if (d1->success.first == 0)
return 1;
for (p1 = d1->success.first; p1; p1 = p1->next)
if (maybe_both_true (p1, d2, 0))
return 1;
return 0;
}
/* Test the current level. */
cmp = maybe_both_true_1 (d1->tests, d2->tests);
if (cmp >= 0)
return cmp;
/* We can't prove that D1 and D2 cannot both be true. If we are only
to check the top level, return 1. Otherwise, see if we can prove
that all choices in both successors are mutually exclusive. If
either does not have any successors, we can't prove they can't both
be true. */
if (toplevel || d1->success.first == 0 || d2->success.first == 0)
return 1;
for (p1 = d1->success.first; p1; p1 = p1->next)
for (p2 = d2->success.first; p2; p2 = p2->next)
if (maybe_both_true (p1, p2, 0))
return 1;
return 0;
}
1991-11-24 20:57:16 +01:00
/* A subroutine of nodes_identical. Examine two tests for equivalence. */
1991-11-24 20:57:16 +01:00
static int
nodes_identical_1 (d1, d2)
struct decision_test *d1, *d2;
{
switch (d1->type)
1991-11-24 20:57:16 +01:00
{
case DT_mode:
return d1->u.mode == d2->u.mode;
case DT_code:
return d1->u.code == d2->u.code;
case DT_pred:
return (d1->u.pred.mode == d2->u.pred.mode
&& strcmp (d1->u.pred.name, d2->u.pred.name) == 0);
case DT_c_test:
return strcmp (d1->u.c_test, d2->u.c_test) == 0;
case DT_veclen:
case DT_veclen_ge:
return d1->u.veclen == d2->u.veclen;
case DT_dup:
return d1->u.dup == d2->u.dup;
case DT_elt_zero_int:
case DT_elt_one_int:
case DT_elt_zero_wide:
case DT_elt_zero_wide_safe:
return d1->u.intval == d2->u.intval;
case DT_accept_op:
return d1->u.opno == d2->u.opno;
case DT_accept_insn:
/* Differences will be handled in merge_accept_insn. */
return 1;
default:
abort ();
1991-11-24 20:57:16 +01:00
}
}
1991-11-24 20:57:16 +01:00
/* True iff the two nodes are identical (on one level only). Due
to the way these lists are constructed, we shouldn't have to
consider different orderings on the tests. */
1991-11-24 20:57:16 +01:00
static int
nodes_identical (d1, d2)
struct decision *d1, *d2;
{
struct decision_test *t1, *t2;
for (t1 = d1->tests, t2 = d2->tests; t1 && t2; t1 = t1->next, t2 = t2->next)
{
if (t1->type != t2->type)
return 0;
if (! nodes_identical_1 (t1, t2))
return 0;
}
/* For success, they should now both be null. */
if (t1 != t2)
return 0;
/* Check that their subnodes are at the same position, as any one set
of sibling decisions must be at the same position. Allowing this
requires complications to find_afterward and when change_state is
invoked. */
if (d1->success.first
&& d2->success.first
&& strcmp (d1->success.first->position, d2->success.first->position))
return 0;
return 1;
}
/* A subroutine of merge_trees; given two nodes that have been declared
identical, cope with two insn accept states. If they differ in the
number of clobbers, then the conflict was created by make_insn_sequence
and we can drop the with-clobbers version on the floor. If both
nodes have no additional clobbers, we have found an ambiguity in the
source machine description. */
static void
merge_accept_insn (oldd, addd)
struct decision *oldd, *addd;
1991-11-24 20:57:16 +01:00
{
struct decision_test *old, *add;
for (old = oldd->tests; old; old = old->next)
if (old->type == DT_accept_insn)
break;
if (old == NULL)
return;
for (add = addd->tests; add; add = add->next)
if (add->type == DT_accept_insn)
break;
if (add == NULL)
return;
/* If one node is for a normal insn and the second is for the base
insn with clobbers stripped off, the second node should be ignored. */
if (old->u.insn.num_clobbers_to_add == 0
&& add->u.insn.num_clobbers_to_add > 0)
{
/* Nothing to do here. */
}
else if (old->u.insn.num_clobbers_to_add > 0
&& add->u.insn.num_clobbers_to_add == 0)
{
/* In this case, replace OLD with ADD. */
old->u.insn = add->u.insn;
}
else
{
message_with_line (add->u.insn.lineno, "`%s' matches `%s'",
get_insn_name (add->u.insn.code_number),
get_insn_name (old->u.insn.code_number));
message_with_line (old->u.insn.lineno, "previous definition of `%s'",
get_insn_name (old->u.insn.code_number));
error_count++;
}
}
/* Merge two decision trees OLDH and ADDH, modifying OLDH destructively. */
static void
merge_trees (oldh, addh)
struct decision_head *oldh, *addh;
{
struct decision *next, *add;
if (addh->first == 0)
return;
if (oldh->first == 0)
{
*oldh = *addh;
return;
}
1991-11-24 20:57:16 +01:00
/* Trying to merge bits at different positions isn't possible. */
if (strcmp (oldh->first->position, addh->first->position))
abort ();
for (add = addh->first; add ; add = next)
1991-11-24 20:57:16 +01:00
{
struct decision *old, *insert_before = NULL;
next = add->next;
/* The semantics of pattern matching state that the tests are
done in the order given in the MD file so that if an insn
matches two patterns, the first one will be used. However,
in practice, most, if not all, patterns are unambiguous so
that their order is independent. In that case, we can merge
identical tests and group all similar modes and codes together.
Scan starting from the end of OLDH until we reach a point
where we reach the head of the list or where we pass a
pattern that could also be true if NEW is true. If we find
an identical pattern, we can merge them. Also, record the
last node that tests the same code and mode and the last one
that tests just the same mode.
If we have no match, place NEW after the closest match we found. */
for (old = oldh->last; old; old = old->prev)
1991-11-24 20:57:16 +01:00
{
if (nodes_identical (old, add))
{
merge_accept_insn (old, add);
merge_trees (&old->success, &add->success);
goto merged_nodes;
}
if (maybe_both_true (old, add, 0))
break;
/* Insert the nodes in DT test type order, which is roughly
how expensive/important the test is. Given that the tests
are also ordered within the list, examining the first is
sufficient. */
print-rtl.c (print_rtx): Cast enums to int for comparison. * print-rtl.c (print_rtx): Cast enums to int for comparison. * c-decl.c (grokdeclarator): Cast enums to int for comparison and shifts. * c-format.c (C_STD_VER): Cast to int for comparisons. (check_function_format): Cast various enums to int for &. (maybe_read_dollar_number): Likewise. (check_format_info): Likewise. (check_format_info_main): Likewise. * expr.c (emit_move_insn_1): Cast enums to unsigned int for comparison. (safe_from_p): Likewise. * varasm.c (const_hash): Cast enum to int for %. * emit-rtl.c (init_emit_once): Use int loop variable to work around pcc enum problems with < and ++ operators. * regclass.c (init_reg_sets_1): Cast enums for comparison. (choose_hard_reg_mode): Use unsigned int to iterate over CCmodes. (regclass_init): Change enum class to int to iterate over reg_classes. * genrecog.c (merge_trees): Cast enums for comparison. * rtl.h (GET_CODE): Cast to enum rtx_code. (PUT_CODE): Cast to ENUM_BITFIELD(rtx_code). (GET_MODE): Cast to enum machine_mode. (PUT_MODE): Cast to ENUM_BITFIELD(machine_mode). (GET_NOTE_INSN_NAME): Cast enum to int. * tree.h (TREE_CODE): Cast to enum tree_code. (TREE_SET_CODE): Cast VALUE to ENUM_BITFIELD(tree_code). * timevar.c (timevar_print): Change loop variable id from enum to unsigned int. * fixinc/fixincl.c (VLEVEL): Cast enums in comparison to unsigned int. * config/i386/i386.md: Use PUT_MODE for mode assignment. * toplev.c (compile_file): Cast enum DFI to int. (decode_d_option): Likewise. From-SVN: r40193
2001-03-02 22:41:37 +01:00
if ((int) add->tests->type < (int) old->tests->type)
insert_before = old;
}
if (insert_before == NULL)
{
add->next = NULL;
add->prev = oldh->last;
oldh->last->next = add;
oldh->last = add;
}
else
{
if ((add->prev = insert_before->prev) != NULL)
add->prev->next = add;
else
oldh->first = add;
add->next = insert_before;
insert_before->prev = add;
}
merged_nodes:;
}
}
/* Walk the tree looking for sub-nodes that perform common tests.
Factor out the common test into a new node. This enables us
(depending on the test type) to emit switch statements later. */
static void
factor_tests (head)
struct decision_head *head;
{
struct decision *first, *next;
for (first = head->first; first && first->next; first = next)
{
enum decision_type type;
struct decision *new, *old_last;
type = first->tests->type;
next = first->next;
/* Want at least two compatible sequential nodes. */
if (next->tests->type != type)
continue;
1991-11-24 20:57:16 +01:00
/* Don't want all node types, just those we can turn into
switch statements. */
if (type != DT_mode
&& type != DT_code
&& type != DT_veclen
&& type != DT_elt_zero_int
&& type != DT_elt_one_int
&& type != DT_elt_zero_wide_safe)
continue;
1991-11-24 20:57:16 +01:00
/* If we'd been performing more than one test, create a new node
below our first test. */
if (first->tests->next != NULL)
{
new = new_decision (first->position, &first->success);
new->tests = first->tests->next;
first->tests->next = NULL;
}
/* Crop the node tree off after our first test. */
first->next = NULL;
old_last = head->last;
head->last = first;
/* For each compatible test, adjust to perform only one test in
the top level node, then merge the node back into the tree. */
do
{
struct decision_head h;
if (next->tests->next != NULL)
{
new = new_decision (next->position, &next->success);
new->tests = next->tests->next;
next->tests->next = NULL;
}
new = next;
next = next->next;
new->next = NULL;
h.first = h.last = new;
1991-11-24 20:57:16 +01:00
merge_trees (head, &h);
}
while (next && next->tests->type == type);
1991-11-24 20:57:16 +01:00
/* After we run out of compatible tests, graft the remaining nodes
back onto the tree. */
if (next)
{
next->prev = head->last;
head->last->next = next;
head->last = old_last;
}
}
1991-11-24 20:57:16 +01:00
/* Recurse. */
for (first = head->first; first; first = first->next)
factor_tests (&first->success);
}
/* After factoring, try to simplify the tests on any one node.
Tests that are useful for switch statements are recognizable
by having only a single test on a node -- we'll be manipulating
nodes with multiple tests:
If we have mode tests or code tests that are redundant with
predicates, remove them. */
static void
simplify_tests (head)
struct decision_head *head;
{
struct decision *tree;
for (tree = head->first; tree; tree = tree->next)
{
struct decision_test *a, *b;
a = tree->tests;
b = a->next;
if (b == NULL)
continue;
/* Find a predicate node. */
while (b && b->type != DT_pred)
b = b->next;
if (b)
{
/* Due to how these tests are constructed, we don't even need
to check that the mode and code are compatible -- they were
generated from the predicate in the first place. */
while (a->type == DT_mode || a->type == DT_code)
a = a->next;
tree->tests = a;
}
}
1991-11-24 20:57:16 +01:00
/* Recurse. */
for (tree = head->first; tree; tree = tree->next)
simplify_tests (&tree->success);
1991-11-24 20:57:16 +01:00
}
/* Count the number of subnodes of HEAD. If the number is high enough,
make the first node in HEAD start a separate subroutine in the C code
that is generated. */
1991-11-24 20:57:16 +01:00
static int
break_out_subroutines (head, initial)
struct decision_head *head;
int initial;
1991-11-24 20:57:16 +01:00
{
int size = 0;
struct decision *sub;
for (sub = head->first; sub; sub = sub->next)
size += 1 + break_out_subroutines (&sub->success, 0);
if (size > SUBROUTINE_THRESHOLD && ! initial)
1991-11-24 20:57:16 +01:00
{
head->first->subroutine_number = ++next_subroutine_number;
1991-11-24 20:57:16 +01:00
size = 1;
}
return size;
}
/* For each node p, find the next alternative that might be true
when p is true. */
1991-11-24 20:57:16 +01:00
static void
find_afterward (head, real_afterward)
struct decision_head *head;
struct decision *real_afterward;
1991-11-24 20:57:16 +01:00
{
struct decision *p, *q, *afterward;
/* We can't propagate alternatives across subroutine boundaries.
This is not incorrect, merely a minor optimization loss. */
1991-11-24 20:57:16 +01:00
p = head->first;
afterward = (p->subroutine_number > 0 ? NULL : real_afterward);
for ( ; p ; p = p->next)
{
/* Find the next node that might be true if this one fails. */
for (q = p->next; q ; q = q->next)
if (maybe_both_true (p, q, 1))
break;
/* If we reached the end of the list without finding one,
use the incoming afterward position. */
if (!q)
q = afterward;
p->afterward = q;
if (q)
q->need_label = 1;
}
/* Recurse. */
for (p = head->first; p ; p = p->next)
if (p->success.first)
find_afterward (&p->success, p->afterward);
/* When we are generating a subroutine, record the real afterward
position in the first node where write_tree can find it, and we
can do the right thing at the subroutine call site. */
p = head->first;
if (p->subroutine_number > 0)
p->afterward = real_afterward;
}
/* Assuming that the state of argument is denoted by OLDPOS, take whatever
actions are necessary to move to NEWPOS. If we fail to move to the
new state, branch to node AFTERWARD if nonzero, otherwise return.
Failure to move to the new state can only occur if we are trying to
match multiple insns and we try to step past the end of the stream. */
static void
change_state (oldpos, newpos, afterward, indent)
const char *oldpos;
const char *newpos;
struct decision *afterward;
const char *indent;
{
int odepth = strlen (oldpos);
int ndepth = strlen (newpos);
int depth;
int old_has_insn, new_has_insn;
/* Pop up as many levels as necessary. */
for (depth = odepth; strncmp (oldpos, newpos, depth) != 0; --depth)
continue;
1991-11-24 20:57:16 +01:00
/* Hunt for the last [A-Z] in both strings. */
for (old_has_insn = odepth - 1; old_has_insn >= 0; --old_has_insn)
c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones. * c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones. * collect2.c (dump_file): Likewise. * cppexp.c (parse_number): Likewise. * cpplex.c (_cpp_lex_direct): Likewise. * final.c (output_asm_insn, asm_fprintf): Likewise. * fix-header.c (inf_scan_ident, main): Likewise. * fixinc/fixfixes.c (char_macro_use_fix, char_macro_def_fix): Likewise. * fold-const.c (real_hex_to_f): Likewise. * gen-protos.c (parse_fn_proto): Likewise. * genattrtab.c (check_attr_test, check_attr_value): Likewise. * genrecog.c (change_state, write_action): Likewise. * gensupport.c (shift_output_template): Likewise. * local-alloc.c (requires_inout): Likewise. * mips-tfile.c (IS_ASM_IDENT): Likewise. * protoize.c (is_id_char, main): Likewise. * real.c (asctoeg): Likewise. * recog.c (asm_operand_ok): Likewise. * reload.c (find_reloads): Likewise. * scan.c (scan_identget_token): Likewise. * sched-vis.c (print_value): Likewise. * stringpool.c (ggc_alloc_string): Likewise. * toplev.c (read_integral_parameter, decode_g_option): Likewise. * tradcif.y (parse_number, yylex, parse_escape): Likewise. * tradcpp.c (rescan): Likewise. * tree.c (clean_symbol_name): Likewise. * varasm.c (decode_reg_name): Likewise. * alpha.h (ASM_OUTPUT_ASCII): Likewise. * darwin.c (name_needs_quotes, func_name_maybe_scoped): Likewise. * dsp16xx.h (ASM_OUTPUT_ASCII): Likewise. * m88k.c (output_ascii): Likewise. * m88k.h (OVERRIDE_OPTIONS): Likewise. * mcore.h (REG_CLASS_FROM_LETTER): Likewise. * ns32k/encore.h (ASM_OUTPUT_ASCII): Likewise. * sh.h (REG_CLASS_FROM_LETTER): Likewise. cp: * xref.c (GNU_xref_member): Use safe-ctype macros and/or fold extra calls into fewer ones. f: * bad.c (ffebad_finish): Use safe-ctype macros and/or fold extra calls into fewer ones. * implic.c (ffeimplic_lookup_): Likewise. * intdoc.c (dumpimp): Likewise. * intrin.c (ffeintrin_init_0): Likewise. * lex.c (ffelex_backslash_, ffelex_cfebackslash_, ffelex_hash_): Likewise. * lex.h (ffelex_is_firstnamechar): Likewise. * target.c (ffetarget_integerhex): Likewise. java: * gjavah.c (jni_print_char, decode_signature_piece): Use safe-ctype macros and/or fold extra calls into fewer ones. * lex.c (java_read_unicode, java_lex): Likewise. * lex.h (JAVA_START_CHAR_P, JAVA_PART_CHAR_P, JAVA_ASCII_DIGIT, JAVA_ASCII_HEXDIGIT, JAVA_ASCII_LETTER): Likewise. * mangle_name.c (append_unicode_mangled_name, unicode_mangling_length): Likewise. From-SVN: r46397
2001-10-21 23:32:15 +02:00
if (ISUPPER (oldpos[old_has_insn]))
break;
for (new_has_insn = ndepth - 1; new_has_insn >= 0; --new_has_insn)
c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones. * c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones. * collect2.c (dump_file): Likewise. * cppexp.c (parse_number): Likewise. * cpplex.c (_cpp_lex_direct): Likewise. * final.c (output_asm_insn, asm_fprintf): Likewise. * fix-header.c (inf_scan_ident, main): Likewise. * fixinc/fixfixes.c (char_macro_use_fix, char_macro_def_fix): Likewise. * fold-const.c (real_hex_to_f): Likewise. * gen-protos.c (parse_fn_proto): Likewise. * genattrtab.c (check_attr_test, check_attr_value): Likewise. * genrecog.c (change_state, write_action): Likewise. * gensupport.c (shift_output_template): Likewise. * local-alloc.c (requires_inout): Likewise. * mips-tfile.c (IS_ASM_IDENT): Likewise. * protoize.c (is_id_char, main): Likewise. * real.c (asctoeg): Likewise. * recog.c (asm_operand_ok): Likewise. * reload.c (find_reloads): Likewise. * scan.c (scan_identget_token): Likewise. * sched-vis.c (print_value): Likewise. * stringpool.c (ggc_alloc_string): Likewise. * toplev.c (read_integral_parameter, decode_g_option): Likewise. * tradcif.y (parse_number, yylex, parse_escape): Likewise. * tradcpp.c (rescan): Likewise. * tree.c (clean_symbol_name): Likewise. * varasm.c (decode_reg_name): Likewise. * alpha.h (ASM_OUTPUT_ASCII): Likewise. * darwin.c (name_needs_quotes, func_name_maybe_scoped): Likewise. * dsp16xx.h (ASM_OUTPUT_ASCII): Likewise. * m88k.c (output_ascii): Likewise. * m88k.h (OVERRIDE_OPTIONS): Likewise. * mcore.h (REG_CLASS_FROM_LETTER): Likewise. * ns32k/encore.h (ASM_OUTPUT_ASCII): Likewise. * sh.h (REG_CLASS_FROM_LETTER): Likewise. cp: * xref.c (GNU_xref_member): Use safe-ctype macros and/or fold extra calls into fewer ones. f: * bad.c (ffebad_finish): Use safe-ctype macros and/or fold extra calls into fewer ones. * implic.c (ffeimplic_lookup_): Likewise. * intdoc.c (dumpimp): Likewise. * intrin.c (ffeintrin_init_0): Likewise. * lex.c (ffelex_backslash_, ffelex_cfebackslash_, ffelex_hash_): Likewise. * lex.h (ffelex_is_firstnamechar): Likewise. * target.c (ffetarget_integerhex): Likewise. java: * gjavah.c (jni_print_char, decode_signature_piece): Use safe-ctype macros and/or fold extra calls into fewer ones. * lex.c (java_read_unicode, java_lex): Likewise. * lex.h (JAVA_START_CHAR_P, JAVA_PART_CHAR_P, JAVA_ASCII_DIGIT, JAVA_ASCII_HEXDIGIT, JAVA_ASCII_LETTER): Likewise. * mangle_name.c (append_unicode_mangled_name, unicode_mangling_length): Likewise. From-SVN: r46397
2001-10-21 23:32:15 +02:00
if (ISUPPER (newpos[new_has_insn]))
break;
/* Go down to desired level. */
while (depth < ndepth)
{
/* It's a different insn from the first one. */
c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones. * c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones. * collect2.c (dump_file): Likewise. * cppexp.c (parse_number): Likewise. * cpplex.c (_cpp_lex_direct): Likewise. * final.c (output_asm_insn, asm_fprintf): Likewise. * fix-header.c (inf_scan_ident, main): Likewise. * fixinc/fixfixes.c (char_macro_use_fix, char_macro_def_fix): Likewise. * fold-const.c (real_hex_to_f): Likewise. * gen-protos.c (parse_fn_proto): Likewise. * genattrtab.c (check_attr_test, check_attr_value): Likewise. * genrecog.c (change_state, write_action): Likewise. * gensupport.c (shift_output_template): Likewise. * local-alloc.c (requires_inout): Likewise. * mips-tfile.c (IS_ASM_IDENT): Likewise. * protoize.c (is_id_char, main): Likewise. * real.c (asctoeg): Likewise. * recog.c (asm_operand_ok): Likewise. * reload.c (find_reloads): Likewise. * scan.c (scan_identget_token): Likewise. * sched-vis.c (print_value): Likewise. * stringpool.c (ggc_alloc_string): Likewise. * toplev.c (read_integral_parameter, decode_g_option): Likewise. * tradcif.y (parse_number, yylex, parse_escape): Likewise. * tradcpp.c (rescan): Likewise. * tree.c (clean_symbol_name): Likewise. * varasm.c (decode_reg_name): Likewise. * alpha.h (ASM_OUTPUT_ASCII): Likewise. * darwin.c (name_needs_quotes, func_name_maybe_scoped): Likewise. * dsp16xx.h (ASM_OUTPUT_ASCII): Likewise. * m88k.c (output_ascii): Likewise. * m88k.h (OVERRIDE_OPTIONS): Likewise. * mcore.h (REG_CLASS_FROM_LETTER): Likewise. * ns32k/encore.h (ASM_OUTPUT_ASCII): Likewise. * sh.h (REG_CLASS_FROM_LETTER): Likewise. cp: * xref.c (GNU_xref_member): Use safe-ctype macros and/or fold extra calls into fewer ones. f: * bad.c (ffebad_finish): Use safe-ctype macros and/or fold extra calls into fewer ones. * implic.c (ffeimplic_lookup_): Likewise. * intdoc.c (dumpimp): Likewise. * intrin.c (ffeintrin_init_0): Likewise. * lex.c (ffelex_backslash_, ffelex_cfebackslash_, ffelex_hash_): Likewise. * lex.h (ffelex_is_firstnamechar): Likewise. * target.c (ffetarget_integerhex): Likewise. java: * gjavah.c (jni_print_char, decode_signature_piece): Use safe-ctype macros and/or fold extra calls into fewer ones. * lex.c (java_read_unicode, java_lex): Likewise. * lex.h (JAVA_START_CHAR_P, JAVA_PART_CHAR_P, JAVA_ASCII_DIGIT, JAVA_ASCII_HEXDIGIT, JAVA_ASCII_LETTER): Likewise. * mangle_name.c (append_unicode_mangled_name, unicode_mangling_length): Likewise. From-SVN: r46397
2001-10-21 23:32:15 +02:00
if (ISUPPER (newpos[depth]))
1991-11-24 20:57:16 +01:00
{
/* We can only fail if we're moving down the tree. */
if (old_has_insn >= 0 && oldpos[old_has_insn] >= newpos[depth])
{
printf ("%stem = peep2_next_insn (%d);\n",
indent, newpos[depth] - 'A');
}
else
{
printf ("%stem = peep2_next_insn (%d);\n",
indent, newpos[depth] - 'A');
printf ("%sif (tem == NULL_RTX)\n", indent);
if (afterward)
printf ("%s goto L%d;\n", indent, afterward->number);
else
printf ("%s goto ret0;\n", indent);
}
printf ("%sx%d = PATTERN (tem);\n", indent, depth + 1);
1991-11-24 20:57:16 +01:00
}
c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones. * c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones. * collect2.c (dump_file): Likewise. * cppexp.c (parse_number): Likewise. * cpplex.c (_cpp_lex_direct): Likewise. * final.c (output_asm_insn, asm_fprintf): Likewise. * fix-header.c (inf_scan_ident, main): Likewise. * fixinc/fixfixes.c (char_macro_use_fix, char_macro_def_fix): Likewise. * fold-const.c (real_hex_to_f): Likewise. * gen-protos.c (parse_fn_proto): Likewise. * genattrtab.c (check_attr_test, check_attr_value): Likewise. * genrecog.c (change_state, write_action): Likewise. * gensupport.c (shift_output_template): Likewise. * local-alloc.c (requires_inout): Likewise. * mips-tfile.c (IS_ASM_IDENT): Likewise. * protoize.c (is_id_char, main): Likewise. * real.c (asctoeg): Likewise. * recog.c (asm_operand_ok): Likewise. * reload.c (find_reloads): Likewise. * scan.c (scan_identget_token): Likewise. * sched-vis.c (print_value): Likewise. * stringpool.c (ggc_alloc_string): Likewise. * toplev.c (read_integral_parameter, decode_g_option): Likewise. * tradcif.y (parse_number, yylex, parse_escape): Likewise. * tradcpp.c (rescan): Likewise. * tree.c (clean_symbol_name): Likewise. * varasm.c (decode_reg_name): Likewise. * alpha.h (ASM_OUTPUT_ASCII): Likewise. * darwin.c (name_needs_quotes, func_name_maybe_scoped): Likewise. * dsp16xx.h (ASM_OUTPUT_ASCII): Likewise. * m88k.c (output_ascii): Likewise. * m88k.h (OVERRIDE_OPTIONS): Likewise. * mcore.h (REG_CLASS_FROM_LETTER): Likewise. * ns32k/encore.h (ASM_OUTPUT_ASCII): Likewise. * sh.h (REG_CLASS_FROM_LETTER): Likewise. cp: * xref.c (GNU_xref_member): Use safe-ctype macros and/or fold extra calls into fewer ones. f: * bad.c (ffebad_finish): Use safe-ctype macros and/or fold extra calls into fewer ones. * implic.c (ffeimplic_lookup_): Likewise. * intdoc.c (dumpimp): Likewise. * intrin.c (ffeintrin_init_0): Likewise. * lex.c (ffelex_backslash_, ffelex_cfebackslash_, ffelex_hash_): Likewise. * lex.h (ffelex_is_firstnamechar): Likewise. * target.c (ffetarget_integerhex): Likewise. java: * gjavah.c (jni_print_char, decode_signature_piece): Use safe-ctype macros and/or fold extra calls into fewer ones. * lex.c (java_read_unicode, java_lex): Likewise. * lex.h (JAVA_START_CHAR_P, JAVA_PART_CHAR_P, JAVA_ASCII_DIGIT, JAVA_ASCII_HEXDIGIT, JAVA_ASCII_LETTER): Likewise. * mangle_name.c (append_unicode_mangled_name, unicode_mangling_length): Likewise. From-SVN: r46397
2001-10-21 23:32:15 +02:00
else if (ISLOWER (newpos[depth]))
printf ("%sx%d = XVECEXP (x%d, 0, %d);\n",
indent, depth + 1, depth, newpos[depth] - 'a');
else
printf ("%sx%d = XEXP (x%d, %c);\n",
indent, depth + 1, depth, newpos[depth]);
++depth;
}
}
/* Print the enumerator constant for CODE -- the upcase version of
the name. */
static void
print_code (code)
enum rtx_code code;
{
alias.c: Remove uses of "register" specifier in declarations of arguments and local... 2001-10-10 Stan Shebs <shebs@apple.com> * alias.c: Remove uses of "register" specifier in declarations of arguments and local variables. * c-common.c: Ditto. * c-convert.c: Ditto. * c-decl.c: Ditto. * c-format.c: Ditto. * c-semantics.c: Ditto. * c-typeck.c: Ditto. * caller-save.c: Ditto. * calls.c: Ditto. * cfg.c: Ditto. * cfgbuild.c: Ditto. * cfgrtl.c: Ditto. * collect2.c: Ditto. * combine.c: Ditto. * convert.c: Ditto. * cppexp.c: Ditto. * cppfiles.c: Ditto. * cse.c: Ditto. * dbxout.c: Ditto. * defaults.h: Ditto. * df.c: Ditto. * dwarf2out.c: Ditto. * dwarfout.c: Ditto. * emit-rtl.c: Ditto. * explow.c: Ditto. * expmed.c: Ditto. * expr.c: Ditto. * final.c: Ditto. * fix-header.c: Ditto. * floatlib.c: Ditto. * flow.c: Ditto. * fold-const.c: Ditto. * function.c: Ditto. * gcc.c: Ditto. * gcse.c: Ditto. * gen-protos.c: Ditto. * genattrtab.c: Ditto. * gencheck.c: Ditto. * genconfig.c: Ditto. * genemit.c: Ditto. * genextract.c: Ditto. * genflags.c: Ditto. * gengenrtl.c: Ditto. * genoutput.c: Ditto. * genpeep.c: Ditto. * genrecog.c: Ditto. * gensupport.c: Ditto. * global.c: Ditto. * gmon.c: Ditto. * graph.c: Ditto. * haifa-sched.c: Ditto. * hard-reg-set.h: Ditto. * hash.c: Ditto. * integrate.c: Ditto. * jump.c: Ditto. * lists.c: Ditto. * local-alloc.c: Ditto. * loop.c: Ditto. * mips-tdump.c: Ditto. * mips-tfile.c: Ditto. * optabs.c: Ditto. * prefix.c: Ditto. * print-rtl.c: Ditto. * read-rtl.c: Ditto. * real.c: Ditto. * recog.c: Ditto. * reg-stack.c: Ditto. * regclass.c: Ditto. * regmove.c: Ditto. * reload.c: Ditto. * reload1.c: Ditto. * reorg.c: Ditto. * resource.c: Ditto. * rtl.c: Ditto. * rtlanal.c: Ditto. * scan.c: Ditto. * sched-deps.c: Ditto. * sched-rgn.c: Ditto. * sdbout.c: Ditto. * simplify-rtx.c: Ditto. * stmt.c: Ditto. * stor-layout.c: Ditto. * toplev.c: Ditto. * tradcif.y: Ditto. * tradcpp.c: Ditto. * tree.c: Ditto. * unroll.c: Ditto. * varasm.c: Ditto. * xcoffout.c: Ditto. From-SVN: r46173
2001-10-11 05:16:15 +02:00
const char *p;
for (p = GET_RTX_NAME (code); *p; p++)
putchar (TOUPPER (*p));
}
1991-11-24 20:57:16 +01:00
/* Emit code to cross an afterward link -- change state and branch. */
1991-11-24 20:57:16 +01:00
static void
write_afterward (start, afterward, indent)
struct decision *start;
struct decision *afterward;
const char *indent;
{
if (!afterward || start->subroutine_number > 0)
printf("%sgoto ret0;\n", indent);
else
{
change_state (start->position, afterward->position, NULL, indent);
printf ("%sgoto L%d;\n", indent, afterward->number);
}
}
/* Emit a switch statement, if possible, for an initial sequence of
nodes at START. Return the first node yet untested. */
static struct decision *
write_switch (start, depth)
struct decision *start;
int depth;
{
struct decision *p = start;
enum decision_type type = p->tests->type;
struct decision *needs_label = NULL;
1991-11-24 20:57:16 +01:00
/* If we have two or more nodes in sequence that test the same one
thing, we may be able to use a switch statement. */
if (!p->next
|| p->tests->next
|| p->next->tests->type != type
|| p->next->tests->next
|| nodes_identical_1 (p->tests, p->next->tests))
return p;
/* DT_code is special in that we can do interesting things with
known predicates at the same time. */
if (type == DT_code)
{
char codemap[NUM_RTX_CODE];
struct decision *ret;
RTX_CODE code;
1991-11-24 20:57:16 +01:00
memset (codemap, 0, sizeof(codemap));
1991-11-24 20:57:16 +01:00
printf (" switch (GET_CODE (x%d))\n {\n", depth);
code = p->tests->u.code;
do
1991-11-24 20:57:16 +01:00
{
if (p != start && p->need_label && needs_label == NULL)
needs_label = p;
printf (" case ");
print_code (code);
printf (":\n goto L%d;\n", p->success.first->number);
p->success.first->need_label = 1;
codemap[code] = 1;
p = p->next;
}
while (p
&& ! p->tests->next
&& p->tests->type == DT_code
&& ! codemap[code = p->tests->u.code]);
/* If P is testing a predicate that we know about and we haven't
seen any of the codes that are valid for the predicate, we can
write a series of "case" statement, one for each possible code.
Since we are already in a switch, these redundant tests are very
cheap and will reduce the number of predicates called. */
/* Note that while we write out cases for these predicates here,
we don't actually write the test here, as it gets kinda messy.
It is trivial to leave this to later by telling our caller that
we only processed the CODE tests. */
if (needs_label != NULL)
ret = needs_label;
else
ret = p;
while (p && p->tests->type == DT_pred
&& p->tests->u.pred.index >= 0)
{
const RTX_CODE *c;
1991-11-24 20:57:16 +01:00
for (c = &preds[p->tests->u.pred.index].codes[0]; *c ; ++c)
if (codemap[(int) *c] != 0)
goto pred_done;
for (c = &preds[p->tests->u.pred.index].codes[0]; *c ; ++c)
1991-11-24 20:57:16 +01:00
{
printf (" case ");
print_code (*c);
printf (":\n");
codemap[(int) *c] = 1;
1991-11-24 20:57:16 +01:00
}
printf (" goto L%d;\n", p->number);
p->need_label = 1;
p = p->next;
1991-11-24 20:57:16 +01:00
}
pred_done:
/* Make the default case skip the predicates we managed to match. */
printf (" default:\n");
if (p != ret)
1991-11-24 20:57:16 +01:00
{
if (p)
{
printf (" goto L%d;\n", p->number);
p->need_label = 1;
}
else
write_afterward (start, start->afterward, " ");
1991-11-24 20:57:16 +01:00
}
else
printf (" break;\n");
printf (" }\n");
return ret;
}
else if (type == DT_mode
|| type == DT_veclen
|| type == DT_elt_zero_int
|| type == DT_elt_one_int
|| type == DT_elt_zero_wide_safe)
{
const char *indent = "";
/* We cast switch parameter to integer, so we must ensure that the value
fits. */
if (type == DT_elt_zero_wide_safe)
{
indent = " ";
printf(" if ((int) XWINT (x%d, 0) == XWINT (x%d, 0))\n", depth, depth);
}
printf ("%s switch (", indent);
switch (type)
{
case DT_mode:
printf ("GET_MODE (x%d)", depth);
break;
case DT_veclen:
printf ("XVECLEN (x%d, 0)", depth);
break;
case DT_elt_zero_int:
printf ("XINT (x%d, 0)", depth);
break;
case DT_elt_one_int:
printf ("XINT (x%d, 1)", depth);
break;
case DT_elt_zero_wide_safe:
/* Convert result of XWINT to int for portability since some C
compilers won't do it and some will. */
printf ("(int) XWINT (x%d, 0)", depth);
break;
default:
abort ();
}
printf (")\n%s {\n", indent);
do
{
/* Merge trees will not unify identical nodes if their
sub-nodes are at different levels. Thus we must check
for duplicate cases. */
struct decision *q;
for (q = start; q != p; q = q->next)
if (nodes_identical_1 (p->tests, q->tests))
goto case_done;
if (p != start && p->need_label && needs_label == NULL)
needs_label = p;
printf ("%s case ", indent);
switch (type)
{
case DT_mode:
printf ("%smode", GET_MODE_NAME (p->tests->u.mode));
break;
case DT_veclen:
printf ("%d", p->tests->u.veclen);
break;
case DT_elt_zero_int:
case DT_elt_one_int:
case DT_elt_zero_wide:
case DT_elt_zero_wide_safe:
printf (HOST_WIDE_INT_PRINT_DEC_C, p->tests->u.intval);
break;
default:
abort ();
}
printf (":\n%s goto L%d;\n", indent, p->success.first->number);
p->success.first->need_label = 1;
p = p->next;
}
while (p && p->tests->type == type && !p->tests->next);
case_done:
printf ("%s default:\n%s break;\n%s }\n",
indent, indent, indent);
1991-11-24 20:57:16 +01:00
return needs_label != NULL ? needs_label : p;
}
else
{
/* None of the other tests are amenable. */
return p;
}
}
1991-11-24 20:57:16 +01:00
/* Emit code for one test. */
static void
write_cond (p, depth, subroutine_type)
struct decision_test *p;
int depth;
enum routine_type subroutine_type;
{
switch (p->type)
{
case DT_mode:
printf ("GET_MODE (x%d) == %smode", depth, GET_MODE_NAME (p->u.mode));
break;
case DT_code:
printf ("GET_CODE (x%d) == ", depth);
print_code (p->u.code);
break;
case DT_veclen:
printf ("XVECLEN (x%d, 0) == %d", depth, p->u.veclen);
break;
case DT_elt_zero_int:
printf ("XINT (x%d, 0) == %d", depth, (int) p->u.intval);
break;
case DT_elt_one_int:
printf ("XINT (x%d, 1) == %d", depth, (int) p->u.intval);
break;
case DT_elt_zero_wide:
case DT_elt_zero_wide_safe:
printf ("XWINT (x%d, 0) == ", depth);
printf (HOST_WIDE_INT_PRINT_DEC_C, p->u.intval);
break;
case DT_veclen_ge:
printf ("XVECLEN (x%d, 0) >= %d", depth, p->u.veclen);
break;
case DT_dup:
printf ("rtx_equal_p (x%d, operands[%d])", depth, p->u.dup);
break;
case DT_pred:
printf ("%s (x%d, %smode)", p->u.pred.name, depth,
GET_MODE_NAME (p->u.pred.mode));
break;
case DT_c_test:
printf ("(%s)", p->u.c_test);
break;
case DT_accept_insn:
switch (subroutine_type)
{
case RECOG:
if (p->u.insn.num_clobbers_to_add == 0)
abort ();
printf ("pnum_clobbers != NULL");
break;
default:
abort ();
1991-11-24 20:57:16 +01:00
}
break;
1991-11-24 20:57:16 +01:00
default:
abort ();
}
}
1991-11-24 20:57:16 +01:00
/* Emit code for one action. The previous tests have succeeded;
TEST is the last of the chain. In the normal case we simply
perform a state change. For the `accept' tests we must do more work. */
1991-11-24 20:57:16 +01:00
static void
write_action (p, test, depth, uncond, success, subroutine_type)
struct decision *p;
struct decision_test *test;
int depth, uncond;
struct decision *success;
enum routine_type subroutine_type;
{
const char *indent;
int want_close = 0;
if (uncond)
indent = " ";
else if (test->type == DT_accept_op || test->type == DT_accept_insn)
{
fputs (" {\n", stdout);
indent = " ";
want_close = 1;
}
else
indent = " ";
1991-11-24 20:57:16 +01:00
if (test->type == DT_accept_op)
{
printf("%soperands[%d] = x%d;\n", indent, test->u.opno, depth);
/* Only allow DT_accept_insn to follow. */
if (test->next)
{
test = test->next;
if (test->type != DT_accept_insn)
abort ();
}
1991-11-24 20:57:16 +01:00
}
/* Sanity check that we're now at the end of the list of tests. */
if (test->next)
abort ();
1991-11-24 20:57:16 +01:00
if (test->type == DT_accept_insn)
1991-11-24 20:57:16 +01:00
{
switch (subroutine_type)
{
case RECOG:
if (test->u.insn.num_clobbers_to_add != 0)
printf ("%s*pnum_clobbers = %d;\n",
indent, test->u.insn.num_clobbers_to_add);
printf ("%sreturn %d;\n", indent, test->u.insn.code_number);
break;
case SPLIT:
printf ("%sreturn gen_split_%d (operands);\n",
indent, test->u.insn.code_number);
break;
case PEEPHOLE2:
{
int match_len = 0, i;
for (i = strlen (p->position) - 1; i >= 0; --i)
c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones. * c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones. * collect2.c (dump_file): Likewise. * cppexp.c (parse_number): Likewise. * cpplex.c (_cpp_lex_direct): Likewise. * final.c (output_asm_insn, asm_fprintf): Likewise. * fix-header.c (inf_scan_ident, main): Likewise. * fixinc/fixfixes.c (char_macro_use_fix, char_macro_def_fix): Likewise. * fold-const.c (real_hex_to_f): Likewise. * gen-protos.c (parse_fn_proto): Likewise. * genattrtab.c (check_attr_test, check_attr_value): Likewise. * genrecog.c (change_state, write_action): Likewise. * gensupport.c (shift_output_template): Likewise. * local-alloc.c (requires_inout): Likewise. * mips-tfile.c (IS_ASM_IDENT): Likewise. * protoize.c (is_id_char, main): Likewise. * real.c (asctoeg): Likewise. * recog.c (asm_operand_ok): Likewise. * reload.c (find_reloads): Likewise. * scan.c (scan_identget_token): Likewise. * sched-vis.c (print_value): Likewise. * stringpool.c (ggc_alloc_string): Likewise. * toplev.c (read_integral_parameter, decode_g_option): Likewise. * tradcif.y (parse_number, yylex, parse_escape): Likewise. * tradcpp.c (rescan): Likewise. * tree.c (clean_symbol_name): Likewise. * varasm.c (decode_reg_name): Likewise. * alpha.h (ASM_OUTPUT_ASCII): Likewise. * darwin.c (name_needs_quotes, func_name_maybe_scoped): Likewise. * dsp16xx.h (ASM_OUTPUT_ASCII): Likewise. * m88k.c (output_ascii): Likewise. * m88k.h (OVERRIDE_OPTIONS): Likewise. * mcore.h (REG_CLASS_FROM_LETTER): Likewise. * ns32k/encore.h (ASM_OUTPUT_ASCII): Likewise. * sh.h (REG_CLASS_FROM_LETTER): Likewise. cp: * xref.c (GNU_xref_member): Use safe-ctype macros and/or fold extra calls into fewer ones. f: * bad.c (ffebad_finish): Use safe-ctype macros and/or fold extra calls into fewer ones. * implic.c (ffeimplic_lookup_): Likewise. * intdoc.c (dumpimp): Likewise. * intrin.c (ffeintrin_init_0): Likewise. * lex.c (ffelex_backslash_, ffelex_cfebackslash_, ffelex_hash_): Likewise. * lex.h (ffelex_is_firstnamechar): Likewise. * target.c (ffetarget_integerhex): Likewise. java: * gjavah.c (jni_print_char, decode_signature_piece): Use safe-ctype macros and/or fold extra calls into fewer ones. * lex.c (java_read_unicode, java_lex): Likewise. * lex.h (JAVA_START_CHAR_P, JAVA_PART_CHAR_P, JAVA_ASCII_DIGIT, JAVA_ASCII_HEXDIGIT, JAVA_ASCII_LETTER): Likewise. * mangle_name.c (append_unicode_mangled_name, unicode_mangling_length): Likewise. From-SVN: r46397
2001-10-21 23:32:15 +02:00
if (ISUPPER (p->position[i]))
{
match_len = p->position[i] - 'A';
break;
}
printf ("%s*_pmatch_len = %d;\n", indent, match_len);
printf ("%stem = gen_peephole2_%d (insn, operands);\n",
indent, test->u.insn.code_number);
printf ("%sif (tem != 0)\n%s return tem;\n", indent, indent);
}
break;
default:
abort ();
}
1991-11-24 20:57:16 +01:00
}
else
{
printf("%sgoto L%d;\n", indent, success->number);
success->need_label = 1;
}
1991-11-24 20:57:16 +01:00
if (want_close)
fputs (" }\n", stdout);
1991-11-24 20:57:16 +01:00
}
/* Return 1 if the test is always true and has no fallthru path. Return -1
if the test does have a fallthru path, but requires that the condition be
terminated. Otherwise return 0 for a normal test. */
/* ??? is_unconditional is a stupid name for a tri-state function. */
1991-11-24 20:57:16 +01:00
static int
is_unconditional (t, subroutine_type)
struct decision_test *t;
enum routine_type subroutine_type;
1991-11-24 20:57:16 +01:00
{
if (t->type == DT_accept_op)
return 1;
1991-11-24 20:57:16 +01:00
if (t->type == DT_accept_insn)
{
switch (subroutine_type)
{
case RECOG:
return (t->u.insn.num_clobbers_to_add == 0);
case SPLIT:
return 1;
case PEEPHOLE2:
return -1;
default:
abort ();
}
}
1991-11-24 20:57:16 +01:00
return 0;
1991-11-24 20:57:16 +01:00
}
/* Emit code for one node -- the conditional and the accompanying action.
Return true if there is no fallthru path. */
1991-11-24 20:57:16 +01:00
static int
write_node (p, depth, subroutine_type)
struct decision *p;
int depth;
enum routine_type subroutine_type;
1991-11-24 20:57:16 +01:00
{
struct decision_test *test, *last_test;
int uncond;
1991-11-24 20:57:16 +01:00
last_test = test = p->tests;
uncond = is_unconditional (test, subroutine_type);
if (uncond == 0)
{
printf (" if (");
write_cond (test, depth, subroutine_type);
while ((test = test->next) != NULL)
{
int uncond2;
last_test = test;
uncond2 = is_unconditional (test, subroutine_type);
if (uncond2 != 0)
break;
printf ("\n && ");
write_cond (test, depth, subroutine_type);
}
printf (")\n");
}
write_action (p, last_test, depth, uncond, p->success.first, subroutine_type);
return uncond > 0;
1991-11-24 20:57:16 +01:00
}
/* Emit code for all of the sibling nodes of HEAD. */
1991-11-24 20:57:16 +01:00
static void
write_tree_1 (head, depth, subroutine_type)
struct decision_head *head;
int depth;
enum routine_type subroutine_type;
1991-11-24 20:57:16 +01:00
{
struct decision *p, *next;
int uncond = 0;
for (p = head->first; p ; p = next)
{
/* The label for the first element was printed in write_tree. */
if (p != head->first && p->need_label)
OUTPUT_LABEL (" ", p->number);
/* Attempt to write a switch statement for a whole sequence. */
next = write_switch (p, depth);
if (p != next)
uncond = 0;
else
{
/* Failed -- fall back and write one node. */
uncond = write_node (p, depth, subroutine_type);
next = p->next;
}
}
/* Finished with this chain. Close a fallthru path by branching
to the afterward node. */
if (! uncond)
write_afterward (head->last, head->last->afterward, " ");
}
/* Write out the decision tree starting at HEAD. PREVPOS is the
position at the node that branched to this node. */
static void
write_tree (head, prevpos, type, initial)
struct decision_head *head;
const char *prevpos;
enum routine_type type;
int initial;
{
alias.c: Remove uses of "register" specifier in declarations of arguments and local... 2001-10-10 Stan Shebs <shebs@apple.com> * alias.c: Remove uses of "register" specifier in declarations of arguments and local variables. * c-common.c: Ditto. * c-convert.c: Ditto. * c-decl.c: Ditto. * c-format.c: Ditto. * c-semantics.c: Ditto. * c-typeck.c: Ditto. * caller-save.c: Ditto. * calls.c: Ditto. * cfg.c: Ditto. * cfgbuild.c: Ditto. * cfgrtl.c: Ditto. * collect2.c: Ditto. * combine.c: Ditto. * convert.c: Ditto. * cppexp.c: Ditto. * cppfiles.c: Ditto. * cse.c: Ditto. * dbxout.c: Ditto. * defaults.h: Ditto. * df.c: Ditto. * dwarf2out.c: Ditto. * dwarfout.c: Ditto. * emit-rtl.c: Ditto. * explow.c: Ditto. * expmed.c: Ditto. * expr.c: Ditto. * final.c: Ditto. * fix-header.c: Ditto. * floatlib.c: Ditto. * flow.c: Ditto. * fold-const.c: Ditto. * function.c: Ditto. * gcc.c: Ditto. * gcse.c: Ditto. * gen-protos.c: Ditto. * genattrtab.c: Ditto. * gencheck.c: Ditto. * genconfig.c: Ditto. * genemit.c: Ditto. * genextract.c: Ditto. * genflags.c: Ditto. * gengenrtl.c: Ditto. * genoutput.c: Ditto. * genpeep.c: Ditto. * genrecog.c: Ditto. * gensupport.c: Ditto. * global.c: Ditto. * gmon.c: Ditto. * graph.c: Ditto. * haifa-sched.c: Ditto. * hard-reg-set.h: Ditto. * hash.c: Ditto. * integrate.c: Ditto. * jump.c: Ditto. * lists.c: Ditto. * local-alloc.c: Ditto. * loop.c: Ditto. * mips-tdump.c: Ditto. * mips-tfile.c: Ditto. * optabs.c: Ditto. * prefix.c: Ditto. * print-rtl.c: Ditto. * read-rtl.c: Ditto. * real.c: Ditto. * recog.c: Ditto. * reg-stack.c: Ditto. * regclass.c: Ditto. * regmove.c: Ditto. * reload.c: Ditto. * reload1.c: Ditto. * reorg.c: Ditto. * resource.c: Ditto. * rtl.c: Ditto. * rtlanal.c: Ditto. * scan.c: Ditto. * sched-deps.c: Ditto. * sched-rgn.c: Ditto. * sdbout.c: Ditto. * simplify-rtx.c: Ditto. * stmt.c: Ditto. * stor-layout.c: Ditto. * toplev.c: Ditto. * tradcif.y: Ditto. * tradcpp.c: Ditto. * tree.c: Ditto. * unroll.c: Ditto. * varasm.c: Ditto. * xcoffout.c: Ditto. From-SVN: r46173
2001-10-11 05:16:15 +02:00
struct decision *p = head->first;
putchar ('\n');
if (p->need_label)
OUTPUT_LABEL (" ", p->number);
if (! initial && p->subroutine_number > 0)
{
static const char * const name_prefix[] = {
"recog", "split", "peephole2"
};
static const char * const call_suffix[] = {
", pnum_clobbers", "", ", _pmatch_len"
};
/* This node has been broken out into a separate subroutine.
Call it, test the result, and branch accordingly. */
if (p->afterward)
{
printf (" tem = %s_%d (x0, insn%s);\n",
name_prefix[type], p->subroutine_number, call_suffix[type]);
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
if (IS_SPLIT (type))
printf (" if (tem != 0)\n return tem;\n");
else
printf (" if (tem >= 0)\n return tem;\n");
change_state (p->position, p->afterward->position, NULL, " ");
printf (" goto L%d;\n", p->afterward->number);
}
else
{
printf (" return %s_%d (x0, insn%s);\n",
name_prefix[type], p->subroutine_number, call_suffix[type]);
}
}
else
{
int depth = strlen (p->position);
change_state (prevpos, p->position, head->last->afterward, " ");
write_tree_1 (head, depth, type);
for (p = head->first; p; p = p->next)
if (p->success.first)
write_tree (&p->success, p->position, type, 0);
}
}
/* Write out a subroutine of type TYPE to do comparisons starting at
node TREE. */
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
static void
write_subroutine (head, type)
struct decision_head *head;
enum routine_type type;
{
int subfunction = head->first ? head->first->subroutine_number : 0;
const char *s_or_e;
char extension[32];
int i;
s_or_e = subfunction ? "static " : "";
if (subfunction)
sprintf (extension, "_%d", subfunction);
else if (type == RECOG)
extension[0] = '\0';
else
strcpy (extension, "_insns");
switch (type)
{
case RECOG:
printf ("%sint recog%s PARAMS ((rtx, rtx, int *));\n", s_or_e, extension);
printf ("%sint\n\
recog%s (x0, insn, pnum_clobbers)\n\
rtx x0 ATTRIBUTE_UNUSED;\n\
rtx insn ATTRIBUTE_UNUSED;\n\
int *pnum_clobbers ATTRIBUTE_UNUSED;\n", s_or_e, extension);
break;
case SPLIT:
printf ("%srtx split%s PARAMS ((rtx, rtx));\n", s_or_e, extension);
printf ("%srtx\n\
split%s (x0, insn)\n\
rtx x0 ATTRIBUTE_UNUSED;\n\
rtx insn ATTRIBUTE_UNUSED;\n", s_or_e, extension);
break;
case PEEPHOLE2:
printf ("%srtx peephole2%s PARAMS ((rtx, rtx, int *));\n",
s_or_e, extension);
printf ("%srtx\n\
peephole2%s (x0, insn, _pmatch_len)\n\
rtx x0 ATTRIBUTE_UNUSED;\n\
rtx insn ATTRIBUTE_UNUSED;\n\
int *_pmatch_len ATTRIBUTE_UNUSED;\n", s_or_e, extension);
break;
}
alias.c: Remove uses of "register" specifier in declarations of arguments and local... 2001-10-10 Stan Shebs <shebs@apple.com> * alias.c: Remove uses of "register" specifier in declarations of arguments and local variables. * c-common.c: Ditto. * c-convert.c: Ditto. * c-decl.c: Ditto. * c-format.c: Ditto. * c-semantics.c: Ditto. * c-typeck.c: Ditto. * caller-save.c: Ditto. * calls.c: Ditto. * cfg.c: Ditto. * cfgbuild.c: Ditto. * cfgrtl.c: Ditto. * collect2.c: Ditto. * combine.c: Ditto. * convert.c: Ditto. * cppexp.c: Ditto. * cppfiles.c: Ditto. * cse.c: Ditto. * dbxout.c: Ditto. * defaults.h: Ditto. * df.c: Ditto. * dwarf2out.c: Ditto. * dwarfout.c: Ditto. * emit-rtl.c: Ditto. * explow.c: Ditto. * expmed.c: Ditto. * expr.c: Ditto. * final.c: Ditto. * fix-header.c: Ditto. * floatlib.c: Ditto. * flow.c: Ditto. * fold-const.c: Ditto. * function.c: Ditto. * gcc.c: Ditto. * gcse.c: Ditto. * gen-protos.c: Ditto. * genattrtab.c: Ditto. * gencheck.c: Ditto. * genconfig.c: Ditto. * genemit.c: Ditto. * genextract.c: Ditto. * genflags.c: Ditto. * gengenrtl.c: Ditto. * genoutput.c: Ditto. * genpeep.c: Ditto. * genrecog.c: Ditto. * gensupport.c: Ditto. * global.c: Ditto. * gmon.c: Ditto. * graph.c: Ditto. * haifa-sched.c: Ditto. * hard-reg-set.h: Ditto. * hash.c: Ditto. * integrate.c: Ditto. * jump.c: Ditto. * lists.c: Ditto. * local-alloc.c: Ditto. * loop.c: Ditto. * mips-tdump.c: Ditto. * mips-tfile.c: Ditto. * optabs.c: Ditto. * prefix.c: Ditto. * print-rtl.c: Ditto. * read-rtl.c: Ditto. * real.c: Ditto. * recog.c: Ditto. * reg-stack.c: Ditto. * regclass.c: Ditto. * regmove.c: Ditto. * reload.c: Ditto. * reload1.c: Ditto. * reorg.c: Ditto. * resource.c: Ditto. * rtl.c: Ditto. * rtlanal.c: Ditto. * scan.c: Ditto. * sched-deps.c: Ditto. * sched-rgn.c: Ditto. * sdbout.c: Ditto. * simplify-rtx.c: Ditto. * stmt.c: Ditto. * stor-layout.c: Ditto. * toplev.c: Ditto. * tradcif.y: Ditto. * tradcpp.c: Ditto. * tree.c: Ditto. * unroll.c: Ditto. * varasm.c: Ditto. * xcoffout.c: Ditto. From-SVN: r46173
2001-10-11 05:16:15 +02:00
printf ("{\n rtx * const operands ATTRIBUTE_UNUSED = &recog_data.operand[0];\n");
for (i = 1; i <= max_depth; i++)
alias.c: Remove uses of "register" specifier in declarations of arguments and local... 2001-10-10 Stan Shebs <shebs@apple.com> * alias.c: Remove uses of "register" specifier in declarations of arguments and local variables. * c-common.c: Ditto. * c-convert.c: Ditto. * c-decl.c: Ditto. * c-format.c: Ditto. * c-semantics.c: Ditto. * c-typeck.c: Ditto. * caller-save.c: Ditto. * calls.c: Ditto. * cfg.c: Ditto. * cfgbuild.c: Ditto. * cfgrtl.c: Ditto. * collect2.c: Ditto. * combine.c: Ditto. * convert.c: Ditto. * cppexp.c: Ditto. * cppfiles.c: Ditto. * cse.c: Ditto. * dbxout.c: Ditto. * defaults.h: Ditto. * df.c: Ditto. * dwarf2out.c: Ditto. * dwarfout.c: Ditto. * emit-rtl.c: Ditto. * explow.c: Ditto. * expmed.c: Ditto. * expr.c: Ditto. * final.c: Ditto. * fix-header.c: Ditto. * floatlib.c: Ditto. * flow.c: Ditto. * fold-const.c: Ditto. * function.c: Ditto. * gcc.c: Ditto. * gcse.c: Ditto. * gen-protos.c: Ditto. * genattrtab.c: Ditto. * gencheck.c: Ditto. * genconfig.c: Ditto. * genemit.c: Ditto. * genextract.c: Ditto. * genflags.c: Ditto. * gengenrtl.c: Ditto. * genoutput.c: Ditto. * genpeep.c: Ditto. * genrecog.c: Ditto. * gensupport.c: Ditto. * global.c: Ditto. * gmon.c: Ditto. * graph.c: Ditto. * haifa-sched.c: Ditto. * hard-reg-set.h: Ditto. * hash.c: Ditto. * integrate.c: Ditto. * jump.c: Ditto. * lists.c: Ditto. * local-alloc.c: Ditto. * loop.c: Ditto. * mips-tdump.c: Ditto. * mips-tfile.c: Ditto. * optabs.c: Ditto. * prefix.c: Ditto. * print-rtl.c: Ditto. * read-rtl.c: Ditto. * real.c: Ditto. * recog.c: Ditto. * reg-stack.c: Ditto. * regclass.c: Ditto. * regmove.c: Ditto. * reload.c: Ditto. * reload1.c: Ditto. * reorg.c: Ditto. * resource.c: Ditto. * rtl.c: Ditto. * rtlanal.c: Ditto. * scan.c: Ditto. * sched-deps.c: Ditto. * sched-rgn.c: Ditto. * sdbout.c: Ditto. * simplify-rtx.c: Ditto. * stmt.c: Ditto. * stor-layout.c: Ditto. * toplev.c: Ditto. * tradcif.y: Ditto. * tradcpp.c: Ditto. * tree.c: Ditto. * unroll.c: Ditto. * varasm.c: Ditto. * xcoffout.c: Ditto. From-SVN: r46173
2001-10-11 05:16:15 +02:00
printf (" rtx x%d ATTRIBUTE_UNUSED;\n", i);
printf (" %s tem ATTRIBUTE_UNUSED;\n", IS_SPLIT (type) ? "rtx" : "int");
if (!subfunction)
printf (" recog_data.insn = NULL_RTX;\n");
if (head->first)
write_tree (head, "", type, 1);
else
printf (" goto ret0;\n");
printf (" ret0:\n return %d;\n}\n\n", IS_SPLIT (type) ? 0 : -1);
}
/* In break_out_subroutines, we discovered the boundaries for the
subroutines, but did not write them out. Do so now. */
1991-11-24 20:57:16 +01:00
static void
write_subroutines (head, type)
struct decision_head *head;
enum routine_type type;
1991-11-24 20:57:16 +01:00
{
struct decision *p;
1991-11-24 20:57:16 +01:00
for (p = head->first; p ; p = p->next)
if (p->success.first)
write_subroutines (&p->success, type);
1991-11-24 20:57:16 +01:00
if (head->first->subroutine_number > 0)
write_subroutine (head, type);
}
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
/* Begin the output file. */
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
static void
write_header ()
{
puts ("\
/* Generated automatically by the program `genrecog' from the target\n\
machine description file. */\n\
\n\
#include \"config.h\"\n\
#include \"system.h\"\n\
#include \"coretypes.h\"\n\
#include \"tm.h\"\n\
#include \"rtl.h\"\n\
#include \"tm_p.h\"\n\
#include \"function.h\"\n\
#include \"insn-config.h\"\n\
#include \"recog.h\"\n\
#include \"real.h\"\n\
#include \"output.h\"\n\
#include \"flags.h\"\n\
#include \"hard-reg-set.h\"\n\
#include \"resource.h\"\n\
#include \"toplev.h\"\n\
#include \"reload.h\"\n\
\n");
puts ("\n\
/* `recog' contains a decision tree that recognizes whether the rtx\n\
X0 is a valid instruction.\n\
\n\
recog returns -1 if the rtx is not valid. If the rtx is valid, recog\n\
returns a nonnegative number which is the insn code number for the\n\
pattern that matched. This is the same as the order in the machine\n\
description of the entry that matched. This number can be used as an\n\
index into `insn_data' and other tables.\n");
puts ("\
The third argument to recog is an optional pointer to an int. If\n\
present, recog will accept a pattern if it matches except for missing\n\
CLOBBER expressions at the end. In that case, the value pointed to by\n\
the optional pointer will be set to the number of CLOBBERs that need\n\
to be added (it should be initialized to zero by the caller). If it");
puts ("\
is set nonzero, the caller should allocate a PARALLEL of the\n\
appropriate size, copy the initial entries, and call add_clobbers\n\
(found in insn-emit.c) to fill in the CLOBBERs.\n\
");
puts ("\n\
The function split_insns returns 0 if the rtl could not\n\
Delete SEQUENCE rtl usage outside of reorg and ssa passes. 2002-06-05 David S. Miller <davem@redhat.com> Delete SEQUENCE rtl usage outside of reorg and ssa passes. * rtl.h (gen_sequence, emit_insns, emit_insns_before, emit_insns_before_scope, emit_insns_after, emit_insns_after_scope): Delete declaration. * ada/misc.c (insert_code_for): Use emit_insn* instead of emit_insns_foo. * config/alpha/alpha.c (alpha_set_memflags_1): Abort on SEQUENCE. (alpha_set_memflags): Fix comment. (set_frame_related_p): Use get_insns instead of gen_sequence. * config/alpha/alpha.md (setjmp receiver splitter): Avoid emitting no insns. * config/arm/arm.c (arm_finalize_pic): Use get_insns instead of gen_sequence. (arm_gen_load_multiple, arm_gen_store_multiple): Likewise. * config/fr30/fr30.c (fr30_move_double): Likewise. * config/i386/i386.c (ix86_expand_int_movcc, ix86_expand_movstr): Likewise. * config/ia64/ia64.c (spill_restore_mem): Likewise. * config/ia64/ia64.md (conditional move spliiter): Avoid emitting no insns. * config/m32r/m32r.c (gen_split_move_double): Use get_insns instead of gen_sequence. * config/mips/mips.c (embedded_pic_fnaddr_reg): Likewise. (mips_expand_prologue, mips16_gp_pseudo_reg): Likewise. * config/sh/sh.c (sh_need_epilogue): Likewise. * config/sparc/sparc.md (current_function_calls_alloca, flat): New attributes. (setjmp pattern and split): Use them to avoid splitter which emits no RTL. * genattrtab.c (main): Emit include of function.h * config/stormy16/stormy16.c (xstormy16_split_cbranch): Use get_insns instead of gen_sequence. * config/cris/cris.c (cris_split_movdx): Likewise. * emit-rtl.c (emit_insns*): Kill. (try_split): Expect insn list instead of SEQUENCE. (make_jump_insn_raw, make_call_insn_raw): Fix comments. (emit_*insn*): Reimplement to work with INSN lists and PATTERNs. Make them abort if a SEQUENCE is given and RTL checking is enabled. (emit_*_scope): Don't forget to set scope on final insn. (gen_sequence): Move from here... * ssa.c (gen_sequence): To here as private function. * builtins.c (expand_builtin_apply_args): Use emit_insn_foo, fix comments. (expand_builtin_return, expand_builtin_mathfn): Likewise. (expand_builtin_strlen): Use get_insns instead of gen_sequence. (expand_builtin_saveregs): Use emit_insn_foo, fix comments. (expand_builtin_expect_jump): Use get_insns and fix comments. * calls.c (try_to_integrate): Use emit_insn_foo. (expand_call, emit_library_call_value_1): Likewise. * expr.c (emit_queue): Handle insn lists instead of SEQUENCE. (emit_move_insn_1): Use get_insns instead of gen_sequence. (expand_expr): Use emit_insn_foo. * cfgrtl.c (commit_one_edge_insertion): Use emit_insn_foo. * except.c (build_post_landing_pads): Likewise. * flow.c (attempt_auto_inc): Likewise. * stmt.c (expand_fixup, fixup_gotos, expand_nl_handler_label, expand_nl_goto_receivers, expand_decl_cleanup): Likewise. * function.c (fixup_var_refs_insn): Use get_insns instead of gen_sequence. (fixup_var_refs_1): Likewise and expect insn list from gen_foo. (fixup_memory_subreg): Use get_insns instead of gen_sequence. (fixup_stack_1, purge_addressof_1, expand_main_function, get_arg_pointer_save_area): Likewise. (optimize_bit_field, instantiate_virtual_regs_1, assign_parms, expand_function_end): Use emit_insn_foo. (record_insns, keep_stack_depressed): Work with insn list instead of SEQUENCE, fix comments. * ifcvt.c (noce_emit_store_flag, noce_try_store_flag, noce_try_store_flag_constants, noce_try_store_flag_inc, noce_try_store_flag_mask, noce_emit_cmove, noce_try_cmove_arith, noce_try_minmax, noce_try_abs): Use emit_insn_foo. (noce_process_if_block): Use get_insns instead of gen_sequence. * optabs.c (add_equal_note): Work with insn list, fix comments. (expand_binop): Expect insn list from GEN_FCN(), use emit_insn_foo. (expand_unop, expand_complex_abs, expand_unop_insn, expand_no_conflict_block): Likewise. (gen_move_insn): Use get_insns instead of gen_sequence. (gen_cond_trap): Likewise. * integrate.c (copy_rtx_and_substitute): Likewise. (emit_initial_value_sets): Use emit_insn_foo. * reload1.c (emit_output_reload_insns, emit_reload_insns): Likewise. (fixup_abnormal_edges): Avoid losing REG_NOTES more intelligently now that RTL generators give insn lists. * sibcall.c (replace_call_placeholder): Use emit_insn_foo. * doloop.c (doloop_modify, doloop_modify_runtime): Use get_insns instead of gen_sequence. (doloop_optimize): Work with insn lists instead of SEQUENCE rtl. * explow.c (emit_stack_save, emit_stack_restore): Use get_insns instead of gen_sequence. * loop.c (move_movables, emit_prefetch_instructions, gen_add_mult, check_dbra_loop, gen_load_of_final_value): Likewise. (loop_regs_update): Work with insn list instead of SEQUENCE rtl. (product_cheap_p): Likewise, and add commentary about RTL wastage here. * lcm.c (optimize_mode_switching): Use get_insns instead of gen_sequence. * profile.c (gen_edge_profiler): Likewise. * regmove.c (copy_src_to_dest): Likewise. * reg-stack.c (compensate_edge): Likewise and fix comment. * gcse.c (process_insert_insn): Likewise. (insert_insn_end_bb): Work with insn list instead of SEQUENCE rtl. * jump.c (delete_prior_computation): Update comment. * genemit.c (gen_expand, gen_split, main): Use get_insns instead of gen_sequence, update comments to match. * recog.c (peephole2_optimize): Work with insn lists instead of SEQUENCE rtl. * sched-vis.c (print_pattern): Abort on SEQUENCE. * unroll.c (unroll_loop, find_splittable_givs, final_giv_value): Use get_insns instead of gen_sequence. (copy_loop_body): Likewise and don't emit dummy NOTE. * genrecog.c: Don't mention SEQUENCE rtl in comments. * combine.c (try_combine): Expect insn lists from split generator. * reorg.c (relax_delay_slots): Emit SEQUENCE into insn list by hand. From-SVN: r54497
2002-06-11 14:22:48 +02:00
be split or the split rtl as an INSN list if it can be.\n\
\n\
The function peephole2_insns returns 0 if the rtl could not\n\
Delete SEQUENCE rtl usage outside of reorg and ssa passes. 2002-06-05 David S. Miller <davem@redhat.com> Delete SEQUENCE rtl usage outside of reorg and ssa passes. * rtl.h (gen_sequence, emit_insns, emit_insns_before, emit_insns_before_scope, emit_insns_after, emit_insns_after_scope): Delete declaration. * ada/misc.c (insert_code_for): Use emit_insn* instead of emit_insns_foo. * config/alpha/alpha.c (alpha_set_memflags_1): Abort on SEQUENCE. (alpha_set_memflags): Fix comment. (set_frame_related_p): Use get_insns instead of gen_sequence. * config/alpha/alpha.md (setjmp receiver splitter): Avoid emitting no insns. * config/arm/arm.c (arm_finalize_pic): Use get_insns instead of gen_sequence. (arm_gen_load_multiple, arm_gen_store_multiple): Likewise. * config/fr30/fr30.c (fr30_move_double): Likewise. * config/i386/i386.c (ix86_expand_int_movcc, ix86_expand_movstr): Likewise. * config/ia64/ia64.c (spill_restore_mem): Likewise. * config/ia64/ia64.md (conditional move spliiter): Avoid emitting no insns. * config/m32r/m32r.c (gen_split_move_double): Use get_insns instead of gen_sequence. * config/mips/mips.c (embedded_pic_fnaddr_reg): Likewise. (mips_expand_prologue, mips16_gp_pseudo_reg): Likewise. * config/sh/sh.c (sh_need_epilogue): Likewise. * config/sparc/sparc.md (current_function_calls_alloca, flat): New attributes. (setjmp pattern and split): Use them to avoid splitter which emits no RTL. * genattrtab.c (main): Emit include of function.h * config/stormy16/stormy16.c (xstormy16_split_cbranch): Use get_insns instead of gen_sequence. * config/cris/cris.c (cris_split_movdx): Likewise. * emit-rtl.c (emit_insns*): Kill. (try_split): Expect insn list instead of SEQUENCE. (make_jump_insn_raw, make_call_insn_raw): Fix comments. (emit_*insn*): Reimplement to work with INSN lists and PATTERNs. Make them abort if a SEQUENCE is given and RTL checking is enabled. (emit_*_scope): Don't forget to set scope on final insn. (gen_sequence): Move from here... * ssa.c (gen_sequence): To here as private function. * builtins.c (expand_builtin_apply_args): Use emit_insn_foo, fix comments. (expand_builtin_return, expand_builtin_mathfn): Likewise. (expand_builtin_strlen): Use get_insns instead of gen_sequence. (expand_builtin_saveregs): Use emit_insn_foo, fix comments. (expand_builtin_expect_jump): Use get_insns and fix comments. * calls.c (try_to_integrate): Use emit_insn_foo. (expand_call, emit_library_call_value_1): Likewise. * expr.c (emit_queue): Handle insn lists instead of SEQUENCE. (emit_move_insn_1): Use get_insns instead of gen_sequence. (expand_expr): Use emit_insn_foo. * cfgrtl.c (commit_one_edge_insertion): Use emit_insn_foo. * except.c (build_post_landing_pads): Likewise. * flow.c (attempt_auto_inc): Likewise. * stmt.c (expand_fixup, fixup_gotos, expand_nl_handler_label, expand_nl_goto_receivers, expand_decl_cleanup): Likewise. * function.c (fixup_var_refs_insn): Use get_insns instead of gen_sequence. (fixup_var_refs_1): Likewise and expect insn list from gen_foo. (fixup_memory_subreg): Use get_insns instead of gen_sequence. (fixup_stack_1, purge_addressof_1, expand_main_function, get_arg_pointer_save_area): Likewise. (optimize_bit_field, instantiate_virtual_regs_1, assign_parms, expand_function_end): Use emit_insn_foo. (record_insns, keep_stack_depressed): Work with insn list instead of SEQUENCE, fix comments. * ifcvt.c (noce_emit_store_flag, noce_try_store_flag, noce_try_store_flag_constants, noce_try_store_flag_inc, noce_try_store_flag_mask, noce_emit_cmove, noce_try_cmove_arith, noce_try_minmax, noce_try_abs): Use emit_insn_foo. (noce_process_if_block): Use get_insns instead of gen_sequence. * optabs.c (add_equal_note): Work with insn list, fix comments. (expand_binop): Expect insn list from GEN_FCN(), use emit_insn_foo. (expand_unop, expand_complex_abs, expand_unop_insn, expand_no_conflict_block): Likewise. (gen_move_insn): Use get_insns instead of gen_sequence. (gen_cond_trap): Likewise. * integrate.c (copy_rtx_and_substitute): Likewise. (emit_initial_value_sets): Use emit_insn_foo. * reload1.c (emit_output_reload_insns, emit_reload_insns): Likewise. (fixup_abnormal_edges): Avoid losing REG_NOTES more intelligently now that RTL generators give insn lists. * sibcall.c (replace_call_placeholder): Use emit_insn_foo. * doloop.c (doloop_modify, doloop_modify_runtime): Use get_insns instead of gen_sequence. (doloop_optimize): Work with insn lists instead of SEQUENCE rtl. * explow.c (emit_stack_save, emit_stack_restore): Use get_insns instead of gen_sequence. * loop.c (move_movables, emit_prefetch_instructions, gen_add_mult, check_dbra_loop, gen_load_of_final_value): Likewise. (loop_regs_update): Work with insn list instead of SEQUENCE rtl. (product_cheap_p): Likewise, and add commentary about RTL wastage here. * lcm.c (optimize_mode_switching): Use get_insns instead of gen_sequence. * profile.c (gen_edge_profiler): Likewise. * regmove.c (copy_src_to_dest): Likewise. * reg-stack.c (compensate_edge): Likewise and fix comment. * gcse.c (process_insert_insn): Likewise. (insert_insn_end_bb): Work with insn list instead of SEQUENCE rtl. * jump.c (delete_prior_computation): Update comment. * genemit.c (gen_expand, gen_split, main): Use get_insns instead of gen_sequence, update comments to match. * recog.c (peephole2_optimize): Work with insn lists instead of SEQUENCE rtl. * sched-vis.c (print_pattern): Abort on SEQUENCE. * unroll.c (unroll_loop, find_splittable_givs, final_giv_value): Use get_insns instead of gen_sequence. (copy_loop_body): Likewise and don't emit dummy NOTE. * genrecog.c: Don't mention SEQUENCE rtl in comments. * combine.c (try_combine): Expect insn lists from split generator. * reorg.c (relax_delay_slots): Emit SEQUENCE into insn list by hand. From-SVN: r54497
2002-06-11 14:22:48 +02:00
be matched. If there was a match, the new rtl is returned in an INSN list,\n\
and LAST_INSN will point to the last recognized insn in the old sequence.\n\
*/\n\n");
}
1991-11-24 20:57:16 +01:00
/* Construct and return a sequence of decisions
that will recognize INSN.
1991-11-24 20:57:16 +01:00
TYPE says what type of routine we are recognizing (RECOG or SPLIT). */
static struct decision_head
make_insn_sequence (insn, type)
rtx insn;
enum routine_type type;
{
rtx x;
const char *c_test = XSTR (insn, type == RECOG ? 2 : 1);
int truth = maybe_eval_c_test (c_test);
struct decision *last;
struct decision_test *test, **place;
struct decision_head head;
top level: * Makefile.in (WARN_CFLAGS): Add -Wwrite-strings. (tree.o): Depend on output.h. * c-decl.c (pending_invalid_xref_file, current_function_prototype_file): Constify. (pushdecl): Constify a local char *. (define_label): Constify filename parameter. * c-lex.c (init_parse): Constify parameter and return value. * c-typeck.c (c_expand_asm_operands): Constify filename parameter. * c-tree.h: Update prototypes. * c-parse.in: Constify filename member of %union, and if_stmt_file. * c-parse.y, c-parse.c, c-parse.h, objc/objc-parse.y, objc/objc-parse.c: Regenerate. * dwarfout.c (dwarfout_init): Constify main_input_filename parameter. * dwarfout.h: Update prototypes. * expr.c (expand_expr): Constify a local char *. * flags.h: Constify main_input_filename. * function.c (expand_function_end): Constify filename parameter. * genrecog.c (make_insn_sequence): Use a character array for c_test_pos. (main): Remove unused variables. * input.h: Constify input_filename, main_input_filename, and file_stack.name. Update prototypes. * output.h: Declare first_global_object_name and weak_global_object_name here, as const char *. * stmt.c (expand_asm_operands): Constify filename parameter. * toplev.c (compile_file, push_srcloc, debug_start_source_file): Constify filename parameter. (input_filename, main_input_filename): Constify. * toplev.h: Update prototypes. * tree.c: Include output.h. Don't declare first_global_object_name or weak_global_object_name. Clean up string bashing in get_file_function_name_long. * tree.h (struct tree_decl): Constify filename member. (input_filename): Constify. Update prototypes. * varasm.c (first_global_object_name, weak_global_object_name): Constify. (assemble_start_function, assemble_variable): Clean up string bashing. * gcc.c: Constify all spec-related strings initialized, transitively, from string constants. Constify all strings and string variables related to multilibs. (set_spec, read_specs): Cast argument to free to PTR. (used_arg): Do not modify multilib_matches. Use strncmp plus length comparison to compare multilib switches. * genmultilib: Constify everything declared in multilib.h. ch: * ch-tree.h: Update prototypes. Remove prototypes for functions declared elsewhere. * decl.c (define_label): Constify filename parameter. * grant.c (globalize_decl, set_default_grant_file): Constify local char * variables. Don't declare first_global_object_name or asm_out_file. * lang.c (chill_real_input_filename): Constify. * lex.c (init_parse): Constify parameter and return value. * parse.c: Don't declare input_filename. (ch_expand_asm_operands): Constify filename parameter. (parse_multi_dimension_case_action): Constify local char *. * satisfy.c (safe_satisfy_decl): Constify local char *. cp: * cp-tree.h: Constify tree_srcloc.filename, tinst_level.file, and pending_inline.filename. Update prototypes. * decl.c (define_label): Constify filename parameter. * decl2.c (warn_if_unknown_interface): Constify local char *. * input.c Constify input_source.filename. Don't declare input_filename or lineno. Constify filename parameter to feed_input. * lex.c (init_parse): Constify parameter and return value. (cp_pragma_interface, cp_pragma_implementation): Constify filename argument. (reinit_parse_for_method, reinit_parse_for_block, reinit_parse_for_expr, feed_defarg, handle_cp_pragma): Constify local char *. * pt.c: Don't declare lineno or input_filename. (print_template_context, tsubst_friend_function, tsubst_decl, tsubst, instantiate_decl): Constify local char *. * semantics.c (expand_body): Constify local char *. * tree.c (build_srcloc): Constify filename parameter. * typeck.c (c_expand_asm_operands): Constify filename parameter. f: * com.c (ffecom_subscript_check_): Constify array_name parameter. Clean up string bashing. (ffecom_arrayref_, ffecom_char_args_x_): Constify array_name parameter. (ffecom_do_entry_, ffecom_gen_sfuncdef_, ffecom_start_progunit_, ffecom_sym_transform_, ffecom_sym_transform_assign_): Constify local char *. (init_parse): Constify parameter and return value. * lex.c: Include dwarfout.h instead of prototyping dwarfout_* functions here. (ffelex_file_pop_, ffelex_file_push_): Constify filename parameter. (ffelex_hash_, ffelex_include_): Constify local char *. * std.c (ffestd_exec_end): Constify local char *. * where.c (ffewhere_file_new): Constify filename parameter. * where.h: Update prototypes. java: * check_init.c (check_init): Constify local char *. * class.c (push_class): Constify local char *. * java_tree.h: Update prototypes. * jcf-io.c (open_class): Constify filename parameter and return value. (find_class): Remove redundant string copy. Cast return from open_class. * jcf-parse.c (read_class, parse_class_file, yyparse): Constify local char *. * jcf-write.c (generate_bytecode_insns, generate_classfile): Constify local char *. * jcf.h (JCF): Constify filename and classname. (JCF_FINISH): Cast args to FREE to char * when appropriate. * lang.c (init_parse): Constify parameter and return value. * lex.c (java_get_line_col): Constify filename parameter. * parse.h: Constify parser_ctxt.filename. Update prototypes. * parse.y (java_parser_context_suspend, issue_warning_error_from_context, safe_layout_class): Constify local char *. * parse.c: Regenerate. From-SVN: r33804
2000-05-09 21:56:01 +02:00
char c_test_pos[2];
/* We should never see an insn whose C test is false at compile time. */
if (truth == 0)
abort ();
record_insn_name (next_insn_code, (type == RECOG ? XSTR (insn, 0) : NULL));
top level: * Makefile.in (WARN_CFLAGS): Add -Wwrite-strings. (tree.o): Depend on output.h. * c-decl.c (pending_invalid_xref_file, current_function_prototype_file): Constify. (pushdecl): Constify a local char *. (define_label): Constify filename parameter. * c-lex.c (init_parse): Constify parameter and return value. * c-typeck.c (c_expand_asm_operands): Constify filename parameter. * c-tree.h: Update prototypes. * c-parse.in: Constify filename member of %union, and if_stmt_file. * c-parse.y, c-parse.c, c-parse.h, objc/objc-parse.y, objc/objc-parse.c: Regenerate. * dwarfout.c (dwarfout_init): Constify main_input_filename parameter. * dwarfout.h: Update prototypes. * expr.c (expand_expr): Constify a local char *. * flags.h: Constify main_input_filename. * function.c (expand_function_end): Constify filename parameter. * genrecog.c (make_insn_sequence): Use a character array for c_test_pos. (main): Remove unused variables. * input.h: Constify input_filename, main_input_filename, and file_stack.name. Update prototypes. * output.h: Declare first_global_object_name and weak_global_object_name here, as const char *. * stmt.c (expand_asm_operands): Constify filename parameter. * toplev.c (compile_file, push_srcloc, debug_start_source_file): Constify filename parameter. (input_filename, main_input_filename): Constify. * toplev.h: Update prototypes. * tree.c: Include output.h. Don't declare first_global_object_name or weak_global_object_name. Clean up string bashing in get_file_function_name_long. * tree.h (struct tree_decl): Constify filename member. (input_filename): Constify. Update prototypes. * varasm.c (first_global_object_name, weak_global_object_name): Constify. (assemble_start_function, assemble_variable): Clean up string bashing. * gcc.c: Constify all spec-related strings initialized, transitively, from string constants. Constify all strings and string variables related to multilibs. (set_spec, read_specs): Cast argument to free to PTR. (used_arg): Do not modify multilib_matches. Use strncmp plus length comparison to compare multilib switches. * genmultilib: Constify everything declared in multilib.h. ch: * ch-tree.h: Update prototypes. Remove prototypes for functions declared elsewhere. * decl.c (define_label): Constify filename parameter. * grant.c (globalize_decl, set_default_grant_file): Constify local char * variables. Don't declare first_global_object_name or asm_out_file. * lang.c (chill_real_input_filename): Constify. * lex.c (init_parse): Constify parameter and return value. * parse.c: Don't declare input_filename. (ch_expand_asm_operands): Constify filename parameter. (parse_multi_dimension_case_action): Constify local char *. * satisfy.c (safe_satisfy_decl): Constify local char *. cp: * cp-tree.h: Constify tree_srcloc.filename, tinst_level.file, and pending_inline.filename. Update prototypes. * decl.c (define_label): Constify filename parameter. * decl2.c (warn_if_unknown_interface): Constify local char *. * input.c Constify input_source.filename. Don't declare input_filename or lineno. Constify filename parameter to feed_input. * lex.c (init_parse): Constify parameter and return value. (cp_pragma_interface, cp_pragma_implementation): Constify filename argument. (reinit_parse_for_method, reinit_parse_for_block, reinit_parse_for_expr, feed_defarg, handle_cp_pragma): Constify local char *. * pt.c: Don't declare lineno or input_filename. (print_template_context, tsubst_friend_function, tsubst_decl, tsubst, instantiate_decl): Constify local char *. * semantics.c (expand_body): Constify local char *. * tree.c (build_srcloc): Constify filename parameter. * typeck.c (c_expand_asm_operands): Constify filename parameter. f: * com.c (ffecom_subscript_check_): Constify array_name parameter. Clean up string bashing. (ffecom_arrayref_, ffecom_char_args_x_): Constify array_name parameter. (ffecom_do_entry_, ffecom_gen_sfuncdef_, ffecom_start_progunit_, ffecom_sym_transform_, ffecom_sym_transform_assign_): Constify local char *. (init_parse): Constify parameter and return value. * lex.c: Include dwarfout.h instead of prototyping dwarfout_* functions here. (ffelex_file_pop_, ffelex_file_push_): Constify filename parameter. (ffelex_hash_, ffelex_include_): Constify local char *. * std.c (ffestd_exec_end): Constify local char *. * where.c (ffewhere_file_new): Constify filename parameter. * where.h: Update prototypes. java: * check_init.c (check_init): Constify local char *. * class.c (push_class): Constify local char *. * java_tree.h: Update prototypes. * jcf-io.c (open_class): Constify filename parameter and return value. (find_class): Remove redundant string copy. Cast return from open_class. * jcf-parse.c (read_class, parse_class_file, yyparse): Constify local char *. * jcf-write.c (generate_bytecode_insns, generate_classfile): Constify local char *. * jcf.h (JCF): Constify filename and classname. (JCF_FINISH): Cast args to FREE to char * when appropriate. * lang.c (init_parse): Constify parameter and return value. * lex.c (java_get_line_col): Constify filename parameter. * parse.h: Constify parser_ctxt.filename. Update prototypes. * parse.y (java_parser_context_suspend, issue_warning_error_from_context, safe_layout_class): Constify local char *. * parse.c: Regenerate. From-SVN: r33804
2000-05-09 21:56:01 +02:00
c_test_pos[0] = '\0';
if (type == PEEPHOLE2)
1991-11-24 20:57:16 +01:00
{
int i, j;
/* peephole2 gets special treatment:
- X always gets an outer parallel even if it's only one entry
- we remove all traces of outer-level match_scratch and match_dup
expressions here. */
x = rtx_alloc (PARALLEL);
PUT_MODE (x, VOIDmode);
XVEC (x, 0) = rtvec_alloc (XVECLEN (insn, 0));
for (i = j = 0; i < XVECLEN (insn, 0); i++)
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
{
rtx tmp = XVECEXP (insn, 0, i);
if (GET_CODE (tmp) != MATCH_SCRATCH && GET_CODE (tmp) != MATCH_DUP)
{
XVECEXP (x, 0, j) = tmp;
j++;
}
}
XVECLEN (x, 0) = j;
c_test_pos[0] = 'A' + j - 1;
c_test_pos[1] = '\0';
}
else if (XVECLEN (insn, type == RECOG) == 1)
x = XVECEXP (insn, type == RECOG, 0);
else
{
x = rtx_alloc (PARALLEL);
XVEC (x, 0) = XVEC (insn, type == RECOG);
PUT_MODE (x, VOIDmode);
}
validate_pattern (x, insn, NULL_RTX, 0);
memset(&head, 0, sizeof(head));
last = add_to_sequence (x, &head, "", type, 1);
/* Find the end of the test chain on the last node. */
for (test = last->tests; test->next; test = test->next)
continue;
place = &test->next;
/* Skip the C test if it's known to be true at compile time. */
if (truth == -1)
{
/* Need a new node if we have another test to add. */
if (test->type == DT_accept_op)
{
last = new_decision (c_test_pos, &last->success);
place = &last->tests;
}
test = new_decision_test (DT_c_test, &place);
test->u.c_test = c_test;
}
test = new_decision_test (DT_accept_insn, &place);
test->u.insn.code_number = next_insn_code;
test->u.insn.lineno = pattern_lineno;
test->u.insn.num_clobbers_to_add = 0;
switch (type)
{
case RECOG:
/* If this is an DEFINE_INSN and X is a PARALLEL, see if it ends
with a group of CLOBBERs of (hard) registers or MATCH_SCRATCHes.
If so, set up to recognize the pattern without these CLOBBERs. */
if (GET_CODE (x) == PARALLEL)
{
int i;
/* Find the last non-clobber in the parallel. */
for (i = XVECLEN (x, 0); i > 0; i--)
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
{
rtx y = XVECEXP (x, 0, i - 1);
if (GET_CODE (y) != CLOBBER
|| (GET_CODE (XEXP (y, 0)) != REG
&& GET_CODE (XEXP (y, 0)) != MATCH_SCRATCH))
break;
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
}
if (i != XVECLEN (x, 0))
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
{
rtx new;
struct decision_head clobber_head;
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
/* Build a similar insn without the clobbers. */
if (i == 1)
new = XVECEXP (x, 0, 0);
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
else
{
int j;
new = rtx_alloc (PARALLEL);
XVEC (new, 0) = rtvec_alloc (i);
for (j = i - 1; j >= 0; j--)
XVECEXP (new, 0, j) = XVECEXP (x, 0, j);
}
/* Recognize it. */
memset (&clobber_head, 0, sizeof(clobber_head));
last = add_to_sequence (new, &clobber_head, "", type, 1);
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
/* Find the end of the test chain on the last node. */
for (test = last->tests; test->next; test = test->next)
continue;
/* We definitely have a new test to add -- create a new
node if needed. */
place = &test->next;
if (test->type == DT_accept_op)
{
last = new_decision ("", &last->success);
place = &last->tests;
}
/* Skip the C test if it's known to be true at compile
time. */
if (truth == -1)
{
test = new_decision_test (DT_c_test, &place);
test->u.c_test = c_test;
}
test = new_decision_test (DT_accept_insn, &place);
test->u.insn.code_number = next_insn_code;
test->u.insn.lineno = pattern_lineno;
test->u.insn.num_clobbers_to_add = XVECLEN (x, 0) - i;
merge_trees (&head, &clobber_head);
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
}
}
break;
case SPLIT:
/* Define the subroutine we will call below and emit in genemit. */
printf ("extern rtx gen_split_%d PARAMS ((rtx *));\n", next_insn_code);
break;
case PEEPHOLE2:
/* Define the subroutine we will call below and emit in genemit. */
printf ("extern rtx gen_peephole2_%d PARAMS ((rtx, rtx *));\n",
next_insn_code);
break;
1991-11-24 20:57:16 +01:00
}
return head;
1991-11-24 20:57:16 +01:00
}
static void
process_tree (head, subroutine_type)
struct decision_head *head;
enum routine_type subroutine_type;
1991-11-24 20:57:16 +01:00
{
if (head->first == NULL)
{
/* We can elide peephole2_insns, but not recog or split_insns. */
if (subroutine_type == PEEPHOLE2)
return;
}
else
{
factor_tests (head);
1991-11-24 20:57:16 +01:00
next_subroutine_number = 0;
break_out_subroutines (head, 1);
find_afterward (head, NULL);
/* We run this after find_afterward, because find_afterward needs
the redundant DT_mode tests on predicates to determine whether
two tests can both be true or not. */
simplify_tests(head);
write_subroutines (head, subroutine_type);
}
write_subroutine (head, subroutine_type);
}
extern int main PARAMS ((int, char **));
1991-11-24 20:57:16 +01:00
int
main (argc, argv)
int argc;
char **argv;
{
rtx desc;
struct decision_head recog_tree, split_tree, peephole2_tree, h;
1991-11-24 20:57:16 +01:00
progname = "genrecog";
memset (&recog_tree, 0, sizeof recog_tree);
memset (&split_tree, 0, sizeof split_tree);
memset (&peephole2_tree, 0, sizeof peephole2_tree);
1991-11-24 20:57:16 +01:00
if (argc <= 1)
c-decl.c (duplicate_decls, [...]): Remove leading capital from diagnostics. * c-decl.c (duplicate_decls, push_parm_decl): Remove leading capital from diagnostics. * c-lex.c (cb_file_change): Similarly. * c-parse.in : Similarly. * cfgrtl.c (verify_flow_info): Similarly. * collect2.c: Similarly. * cppfiles.c (find_include_file): Similarly. * cppinit.c (cpp_handle_option): Similarly. * cpplex.c (cpp_spell_token): Similarly. * cppmain.c (do_preprocessing): Similarly. * gcc.c (translate_options, process_command, do_spec1, main, pfatal_execute): Similarly. * genattr.c (main): Similarly. * genattrtab.c (check_attr_test, operate_exp, simplify_test_exp, write_test_expr, main): Similarly. * gencodes.c (main): Similarly. * genconfig.c (main): Similarly. * genconstants.c (main): Similarly. * genemit.c (main): Similarly. * genextract.c (main): Similarly. * genflags.c (main): Similarly. * genopinit.c (main): Similarly. * genoutput.c (process_template, main): Similarly. * genpeep.c (main): Similarly. * genrecog.c (main): Similarly. * gensupport.c (is_predicable, identify_predicable_attribute, alter_predicate_for_insn, init_md_reader_args, main): Similarly. * ggc-page.c (alloc_anon): Similarly. * mips-tfile.c (add_string, add_procedure, add_file, read_line, parse_begin, parse_bend, parse_def, parse_end, parse_file, parse_stabs_common, parse_stabs, write_varray, write_object, read_seek, copy_object, main, error): Similarly. * profile.c (compute_branch_probabilities): Similarly. * reg-stack.c (check_asm_stack_operands): Similarly. * reload.c (find_reloads): Similarly. * reload1.c (spill_failure, failed_reload): Similarly. * rtl-error.c (_fatal_insn_not_found): Similarly. * toplev.c (read_integral_parameter, crash_signal, decode_f_option, set_target_switch, parse_options_and_default_flags) : Similarly. * tradcif.y (parse_number, yylex): Similarly. * tradcpp.c (main, fancy_abort): Similarly. * tree.c (tree_check_failed): Similarly. * varray.c (varray_check_failed): Similarly. * xcoffout.c (xcoff_output_standard_types): Similarly. cp: * call.c (build_java_interface_fn_ref): Similarly. * except.c (is_admissible_throw_operand): Similarly. * init.c (build_java_class_ref): Similarly. * xref.c (open_xref_file): Similarly. objc: * objc-act.c (get_object_ref, lookup_and_install_protocols, build_objc_string_object, objc_declare_alias, build_ivar_chain, finish_message_expr, build_protocol_expr, is_public, start_class): Similarly. testsuite: * objc.dg/alias.m: Update. * objc.dg/class-1.m: Update. * objc.dg/const-str-1.m: Update. * objc.dg/fwd-proto-1.m: Update. * objc.dg/id-1.m: Update. * objc.dg/super-class-1.m: Update. From-SVN: r47518
2001-12-02 01:04:36 +01:00
fatal ("no input file name");
1991-11-24 20:57:16 +01:00
if (init_md_reader_args (argc, argv) != SUCCESS_EXIT_CODE)
return (FATAL_EXIT_CODE);
1991-11-24 20:57:16 +01:00
next_insn_code = 0;
next_index = 0;
write_header ();
1991-11-24 20:57:16 +01:00
/* Read the machine description. */
while (1)
{
desc = read_md_rtx (&pattern_lineno, &next_insn_code);
if (desc == NULL)
1991-11-24 20:57:16 +01:00
break;
if (GET_CODE (desc) == DEFINE_INSN)
{
h = make_insn_sequence (desc, RECOG);
merge_trees (&recog_tree, &h);
}
1991-11-24 20:57:16 +01:00
else if (GET_CODE (desc) == DEFINE_SPLIT)
{
h = make_insn_sequence (desc, SPLIT);
merge_trees (&split_tree, &h);
}
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
else if (GET_CODE (desc) == DEFINE_PEEPHOLE2)
{
h = make_insn_sequence (desc, PEEPHOLE2);
merge_trees (&peephole2_tree, &h);
}
1991-11-24 20:57:16 +01:00
next_index++;
}
if (error_count)
return FATAL_EXIT_CODE;
puts ("\n\n");
1991-11-24 20:57:16 +01:00
process_tree (&recog_tree, RECOG);
process_tree (&split_tree, SPLIT);
process_tree (&peephole2_tree, PEEPHOLE2);
backport: Makefile.in (STAGESTUFF): Add *.peephole2. Merge peephole2 from new_ia32_branch: * Makefile.in (STAGESTUFF): Add *.peephole2. (mostlyclean): Likewise. (recog.o): Depend on resource.h. * final.c (peephole): Conditionalize decl on HAVE_peephole. (final_scan_insn): Likewise for the invocation of peephole. * genconfig.c (main): Look for peephole and peephole2 patterns. Emit HAVE_peephole* accordingly. * genpeep.c (main): Conditionalize entire output on HAVE_peephole. * flags.h (flag_peephole2): Declare. * toplev.c: New pass peephole2. New flag -fpeephole2. * genattrtab.c (main): Count DEFINE_PEEPHOLE2. * gencodes.c (main): Likewise. * genextract.c (main): Likewise. * genoutput.c (main): Likewise. * genemit.c (max_operand_1): Look for the max scratch operand. (gen_rtx_scratch): New. (gen_exp): Use it, and pass on new arg subroutine_type. (gen_expand): Take max scratch into account. (gen_split): Emit peephole2 functions. (output_peephole2_scratch): New. (main): Include hard-reg-set.h and resource.h. Handle peephole2. * genrecog.c (routine_type): Add PEEPHOLE2. (IS_SPLIT): New. (make_insn_sequence): Match outer parallel for peep2. Discard top level scratches and dups. (add_to_sequence): New args insn_type and top. Update all callers. Handle toplevel peep2 matching insns. (write_subroutine): Handle peep2. (write_tree_1): Likewise. (write_tree): Likewise. (main): Likewise. (change_state): New arg afterward. Update all callers. Handle matching separate insns. * recog.c (recog_next_insn): New. (peephole2_optimize): New. * rtl.def (DEFINE_PEEPHOLE2): New. * resource.c (find_free_register): New argument last_insn. Use it to find a register available through the entire span. * resource.h (find_free_register): Update prototype. From-SVN: r29015
1999-08-31 22:37:09 +02:00
1991-11-24 20:57:16 +01:00
fflush (stdout);
return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE);
1991-11-24 20:57:16 +01:00
}
/* Define this so we can link with print-rtl.o to get debug_rtx function. */
const char *
get_insn_name (code)
int code;
{
if (code < insn_name_ptr_size)
return insn_name_ptr[code];
else
return NULL;
}
static void
record_insn_name (code, name)
int code;
const char *name;
{
static const char *last_real_name = "insn";
static int last_real_code = 0;
char *new;
if (insn_name_ptr_size <= code)
{
int new_size;
new_size = (insn_name_ptr_size ? insn_name_ptr_size * 2 : 512);
insn_name_ptr =
(char **) xrealloc (insn_name_ptr, sizeof(char *) * new_size);
memset (insn_name_ptr + insn_name_ptr_size, 0,
sizeof(char *) * (new_size - insn_name_ptr_size));
insn_name_ptr_size = new_size;
}
if (!name || name[0] == '\0')
{
new = xmalloc (strlen (last_real_name) + 10);
sprintf (new, "%s+%d", last_real_name, code - last_real_code);
}
else
{
last_real_name = new = xstrdup (name);
last_real_code = code;
}
insn_name_ptr[code] = new;
}
static void
debug_decision_2 (test)
struct decision_test *test;
{
switch (test->type)
{
case DT_mode:
fprintf (stderr, "mode=%s", GET_MODE_NAME (test->u.mode));
break;
case DT_code:
fprintf (stderr, "code=%s", GET_RTX_NAME (test->u.code));
break;
case DT_veclen:
fprintf (stderr, "veclen=%d", test->u.veclen);
break;
case DT_elt_zero_int:
fprintf (stderr, "elt0_i=%d", (int) test->u.intval);
break;
case DT_elt_one_int:
fprintf (stderr, "elt1_i=%d", (int) test->u.intval);
break;
case DT_elt_zero_wide:
fprintf (stderr, "elt0_w=" HOST_WIDE_INT_PRINT_DEC, test->u.intval);
break;
case DT_elt_zero_wide_safe:
fprintf (stderr, "elt0_ws=" HOST_WIDE_INT_PRINT_DEC, test->u.intval);
break;
case DT_veclen_ge:
fprintf (stderr, "veclen>=%d", test->u.veclen);
break;
case DT_dup:
fprintf (stderr, "dup=%d", test->u.dup);
break;
case DT_pred:
fprintf (stderr, "pred=(%s,%s)",
test->u.pred.name, GET_MODE_NAME(test->u.pred.mode));
break;
case DT_c_test:
{
char sub[16+4];
strncpy (sub, test->u.c_test, sizeof(sub));
memcpy (sub+16, "...", 4);
fprintf (stderr, "c_test=\"%s\"", sub);
}
break;
case DT_accept_op:
fprintf (stderr, "A_op=%d", test->u.opno);
break;
case DT_accept_insn:
fprintf (stderr, "A_insn=(%d,%d)",
test->u.insn.code_number, test->u.insn.num_clobbers_to_add);
break;
default:
abort ();
}
}
static void
debug_decision_1 (d, indent)
struct decision *d;
int indent;
{
int i;
struct decision_test *test;
if (d == NULL)
{
for (i = 0; i < indent; ++i)
putc (' ', stderr);
fputs ("(nil)\n", stderr);
return;
}
for (i = 0; i < indent; ++i)
putc (' ', stderr);
putc ('{', stderr);
test = d->tests;
if (test)
{
debug_decision_2 (test);
while ((test = test->next) != NULL)
{
fputs (" + ", stderr);
debug_decision_2 (test);
}
}
fprintf (stderr, "} %d n %d a %d\n", d->number,
(d->next ? d->next->number : -1),
(d->afterward ? d->afterward->number : -1));
}
static void
debug_decision_0 (d, indent, maxdepth)
struct decision *d;
int indent, maxdepth;
{
struct decision *n;
int i;
if (maxdepth < 0)
return;
if (d == NULL)
{
for (i = 0; i < indent; ++i)
putc (' ', stderr);
fputs ("(nil)\n", stderr);
return;
}
debug_decision_1 (d, indent);
for (n = d->success.first; n ; n = n->next)
debug_decision_0 (n, indent + 2, maxdepth - 1);
}
void
debug_decision (d)
struct decision *d;
{
debug_decision_0 (d, 0, 1000000);
}
void
debug_decision_list (d)
struct decision *d;
{
while (d)
{
debug_decision_0 (d, 0, 0);
d = d->next;
}
}