gcc/gcc/reg-stack.c

2917 lines
83 KiB
C
Raw Normal View History

1991-12-26 11:05:42 +01:00
/* Register to Stack convert for GNU compiler.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003 Free Software Foundation, Inc.
1991-12-26 11:05:42 +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.
1991-12-26 11:05:42 +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
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.
1991-12-26 11:05:42 +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
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.
1991-12-26 11:05:42 +01:00
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. */
1991-12-26 11:05:42 +01:00
/* This pass converts stack-like registers from the "flat register
file" model that gcc uses, to a stack convention that the 387 uses.
* The form of the input:
On input, the function consists of insn that have had their
registers fully allocated to a set of "virtual" registers. Note that
the word "virtual" is used differently here than elsewhere in gcc: for
each virtual stack reg, there is a hard reg, but the mapping between
them is not known until this pass is run. On output, hard register
numbers have been substituted, and various pop and exchange insns have
been emitted. The hard register numbers and the virtual register
numbers completely overlap - before this pass, all stack register
numbers are virtual, and afterward they are all hard.
1991-12-26 11:05:42 +01:00
The virtual registers can be manipulated normally by gcc, and their
semantics are the same as for normal registers. After the hard
register numbers are substituted, the semantics of an insn containing
stack-like regs are not the same as for an insn with normal regs: for
instance, it is not safe to delete an insn that appears to be a no-op
move. In general, no insn containing hard regs should be changed
after this pass is done.
* The form of the output:
After this pass, hard register numbers represent the distance from
the current top of stack to the desired register. A reference to
FIRST_STACK_REG references the top of stack, FIRST_STACK_REG + 1,
represents the register just below that, and so forth. Also, REG_DEAD
notes indicate whether or not a stack register should be popped.
A "swap" insn looks like a parallel of two patterns, where each
pattern is a SET: one sets A to B, the other B to A.
A "push" or "load" insn is a SET whose SET_DEST is FIRST_STACK_REG
and whose SET_DEST is REG or MEM. Any other SET_DEST, such as PLUS,
will replace the existing stack top, not push a new value.
A store insn is a SET whose SET_DEST is FIRST_STACK_REG, and whose
SET_SRC is REG or MEM.
The case where the SET_SRC and SET_DEST are both FIRST_STACK_REG
1991-12-26 11:05:42 +01:00
appears ambiguous. As a special case, the presence of a REG_DEAD note
for FIRST_STACK_REG differentiates between a load insn and a pop.
If a REG_DEAD is present, the insn represents a "pop" that discards
the top of the register stack. If there is no REG_DEAD note, then the
insn represents a "dup" or a push of the current top of stack onto the
stack.
* Methodology:
Existing REG_DEAD and REG_UNUSED notes for stack registers are
deleted and recreated from scratch. REG_DEAD is never created for a
SET_DEST, only REG_UNUSED.
* asm_operands:
1991-12-26 11:05:42 +01:00
There are several rules on the usage of stack-like regs in
asm_operands insns. These rules apply only to the operands that are
stack-like regs:
1. Given a set of input regs that die in an asm_operands, it is
necessary to know which are implicitly popped by the asm, and
which must be explicitly popped by gcc.
An input reg that is implicitly popped by the asm must be
explicitly clobbered, unless it is constrained to match an
output operand.
2. For any input reg that is implicitly popped by an asm, it is
necessary to know how to adjust the stack to compensate for the pop.
If any non-popped input is closer to the top of the reg-stack than
the implicitly popped reg, it would not be possible to know what the
stack looked like - it's not clear how the rest of the stack "slides
up".
All implicitly popped input regs must be closer to the top of
the reg-stack than any input that is not implicitly popped.
3. It is possible that if an input dies in an insn, reload might
use the input reg for an output reload. Consider this example:
asm ("foo" : "=t" (a) : "f" (b));
This asm says that input B is not popped by the asm, and that
the asm pushes a result onto the reg-stack, ie, the stack is one
deeper after the asm than it was before. But, it is possible that
reload will think that it can use the same reg for both the input and
the output, if input B dies in this insn.
If any input operand uses the "f" constraint, all output reg
constraints must use the "&" earlyclobber.
The asm above would be written as
asm ("foo" : "=&t" (a) : "f" (b));
4. Some operands need to be in particular places on the stack. All
output operands fall in this category - there is no other way to
know which regs the outputs appear in unless the user indicates
this in the constraints.
Output operands must specifically indicate which reg an output
appears in after an asm. "=f" is not allowed: the operand
constraints must select a class with a single reg.
5. Output operands may not be "inserted" between existing stack regs.
Since no 387 opcode uses a read/write operand, all output operands
are dead before the asm_operands, and are pushed by the asm_operands.
It makes no sense to push anywhere but the top of the reg-stack.
Output operands must start at the top of the reg-stack: output
operands may not "skip" a reg.
6. Some asm statements may need extra stack space for internal
calculations. This can be guaranteed by clobbering stack registers
unrelated to the inputs and outputs.
Here are a couple of reasonable asms to want to write. This asm
takes one input, which is internally popped, and produces two outputs.
asm ("fsincos" : "=t" (cos), "=u" (sin) : "0" (inp));
This asm takes two inputs, which are popped by the fyl2xp1 opcode,
and replaces them with one output. The user must code the "st(1)"
clobber for reg-stack.c to know that fyl2xp1 pops both inputs.
asm ("fyl2xp1" : "=t" (result) : "0" (x), "u" (y) : "st(1)");
*/
1991-12-26 11:05:42 +01:00
#include "config.h"
Major cutover to using system.h: * Makefile.in (alias.o, bitmap.o, c-aux-info.o, c-common.o, c-decl.o, c-iterate.o, c-lang.o, c-lex.o, c-pragma.o, c-typeck.o, caller-save.o, calls.o, collect2.o, combine.o, cse.o, dbxout.o, dwarf2out.o, dwarfout.o, emit-rtl.o, except.o, explow.o, expmed.o, expr.o, final.o, flow.o, function.o, getpwd.o, global.o, integrate.o, jump.o, local-alloc.o, loop.o, optabs.o, pexecute.o, prefix.o, print-rtl.o, print-tree.o, profile.o, real.o, recog.o, reg-stack.o, regclass.o, regmove.o, reload.o, reload1.o, reorg.o, rtl.o, rtlanal.o, sdbout.o, stmt.o, stor-layout.o, stupid.o, tlink.o, toplev.o, tree.o, unroll.o, varasm.o, xcoffout.o): Depend on system.h. * alias.c, bitmap.c, c-aux-info.c, c-common.c, c-decl.c, c-iterate.c, c-lang.c, c-lex.c, c-pragma.c, c-typeck.c, caller-save.c, calls.c, collect2.c, combine.c, cse.c, dbxout.c, dwarf2out.c, dwarfout.c, emit-rtl.c, except.c, explow.c, expmed.c, expr.c, final.c, flow.c, function.c, gcc.c, getpwd.c, global.c, integrate.c, jump.c, local-alloc.c, loop.c, optabs.c, pexecute.c, prefix.c, print-rtl.c, print-tree.c, profile.c, real.c, recog.c, reg-stack.c, regclass.c, regmove.c, reload.c, reload1.c, reorg.c, rtl.c, rtlanal.c, sched.c, sdbout.c, stmt.c, stor-layout.c, stupid.c, tlink.c, toplev.c, tree.c, unroll.c, varasm.c, xcoffout.c: Include system.h. Organize include ordering so that stdarg/varargs comes before other system headers. Remove spurious casts of functions assured of a prototype in system.h. From-SVN: r18726
1998-03-20 15:58:42 +01:00
#include "system.h"
#include "coretypes.h"
#include "tm.h"
1991-12-26 11:05:42 +01:00
#include "tree.h"
#include "rtl.h"
#include "tm_p.h"
#include "function.h"
#include "insn-config.h"
1991-12-26 11:05:42 +01:00
#include "regs.h"
#include "hard-reg-set.h"
#include "flags.h"
#include "toplev.h"
#include "recog.h"
#include "output.h"
#include "basic-block.h"
#include "varray.h"
#include "reload.h"
#include "ggc.h"
/* We use this array to cache info about insns, because otherwise we
spend too much time in stack_regs_mentioned_p.
Indexed by insn UIDs. A value of zero is uninitialized, one indicates
the insn uses stack registers, two indicates the insn does not use
stack registers. */
static GTY(()) varray_type stack_regs_mentioned_data;
1991-12-26 11:05:42 +01:00
#ifdef STACK_REGS
#define REG_STACK_SIZE (LAST_STACK_REG - FIRST_STACK_REG + 1)
/* This is the basic stack record. TOP is an index into REG[] such
that REG[TOP] is the top of stack. If TOP is -1 the stack is empty.
If TOP is -2, REG[] is not yet initialized. Stack initialization
consists of placing each live reg in array `reg' and setting `top'
appropriately.
REG_SET indicates which registers are live. */
1991-12-26 11:05:42 +01:00
typedef struct stack_def
{
int top; /* index to top stack element */
HARD_REG_SET reg_set; /* set of live registers */
unsigned char reg[REG_STACK_SIZE];/* register - stack mapping */
1991-12-26 11:05:42 +01:00
} *stack;
/* This is used to carry information about basic blocks. It is
attached to the AUX field of the standard CFG block. */
1991-12-26 11:05:42 +01:00
typedef struct block_info_def
{
struct stack_def stack_in; /* Input stack configuration. */
struct stack_def stack_out; /* Output stack configuration. */
HARD_REG_SET out_reg_set; /* Stack regs live on output. */
int done; /* True if block already converted. */
int predecessors; /* Number of predecessors that needs
to be visited. */
} *block_info;
1991-12-26 11:05:42 +01:00
#define BLOCK_INFO(B) ((block_info) (B)->aux)
1991-12-26 11:05:42 +01:00
/* Passed to change_stack to indicate where to emit insns. */
enum emit_where
{
EMIT_AFTER,
EMIT_BEFORE
};
1991-12-26 11:05:42 +01:00
/* The block we're currently working on. */
static basic_block current_block;
/* This is the register file for all register after conversion. */
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
static rtx
FP_mode_reg[LAST_STACK_REG+1-FIRST_STACK_REG][(int) MAX_MACHINE_MODE];
#define FP_MODE_REG(regno,mode) \
(FP_mode_reg[(regno)-FIRST_STACK_REG][(int) (mode)])
1991-12-26 11:05:42 +01:00
/* Used to initialize uninitialized registers. */
static rtx nan;
1991-12-26 11:05:42 +01:00
/* Forward declarations */
static int stack_regs_mentioned_p (rtx pat);
static void straighten_stack (rtx, stack);
static void pop_stack (stack, int);
static rtx *get_true_reg (rtx *);
static int check_asm_stack_operands (rtx);
static int get_asm_operand_n_inputs (rtx);
static rtx stack_result (tree);
static void replace_reg (rtx *, int);
static void remove_regno_note (rtx, enum reg_note, unsigned int);
static int get_hard_regnum (stack, rtx);
static rtx emit_pop_insn (rtx, stack, rtx, enum emit_where);
static void emit_swap_insn (rtx, stack, rtx);
static void move_for_stack_reg (rtx, stack, rtx);
static int swap_rtx_condition_1 (rtx);
static int swap_rtx_condition (rtx);
static void compare_for_stack_reg (rtx, stack, rtx);
static void subst_stack_regs_pat (rtx, stack, rtx);
static void subst_asm_stack_regs (rtx, stack);
static void subst_stack_regs (rtx, stack);
static void change_stack (rtx, stack, stack, enum emit_where);
static int convert_regs_entry (void);
static void convert_regs_exit (void);
static int convert_regs_1 (FILE *, basic_block);
static int convert_regs_2 (FILE *, basic_block);
static int convert_regs (FILE *);
static void print_stack (FILE *, stack);
static rtx next_flags_user (rtx);
static void record_label_references (rtx, rtx);
static bool compensate_edge (edge, FILE *);
/* Return nonzero if any stack register is mentioned somewhere within PAT. */
static int
stack_regs_mentioned_p (rtx pat)
{
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 *fmt;
int i;
if (STACK_REG_P (pat))
return 1;
fmt = GET_RTX_FORMAT (GET_CODE (pat));
for (i = GET_RTX_LENGTH (GET_CODE (pat)) - 1; i >= 0; i--)
{
if (fmt[i] == '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 = XVECLEN (pat, i) - 1; j >= 0; j--)
if (stack_regs_mentioned_p (XVECEXP (pat, i, j)))
return 1;
}
else if (fmt[i] == 'e' && stack_regs_mentioned_p (XEXP (pat, i)))
return 1;
}
return 0;
}
/* Return nonzero if INSN mentions stacked registers, else return zero. */
int
stack_regs_mentioned (rtx insn)
{
unsigned int uid, max;
int test;
if (! INSN_P (insn) || !stack_regs_mentioned_data)
return 0;
uid = INSN_UID (insn);
max = VARRAY_SIZE (stack_regs_mentioned_data);
if (uid >= max)
{
/* Allocate some extra size to avoid too many reallocs, but
do not grow too quickly. */
max = uid + uid / 20;
VARRAY_GROW (stack_regs_mentioned_data, max);
}
test = VARRAY_CHAR (stack_regs_mentioned_data, uid);
if (test == 0)
{
/* This insn has yet to be examined. Do so now. */
test = stack_regs_mentioned_p (PATTERN (insn)) ? 1 : 2;
VARRAY_CHAR (stack_regs_mentioned_data, uid) = test;
}
return test == 1;
}
static rtx ix86_flags_rtx;
static rtx
next_flags_user (rtx insn)
{
/* Search forward looking for the first use of this value.
Stop at block boundaries. */
while (insn != current_block->end)
{
insn = NEXT_INSN (insn);
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
if (INSN_P (insn) && reg_mentioned_p (ix86_flags_rtx, PATTERN (insn)))
return insn;
if (GET_CODE (insn) == CALL_INSN)
return NULL_RTX;
}
return NULL_RTX;
}
1991-12-26 11:05:42 +01:00
/* Reorganize the stack into ascending numbers,
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
after this insn. */
static void
straighten_stack (rtx insn, stack regstack)
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
{
struct stack_def temp_stack;
int top;
/* If there is only a single register on the stack, then the stack is
already in increasing order and no reorganization is needed.
Similarly if the stack is empty. */
if (regstack->top <= 0)
return;
COPY_HARD_REG_SET (temp_stack.reg_set, regstack->reg_set);
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
for (top = temp_stack.top = regstack->top; top >= 0; top--)
temp_stack.reg[top] = FIRST_STACK_REG + temp_stack.top - top;
change_stack (insn, regstack, &temp_stack, EMIT_AFTER);
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
}
/* Pop a register from the stack. */
static void
pop_stack (stack regstack, int regno)
{
int top = regstack->top;
CLEAR_HARD_REG_BIT (regstack->reg_set, regno);
regstack->top--;
/* If regno was not at the top of stack then adjust stack. */
if (regstack->reg [top] != regno)
{
int i;
for (i = regstack->top; i >= 0; i--)
if (regstack->reg [i] == regno)
{
int j;
for (j = i; j < top; j++)
regstack->reg [j] = regstack->reg [j + 1];
break;
}
}
}
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
1991-12-26 11:05:42 +01:00
/* Convert register usage from "flat" register file usage to a "stack
register file. FIRST is the first insn in the function, FILE is the
dump file, if used.
Construct a CFG and run life analysis. Then convert each insn one
by one. Run a last cleanup_cfg pass, if optimizing, to eliminate
code duplication created when the converter inserts pop insns on
the edges. */
1991-12-26 11:05:42 +01:00
bool
reg_to_stack (rtx first, FILE *file)
1991-12-26 11:05:42 +01:00
{
bb-reorder.c (make_reorder_chain, [...]): Use FOR_EACH_BB macros to iterate over basic block chain. * bb-reorder.c (make_reorder_chain, make_reorder_chain_1): Use FOR_EACH_BB macros to iterate over basic block chain. * cfg.c (clear_edges, clear_bb_flags, dump_flow_info, alloc_aux_for_blocks, clear_aux_for_blocks, alloc_aux_for_edges): Likewise. * cfganal.c (set_edge_can_fallthru_flag, flow_call_edges_add, find_unreachable_blocks, create_edge_list, verify_edge_list, remove_fake_edges, add_noreturn_fake_exit_edges, flow_preorder_transversal_compute, flow_dfs_compute_reverse_execute): Likewise. * cfgbuild.c (make_edges, find_basic_blocks, find_many_sub_basic_blocks, find_sub_basic_blocks): Likewise. * cfgcleanup.c (try_optimize_cfg, delete_unreachable_blocks): Likewise. * cfglayout.c (record_effective_endpoints, cleanup_unconditional_jumps): Likewise. * cfgloop.c (flow_loops_cfg_dump, flow_loops_find): Likewise. * cfgrtl.c (compute_bb_for_insn, tidy_fallthru_edges, commit_edge_insertions, commit_edge_insertions_watch_calls, print_rtl_with_bb, verify_flow_info, purge_all_dead_edges): Likewise. * combine.c (combine_instructions, reg_dead_at_p): Likewise. * conflict.c (conflict_graph_compute): Likewise. * df.c (df_bitmaps_alloc, df_bitmaps_free, df_alloc, df_analyse_1, df_modified_p, df_refs_unlink, df_dump): Likewise. * dominance.c (calc_dfs_tree, calculate_dominance_info): Likewise. * final.c (compute_alignments): Likewise. * flow.c (update_life_info, update_life_info_in_dirty_blocks, delete_noop_moves, calculate_global_regs_live, allocate_bb_life_data, count_or_remove_death_notes): Likewise. * gcse.c (oprs_unchanged_p, record_last_reg_set_info, compute_hash_table, compute_kill_rd, compute_rd, compute_ae_kill, classic_gcse, compute_transp, cprop, compute_pre_data, compute_transpout, invalidate_nonnull_info, delete_null_pointer_checks_1, delete_null_pointer_checks, compute_code_hoist_vbeinout, hoist_code, compute_ld_motion_mems, compute_store_table, build_store_vectors, store_motion): Likewise. * global.c (global_conflicts, mark_elimination): Likewise. * graph.c (print_rtl_graph_with_bb): Likewise. * haifa-sched.c (sched_init): Likewise. * ifcvt.c (if_convert): Likewise. * lcm.c (compute_antinout_edge, compute_laterin, compute_insert_delete, compute_available, compute_nearerout, compute_rev_insert_delete, optimize_mode_switching): Likewise. * local-alloc.c (local_alloc, update_equiv_regs): Likewise. * predict.c (estimate_probability, note_prediction_to_br_prob, propagate_freq, counts_to_freqs, expensive_function_p, estimate_bb_frequencies): Likewise. * profile.c (instrument_edges, get_exec_counts, compute_branch_probabilities, compute_checksum, branch_prob, find_spanning_tree): Likewise. * recog.c (split_all_insns, peephole2_optimize): Likewise. * reg-stack.c (reg_to_stack, convert_regs_entry, convert_regs): Likewise. * regclass.c (scan_one_insn, regclass): Likewise. * regmove.c (mark_flags_life_zones, regmove_optimize, record_stack_memrefs): Likewise. * regrename.c (regrename_optimize, copyprop_hardreg_forward): Likewise. * reload1.c (reload, reload_combine, fixup_abnormal_edges): Likewise. * resource.c (find_basic_block): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (is_cfg_nonregular, build_control_flow, find_single_block_region, find_rgns, schedule_insns) * sibcall.c (optimize_sibling_and_tail_recursive_call) * ssa-ccp.c (optimize_unexecutable_edges, ssa_ccp_df_delete_unreachable_insns): Likewise. * ssa-dce.c (ssa_eliminate_dead_code): Likewise. * ssa.c (find_evaluations, compute_dominance_frontiers_1, rename_block, convert_to_ssa, compute_conservative_reg_partition, compute_coalesced_reg_partition, rename_equivalent_regs, convert_from_ssa): Likewise. * config/ia64/ia64.c (emit_predicate_relation_info, process_epilogue, process_for_unwind_directive): Likewise. * df.c (FOR_ALL_BBS): Removed. * gcse.c (struct null_pointer_info): Type of current_block field changed. (struct reg_avail_info): Type of last_bb field changed. * config/ia64/ia64.c (block_num): Removed. (need_copy_state): Type changed. (last_block): New. From-SVN: r53804
2002-05-23 21:23:51 +02:00
basic_block bb;
int i;
int max_uid;
/* Clean up previous run. */
stack_regs_mentioned_data = 0;
/* See if there is something to do. Flow analysis is quite
expensive so we might save some compilation time. */
for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++)
if (regs_ever_live[i])
break;
if (i > LAST_STACK_REG)
return false;
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
/* Ok, floating point instructions exist. If not optimizing,
build the CFG and run life analysis.
Also need to rebuild life when superblock scheduling is done
as it don't update liveness yet. */
if (!optimize
|| (flag_sched2_use_superblocks
&& flag_schedule_insns_after_reload))
{
count_or_remove_death_notes (NULL, 1);
life_analysis (first, file, PROP_DEATH_NOTES);
}
mark_dfs_back_edges ();
1991-12-26 11:05:42 +01:00
/* Set up block info for each basic block. */
Makefile.in (cfgrtl.o): Add. * Makefile.in (cfgrtl.o): Add. * basic-block.h (alloc_block, alloc_aux_for_block, alloc_aux_for_blocks, free_aux_for_block, alloc_aux_for_edge, alloc_aux_for_edges, free_aux_for_edge): Declare. * cfg.c (HAVE_return): Undefine. * basic-block.h (alloc_block, alloc_aux_for_block, alloc_aux_for_blocks, free_aux_for_block, alloc_aux_for_edge, alloc_aux_for_edges, free_aux_for_edge): New global functions. (first_delete_block): New static variable. (init_flow): Clear first_delete_block. (basic_block_for_insn, label_value_list, tail_recursion_label_list, can_delete_note_p, can_delete_label_p, commit_one_edge_insertion, try_redirect_by_replacing_jump, last_loop_beg_note, back_edge_of_syntactic_loop_p, force_nonfallthru_and_redirect, delete_insn, delete_insn_chain, create_basic_block_structure, create_basic_block, flow_delete_block, compute_bb_for_insn, free_bb_for_insn, update_bb_for_insn, set_block_for_insn, set_block_for_new_insns, split_block, merge_blocks_nomove, block_label, try_redirect_by_replacing_jump, last_loop_beg_note, redirect_edge_and_branch, force_nonfallthru_and_redirect, force_nonfallthru, redirect_edge_and_branch_force, tidy_fallthru_edge, tidy_fallthru_edges, split_edge, insert_insn_on_edge, commit_one_edge_insertion, commit_edge_insertions, dump_bb, debug_bb, debug_bb_n, print_rtl_with_bb, verify_flow_info, purge_dead_edges, purge_all_dead_edges): Move to .... * cfgrtl.c: New file; .... Here. * bb-reorder.c (fixup_reorder_chain): Use alloc_aux_for_block. (reroder_basic_block): Use alloc_aux_for_blocks. * predict.c (estimate_bb_frequencies): Likewise; use alloc_aux_for_edges. * profile.c (compute_branch_probabilities): Likewise. (branch_prob): Likewise. * reg-stack.c (reg_to_stack): Likewise. * emit-rtl.c (emit_insns_after): Never return NULL. * basic-block.h (set_block_for_new_insns): Delete. * cfgrtl.c (set_block_for_new_insns): Delete. * cfgcleanup.c (try_optimize_cfg): Add fake exit edges for noreturn calls when crossjumping. * cfgcleanup.c (try_simplify_condjump): Cleanup invert_jump call. * unroll.c (copy_loop_body): Use delete_insn. * final.c (final, final_scan_insn): Use delete_insn/delete_note. * function.c (fixup_var_refs_insn, fixup_var_refs_1, keep_stack_depressed): Likewise. * gcse.c (cprop_cc0_jump): Likewise. * local-alloc.c (update_equiv_regs): Likewise. * loop.c (scan_loop, loop_delete_insns): Likewise. * regmove.c (try_auto_increment, fixup_match_1): Likewise. * reload1.c (reload, calculate_needs_all_insns, reload_as_needed, delete_output_reload, delete_address_reloads_1, reload_cse_delete_noop_set, reload_combine, reload_cse_move2add): Likewise. * sibcall.c (replace_call_placeholder): Likewise. * cse.c (cse_insn): Likewise. From-SVN: r45807
2001-09-25 17:26:55 +02:00
alloc_aux_for_blocks (sizeof (struct block_info_def));
bb-reorder.c (make_reorder_chain, [...]): Use FOR_EACH_BB macros to iterate over basic block chain. * bb-reorder.c (make_reorder_chain, make_reorder_chain_1): Use FOR_EACH_BB macros to iterate over basic block chain. * cfg.c (clear_edges, clear_bb_flags, dump_flow_info, alloc_aux_for_blocks, clear_aux_for_blocks, alloc_aux_for_edges): Likewise. * cfganal.c (set_edge_can_fallthru_flag, flow_call_edges_add, find_unreachable_blocks, create_edge_list, verify_edge_list, remove_fake_edges, add_noreturn_fake_exit_edges, flow_preorder_transversal_compute, flow_dfs_compute_reverse_execute): Likewise. * cfgbuild.c (make_edges, find_basic_blocks, find_many_sub_basic_blocks, find_sub_basic_blocks): Likewise. * cfgcleanup.c (try_optimize_cfg, delete_unreachable_blocks): Likewise. * cfglayout.c (record_effective_endpoints, cleanup_unconditional_jumps): Likewise. * cfgloop.c (flow_loops_cfg_dump, flow_loops_find): Likewise. * cfgrtl.c (compute_bb_for_insn, tidy_fallthru_edges, commit_edge_insertions, commit_edge_insertions_watch_calls, print_rtl_with_bb, verify_flow_info, purge_all_dead_edges): Likewise. * combine.c (combine_instructions, reg_dead_at_p): Likewise. * conflict.c (conflict_graph_compute): Likewise. * df.c (df_bitmaps_alloc, df_bitmaps_free, df_alloc, df_analyse_1, df_modified_p, df_refs_unlink, df_dump): Likewise. * dominance.c (calc_dfs_tree, calculate_dominance_info): Likewise. * final.c (compute_alignments): Likewise. * flow.c (update_life_info, update_life_info_in_dirty_blocks, delete_noop_moves, calculate_global_regs_live, allocate_bb_life_data, count_or_remove_death_notes): Likewise. * gcse.c (oprs_unchanged_p, record_last_reg_set_info, compute_hash_table, compute_kill_rd, compute_rd, compute_ae_kill, classic_gcse, compute_transp, cprop, compute_pre_data, compute_transpout, invalidate_nonnull_info, delete_null_pointer_checks_1, delete_null_pointer_checks, compute_code_hoist_vbeinout, hoist_code, compute_ld_motion_mems, compute_store_table, build_store_vectors, store_motion): Likewise. * global.c (global_conflicts, mark_elimination): Likewise. * graph.c (print_rtl_graph_with_bb): Likewise. * haifa-sched.c (sched_init): Likewise. * ifcvt.c (if_convert): Likewise. * lcm.c (compute_antinout_edge, compute_laterin, compute_insert_delete, compute_available, compute_nearerout, compute_rev_insert_delete, optimize_mode_switching): Likewise. * local-alloc.c (local_alloc, update_equiv_regs): Likewise. * predict.c (estimate_probability, note_prediction_to_br_prob, propagate_freq, counts_to_freqs, expensive_function_p, estimate_bb_frequencies): Likewise. * profile.c (instrument_edges, get_exec_counts, compute_branch_probabilities, compute_checksum, branch_prob, find_spanning_tree): Likewise. * recog.c (split_all_insns, peephole2_optimize): Likewise. * reg-stack.c (reg_to_stack, convert_regs_entry, convert_regs): Likewise. * regclass.c (scan_one_insn, regclass): Likewise. * regmove.c (mark_flags_life_zones, regmove_optimize, record_stack_memrefs): Likewise. * regrename.c (regrename_optimize, copyprop_hardreg_forward): Likewise. * reload1.c (reload, reload_combine, fixup_abnormal_edges): Likewise. * resource.c (find_basic_block): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (is_cfg_nonregular, build_control_flow, find_single_block_region, find_rgns, schedule_insns) * sibcall.c (optimize_sibling_and_tail_recursive_call) * ssa-ccp.c (optimize_unexecutable_edges, ssa_ccp_df_delete_unreachable_insns): Likewise. * ssa-dce.c (ssa_eliminate_dead_code): Likewise. * ssa.c (find_evaluations, compute_dominance_frontiers_1, rename_block, convert_to_ssa, compute_conservative_reg_partition, compute_coalesced_reg_partition, rename_equivalent_regs, convert_from_ssa): Likewise. * config/ia64/ia64.c (emit_predicate_relation_info, process_epilogue, process_for_unwind_directive): Likewise. * df.c (FOR_ALL_BBS): Removed. * gcse.c (struct null_pointer_info): Type of current_block field changed. (struct reg_avail_info): Type of last_bb field changed. * config/ia64/ia64.c (block_num): Removed. (need_copy_state): Type changed. (last_block): New. From-SVN: r53804
2002-05-23 21:23:51 +02:00
FOR_EACH_BB_REVERSE (bb)
{
edge e;
for (e = bb->pred; e; e = e->pred_next)
if (!(e->flags & EDGE_DFS_BACK)
&& e->src != ENTRY_BLOCK_PTR)
BLOCK_INFO (bb)->predecessors++;
}
1991-12-26 11:05:42 +01:00
/* Create the replacement registers up front. */
for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++)
{
enum machine_mode mode;
for (mode = GET_CLASS_NARROWEST_MODE (MODE_FLOAT);
mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
FP_MODE_REG (i, mode) = gen_rtx_REG (mode, i);
for (mode = GET_CLASS_NARROWEST_MODE (MODE_COMPLEX_FLOAT);
mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
FP_MODE_REG (i, mode) = gen_rtx_REG (mode, i);
}
1991-12-26 11:05:42 +01:00
ix86_flags_rtx = gen_rtx_REG (CCmode, FLAGS_REG);
1991-12-26 11:05:42 +01:00
/* A QNaN for initializing uninitialized variables.
1991-12-26 11:05:42 +01:00
??? We can't load from constant memory in PIC mode, because
we're inserting these instructions before the prologue and
the PIC register hasn't been set up. In that case, fall back
on zero, which we can get from `ldz'. */
1991-12-26 11:05:42 +01:00
if (flag_pic)
nan = CONST0_RTX (SFmode);
else
{
nan = gen_lowpart (SFmode, GEN_INT (0x7fc00000));
nan = force_const_mem (SFmode, nan);
}
1991-12-26 11:05:42 +01:00
/* Allocate a cache for stack_regs_mentioned. */
max_uid = get_max_uid ();
VARRAY_CHAR_INIT (stack_regs_mentioned_data, max_uid + 1,
"stack_regs_mentioned cache");
1991-12-26 11:05:42 +01:00
convert_regs (file);
Makefile.in (cfgrtl.o): Add. * Makefile.in (cfgrtl.o): Add. * basic-block.h (alloc_block, alloc_aux_for_block, alloc_aux_for_blocks, free_aux_for_block, alloc_aux_for_edge, alloc_aux_for_edges, free_aux_for_edge): Declare. * cfg.c (HAVE_return): Undefine. * basic-block.h (alloc_block, alloc_aux_for_block, alloc_aux_for_blocks, free_aux_for_block, alloc_aux_for_edge, alloc_aux_for_edges, free_aux_for_edge): New global functions. (first_delete_block): New static variable. (init_flow): Clear first_delete_block. (basic_block_for_insn, label_value_list, tail_recursion_label_list, can_delete_note_p, can_delete_label_p, commit_one_edge_insertion, try_redirect_by_replacing_jump, last_loop_beg_note, back_edge_of_syntactic_loop_p, force_nonfallthru_and_redirect, delete_insn, delete_insn_chain, create_basic_block_structure, create_basic_block, flow_delete_block, compute_bb_for_insn, free_bb_for_insn, update_bb_for_insn, set_block_for_insn, set_block_for_new_insns, split_block, merge_blocks_nomove, block_label, try_redirect_by_replacing_jump, last_loop_beg_note, redirect_edge_and_branch, force_nonfallthru_and_redirect, force_nonfallthru, redirect_edge_and_branch_force, tidy_fallthru_edge, tidy_fallthru_edges, split_edge, insert_insn_on_edge, commit_one_edge_insertion, commit_edge_insertions, dump_bb, debug_bb, debug_bb_n, print_rtl_with_bb, verify_flow_info, purge_dead_edges, purge_all_dead_edges): Move to .... * cfgrtl.c: New file; .... Here. * bb-reorder.c (fixup_reorder_chain): Use alloc_aux_for_block. (reroder_basic_block): Use alloc_aux_for_blocks. * predict.c (estimate_bb_frequencies): Likewise; use alloc_aux_for_edges. * profile.c (compute_branch_probabilities): Likewise. (branch_prob): Likewise. * reg-stack.c (reg_to_stack): Likewise. * emit-rtl.c (emit_insns_after): Never return NULL. * basic-block.h (set_block_for_new_insns): Delete. * cfgrtl.c (set_block_for_new_insns): Delete. * cfgcleanup.c (try_optimize_cfg): Add fake exit edges for noreturn calls when crossjumping. * cfgcleanup.c (try_simplify_condjump): Cleanup invert_jump call. * unroll.c (copy_loop_body): Use delete_insn. * final.c (final, final_scan_insn): Use delete_insn/delete_note. * function.c (fixup_var_refs_insn, fixup_var_refs_1, keep_stack_depressed): Likewise. * gcse.c (cprop_cc0_jump): Likewise. * local-alloc.c (update_equiv_regs): Likewise. * loop.c (scan_loop, loop_delete_insns): Likewise. * regmove.c (try_auto_increment, fixup_match_1): Likewise. * reload1.c (reload, calculate_needs_all_insns, reload_as_needed, delete_output_reload, delete_address_reloads_1, reload_cse_delete_noop_set, reload_combine, reload_cse_move2add): Likewise. * sibcall.c (replace_call_placeholder): Likewise. * cse.c (cse_insn): Likewise. From-SVN: r45807
2001-09-25 17:26:55 +02:00
free_aux_for_blocks ();
return true;
1991-12-26 11:05:42 +01:00
}
/* Check PAT, which is in INSN, for LABEL_REFs. Add INSN to the
label's chain of references, and note which insn contains each
1996-07-04 00:07:53 +02:00
reference. */
1991-12-26 11:05:42 +01:00
static void
record_label_references (rtx insn, rtx pat)
1991-12-26 11:05:42 +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
enum rtx_code code = GET_CODE (pat);
int i;
const char *fmt;
1991-12-26 11:05:42 +01:00
if (code == LABEL_REF)
{
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
rtx label = XEXP (pat, 0);
rtx ref;
1991-12-26 11:05:42 +01:00
if (GET_CODE (label) != CODE_LABEL)
abort ();
1996-07-04 00:07:53 +02:00
/* If this is an undefined label, LABEL_REFS (label) contains
garbage. */
if (INSN_UID (label) == 0)
return;
1996-07-04 00:07:53 +02:00
/* Don't make a duplicate in the code_label's chain. */
1991-12-26 11:05:42 +01:00
for (ref = LABEL_REFS (label);
ref && ref != label;
ref = LABEL_NEXTREF (ref))
1991-12-26 11:05:42 +01:00
if (CONTAINING_INSN (ref) == insn)
return;
CONTAINING_INSN (pat) = insn;
LABEL_NEXTREF (pat) = LABEL_REFS (label);
LABEL_REFS (label) = pat;
return;
}
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
record_label_references (insn, XEXP (pat, i));
if (fmt[i] == '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;
1991-12-26 11:05:42 +01:00
for (j = 0; j < XVECLEN (pat, i); j++)
record_label_references (insn, XVECEXP (pat, i, j));
}
}
}
/* Return a pointer to the REG expression within PAT. If PAT is not a
REG, possible enclosed by a conversion rtx, return the inner part of
1996-07-04 00:07:53 +02:00
PAT that stopped the search. */
1991-12-26 11:05:42 +01:00
static rtx *
get_true_reg (rtx *pat)
1991-12-26 11:05:42 +01:00
{
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
for (;;)
switch (GET_CODE (*pat))
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
{
case SUBREG:
/* Eliminate FP subregister accesses in favor of the
actual FP register in use. */
{
rtx subreg;
if (FP_REG_P (subreg = SUBREG_REG (*pat)))
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
{
Use byte offsets in SUBREGs instead of words. 2001-04-03 Jakub Jelinek <jakub@redhat.com> David S. Miller <davem@pierdol.cobaltmicro.com> Andrew MacLeod <amacleod@redhat.com> Use byte offsets in SUBREGs instead of words. * alias.c (nonlocal_mentioned_p): Use subreg_regno function. * caller-save.c (mark_set_regs): Change callers of subreg_hard_regno to pass new argument. (add_stored_regs): Use subreg_regno_offset function. * calls.c (expand_call): For non-paradoxical SUBREG take endianess into account. (precompute_arguments): Use gen_lowpart_SUBREG. * combine.c (try_combine): Replace explicit XEXP with SUBREG_REG. (combine_simplify_rtx): Rework to use SUBREG_BYTE. (simplify_set): Rework to use SUBREG_BYTE. (expand_field_assignment): Use SUBREG_BYTE. (make_extraction): Use SUBREG_BYTE. (if_then_else_cond): Use SUBREG_BYTE. (apply_distributive_law): Use SUBREG_BYTE and fixup subreg comments. (gen_lowpart_for_combine): Compute full byte offset. * cse.c (mention_regs): Use SUBREG_BYTE. (remove_invalid_subreg_refs): Rework to use SUBREG_BYTE. (canon_hash): Use SUBREG_BYTE. (fold_rtx): Pass SUBREG_BYTE div UNITS_PER_WORD to operand_subword. (gen_lowpart_if_possible): Formatting. * dbxout.c (dbxout_symbol_location): Compute SUBREG hard regnos correctly. * dwarf2out.c (is_pseudo_reg): Fixup explicit XEXP into SUBREG_REG (mem_loc_descriptor): Fixup explicit XEXP into SUBREG_REG (loc_descriptor): Fixup explicit XEXP into SUBREG_REG * dwarfout.c (is_pseudo_reg): Fixup explicit XEXP into SUBREG_REG (output_mem_loc_descriptor): Fixup explicit XEXP into SUBREG_REG (output_loc_descriptor): Fixup explicit XEXP into SUBREG_REG * emit-rtl.c (gen_rtx_SUBREG): New function, used to verify certain invariants about SUBREGs the compiler creates. (gen_lowpart_SUBREG): New function. (subreg_hard_regno): New function to get the final register number. (gen_lowpart_common): Use SUBREG_BYTE. (gen_imagpart): Spacing nits. (subreg_realpart_p): Use SUBREG_BYTE. (gen_highpart): Use SUBREG_BYTE. (subreg_lowpart_p): Always compute endian corrected goal offset, even at the byte level, then compare against that. (constant_subword): New function, pulled out all constant cases from operand_subword and changed second argument name to offset. (operand_subword): Detect non REG/SUBREG/CONCAT/MEM cases early and call constant_subword to do the work. Return const0_rtx if looking for a word outside of OP. (operand_subword_force): Change second arg name to offset. * expmed.c (store_bit_field): Use SUBREG_BYTE. (store_split_bit_field): Use SUBREG_BYTE. (extract_bit_field): Use SUBREG_BYTE. (extract_split_bit_field): Use SUBREG_BYTE. (expand_shift): Use SUBREG_BYTE. * expr.c (store_expr, expand_expr): Use gen_lowpart_SUBREG. * final.c (alter_subreg) Use subreg_hard_regno and SUBREG_BYTE. * flow.c (set_noop_p): Use SUBREG_BYTE. (mark_set_1): Remove ALTER_HARD_SUBREG. Use subreg_regno_offset instead. * function.c (fixup_var_refs_1): Fixup explicit XEXP into a SUBREG_REG. (fixup_memory_subreg): Use SUBREG_BYTE and remove byte endian correction code. (optimize_bit_field): Use SUBREG_BYTE. (purge_addressof_1): Use SUBREG_BYTE. (purge_single_hard_subreg_set): Use subreg_regno_offset function. (assign_params): Mark arguments SUBREG_PROMOTED_VAR_P if they are actually promoted by the caller and PROMOTE_FOR_CALLS_ONLY is true. * gengenrtl.c (special_rtx): Add SUBREG. * global.c (mark_reg_store): Use SUBREG_BYTE. (set_preference): Rework to use subreg_regno_offset and SUBREG_BYTE. * ifcvt (noce_emit_move_insn): Use SUBREG_BYTE. * integrate.c (copy_rtx_and_substitute): Use SUBREG_BYTE and make sure final byte offset is congruent to subreg's mode size. (subst_constants): Use SUBREG_BYTE. (mark_stores): Use subreg_regno_offset function. * jump.c (rtx_renumbered_equal_p, true_regnum): Use subreg_regno_offset function and SUBREG_BYTE. * local-alloc.c (combine_regs): Use subreg_regno_offset function. (reg_is_born): Use subreg_hard_regno. * recog.c (valid_replace_rtx_1): Use SUBREG_BYTE and remove byte endian correction code. Don't combine subregs unless resulting offset aligns with type. Fix subreg constant extraction for DImode. Simplify SUBREG of VOIDmode CONST_DOUBLE. (general_operand): Remove dead mode_altering_drug code. (indirect_operand): Use SUBREG_BYTE. (constrain_operands): Use subreg_regno_offset function. * reg-stack.c (get_true_reg): Use subreg_regno_offset function. * regmove.c (regmove_optimize): Use SUBREG_BYTE. (optimize_reg_copy_3): Use gen_lowpart_SUBREG. * regs.h (REG_SIZE): Allow target to override. (REGMODE_NATURAL_SIZE): New macro which target can override. * reload.c (reload_inner_reg_of_subreg): subreg_regno should be used on the entire subreg rtx. (push_reload): Use SUBREG_BYTE in comments and code. (find_dummy_reload): Use subreg_regno_offset. Only adjust offsets for hard registers inside subregs. (operands_match_p): Use subreg_regno_offset. (find_reloads): Use SUBREG_BYTE and only advance offset for subregs containing hard regs. (find_reload_toplev): Use SUBREG_BYTE. Remove byte endian corrections when fixing up MEM subregs. (find_reloads_address_1): Use SUBREG_BYTE, subreg_regno, and subreg_regno_offset where appropriate. (find_reloads_subreg_address): Use SUBREG_BYTE. Remove byte endian corrections when fixing up MEM subregs. (subst_reloads): When combining two subregs, make sure final offset is congruent to subreg's mode size. (find_replacement): Use SUBREG_BYTE and subreg_regno_offset. (refers_to_regno_for_reload_p): Use subreg_regno. (reg_overlap_mentioned_for_reload_p): Use subreg_regno_offset. * reload1.c (eliminate_regs) Use SUBREG_BYTE. Remove byte endian correction code for memory subreg fixups. (forget_old_reload_1): Use subreg_regno_offset. (choose_reload_regs): Use subreg_regno. (emit_input_reload_insns): Use SUBREG_BYTE. (reload_combine_note_store): Use subreg_regno_offset. (move2add_note_store): Use subreg_regno_offset. * resource.c (update_live_status, mark_referenced_resources): Use subreg_regno function. (mark_set_resources): Use subreg_regno function. * rtl.h (SUBREG_WORD): Rename to SUBREG_BYTE. (subreg_regno_offset, subreg_regno): Define prototypes. (subreg_hard_regno, constant_subword, gen_rtx_SUBREG): Newi functions. (gen_lowpart_SUBREG): Add prototype. * rtl.texi (subreg): Update to reflect new byte offset representation. Add mentioning of the effect that BYTES_BIG_ENDIAN has on subregs now. * rtlanal.c (refers_to_regno_p): Use subreg_regno. (reg_overlap_mentioned_p): Use subreg_regno. (replace_regs); Make sure final offset of combined subreg is congruent to size of subreg's mode. (subreg_regno_offset): New function. (subreg_regno): New function. * sched-vis.c (print_value): Change SUBREG_WORD to SUBREG_BYTE. * sdbout.c (sdbout_symbol): Compute offset using alter_subreg. * stmt.c (expand_anon_union_decl): Use gen_lowpart_SUBREG. * tm.texi (ALTER_HARD_SUBREG): Remove, it is now dead. (SUBREG_REGNO_OFFSET): Describe SUBREG_REGNO_OFFSET overrides. * config/a29k/a29k.c (gpc_reg_operand): Use subreg_regno. (a29k_get_reloaded_address): Use SUBREG_BYTE. (print_operand): Use SUBREG_BYTE. * config/alpha/alpha.c (print_operand_address): Use SUBREG_BYTE. * config/arm/arm.c (arm_reload_in_hi): Use SUBREG_BYTE. (arm_reload_out_hi): Use SUBREG_BYTE. * config/d30v/d30v.c (d30v_split_double): Use subreg_regno_offset instead of SUBREG_WORD. (d30v_print_operand_memory_reference): Use subreg_regno_offset. * config/dsp16xx/dsp16xx.md (extendqihi2, zero_extendqihi2): Fix SUBREG creation to use byte offset. * config/h8300/h8300.md (Unnamed HImode zero extraction and 16bit inverted load insns): Fix explicit rtl subregs to use byte offsets. * config/i370/i370.md (cmpstrsi, movstrsi, mulsi3, divsi3, udivsi3, umodsi3): Generate SUBREGs with byte offsets. * config/i860/i860.c (single_insn_src_p): Use SUBREG_BYTE. * config/i860/i860.md (mulsi3_big): Fixup explicit SUBREGs in rtl to use byte offsets. (unnamed fmlow.dd insn): Fixup SUBREGS to use byte offsets. * config/i960/i960.md (extendhisi2): Generate SUBREGs with byte offsets, also make sure it is congruent to SUBREG's mode size. (extendqisi2, extendqihi2, zero_extendhisi2, zero_extendqisi2, unnamed ldob insn): Generate SUBREGs with byte offset. (zero_extendqihi2): SUBREG's are byte offsets. * config/m68hc11/m68hc11.c (m68hc11_gen_lowpart): Use SUBREG_BYTE. (m68hc11_gen_highpart): Use SUBREG_BYTE. * config/m68k/m68k.md (zero_extendhisi2, zero_extendqihi2, zero-extendqisi2): Generate SUBREGs with byte offset. (umulsidi3, mulsidi3, subreghi1ashrdi_const32, subregsi1ashrdi_const32, subreg1lshrdi_const32): Fixup explicit subregs in rtl to use byte offsets. * config/m88k/m88k.md (extendsidi2): fixup subregs to use byte offset. * config/mips/mips.c (mips_move_1word): Use subreg_regno_offset. (mips_move_2words): Use subreg_regno_offset. (mips_secondary_reload_class): Use subreg_regno_offset. * config/mips/mips.md (DImode plus, minus, move, and logical op splits): Fixup explicit subregs in rtl to use byte offsets. * config/mn10200/mn10200.c (print_operand): Use subreg_regno function. * config/mn10300/mn10300.c (print_operand): Use subreg_regno function. * config/ns32k/ns32k.md (udivmoddisi4): Fix explicit subregs in rtl to use byte offsets. * config/pa/pa.c (emit_move_sequence): Use SUBREG_BYTE. * config/pa/pa.md (floatunssisf2, floatunssidf2, mulsi3): fix explicit subregs to use byte offsets. * config/pdp11/pdp11.md (zero_extendhisi2, modhi3, modhi3+1): Fixup explicit subregs in rtl to use byte offsets. * config/romp/romp.c (memory_offset_in_range_p): Use SUBREG_BYTE and remove byte endian correction code. * config/sh/sh.c (output_movedouble): Use subreg_regno. (gen_ashift_hi): Use SUBREG_BYTE. (regs_used): Use subreg_regno_offset. (machine_dependent_reorg): Use subreg_regno_offset. * config/sh/sh.h (INDEX_REGISTER_RTX_P): Use SUBREG_BYTE. * config/sh/sh.md (DImode and DFmode move splits): Use subreg_regno. (movdf_i4): Subregs are byte offsets now. * config/sparc/sparc.c (ultra_find_type): Use SUBREG_BYTE. * config/sparc/sparc.h (ALTER_HARD_SUBREG): Removed. (REGMODE_NATURAL_SIZE): Override. (REG_SIZE): For SUBREG check float mode on SUBREG_REG's mode. * config/sparc/sparc.md (TFmode move splits): Generate SUBREGs with byte offsets. (zero_extendhisi2, zero_extendqidi2_insn, extendhisi2, extendqihi2, sign_extendqihi2_insn, sign_extendqisi2_insn, extendqidi2): Generate SUBREGs with byte offsets, also make sure it is congruent to SUBREG's mode size. (smulsi3_highpart_v8plus): Fix explicit subregs in rtl to use byte offsets. (cmp_siqi_trunc, cmp_siqi_trunc_set, cmp_diqi_trunc, cmp_diqi_trunc_set, lshrdi3_v8plus+1, lshrdi3_v8plus+2, lshrdi3_v8plus+3, lshrdi3_v8plus+4): Use proper SUBREG_BYTE offset for non-paradoxical subregs in patterns. * config/v850/v850.c (print_operand, output_move_double): Use subreg_regno function. Co-Authored-By: Andrew MacLeod <amacleod@redhat.com> Co-Authored-By: David S. Miller <davem@pierdol.cobaltmicro.com> From-SVN: r41058
2001-04-03 17:06:12 +02:00
int regno_off = subreg_regno_offset (REGNO (subreg),
GET_MODE (subreg),
SUBREG_BYTE (*pat),
GET_MODE (*pat));
*pat = FP_MODE_REG (REGNO (subreg) + regno_off,
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
GET_MODE (subreg));
default:
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
return pat;
}
}
case FLOAT:
case FIX:
case FLOAT_EXTEND:
pat = & XEXP (*pat, 0);
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
}
1991-12-26 11:05:42 +01:00
}
/* Set if we find any malformed asms in a block. */
static bool any_malformed_asm;
/* There are many rules that an asm statement for stack-like regs must
follow. Those rules are explained at the top of this file: the rule
1996-07-04 00:07:53 +02:00
numbers below refer to that explanation. */
static int
check_asm_stack_operands (rtx insn)
{
int i;
int n_clobbers;
int malformed_asm = 0;
rtx body = PATTERN (insn);
char reg_used_as_output[FIRST_PSEUDO_REGISTER];
char implicitly_dies[FIRST_PSEUDO_REGISTER];
int alt;
builtins.c (expand_builtin_strlen): Initialize variable `icode'. * builtins.c (expand_builtin_strlen): Initialize variable `icode'. * calls.c (expand_call): Likewise for `old_stack_arg_under_construction'. * cpphash.c (macroexpand): Likewise for `args' and `rest_zero'. * function.c (pad_to_arg_alignment): Likewise for `save_var' and `save_constant'. * gcc.c (execute): Likewise for `ut' and `st'. * genattrtab.c (attr_rtx): Likewise for `rt_val'. * genopinit.c (gen_insn): Likewise for `m1', `m2' and `op'. * jump.c (jump_optimize_1): Likewise for `temp2'. * local-alloc.c (block_alloc): Likewise for `r1'. * loop.c (recombine_givs): Likewise for `life_start' and `life_end'. * reg-stack.c (check_asm_stack_operands): Likewise for `clobber_reg'. (subst_asm_stack_regs): Likewise for `clobber_reg' and `clobber_loc'. * regmove.c (fixup_match_1): Likewise for `insn_const', `dst_node' and `set2'. * reload.c (find_reloads): Likewise for `goal_alternative_number' and `goal_earlyclobber'. * scan-decls.c (scan_decls): Likewise for `prev_id_end'. * sdbout.c (sdbout_one_type): Likewise for `member_scl'. * stupid.c (stupid_life_analysis): Likewise for `chain'. * unroll.c (copy_loop_body): Likewise for `copy'. * varasm.c (output_constructor): Likewise for `byte'. ch: * actions.c (update_else_range_for_int_const): Initialize variables `lowval' and `highval'. (update_else_range_for_range): Likewise for `low_range_val' and `high_range_val'. cp: * class.c (warn_hidden): Initialize variable `fndecl'. From-SVN: r31207
2000-01-04 17:29:41 +01:00
rtx *clobber_reg = 0;
int n_inputs, n_outputs;
/* Find out what the constraints require. If no constraint
alternative matches, this asm is malformed. */
extract_insn (insn);
constrain_operands (1);
alt = which_alternative;
preprocess_constraints ();
n_inputs = get_asm_operand_n_inputs (body);
n_outputs = recog_data.n_operands - n_inputs;
if (alt < 0)
{
malformed_asm = 1;
/* Avoid further trouble with this insn. */
PATTERN (insn) = gen_rtx_USE (VOIDmode, const0_rtx);
return 0;
}
1996-07-04 00:07:53 +02:00
/* Strip SUBREGs here to make the following code simpler. */
for (i = 0; i < recog_data.n_operands; i++)
if (GET_CODE (recog_data.operand[i]) == SUBREG
&& GET_CODE (SUBREG_REG (recog_data.operand[i])) == REG)
recog_data.operand[i] = SUBREG_REG (recog_data.operand[i]);
/* Set up CLOBBER_REG. */
n_clobbers = 0;
if (GET_CODE (body) == PARALLEL)
{
clobber_reg = alloca (XVECLEN (body, 0) * sizeof (rtx));
for (i = 0; i < XVECLEN (body, 0); i++)
if (GET_CODE (XVECEXP (body, 0, i)) == CLOBBER)
{
rtx clobber = XVECEXP (body, 0, i);
rtx reg = XEXP (clobber, 0);
if (GET_CODE (reg) == SUBREG && GET_CODE (SUBREG_REG (reg)) == REG)
reg = SUBREG_REG (reg);
if (STACK_REG_P (reg))
{
clobber_reg[n_clobbers] = reg;
n_clobbers++;
}
}
}
/* Enforce rule #4: Output operands must specifically indicate which
reg an output appears in after an asm. "=f" is not allowed: the
operand constraints must select a class with a single reg.
Also enforce rule #5: Output operands must start at the top of
1996-07-04 00:07:53 +02:00
the reg-stack: output operands may not "skip" a reg. */
memset (reg_used_as_output, 0, sizeof (reg_used_as_output));
for (i = 0; i < n_outputs; i++)
if (STACK_REG_P (recog_data.operand[i]))
{
if (reg_class_size[(int) recog_op_alt[i][alt].class] != 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
error_for_asm (insn, "output constraint %d must specify a single register", i);
malformed_asm = 1;
}
else
{
int j;
for (j = 0; j < n_clobbers; j++)
if (REGNO (recog_data.operand[i]) == REGNO (clobber_reg[j]))
{
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
error_for_asm (insn, "output constraint %d cannot be specified together with \"%s\" clobber",
i, reg_names [REGNO (clobber_reg[j])]);
malformed_asm = 1;
break;
}
if (j == n_clobbers)
reg_used_as_output[REGNO (recog_data.operand[i])] = 1;
}
}
/* Search for first non-popped reg. */
for (i = FIRST_STACK_REG; i < LAST_STACK_REG + 1; i++)
if (! reg_used_as_output[i])
break;
/* If there are any other popped regs, that's an error. */
for (; i < LAST_STACK_REG + 1; i++)
if (reg_used_as_output[i])
break;
if (i != LAST_STACK_REG + 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
error_for_asm (insn, "output regs must be grouped at top of stack");
malformed_asm = 1;
}
/* Enforce rule #2: All implicitly popped input regs must be closer
to the top of the reg-stack than any input that is not implicitly
1996-07-04 00:07:53 +02:00
popped. */
memset (implicitly_dies, 0, sizeof (implicitly_dies));
for (i = n_outputs; i < n_outputs + n_inputs; i++)
if (STACK_REG_P (recog_data.operand[i]))
{
/* An input reg is implicitly popped if it is tied to an
1996-07-04 00:07:53 +02:00
output, or if there is a CLOBBER for it. */
int j;
for (j = 0; j < n_clobbers; j++)
if (operands_match_p (clobber_reg[j], recog_data.operand[i]))
break;
if (j < n_clobbers || recog_op_alt[i][alt].matches >= 0)
implicitly_dies[REGNO (recog_data.operand[i])] = 1;
}
/* Search for first non-popped reg. */
for (i = FIRST_STACK_REG; i < LAST_STACK_REG + 1; i++)
if (! implicitly_dies[i])
break;
/* If there are any other popped regs, that's an error. */
for (; i < LAST_STACK_REG + 1; i++)
if (implicitly_dies[i])
break;
if (i != LAST_STACK_REG + 1)
{
error_for_asm (insn,
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
"implicitly popped regs must be grouped at top of stack");
malformed_asm = 1;
}
2003-01-06 21:02:56 +01:00
/* Enforce rule #3: If any input operand uses the "f" constraint, all
output constraints must use the "&" earlyclobber.
??? Detect this more deterministically by having constrain_asm_operands
1996-07-04 00:07:53 +02:00
record any earlyclobber. */
for (i = n_outputs; i < n_outputs + n_inputs; i++)
if (recog_op_alt[i][alt].matches == -1)
{
int j;
for (j = 0; j < n_outputs; j++)
if (operands_match_p (recog_data.operand[j], recog_data.operand[i]))
{
error_for_asm (insn,
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
"output operand %d must use `&' constraint", j);
malformed_asm = 1;
}
}
if (malformed_asm)
{
/* Avoid further trouble with this insn. */
PATTERN (insn) = gen_rtx_USE (VOIDmode, const0_rtx);
any_malformed_asm = true;
return 0;
}
1991-12-26 11:05:42 +01:00
return 1;
1991-12-26 11:05:42 +01:00
}
/* Calculate the number of inputs and outputs in BODY, an
asm_operands. N_OPERANDS is the total number of operands, and
N_INPUTS and N_OUTPUTS are pointers to ints into which the results are
1996-07-04 00:07:53 +02:00
placed. */
static int
get_asm_operand_n_inputs (rtx body)
{
if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
return ASM_OPERANDS_INPUT_LENGTH (SET_SRC (body));
else if (GET_CODE (body) == ASM_OPERANDS)
return ASM_OPERANDS_INPUT_LENGTH (body);
else if (GET_CODE (body) == PARALLEL
&& GET_CODE (XVECEXP (body, 0, 0)) == SET)
return ASM_OPERANDS_INPUT_LENGTH (SET_SRC (XVECEXP (body, 0, 0)));
else if (GET_CODE (body) == PARALLEL
&& GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
return ASM_OPERANDS_INPUT_LENGTH (XVECEXP (body, 0, 0));
abort ();
}
/* If current function returns its result in an fp stack register,
return the REG. Otherwise, return 0. */
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
static rtx
stack_result (tree decl)
{
rtx result;
/* If the value is supposed to be returned in memory, then clearly
it is not returned in a stack register. */
targhooks.c: New file. * targhooks.c: New file. * targhooks.h: New file. * Makefile.in: Add targhooks.o support. (function.o): Depend on$(TARGET_H). (stmt.o): Likewise. (combine.o): Depend on $(TREE_H) and $(TARGET_H). * builtins.c (apply_args_size, expand_builtin_apply_args_1, expand_builtin_apply): Convert to calls.struct_value_rtx hook. (expand_builtin_saveregs): Convert to calls.expand_builtin_saveregs hook. * c-decl.c (start_decl): Handle new calls.promote_prototypes hook here, instead of ... (get_parm_info) ... here. (store_parm_decls_oldstyle): Convert to calls.promote_prototypes hook. (finish_function): Handle calls.promote_prototypes hook here too. * c-typeck.c (convert_arguments): Convert to calls.promote_prototypes hook. (c_convert_parm_for_inlining): Likewise. * calls.c (initialize_argument_information): Convert to calls.promote_function_args hook. (expand_call): Convert to calls.struct_value_rtx, calls.strict_argument_naming, calls.pretend_outgoing_varargs_named, and calls.promote_function_return hooks. Pass fndecl to aggregate_value_p. Initialize CUMULATIVE_ARGS before calling hooks, so they can use that. (emit_library_call_value_1): Likewise. * combine.c (setup_incoming_promotions): Convert to calls.promote_function_args hook. * emit-rtl.c: Convert to calls.struct_value_rtx hook. * expr.c (expand_assignment): Pass call to aggregate_value_p. (expand_expr): Likewise. * expr.h: Remove support for SETUP_INCOMING_VARARGS, STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED, RETURN_IN_MEMORY macro defaults. * final.c (profile_function): Convert to calls.struct_value_rtx hook. * function.c (aggregate_value_p): Accept function type tree as second parameter; try to deduce fntype from it. Convert to calls.return_in_memory hook. (assign_parms): Convert to calls.setup_incoming_varargs, calls.strict_argument_naming, calls.promote_function_args, calls.pretend_outgoing_varargs_named hooks. Pass fndecl to aggregate_value_p. (expand_function_start): Likewise. Convert to calls.struct_value_rtx hook. (expand_function_end): Convert to calls.promote_function_return hook. (allocate_struct_function): Pass fndecl to aggregate_value_p. * hard-reg-set.h: Update comments to new hook names. * integrate.c (expand_inline_function): Pass fndecl to aggregate_value_p. * reg-stack.c (stack_result): Likewise. * rtl.h (struct_value_rtx, struct_value_incoming_rtx): Delete. * stmt.c (expand_value_return): Convert to calls.promote_function_return hook. * target-def.h: Add TARGET_PROMOTE_FUNCTION_ARGS, TARGET_PROMOTE_FUNCTION_RETURN, TARGET_PROMOTE_PROTOTYPES, TARGET_STRUCT_VALUE_RTX, TARGET_RETURN_IN_MEMORY, TARGET_EXPAND_BUILTIN_SAVEREGS, TARGET_SETUP_INCOMING_VARARGS, TARGET_STRICT_ARGUMENT_NAMING, TARGET_PRETEND_OUTGOING_VARARGS_NAMED, and TARGET_CALLS. * target.h: Likewise. * tree.h (aggregate_value_p): Also takes a tree to deduce function attributes from (for target hooks). * doc/tm.texi (PROMOTE_FUNCTION_ARGS, PROMOTE_FUNCTION_RETURN, PROMOTE_PROTOTYPES, RETURN_IN_MEMORY, STRUCT_VALUE_REGNUM, STRUCT_VALUE, STRUCT_VALUE_INCOMING_REGNUM, STRUCT_VALUE_INCOMING, EXPAND_BUILTIN_SAVEREGS, SETUP_INCOMING_VARARGS, STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED): Convert to hooks. * config/alpha/alpha.c (alpha_output_mi_thunk_osf): Pass function to aggregate_value_p. * config/arm/arm.c (arm_init_cumulative_args, arm_output_mi_thunk): Likewise. * config/i386/i386.c (ix86_return_pops_args, x86_this_parameter): Likewise. * config/mips/mips.c (mips_save_reg_p, mips_expand_prologue, mips_can_use_return_insn): Likewise. * config/rs6000/rs6000.c (rs6000_output_mi_thunk): Likewise. * config/s390/s390.c (s390_output_mi_thunk): Likewise. * config/sparc/sparc.c (sparc_output_mi_thunk): Pass function to aggregate_value_p. * config/story16/stormy16.c (xstormy16_asm_output_mi_thunk): Pass function to aggregate_value_p. * objc/objc-act.c (generate_struct_by_value_array): Pass NULL to aggregate_value_p. * config/sh/sh-protos.h (sh_builtin_saveregs): Remove. (sh_attr_renesas_p, sh_cfun_attr_renesas_p, sh_function_arg, sh_function_arg_advance, sh_pass_in_reg_p): New. * config/sh/sh.c (sh_handle_renesas_attribute, sh_promote_prototypes, sh_struct_value_rtx, sh_return_in_memory, sh_builtin_saveregs, sh_setup_incoming_varargs, sh_strict_argument_naming, sh_pretend_outgoing_varargs_named): New decls. (targetm): Add new hooks. (calc_live_regs): Save MACL and MACH if the function has the renesas attribute. (sh_expand_prologue): Support renesas attribute. (sh_builtin_saveregs): Make static. (sh_build_va_list): Support renesas attribute. (sh_va_start): Likewise. (sh_va_arg): Likewise. (sh_promote_prototypes): New. (sh_function_arg): New, moved from sh.h. Support renesas attribute. (sh_function_arg_advance): Likewise. (sh_return_in_memory): Likewise. (sh_strict_argument_naming): Likewise. (sh_pretend_outgoing_varargs_named): Likewise. (sh_struct_value_rtx): New. (sh_attribute): Add renesas attribute. (sh_handle_renesas_attribute): New. (sh_attr_renesas_p, sh_cfun_attr_renesas_p): New. (sh_ms_bitfield_layout_p): Support renesas attribute also. (sh_output_mi_thunk): Pass function to aggregate_value_p. * config/sh/sh.h (TARGET_SWITCHES): Add -mrenesas as an alias for -mhitachi. (STRUCT_VALUE_REGNUM, STRUCT_VALUE, RETURN_IN_MEMORY): Moved to target hooks. (sh_args): Add renesas_abi flag. (INIT_CUMULATIVE_ARGS): Set it. Pass fndecl to aggregate_value_p. (FUNCTION_ARG_ADVANCE, FUNCTION_ARG): Move to sh.c. (PASS_IN_REG_P): Support renesas attribute. Pass DF and TF on the stack for the renesas abi. (STRICT_ARGUMENT_NAMING, PRETEND_OUTGOING_VARARGS_NAMED, SETUP_INCOMING_VARARGS, EXPAND_BUILTIN_SAVEREGS, PROMOTE_PROTOTYPES): Moved to sh.c. * config/sh/sh.md (call): Set call cookie to indicate renesas calls. * decl.c (finish_function): Pass fndecl to aggregate_value_p. * misc.c (default_pass_by_ref): Convert to calls.return_in_memory hook. From-SVN: r71048
2003-09-04 05:18:05 +02:00
if (aggregate_value_p (DECL_RESULT (decl), decl))
return 0;
varasm.c (assemble_alias): Use DECL_ASSEMBLER_NAME... * varasm.c (assemble_alias): Use DECL_ASSEMBLER_NAME, not the contents of the RTL, to determine the name of the object. * tree.h (DECL_RTL): Allocate RTL lazily. (SET_DECL_RTL): New macro. (DECL_RTL_SET_P): Likewise. (COPY_DECL_RTL): Likewise. (DECL_RTL_IF_SET): Likewise. * varasm.c (make_decl_rtl): Add assertions about the kind of declaration we are processing. * c-decl.c (duplicate_decls): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc. (start_decl): Likewise. (finish_decl): Likewise. * c-semantics.c (emit_local_var): Likewise. * calls.c (expand_call): Likewise. * dbxout.c (dbxout_symbol): Likewise. * emit-rtl.c (unshare_all_rtl): Likewise. (unshare_all_decls): Likewise. (reset_used_decls): Likewise. * expr.c (store_constructor): Likewise. (safe_from_p): Likewise. (expand_expr): Likewise. * function.c (put_var_into_stack): Likewise. (instantiate_decls_1): Likewise. (assign_parms): Likewise. (expand_function_start): Likewise. (expand_function_end): Likewise. * ggc-common.c (gcc_mark_trees): Likewise. * integrate.c (function_cannot_inline_p): Likewise. (copy_decl_for_inlining): Likewise. (expand_inline_function): Likewise. (integrate_parm_decls): Likewise. (integrate_decl_tree): Likewise. * print-tree.c (print_node): Likewise. * reg-stack.c (stack_result): Likewise. * stmt.c (label_rtx): Likewise. (expand_return): Likewise. (expand_decl): Likewise. (expand_decl_cleanup): Likewise. (expand_anon_union_decl): Likewise. * toplev.c (check_global_declarations): Likewise. (rest_of_decl_compilation): Likewise. * tree.c (simple_cst_equal): Likewise. * objc/objc-act.c (generate_static_references): Likewise. * class.c (build_clone): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc. * cp-tree.h (DECL_IN_MEMORY_P): Likewise. * decl.c (duplicate_decls): Likewise. (builtin_function): Likewise. (build_library_fn): Likewise. (build_cp_library_fn): Likewise. (check_initializer): Likewise. (cp_finish_decl): Likewise. * decl2.c (grokfield): Likewise. (grok_function_init): Remove #if 0'd code. (finish_anon_union): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc. * friend.c (do_friend): Likewise. * init.c (get_temp_regvar): Likewise. * method.c (make_thunk): Likewise. * pt.c (tsubst_friend_function): Likewise. (tsubst_decl): Likewise. (regenerate_decl_from_template): Likewise. * semantics.c (genrtl_named_return_value): Likewise. (expand_body): Likewise. (genrtl_finish_function): Likewise. * tree.c (cp_tree_equal): Likewise. * com.c (ffecom_member_phase_2): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc. (duplicate_decls): Likewise. (start_decl): Likewise. * class.c (build_static_field_ref): Likewise. (make_method_value): Likewise. (get_dispatch_table): Likewise. * decl.c (push_jvm_slot): Use COPY_DECL_RTL, DECL_RTL_SET_P, etc. From-SVN: r40482
2001-03-15 03:51:03 +01:00
result = DECL_RTL_IF_SET (DECL_RESULT (decl));
if (result != 0)
{
#ifdef FUNCTION_OUTGOING_VALUE
result
= FUNCTION_OUTGOING_VALUE (TREE_TYPE (DECL_RESULT (decl)), decl);
#else
result = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (decl)), decl);
#endif
}
return result != 0 && STACK_REG_P (result) ? result : 0;
}
1991-12-26 11:05:42 +01:00
/*
* This section deals with stack register substitution, and forms the second
* pass over the RTL.
*/
1991-12-26 11:05:42 +01:00
/* Replace REG, which is a pointer to a stack reg RTX, with an RTX for
1996-07-04 00:07:53 +02:00
the desired hard REGNO. */
1991-12-26 11:05:42 +01:00
static void
replace_reg (rtx *reg, int regno)
1991-12-26 11:05:42 +01:00
{
if (regno < FIRST_STACK_REG || regno > LAST_STACK_REG
|| ! STACK_REG_P (*reg))
abort ();
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
switch (GET_MODE_CLASS (GET_MODE (*reg)))
{
default: abort ();
case MODE_FLOAT:
case MODE_COMPLEX_FLOAT:;
}
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
*reg = FP_MODE_REG (regno, GET_MODE (*reg));
1991-12-26 11:05:42 +01:00
}
/* Remove a note of type NOTE, which must be found, for register
1996-07-04 00:07:53 +02:00
number REGNO from INSN. Remove only one such note. */
1991-12-26 11:05:42 +01:00
static void
remove_regno_note (rtx insn, enum reg_note note, unsigned int regno)
1991-12-26 11:05:42 +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
rtx *note_link, this;
1991-12-26 11:05:42 +01:00
note_link = &REG_NOTES (insn);
1991-12-26 11:05:42 +01:00
for (this = *note_link; this; this = XEXP (this, 1))
if (REG_NOTE_KIND (this) == note
&& REG_P (XEXP (this, 0)) && REGNO (XEXP (this, 0)) == regno)
{
*note_link = XEXP (this, 1);
return;
}
else
note_link = &XEXP (this, 1);
abort ();
}
/* Find the hard register number of virtual register REG in REGSTACK.
The hard register number is relative to the top of the stack. -1 is
1996-07-04 00:07:53 +02:00
returned if the register is not found. */
1991-12-26 11:05:42 +01:00
static int
get_hard_regnum (stack regstack, rtx reg)
1991-12-26 11:05:42 +01:00
{
int i;
if (! STACK_REG_P (reg))
abort ();
for (i = regstack->top; i >= 0; i--)
if (regstack->reg[i] == REGNO (reg))
break;
return i >= 0 ? (FIRST_STACK_REG + regstack->top - i) : -1;
}
/* Emit an insn to pop virtual register REG before or after INSN.
REGSTACK is the stack state after INSN and is updated to reflect this
pop. WHEN is either emit_insn_before or emit_insn_after. A pop insn
is represented as a SET whose destination is the register to be popped
and source is the top of stack. A death note for the top of stack
1996-07-04 00:07:53 +02:00
cases the movdf pattern to pop. */
1991-12-26 11:05:42 +01:00
static rtx
emit_pop_insn (rtx insn, stack regstack, rtx reg, enum emit_where where)
1991-12-26 11:05:42 +01:00
{
rtx pop_insn, pop_rtx;
int hard_regno;
/* For complex types take care to pop both halves. These may survive in
CLOBBER and USE expressions. */
if (COMPLEX_MODE_P (GET_MODE (reg)))
{
rtx reg1 = FP_MODE_REG (REGNO (reg), DFmode);
rtx reg2 = FP_MODE_REG (REGNO (reg) + 1, DFmode);
pop_insn = NULL_RTX;
if (get_hard_regnum (regstack, reg1) >= 0)
pop_insn = emit_pop_insn (insn, regstack, reg1, where);
if (get_hard_regnum (regstack, reg2) >= 0)
pop_insn = emit_pop_insn (insn, regstack, reg2, where);
if (!pop_insn)
abort ();
return pop_insn;
}
1991-12-26 11:05:42 +01:00
hard_regno = get_hard_regnum (regstack, reg);
if (hard_regno < FIRST_STACK_REG)
abort ();
pop_rtx = gen_rtx_SET (VOIDmode, FP_MODE_REG (hard_regno, DFmode),
FP_MODE_REG (FIRST_STACK_REG, DFmode));
1991-12-26 11:05:42 +01:00
if (where == EMIT_AFTER)
basic-block.h (free_bb_for_insn): Declare. * basic-block.h (free_bb_for_insn): Declare. * bb-reorder.c (label_for_bb): Use block_label. (emit_jump_to_block_after): Remove. (insert_intra_1): Do not update block_for_insn. (insert_inter_bb_scope_notes): Likewise; update bb->end * cfg.c (free_bb_for_insn): New. (try_rediret_by_replacing_jump): Avoid set_block_for_new_insns call. (force_nonfallthru_and_redirect): Likewise; do not update BB boundaries. (commit_one_edge_insertion): Likewise. (commit_one_edge_insertion): Do not update BB boundary. (commit_edge_insertions): Do not call compute_bb_for_insn. * cfgbuild.c (find_basic_blocks): Do not free basic_block_for_insn. * cfgcleanup.c (merge_blocks_move_predecessor): Use reorder_insns_nobb. (merge_blocks_move_successor_nojumps): Likewise. (try_crossjump_to_edge): Do not update block_for_insn. * combine.c (combine_instructions): Remove compute_bb_for_insn call. * df.c (df_pattern_emit_later): Do not update BB boundary. (df_jump_pattern_emit_after): Likewise. (df_insn_move_before): Use emit_insn_before. * emit-rtl.c (try_split): Emit after trial to get bb boundary updated properly. (add_insn_after, add_insn_before, emit_insns_after): Update BB boundaries and basic_block_for_insn. (reorder_insns_nobb): Rename from reorder_insns. (reorder_insns): New. (emit_block_insn_before, emit_block_insn_after): Kill. * flow.c (check_function_return_warnings): Do not call compute_bb_for_insn; Do not free basic_block_for_insn. (attempt_auto_inc): Do not update basic_block_for_insn. * function.c (emit_return_into_block): Likewise; do not update BB boundaries. * gcse.c (handle_avail_expr): Do not update basic_block_for_insn. (insert_insn_end_bb): Use emit_insn_before; Likewise. (pre_insert_copy_insn): Likewise. (update_ld_motion_notes): Likewise. (insert_insn_start_bb): Likewise. (replace_store_insn): Likewise. * ifcvt.c (noce_process_if_block): Likewise. (if_convert): Do not call compute_bb_for_insn. * lcm.c (optimize_mode_switching): Do not update BB boundaries. Use emit_insn_before and emit_insn_after. * recog.c (split_all_insns): Do not update BB boundaries; Do not call compute_bb_for_insn. (peephole2_optimize): Do not update BB boundaries. * reg-stack.c (emit_pop_insn): Use emit_insn_after and emit_insn_before. (emit_swap_insn): Likewise. (convert_regs_1): Likewise. * reload1.c (reload): Call compute_bb_for_insn. * rtl.h (reorder_insns_nobb): Declare. * ssa.c (rename_equivalent_regs): Use emit_insn_before. * toplev.c (rest_of_compilation): Call free_bb_for_insn at places CFG is invalidated; do not call compute_bb_for_insn. * cfg.c (expunge_block): Invalidate BB structure. * (merge_blocks_nomove): Update properly BLOCK_FOR_INSN array. * cfg.c (verify_flow_info): Verify the basic_block_for_insn array. From-SVN: r45647
2001-09-16 22:21:30 +02:00
pop_insn = emit_insn_after (pop_rtx, insn);
else
basic-block.h (free_bb_for_insn): Declare. * basic-block.h (free_bb_for_insn): Declare. * bb-reorder.c (label_for_bb): Use block_label. (emit_jump_to_block_after): Remove. (insert_intra_1): Do not update block_for_insn. (insert_inter_bb_scope_notes): Likewise; update bb->end * cfg.c (free_bb_for_insn): New. (try_rediret_by_replacing_jump): Avoid set_block_for_new_insns call. (force_nonfallthru_and_redirect): Likewise; do not update BB boundaries. (commit_one_edge_insertion): Likewise. (commit_one_edge_insertion): Do not update BB boundary. (commit_edge_insertions): Do not call compute_bb_for_insn. * cfgbuild.c (find_basic_blocks): Do not free basic_block_for_insn. * cfgcleanup.c (merge_blocks_move_predecessor): Use reorder_insns_nobb. (merge_blocks_move_successor_nojumps): Likewise. (try_crossjump_to_edge): Do not update block_for_insn. * combine.c (combine_instructions): Remove compute_bb_for_insn call. * df.c (df_pattern_emit_later): Do not update BB boundary. (df_jump_pattern_emit_after): Likewise. (df_insn_move_before): Use emit_insn_before. * emit-rtl.c (try_split): Emit after trial to get bb boundary updated properly. (add_insn_after, add_insn_before, emit_insns_after): Update BB boundaries and basic_block_for_insn. (reorder_insns_nobb): Rename from reorder_insns. (reorder_insns): New. (emit_block_insn_before, emit_block_insn_after): Kill. * flow.c (check_function_return_warnings): Do not call compute_bb_for_insn; Do not free basic_block_for_insn. (attempt_auto_inc): Do not update basic_block_for_insn. * function.c (emit_return_into_block): Likewise; do not update BB boundaries. * gcse.c (handle_avail_expr): Do not update basic_block_for_insn. (insert_insn_end_bb): Use emit_insn_before; Likewise. (pre_insert_copy_insn): Likewise. (update_ld_motion_notes): Likewise. (insert_insn_start_bb): Likewise. (replace_store_insn): Likewise. * ifcvt.c (noce_process_if_block): Likewise. (if_convert): Do not call compute_bb_for_insn. * lcm.c (optimize_mode_switching): Do not update BB boundaries. Use emit_insn_before and emit_insn_after. * recog.c (split_all_insns): Do not update BB boundaries; Do not call compute_bb_for_insn. (peephole2_optimize): Do not update BB boundaries. * reg-stack.c (emit_pop_insn): Use emit_insn_after and emit_insn_before. (emit_swap_insn): Likewise. (convert_regs_1): Likewise. * reload1.c (reload): Call compute_bb_for_insn. * rtl.h (reorder_insns_nobb): Declare. * ssa.c (rename_equivalent_regs): Use emit_insn_before. * toplev.c (rest_of_compilation): Call free_bb_for_insn at places CFG is invalidated; do not call compute_bb_for_insn. * cfg.c (expunge_block): Invalidate BB structure. * (merge_blocks_nomove): Update properly BLOCK_FOR_INSN array. * cfg.c (verify_flow_info): Verify the basic_block_for_insn array. From-SVN: r45647
2001-09-16 22:21:30 +02:00
pop_insn = emit_insn_before (pop_rtx, insn);
1991-12-26 11:05:42 +01:00
REG_NOTES (pop_insn)
= gen_rtx_EXPR_LIST (REG_DEAD, FP_MODE_REG (FIRST_STACK_REG, DFmode),
REG_NOTES (pop_insn));
1991-12-26 11:05:42 +01:00
regstack->reg[regstack->top - (hard_regno - FIRST_STACK_REG)]
= regstack->reg[regstack->top];
regstack->top -= 1;
CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (reg));
return pop_insn;
}
/* Emit an insn before or after INSN to swap virtual register REG with
the top of stack. REGSTACK is the stack state before the swap, and
is updated to reflect the swap. A swap insn is represented as a
PARALLEL of two patterns: each pattern moves one reg to the other.
1991-12-26 11:05:42 +01:00
1996-07-04 00:07:53 +02:00
If REG is already at the top of the stack, no insn is emitted. */
1991-12-26 11:05:42 +01:00
static void
emit_swap_insn (rtx insn, stack regstack, rtx reg)
1991-12-26 11:05:42 +01:00
{
int hard_regno;
rtx swap_rtx;
int tmp, other_reg; /* swap regno temps */
rtx i1; /* the stack-reg insn prior to INSN */
rtx i1set = NULL_RTX; /* the SET rtx within I1 */
1991-12-26 11:05:42 +01:00
hard_regno = get_hard_regnum (regstack, reg);
if (hard_regno < FIRST_STACK_REG)
abort ();
1991-12-26 11:05:42 +01:00
if (hard_regno == FIRST_STACK_REG)
return;
other_reg = regstack->top - (hard_regno - FIRST_STACK_REG);
1991-12-26 11:05:42 +01:00
tmp = regstack->reg[other_reg];
regstack->reg[other_reg] = regstack->reg[regstack->top];
1991-12-26 11:05:42 +01:00
regstack->reg[regstack->top] = tmp;
/* Find the previous insn involving stack regs, but don't pass a
block boundary. */
i1 = NULL;
if (current_block && insn != current_block->head)
{
rtx tmp = PREV_INSN (insn);
rtx limit = PREV_INSN (current_block->head);
while (tmp != limit)
{
if (GET_CODE (tmp) == CODE_LABEL
|| GET_CODE (tmp) == CALL_INSN
|| NOTE_INSN_BASIC_BLOCK_P (tmp)
|| (GET_CODE (tmp) == INSN
&& stack_regs_mentioned (tmp)))
{
i1 = tmp;
break;
}
tmp = PREV_INSN (tmp);
}
}
if (i1 != NULL_RTX
&& (i1set = single_set (i1)) != NULL_RTX)
{
rtx i1src = *get_true_reg (&SET_SRC (i1set));
rtx i1dest = *get_true_reg (&SET_DEST (i1set));
1991-12-26 11:05:42 +01:00
/* If the previous register stack push was from the reg we are to
1996-07-04 00:07:53 +02:00
swap with, omit the swap. */
if (GET_CODE (i1dest) == REG && REGNO (i1dest) == FIRST_STACK_REG
regmove.c (replace_in_call_usage): Fix warnings. 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * regmove.c (replace_in_call_usage): Fix warnings. * sched-deps.c (add_dependence): Fix warnings. * simplify-rtx.c (simplify_subreg): Likewise. Return NULL_RTX instead of NULL. * reg-stack.c (emit_swap_insn): Eliminate warnings. (subst_asm_stack_regs): Likewise. * combine.c (num_sign_bit_copies): Cast bitwidth to int to avoid warnings. * dwarf2out.c (output_call_frame_info): Declare i as int. (build_abbrev_table): Declare n_alloc as int. (dwarf2out_finish): Initialize die. * except.c: Declare sjlj_funcdef_number as unsigned. (connect_post_landing_pads): Declare j as unsigned. (convert_to_eh_region_ranges): Initialize call_site. (output_function_exception_table): Initialize tt_format_size. * expr.c (move_by_pieces_1): Initialize to1. (store_constructor): Initialize minelt and maxelt. * flow.c (mark_regs_live_at_end): Declare i as unsigned. * function.c (instantiate_decls): Avoid signed/unsigned warning. * c-decl.c (combine_parm_decls): Unused, remove. * c-tree.h: Remove prototype for combine_parm_decls. * reload.c (push_reload): Fix warning. (regno_clobbered_p): Likewise. * reload1.c (replace_pseudos_in_call_usage): Likewise. (reload_combine): Likewise. * bitmap.c: Rename bitmap_zero to bitmap_zero_bits to fix warnings. * bitmap.h: Rename bitmap_zero to bitmap_zero_bits to fix warnings. * bitmap.c (bitmap_operation): Change user. * bitmap.h (EXECUTE_IF_AND_COMPL_IN_BITMAP): Likewise. For cp/: 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * call.c (build_op_delete_call): Initialize fn. (convert_like_real): Delete conditional. (joust): Initialize *w and *l. * class.c: Add prototype for binfo_ctor_vtable. (get_primary_binfo): Initialize result. * init.c (build_java_class_ref): Initialize name. * typeck.c (unary_complex_lvalue): Do not duplicate the argument to modify, pre-, or post-increment when used as an lvalue and when the argument has side-effects. For ch/: 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * ch-tree.h: Remove prototype for combine_parm_decls, unused function. From-SVN: r43893
2001-07-10 12:38:10 +02:00
&& GET_CODE (i1src) == REG
&& REGNO (i1src) == (unsigned) hard_regno - 1
&& find_regno_note (i1, REG_DEAD, FIRST_STACK_REG) == NULL_RTX)
return;
/* If the previous insn wrote to the reg we are to swap with,
omit the swap. */
regmove.c (replace_in_call_usage): Fix warnings. 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * regmove.c (replace_in_call_usage): Fix warnings. * sched-deps.c (add_dependence): Fix warnings. * simplify-rtx.c (simplify_subreg): Likewise. Return NULL_RTX instead of NULL. * reg-stack.c (emit_swap_insn): Eliminate warnings. (subst_asm_stack_regs): Likewise. * combine.c (num_sign_bit_copies): Cast bitwidth to int to avoid warnings. * dwarf2out.c (output_call_frame_info): Declare i as int. (build_abbrev_table): Declare n_alloc as int. (dwarf2out_finish): Initialize die. * except.c: Declare sjlj_funcdef_number as unsigned. (connect_post_landing_pads): Declare j as unsigned. (convert_to_eh_region_ranges): Initialize call_site. (output_function_exception_table): Initialize tt_format_size. * expr.c (move_by_pieces_1): Initialize to1. (store_constructor): Initialize minelt and maxelt. * flow.c (mark_regs_live_at_end): Declare i as unsigned. * function.c (instantiate_decls): Avoid signed/unsigned warning. * c-decl.c (combine_parm_decls): Unused, remove. * c-tree.h: Remove prototype for combine_parm_decls. * reload.c (push_reload): Fix warning. (regno_clobbered_p): Likewise. * reload1.c (replace_pseudos_in_call_usage): Likewise. (reload_combine): Likewise. * bitmap.c: Rename bitmap_zero to bitmap_zero_bits to fix warnings. * bitmap.h: Rename bitmap_zero to bitmap_zero_bits to fix warnings. * bitmap.c (bitmap_operation): Change user. * bitmap.h (EXECUTE_IF_AND_COMPL_IN_BITMAP): Likewise. For cp/: 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * call.c (build_op_delete_call): Initialize fn. (convert_like_real): Delete conditional. (joust): Initialize *w and *l. * class.c: Add prototype for binfo_ctor_vtable. (get_primary_binfo): Initialize result. * init.c (build_java_class_ref): Initialize name. * typeck.c (unary_complex_lvalue): Do not duplicate the argument to modify, pre-, or post-increment when used as an lvalue and when the argument has side-effects. For ch/: 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * ch-tree.h: Remove prototype for combine_parm_decls, unused function. From-SVN: r43893
2001-07-10 12:38:10 +02:00
if (GET_CODE (i1dest) == REG && REGNO (i1dest) == (unsigned) hard_regno
&& GET_CODE (i1src) == REG && REGNO (i1src) == FIRST_STACK_REG
&& find_regno_note (i1, REG_DEAD, FIRST_STACK_REG) == NULL_RTX)
return;
}
swap_rtx = gen_swapxf (FP_MODE_REG (hard_regno, XFmode),
FP_MODE_REG (FIRST_STACK_REG, XFmode));
if (i1)
basic-block.h (free_bb_for_insn): Declare. * basic-block.h (free_bb_for_insn): Declare. * bb-reorder.c (label_for_bb): Use block_label. (emit_jump_to_block_after): Remove. (insert_intra_1): Do not update block_for_insn. (insert_inter_bb_scope_notes): Likewise; update bb->end * cfg.c (free_bb_for_insn): New. (try_rediret_by_replacing_jump): Avoid set_block_for_new_insns call. (force_nonfallthru_and_redirect): Likewise; do not update BB boundaries. (commit_one_edge_insertion): Likewise. (commit_one_edge_insertion): Do not update BB boundary. (commit_edge_insertions): Do not call compute_bb_for_insn. * cfgbuild.c (find_basic_blocks): Do not free basic_block_for_insn. * cfgcleanup.c (merge_blocks_move_predecessor): Use reorder_insns_nobb. (merge_blocks_move_successor_nojumps): Likewise. (try_crossjump_to_edge): Do not update block_for_insn. * combine.c (combine_instructions): Remove compute_bb_for_insn call. * df.c (df_pattern_emit_later): Do not update BB boundary. (df_jump_pattern_emit_after): Likewise. (df_insn_move_before): Use emit_insn_before. * emit-rtl.c (try_split): Emit after trial to get bb boundary updated properly. (add_insn_after, add_insn_before, emit_insns_after): Update BB boundaries and basic_block_for_insn. (reorder_insns_nobb): Rename from reorder_insns. (reorder_insns): New. (emit_block_insn_before, emit_block_insn_after): Kill. * flow.c (check_function_return_warnings): Do not call compute_bb_for_insn; Do not free basic_block_for_insn. (attempt_auto_inc): Do not update basic_block_for_insn. * function.c (emit_return_into_block): Likewise; do not update BB boundaries. * gcse.c (handle_avail_expr): Do not update basic_block_for_insn. (insert_insn_end_bb): Use emit_insn_before; Likewise. (pre_insert_copy_insn): Likewise. (update_ld_motion_notes): Likewise. (insert_insn_start_bb): Likewise. (replace_store_insn): Likewise. * ifcvt.c (noce_process_if_block): Likewise. (if_convert): Do not call compute_bb_for_insn. * lcm.c (optimize_mode_switching): Do not update BB boundaries. Use emit_insn_before and emit_insn_after. * recog.c (split_all_insns): Do not update BB boundaries; Do not call compute_bb_for_insn. (peephole2_optimize): Do not update BB boundaries. * reg-stack.c (emit_pop_insn): Use emit_insn_after and emit_insn_before. (emit_swap_insn): Likewise. (convert_regs_1): Likewise. * reload1.c (reload): Call compute_bb_for_insn. * rtl.h (reorder_insns_nobb): Declare. * ssa.c (rename_equivalent_regs): Use emit_insn_before. * toplev.c (rest_of_compilation): Call free_bb_for_insn at places CFG is invalidated; do not call compute_bb_for_insn. * cfg.c (expunge_block): Invalidate BB structure. * (merge_blocks_nomove): Update properly BLOCK_FOR_INSN array. * cfg.c (verify_flow_info): Verify the basic_block_for_insn array. From-SVN: r45647
2001-09-16 22:21:30 +02:00
emit_insn_after (swap_rtx, i1);
else if (current_block)
basic-block.h (free_bb_for_insn): Declare. * basic-block.h (free_bb_for_insn): Declare. * bb-reorder.c (label_for_bb): Use block_label. (emit_jump_to_block_after): Remove. (insert_intra_1): Do not update block_for_insn. (insert_inter_bb_scope_notes): Likewise; update bb->end * cfg.c (free_bb_for_insn): New. (try_rediret_by_replacing_jump): Avoid set_block_for_new_insns call. (force_nonfallthru_and_redirect): Likewise; do not update BB boundaries. (commit_one_edge_insertion): Likewise. (commit_one_edge_insertion): Do not update BB boundary. (commit_edge_insertions): Do not call compute_bb_for_insn. * cfgbuild.c (find_basic_blocks): Do not free basic_block_for_insn. * cfgcleanup.c (merge_blocks_move_predecessor): Use reorder_insns_nobb. (merge_blocks_move_successor_nojumps): Likewise. (try_crossjump_to_edge): Do not update block_for_insn. * combine.c (combine_instructions): Remove compute_bb_for_insn call. * df.c (df_pattern_emit_later): Do not update BB boundary. (df_jump_pattern_emit_after): Likewise. (df_insn_move_before): Use emit_insn_before. * emit-rtl.c (try_split): Emit after trial to get bb boundary updated properly. (add_insn_after, add_insn_before, emit_insns_after): Update BB boundaries and basic_block_for_insn. (reorder_insns_nobb): Rename from reorder_insns. (reorder_insns): New. (emit_block_insn_before, emit_block_insn_after): Kill. * flow.c (check_function_return_warnings): Do not call compute_bb_for_insn; Do not free basic_block_for_insn. (attempt_auto_inc): Do not update basic_block_for_insn. * function.c (emit_return_into_block): Likewise; do not update BB boundaries. * gcse.c (handle_avail_expr): Do not update basic_block_for_insn. (insert_insn_end_bb): Use emit_insn_before; Likewise. (pre_insert_copy_insn): Likewise. (update_ld_motion_notes): Likewise. (insert_insn_start_bb): Likewise. (replace_store_insn): Likewise. * ifcvt.c (noce_process_if_block): Likewise. (if_convert): Do not call compute_bb_for_insn. * lcm.c (optimize_mode_switching): Do not update BB boundaries. Use emit_insn_before and emit_insn_after. * recog.c (split_all_insns): Do not update BB boundaries; Do not call compute_bb_for_insn. (peephole2_optimize): Do not update BB boundaries. * reg-stack.c (emit_pop_insn): Use emit_insn_after and emit_insn_before. (emit_swap_insn): Likewise. (convert_regs_1): Likewise. * reload1.c (reload): Call compute_bb_for_insn. * rtl.h (reorder_insns_nobb): Declare. * ssa.c (rename_equivalent_regs): Use emit_insn_before. * toplev.c (rest_of_compilation): Call free_bb_for_insn at places CFG is invalidated; do not call compute_bb_for_insn. * cfg.c (expunge_block): Invalidate BB structure. * (merge_blocks_nomove): Update properly BLOCK_FOR_INSN array. * cfg.c (verify_flow_info): Verify the basic_block_for_insn array. From-SVN: r45647
2001-09-16 22:21:30 +02:00
emit_insn_before (swap_rtx, current_block->head);
else
emit_insn_before (swap_rtx, insn);
1991-12-26 11:05:42 +01:00
}
/* Handle a move to or from a stack register in PAT, which is in INSN.
1996-07-04 00:07:53 +02:00
REGSTACK is the current stack. */
1991-12-26 11:05:42 +01:00
static void
move_for_stack_reg (rtx insn, stack regstack, rtx pat)
1991-12-26 11:05:42 +01:00
{
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
rtx *psrc = get_true_reg (&SET_SRC (pat));
rtx *pdest = get_true_reg (&SET_DEST (pat));
rtx src, dest;
1991-12-26 11:05:42 +01:00
rtx note;
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
src = *psrc; dest = *pdest;
if (STACK_REG_P (src) && STACK_REG_P (dest))
1991-12-26 11:05:42 +01:00
{
/* Write from one stack reg to another. If SRC dies here, then
1996-07-04 00:07:53 +02:00
just change the register mapping and delete the insn. */
1991-12-26 11:05:42 +01:00
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
note = find_regno_note (insn, REG_DEAD, REGNO (src));
1991-12-26 11:05:42 +01:00
if (note)
{
int i;
1996-07-04 00:07:53 +02:00
/* If this is a no-op move, there must not be a REG_DEAD note. */
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
if (REGNO (src) == REGNO (dest))
1991-12-26 11:05:42 +01:00
abort ();
for (i = regstack->top; i >= 0; i--)
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
if (regstack->reg[i] == REGNO (src))
1991-12-26 11:05:42 +01:00
break;
1996-07-04 00:07:53 +02:00
/* The source must be live, and the dest must be dead. */
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
if (i < 0 || get_hard_regnum (regstack, dest) >= FIRST_STACK_REG)
1991-12-26 11:05:42 +01:00
abort ();
/* It is possible that the dest is unused after this insn.
1996-07-04 00:07:53 +02:00
If so, just pop the src. */
1991-12-26 11:05:42 +01:00
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
if (find_regno_note (insn, REG_UNUSED, REGNO (dest)))
1991-12-26 11:05:42 +01:00
{
emit_pop_insn (insn, regstack, src, EMIT_AFTER);
1991-12-26 11:05:42 +01:00
basic-block.h (flow_delete_insn, [...]): Kill. * basic-block.h (flow_delete_insn, flow_delete_insn_chain): Kill. * cfg.c (delete_insn): Rename from ....; use remove_insn; do not remove some labels. (flow_delete_insn): This one. (delete_insn_chain): Rename from ...; do not care labels. (flow_delete_insn_chain): ... this one. (flow_delete_block): Remove the insns one BB has been expunged. (merge_blocks_nomove): Likewise. (try_redirect_by_replacing_jump): Use delete_insn[_chain]; do not care updating BB boundaries. (tidy_fallthru_edge): Likewise. (commit_one_edge_insertion): Likewise. * cfgbuild.c (find_basic_block): Likewise. (find_basic_blocks_1): Likewise. * cfgcleanup.c (merge_blocks_move_predecessor_nojumps): Likewise. (try_crossjump_to_edge): Likewise. (try_optimize_cfg): Likewise. * cse.c (delete_trivially_dead_insns): Likewise. * df.c (df_insn_delete): Likewise. * doloop.c (doloop_modify): Use delete_related_insns. * emit-rtl.c (try_split): Likewise. (remove_insn): Update BB boundaries. * expect.c (connect_post_landing_pads): Use delete_related_insns. * flow.c (delete_dead_jumptables): Use delete_insn[_chain]; do not care updating BB boundaries. (propagate_block_delete_insn): Likewise. (propagate_block_delete_libcall): Likewise. * function.c (delete_handlers): Use delete_related_insns. (thread_prologue_and_epilogue_insns): Likewise. * gcse.c (delete_null_pointer_checks): Use delete_related_insns. * genpeep.c (gen_peephole): Use delete_related_insns. * ifcvt.c (noce_process_if_block): Use delete_insn; do not care updating BB boundaries. (find_cond_trap): Likewise. * integrate.c (save_for_inline): Use delete_related_insns. (copy_insn_list): Likewise. * jump.c (pruge_linie_number_notes): Likewise. (duplicate_loop_exit_test): Likewise. (delete_computation): Likewise. (delete_related_insn): Rename from ...; use delete_insn (delete_insn): ... this one. (redirect_jump): Use delete_related_insns. * loop.c (scan_loop): Likewise. (move_movables): Likewise. (find_and_verify_loops): Likewise. (check_dbra_loop): Likewise. * recog.c (peephole2_optimize): Likewise. * reg-stack.c (delete_insn_for_stacker): Remove. (move_for_stack_reg): Use delete_insn. * regmove.c (combine_stack_adjustments_for_block): Likewise. * reload1.c (delete_address_reloads): Use delete_related_insns. (fixup_abnormal_edges): Use delete_insn. * recog.c (emit_delay_sequence): Use delete_related_insns. (delete_from-delay_slot): Likewise. (delete_scheduled_jump): likewise. (optimize_skip): Likewise. (try_merge_delay_insns): Likewise. (full_simple_delay_slots): Likewise. (fill_slots_from_thread): Likewise. (relax_delay_slots): Likewise. (make_return_insns): Likewise. (dbr_schedule): Likewise. * rtl.h (delete_insn): Rename to delete_related_insns. (delete_insn, delete_insn_chain): New prototypes. * ssa-ccp (sse_fast_dce): Remove deleting of DEF, as it is done by df_insn_delete already. * ssa-dce.c (delete_insn_bb): Use delete_insn. * ssa.c (convert_from_ssa): Use delete_related_insns. * unroll.c (unroll_loop): Likewise. (calculate_giv_inc): Likewise. (copy_loop_body): Likewise. * i386-protos.h (ix86_libcall_value, ix86_function_value, ix86_function_arg_regno_p, ix86_function_arg_boundary, ix86_return_in_memory, ix86_function_value): Declare. * i386.c (x86_64_int_parameter_registers, x86_64_int_return_registers): new static valurables. (x86_64_reg_class): New enum (x86_64_reg_class_name): New array. (classify_argument, examine_argument, construct_container, merge_classes): New static functions. (optimization_options): Enable flag_omit_frame_pointer and disable flag_pcc_struct_return on 64bit. (ix86_libcall_value, ix86_function_value, ix86_function_arg_regno_p, ix86_function_arg_boundary, ix86_return_in_memory, ix86_function_value): New global functions. (init_cumulative_args): Refuse regparm on x86_64, set maybe_vaarg. (function_arg_advance): Handle x86_64 passing conventions. (function_arg): Likewise. * i386.h (FUNCTION_ARG_BOUNDARY): New macro. (RETURN_IN_MEMORY): Move offline. (FUNCTION_VALUE, LIBCALL_VALUE): Likewise. (FUNCTION_VALUE_REGNO_P): New macro. (FUNCTION_ARG_REGNO_P): Move offline. (struct ix86_args): Add maybe_vaarg. * next.h (FUNCTION_VALUE_REGNO_P): Delete. * unix.h (FUNCTION_VALUE_REGNO_P): Delete. From-SVN: r45726
2001-09-21 14:55:18 +02:00
delete_insn (insn);
1991-12-26 11:05:42 +01:00
return;
}
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
regstack->reg[i] = REGNO (dest);
1991-12-26 11:05:42 +01:00
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
SET_HARD_REG_BIT (regstack->reg_set, REGNO (dest));
CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (src));
1991-12-26 11:05:42 +01:00
basic-block.h (flow_delete_insn, [...]): Kill. * basic-block.h (flow_delete_insn, flow_delete_insn_chain): Kill. * cfg.c (delete_insn): Rename from ....; use remove_insn; do not remove some labels. (flow_delete_insn): This one. (delete_insn_chain): Rename from ...; do not care labels. (flow_delete_insn_chain): ... this one. (flow_delete_block): Remove the insns one BB has been expunged. (merge_blocks_nomove): Likewise. (try_redirect_by_replacing_jump): Use delete_insn[_chain]; do not care updating BB boundaries. (tidy_fallthru_edge): Likewise. (commit_one_edge_insertion): Likewise. * cfgbuild.c (find_basic_block): Likewise. (find_basic_blocks_1): Likewise. * cfgcleanup.c (merge_blocks_move_predecessor_nojumps): Likewise. (try_crossjump_to_edge): Likewise. (try_optimize_cfg): Likewise. * cse.c (delete_trivially_dead_insns): Likewise. * df.c (df_insn_delete): Likewise. * doloop.c (doloop_modify): Use delete_related_insns. * emit-rtl.c (try_split): Likewise. (remove_insn): Update BB boundaries. * expect.c (connect_post_landing_pads): Use delete_related_insns. * flow.c (delete_dead_jumptables): Use delete_insn[_chain]; do not care updating BB boundaries. (propagate_block_delete_insn): Likewise. (propagate_block_delete_libcall): Likewise. * function.c (delete_handlers): Use delete_related_insns. (thread_prologue_and_epilogue_insns): Likewise. * gcse.c (delete_null_pointer_checks): Use delete_related_insns. * genpeep.c (gen_peephole): Use delete_related_insns. * ifcvt.c (noce_process_if_block): Use delete_insn; do not care updating BB boundaries. (find_cond_trap): Likewise. * integrate.c (save_for_inline): Use delete_related_insns. (copy_insn_list): Likewise. * jump.c (pruge_linie_number_notes): Likewise. (duplicate_loop_exit_test): Likewise. (delete_computation): Likewise. (delete_related_insn): Rename from ...; use delete_insn (delete_insn): ... this one. (redirect_jump): Use delete_related_insns. * loop.c (scan_loop): Likewise. (move_movables): Likewise. (find_and_verify_loops): Likewise. (check_dbra_loop): Likewise. * recog.c (peephole2_optimize): Likewise. * reg-stack.c (delete_insn_for_stacker): Remove. (move_for_stack_reg): Use delete_insn. * regmove.c (combine_stack_adjustments_for_block): Likewise. * reload1.c (delete_address_reloads): Use delete_related_insns. (fixup_abnormal_edges): Use delete_insn. * recog.c (emit_delay_sequence): Use delete_related_insns. (delete_from-delay_slot): Likewise. (delete_scheduled_jump): likewise. (optimize_skip): Likewise. (try_merge_delay_insns): Likewise. (full_simple_delay_slots): Likewise. (fill_slots_from_thread): Likewise. (relax_delay_slots): Likewise. (make_return_insns): Likewise. (dbr_schedule): Likewise. * rtl.h (delete_insn): Rename to delete_related_insns. (delete_insn, delete_insn_chain): New prototypes. * ssa-ccp (sse_fast_dce): Remove deleting of DEF, as it is done by df_insn_delete already. * ssa-dce.c (delete_insn_bb): Use delete_insn. * ssa.c (convert_from_ssa): Use delete_related_insns. * unroll.c (unroll_loop): Likewise. (calculate_giv_inc): Likewise. (copy_loop_body): Likewise. * i386-protos.h (ix86_libcall_value, ix86_function_value, ix86_function_arg_regno_p, ix86_function_arg_boundary, ix86_return_in_memory, ix86_function_value): Declare. * i386.c (x86_64_int_parameter_registers, x86_64_int_return_registers): new static valurables. (x86_64_reg_class): New enum (x86_64_reg_class_name): New array. (classify_argument, examine_argument, construct_container, merge_classes): New static functions. (optimization_options): Enable flag_omit_frame_pointer and disable flag_pcc_struct_return on 64bit. (ix86_libcall_value, ix86_function_value, ix86_function_arg_regno_p, ix86_function_arg_boundary, ix86_return_in_memory, ix86_function_value): New global functions. (init_cumulative_args): Refuse regparm on x86_64, set maybe_vaarg. (function_arg_advance): Handle x86_64 passing conventions. (function_arg): Likewise. * i386.h (FUNCTION_ARG_BOUNDARY): New macro. (RETURN_IN_MEMORY): Move offline. (FUNCTION_VALUE, LIBCALL_VALUE): Likewise. (FUNCTION_VALUE_REGNO_P): New macro. (FUNCTION_ARG_REGNO_P): Move offline. (struct ix86_args): Add maybe_vaarg. * next.h (FUNCTION_VALUE_REGNO_P): Delete. * unix.h (FUNCTION_VALUE_REGNO_P): Delete. From-SVN: r45726
2001-09-21 14:55:18 +02:00
delete_insn (insn);
1991-12-26 11:05:42 +01:00
return;
}
1996-07-04 00:07:53 +02:00
/* The source reg does not die. */
1991-12-26 11:05:42 +01:00
/* If this appears to be a no-op move, delete it, or else it
will confuse the machine description output patterns. But if
it is REG_UNUSED, we must pop the reg now, as per-insn processing
1996-07-04 00:07:53 +02:00
for REG_UNUSED will not work for deleted insns. */
1991-12-26 11:05:42 +01:00
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
if (REGNO (src) == REGNO (dest))
1991-12-26 11:05:42 +01:00
{
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
if (find_regno_note (insn, REG_UNUSED, REGNO (dest)))
emit_pop_insn (insn, regstack, dest, EMIT_AFTER);
1991-12-26 11:05:42 +01:00
basic-block.h (flow_delete_insn, [...]): Kill. * basic-block.h (flow_delete_insn, flow_delete_insn_chain): Kill. * cfg.c (delete_insn): Rename from ....; use remove_insn; do not remove some labels. (flow_delete_insn): This one. (delete_insn_chain): Rename from ...; do not care labels. (flow_delete_insn_chain): ... this one. (flow_delete_block): Remove the insns one BB has been expunged. (merge_blocks_nomove): Likewise. (try_redirect_by_replacing_jump): Use delete_insn[_chain]; do not care updating BB boundaries. (tidy_fallthru_edge): Likewise. (commit_one_edge_insertion): Likewise. * cfgbuild.c (find_basic_block): Likewise. (find_basic_blocks_1): Likewise. * cfgcleanup.c (merge_blocks_move_predecessor_nojumps): Likewise. (try_crossjump_to_edge): Likewise. (try_optimize_cfg): Likewise. * cse.c (delete_trivially_dead_insns): Likewise. * df.c (df_insn_delete): Likewise. * doloop.c (doloop_modify): Use delete_related_insns. * emit-rtl.c (try_split): Likewise. (remove_insn): Update BB boundaries. * expect.c (connect_post_landing_pads): Use delete_related_insns. * flow.c (delete_dead_jumptables): Use delete_insn[_chain]; do not care updating BB boundaries. (propagate_block_delete_insn): Likewise. (propagate_block_delete_libcall): Likewise. * function.c (delete_handlers): Use delete_related_insns. (thread_prologue_and_epilogue_insns): Likewise. * gcse.c (delete_null_pointer_checks): Use delete_related_insns. * genpeep.c (gen_peephole): Use delete_related_insns. * ifcvt.c (noce_process_if_block): Use delete_insn; do not care updating BB boundaries. (find_cond_trap): Likewise. * integrate.c (save_for_inline): Use delete_related_insns. (copy_insn_list): Likewise. * jump.c (pruge_linie_number_notes): Likewise. (duplicate_loop_exit_test): Likewise. (delete_computation): Likewise. (delete_related_insn): Rename from ...; use delete_insn (delete_insn): ... this one. (redirect_jump): Use delete_related_insns. * loop.c (scan_loop): Likewise. (move_movables): Likewise. (find_and_verify_loops): Likewise. (check_dbra_loop): Likewise. * recog.c (peephole2_optimize): Likewise. * reg-stack.c (delete_insn_for_stacker): Remove. (move_for_stack_reg): Use delete_insn. * regmove.c (combine_stack_adjustments_for_block): Likewise. * reload1.c (delete_address_reloads): Use delete_related_insns. (fixup_abnormal_edges): Use delete_insn. * recog.c (emit_delay_sequence): Use delete_related_insns. (delete_from-delay_slot): Likewise. (delete_scheduled_jump): likewise. (optimize_skip): Likewise. (try_merge_delay_insns): Likewise. (full_simple_delay_slots): Likewise. (fill_slots_from_thread): Likewise. (relax_delay_slots): Likewise. (make_return_insns): Likewise. (dbr_schedule): Likewise. * rtl.h (delete_insn): Rename to delete_related_insns. (delete_insn, delete_insn_chain): New prototypes. * ssa-ccp (sse_fast_dce): Remove deleting of DEF, as it is done by df_insn_delete already. * ssa-dce.c (delete_insn_bb): Use delete_insn. * ssa.c (convert_from_ssa): Use delete_related_insns. * unroll.c (unroll_loop): Likewise. (calculate_giv_inc): Likewise. (copy_loop_body): Likewise. * i386-protos.h (ix86_libcall_value, ix86_function_value, ix86_function_arg_regno_p, ix86_function_arg_boundary, ix86_return_in_memory, ix86_function_value): Declare. * i386.c (x86_64_int_parameter_registers, x86_64_int_return_registers): new static valurables. (x86_64_reg_class): New enum (x86_64_reg_class_name): New array. (classify_argument, examine_argument, construct_container, merge_classes): New static functions. (optimization_options): Enable flag_omit_frame_pointer and disable flag_pcc_struct_return on 64bit. (ix86_libcall_value, ix86_function_value, ix86_function_arg_regno_p, ix86_function_arg_boundary, ix86_return_in_memory, ix86_function_value): New global functions. (init_cumulative_args): Refuse regparm on x86_64, set maybe_vaarg. (function_arg_advance): Handle x86_64 passing conventions. (function_arg): Likewise. * i386.h (FUNCTION_ARG_BOUNDARY): New macro. (RETURN_IN_MEMORY): Move offline. (FUNCTION_VALUE, LIBCALL_VALUE): Likewise. (FUNCTION_VALUE_REGNO_P): New macro. (FUNCTION_ARG_REGNO_P): Move offline. (struct ix86_args): Add maybe_vaarg. * next.h (FUNCTION_VALUE_REGNO_P): Delete. * unix.h (FUNCTION_VALUE_REGNO_P): Delete. From-SVN: r45726
2001-09-21 14:55:18 +02:00
delete_insn (insn);
1991-12-26 11:05:42 +01:00
return;
}
/* The destination ought to be dead. */
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
if (get_hard_regnum (regstack, dest) >= FIRST_STACK_REG)
1991-12-26 11:05:42 +01:00
abort ();
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
replace_reg (psrc, get_hard_regnum (regstack, src));
1991-12-26 11:05:42 +01:00
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
regstack->reg[++regstack->top] = REGNO (dest);
SET_HARD_REG_BIT (regstack->reg_set, REGNO (dest));
replace_reg (pdest, FIRST_STACK_REG);
1991-12-26 11:05:42 +01:00
}
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
else if (STACK_REG_P (src))
1991-12-26 11:05:42 +01:00
{
/* Save from a stack reg to MEM, or possibly integer reg. Since
only top of stack may be saved, emit an exchange first if
1996-07-04 00:07:53 +02:00
needs be. */
1991-12-26 11:05:42 +01:00
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
emit_swap_insn (insn, regstack, src);
1991-12-26 11:05:42 +01:00
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
note = find_regno_note (insn, REG_DEAD, REGNO (src));
1991-12-26 11:05:42 +01:00
if (note)
{
replace_reg (&XEXP (note, 0), FIRST_STACK_REG);
regstack->top--;
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (src));
1991-12-26 11:05:42 +01:00
}
else if ((GET_MODE (src) == XFmode || GET_MODE (src) == TFmode)
&& regstack->top < REG_STACK_SIZE - 1)
{
/* A 387 cannot write an XFmode value to a MEM without
clobbering the source reg. The output code can handle
this by reading back the value from the MEM.
But it is more efficient to use a temp register if one is
available. Push the source value here if the register
stack is not full, and then write the value to memory via
a pop. */
rtx push_rtx, push_insn;
rtx top_stack_reg = FP_MODE_REG (FIRST_STACK_REG, GET_MODE (src));
if (GET_MODE (src) == TFmode)
push_rtx = gen_movtf (top_stack_reg, top_stack_reg);
else
push_rtx = gen_movxf (top_stack_reg, top_stack_reg);
push_insn = emit_insn_before (push_rtx, insn);
REG_NOTES (insn) = gen_rtx_EXPR_LIST (REG_DEAD, top_stack_reg,
REG_NOTES (insn));
}
1991-12-26 11:05:42 +01:00
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
replace_reg (psrc, FIRST_STACK_REG);
1991-12-26 11:05:42 +01:00
}
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
else if (STACK_REG_P (dest))
1991-12-26 11:05:42 +01:00
{
/* Load from MEM, or possibly integer REG or constant, into the
stack regs. The actual target is always the top of the
stack. The stack mapping is changed to reflect that DEST is
now at top of stack. */
/* The destination ought to be dead. */
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
if (get_hard_regnum (regstack, dest) >= FIRST_STACK_REG)
1991-12-26 11:05:42 +01:00
abort ();
if (regstack->top >= REG_STACK_SIZE)
abort ();
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
regstack->reg[++regstack->top] = REGNO (dest);
SET_HARD_REG_BIT (regstack->reg_set, REGNO (dest));
replace_reg (pdest, FIRST_STACK_REG);
1991-12-26 11:05:42 +01:00
}
else
abort ();
}
/* Swap the condition on a branch, if there is one. Return true if we
found a condition to swap. False if the condition was not used as
such. */
static int
swap_rtx_condition_1 (rtx pat)
{
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 *fmt;
int i, r = 0;
if (GET_RTX_CLASS (GET_CODE (pat)) == '<')
{
PUT_CODE (pat, swap_condition (GET_CODE (pat)));
r = 1;
}
else
{
fmt = GET_RTX_FORMAT (GET_CODE (pat));
for (i = GET_RTX_LENGTH (GET_CODE (pat)) - 1; i >= 0; i--)
{
if (fmt[i] == '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 = XVECLEN (pat, i) - 1; j >= 0; j--)
r |= swap_rtx_condition_1 (XVECEXP (pat, i, j));
}
else if (fmt[i] == 'e')
r |= swap_rtx_condition_1 (XEXP (pat, i));
}
}
return r;
}
static int
swap_rtx_condition (rtx insn)
{
rtx pat = PATTERN (insn);
/* We're looking for a single set to cc0 or an HImode temporary. */
if (GET_CODE (pat) == SET
&& GET_CODE (SET_DEST (pat)) == REG
&& REGNO (SET_DEST (pat)) == FLAGS_REG)
{
insn = next_flags_user (insn);
if (insn == NULL_RTX)
return 0;
pat = PATTERN (insn);
}
/* See if this is, or ends in, a fnstsw, aka unspec 9. If so, we're
not doing anything with the cc value right now. We may be able to
search for one though. */
if (GET_CODE (pat) == SET
&& GET_CODE (SET_SRC (pat)) == UNSPEC
&& XINT (SET_SRC (pat), 1) == UNSPEC_FNSTSW)
{
rtx dest = SET_DEST (pat);
/* Search forward looking for the first use of this value.
Stop at block boundaries. */
while (insn != current_block->end)
{
insn = NEXT_INSN (insn);
alias.c (mark_constant_function): Use INSN_P. * alias.c (mark_constant_function): Use INSN_P. (init_alias_analysis): Likewise. * combine.c (combine_instructions): Use INSN_P. (can_combine_p): Likewise. (try_combine): Likewise. (distribute_notes): Likewise. (distribute_links): Likewise. * cse.c (cse_around_loop): Use INSN_P. (invalidate_skipped_block): Likewise. (cse_set_around_loop): Likewise. (cse_end_of_basic_block): Likewise. (delete_trivially_dead_insns): Likewise. * emit-rtl.c (unshare_all_rtl_again): Use INSN_P. (unshare_all_rtl_1): Likewise. (next_cc0_user): Likewise. (try_split make_insn_raw): Likewise. (remove_unnecessary_notes): Likewise. * final.c (shorten_branches): Use INSN_P. (leaf_renumber_regs): Likewise. (leaf_renumber_regs_insn): Likewise. * flow.c (find_label_refs): Use INSN_P. (verify_wide_reg): Likewise. (notice_stack_pointer_modification): Likewise. (count_or_remove_death_notes): Likewise. (verify_flow_info): Likewise. (clear_log_links): Likewise. * function.c (fixup_var_refs_insns): Use INSN_P. (compute_insns_for_mem): Likewise. * gcse.c (alloc_gcse_mem): Use INSN_P. (compute_sets): Likewise. (compute_hash_table): Likewise. (classic_gcse): Likewise. (cprop): Likewise. (insert_insn_end_bb): Likewise. (delete_null_pointer_checks_1): Likewise. * global.c (expand_preferences): Use INSN_P. (build_insn_chain): Likewise. * graph.c (node_data): Use INSN_P. * haifa-sched.c (priority): Use INSN_P. (rm_line_notes): Likewise. (rm_other_notes): Likewise. (find_insn_reg_weight): Likewise. (init_target_units): Likewise. (schedule_block): Likewise. (compute_block_forward_dependences): Likewise. (debug_dependencies): Likewise. (set_priorities): Likewise. * integrate.c (function_cannot_inline_p): Use INSN_P. (save_parm_insns): Likewise. (copy_insn_list): Likewise. * jump.c (mark_all_labels): Use INSN_P. (never_reached_warning): Likewise. * lcm.c (optimize_mode_switching): Use INSN_P. * local-alloc.c (validate_equiv_mem): Use INSN_P. (memref_used_between_p): Likewise. (update_equiv_regs): Likewise. (block_alloc): Likewise. (no_conflict_p): Likewise. * loop.c (scan_loop): Use INSN_P. (find_and_verify_loops): Likewise. (count_loop_regs_set): Likewise. (loop_reg_used_before_p): Likewise. (strength_reduce): Likewise. (recombine_givs): Likewise. (check_dbra_loop): Likewise. (load_mems): Likewise. (try_copy_prop): Likewise. * print-rtl.c (print_rtx): Use INSN_P. * recog.c (find_single_use): Use INSN_P. * reg-stack.c (stack_regs_mentioned): Use INSN_P. (next_flags_user): Likewise. (swap_rtx_condition): Likewise. * regmove.c (mark_flags_life_zones): Use INSN_P. (optimize_reg_copy_1): Likewise. (optimize_reg_copy_2): Likewise. (optimize_reg_copy_3): Likewise. (reg_is_remote_constant_p): Likewise. (fixup_match_2): Likewise. (regmove_optimize): Likewise. (fixup_match_1): Likewise. * regrename.c (build_def_use): Use INSN_P. (replace_reg_in_block): Likewise. (consider_use): Likewise. * reload.c (find_equiv_reg): Use INSN_P. * reload1.c (reload): Use INSN_P. (maybe_fix_stack_asms): Likewise. (calculate_needs_all_insns): Likewise. (reload_as_needed): Likewise. (emit_output_reload_insns): Likewise. (delete_address_reloads_1): Likewise. (reload_cse_regs_1): Likewise. (reload_combine): Likewise. (reload_cse_move2add): Likewise. * reorg.c (redundant_insn): Use INSN_P. (dbr_schedule): Likewise. * resource.c (find_dead_or_set_registers): Use INSN_P. (mark_target_live_regs): Likewise. * rtlanal.c (reg_used_between_p): Use INSN_P. (reg_referenced_between_p): Likewise. (reg_set_between_p): Likewise. (reg_set_p): Likewise. (single_set): Likewise. (multiple_sets): Likewise. (find_last_value): Likewise. (reg_set_last): Likewise. (find_reg_note): Likewise. (find_regno_note): Likewise. * sibcall.c (sequence_uses_addressof): Use INSN_P. * simplify-rtx.c (cselib_process_insn): Use INSN_P. * ssa.c (find_evaluations): Use INSN_P. (rename_block): Likewise. (rename_equivalent_regs): Likewise. * unroll.c (loop_find_equiv_value): Use INSN_P. (set_dominates_use): Likewise. * varasm.c (mark_constant_pool): Use INSN_P. (mark_constants): Likewise. * config/alpha/alpha.c (alpha_does_function_need_gp): Use INSN_P. (alphaev4_next_group): Likewise. (alphaev5_next_group): Likewise. * config/c4x/c4x.c (c4x_process_after_reload): Use INSN_P. (c4x_rptb_rpts_p): Likewise. * config/mips/mips.c (mips16_optimize_gp): Use INSN_P. * config/rs6000/rs6000.c (uses_TOC): Use INSN_P. (rs6000_adjust_priority): Likewise. * config/sh/sh.c (sh_loop_align): Use INSN_P. (machine_dependent_reorg): Likewise. (split_branches): Likewise. * config/tahoe/tahoe.c (tahoe_cmp_check): Use INSN_P. From-SVN: r35494
2000-08-04 22:28:08 +02:00
if (INSN_P (insn) && reg_mentioned_p (dest, insn))
break;
if (GET_CODE (insn) == CALL_INSN)
return 0;
}
/* So we've found the insn using this value. If it is anything
other than sahf, aka unspec 10, or the value does not die
(meaning we'd have to search further), then we must give up. */
pat = PATTERN (insn);
if (GET_CODE (pat) != SET
|| GET_CODE (SET_SRC (pat)) != UNSPEC
|| XINT (SET_SRC (pat), 1) != UNSPEC_SAHF
|| ! dead_or_set_p (insn, dest))
return 0;
/* Now we are prepared to handle this as a normal cc0 setter. */
insn = next_flags_user (insn);
if (insn == NULL_RTX)
return 0;
pat = PATTERN (insn);
}
if (swap_rtx_condition_1 (pat))
{
int fail = 0;
INSN_CODE (insn) = -1;
if (recog_memoized (insn) == -1)
fail = 1;
/* In case the flags don't die here, recurse to try fix
following user too. */
else if (! dead_or_set_p (insn, ix86_flags_rtx))
{
insn = next_flags_user (insn);
if (!insn || !swap_rtx_condition (insn))
fail = 1;
}
if (fail)
{
swap_rtx_condition_1 (pat);
return 0;
}
return 1;
}
return 0;
}
1991-12-26 11:05:42 +01:00
/* Handle a comparison. Special care needs to be taken to avoid
causing comparisons that a 387 cannot do correctly, such as EQ.
Also, a pop insn may need to be emitted. The 387 does have an
1991-12-26 11:05:42 +01:00
`fcompp' insn that can pop two regs, but it is sometimes too expensive
to do this - a `fcomp' followed by a `fstpl %st(0)' may be easier to
set up. */
1991-12-26 11:05:42 +01:00
static void
compare_for_stack_reg (rtx insn, stack regstack, rtx pat_src)
1991-12-26 11:05:42 +01:00
{
rtx *src1, *src2;
rtx src1_note, src2_note;
rtx flags_user;
src1 = get_true_reg (&XEXP (pat_src, 0));
src2 = get_true_reg (&XEXP (pat_src, 1));
flags_user = next_flags_user (insn);
1991-12-26 11:05:42 +01:00
/* ??? If fxch turns out to be cheaper than fstp, give priority to
1996-07-04 00:07:53 +02:00
registers that die in this insn - move those to stack top first. */
if ((! STACK_REG_P (*src1)
|| (STACK_REG_P (*src2)
&& get_hard_regnum (regstack, *src2) == FIRST_STACK_REG))
&& swap_rtx_condition (insn))
{
rtx temp;
temp = XEXP (pat_src, 0);
XEXP (pat_src, 0) = XEXP (pat_src, 1);
XEXP (pat_src, 1) = temp;
1991-12-26 11:05:42 +01:00
src1 = get_true_reg (&XEXP (pat_src, 0));
src2 = get_true_reg (&XEXP (pat_src, 1));
INSN_CODE (insn) = -1;
}
1991-12-26 11:05:42 +01:00
1996-07-04 00:07:53 +02:00
/* We will fix any death note later. */
1991-12-26 11:05:42 +01:00
src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
if (STACK_REG_P (*src2))
src2_note = find_regno_note (insn, REG_DEAD, REGNO (*src2));
else
src2_note = NULL_RTX;
1991-12-26 11:05:42 +01:00
emit_swap_insn (insn, regstack, *src1);
1991-12-26 11:05:42 +01:00
replace_reg (src1, FIRST_STACK_REG);
if (STACK_REG_P (*src2))
replace_reg (src2, get_hard_regnum (regstack, *src2));
1991-12-26 11:05:42 +01:00
if (src1_note)
{
pop_stack (regstack, REGNO (XEXP (src1_note, 0)));
1991-12-26 11:05:42 +01:00
replace_reg (&XEXP (src1_note, 0), FIRST_STACK_REG);
}
/* If the second operand dies, handle that. But if the operands are
the same stack register, don't bother, because only one death is
1996-07-04 00:07:53 +02:00
needed, and it was just handled. */
1991-12-26 11:05:42 +01:00
if (src2_note
&& ! (STACK_REG_P (*src1) && STACK_REG_P (*src2)
1991-12-26 11:05:42 +01:00
&& REGNO (*src1) == REGNO (*src2)))
{
/* As a special case, two regs may die in this insn if src2 is
next to top of stack and the top of stack also dies. Since
we have already popped src1, "next to top of stack" is really
1996-07-04 00:07:53 +02:00
at top (FIRST_STACK_REG) now. */
1991-12-26 11:05:42 +01:00
if (get_hard_regnum (regstack, XEXP (src2_note, 0)) == FIRST_STACK_REG
&& src1_note)
{
pop_stack (regstack, REGNO (XEXP (src2_note, 0)));
1991-12-26 11:05:42 +01:00
replace_reg (&XEXP (src2_note, 0), FIRST_STACK_REG + 1);
}
else
{
/* The 386 can only represent death of the first operand in
the case handled above. In all other cases, emit a separate
pop and remove the death note from here. */
/* link_cc0_insns (insn); */
remove_regno_note (insn, REG_DEAD, REGNO (XEXP (src2_note, 0)));
1991-12-26 11:05:42 +01:00
emit_pop_insn (insn, regstack, XEXP (src2_note, 0),
EMIT_AFTER);
1991-12-26 11:05:42 +01:00
}
}
}
/* Substitute new registers in PAT, which is part of INSN. REGSTACK
1996-07-04 00:07:53 +02:00
is the current register layout. */
1991-12-26 11:05:42 +01:00
static void
subst_stack_regs_pat (rtx insn, stack regstack, rtx pat)
1991-12-26 11:05:42 +01:00
{
rtx *dest, *src;
switch (GET_CODE (pat))
{
case USE:
/* Deaths in USE insns can happen in non optimizing compilation.
Handle them by popping the dying register. */
src = get_true_reg (&XEXP (pat, 0));
if (STACK_REG_P (*src)
&& find_regno_note (insn, REG_DEAD, REGNO (*src)))
{
emit_pop_insn (insn, regstack, *src, EMIT_AFTER);
return;
}
/* ??? Uninitialized USE should not happen. */
else if (get_hard_regnum (regstack, *src) == -1)
abort ();
break;
1991-12-26 11:05:42 +01:00
case CLOBBER:
{
rtx note;
1991-12-26 11:05:42 +01:00
dest = get_true_reg (&XEXP (pat, 0));
if (STACK_REG_P (*dest))
{
note = find_reg_note (insn, REG_DEAD, *dest);
if (pat != PATTERN (insn))
{
/* The fix_truncdi_1 pattern wants to be able to allocate
it's own scratch register. It does this by clobbering
an fp reg so that it is assured of an empty reg-stack
register. If the register is live, kill it now.
Remove the DEAD/UNUSED note so we don't try to kill it
later too. */
if (note)
emit_pop_insn (insn, regstack, *dest, EMIT_BEFORE);
else
{
note = find_reg_note (insn, REG_UNUSED, *dest);
if (!note)
abort ();
}
remove_note (insn, note);
replace_reg (dest, LAST_STACK_REG);
}
else
{
/* A top-level clobber with no REG_DEAD, and no hard-regnum
indicates an uninitialized value. Because reload removed
all other clobbers, this must be due to a function
returning without a value. Load up a NaN. */
if (! note
&& get_hard_regnum (regstack, *dest) == -1)
{
pat = gen_rtx_SET (VOIDmode,
FP_MODE_REG (REGNO (*dest), SFmode),
nan);
PATTERN (insn) = pat;
move_for_stack_reg (insn, regstack, pat);
}
if (! note && COMPLEX_MODE_P (GET_MODE (*dest))
&& get_hard_regnum (regstack, FP_MODE_REG (REGNO (*dest), DFmode)) == -1)
{
pat = gen_rtx_SET (VOIDmode,
FP_MODE_REG (REGNO (*dest) + 1, SFmode),
nan);
PATTERN (insn) = pat;
move_for_stack_reg (insn, regstack, pat);
}
}
}
1991-12-26 11:05:42 +01:00
break;
}
1991-12-26 11:05:42 +01:00
case SET:
{
rtx *src1 = (rtx *) 0, *src2;
rtx src1_note, src2_note;
rtx pat_src;
dest = get_true_reg (&SET_DEST (pat));
src = get_true_reg (&SET_SRC (pat));
pat_src = SET_SRC (pat);
/* See if this is a `movM' pattern, and handle elsewhere if so. */
if (STACK_REG_P (*src)
|| (STACK_REG_P (*dest)
&& (GET_CODE (*src) == REG || GET_CODE (*src) == MEM
|| GET_CODE (*src) == CONST_DOUBLE)))
{
move_for_stack_reg (insn, regstack, pat);
break;
}
1991-12-26 11:05:42 +01:00
switch (GET_CODE (pat_src))
{
case COMPARE:
compare_for_stack_reg (insn, regstack, pat_src);
break;
1991-12-26 11:05:42 +01:00
case CALL:
{
int count;
for (count = HARD_REGNO_NREGS (REGNO (*dest), GET_MODE (*dest));
--count >= 0;)
{
regstack->reg[++regstack->top] = REGNO (*dest) + count;
SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest) + count);
}
}
replace_reg (dest, FIRST_STACK_REG);
break;
1991-12-26 11:05:42 +01:00
case REG:
/* This is a `tstM2' case. */
if (*dest != cc0_rtx)
abort ();
src1 = src;
1991-12-26 11:05:42 +01:00
/* Fall through. */
1991-12-26 11:05:42 +01:00
case FLOAT_TRUNCATE:
case SQRT:
case ABS:
case NEG:
/* These insns only operate on the top of the stack. DEST might
be cc0_rtx if we're processing a tstM pattern. Also, it's
possible that the tstM case results in a REG_DEAD note on the
source. */
1991-12-26 11:05:42 +01:00
if (src1 == 0)
src1 = get_true_reg (&XEXP (pat_src, 0));
1991-12-26 11:05:42 +01:00
emit_swap_insn (insn, regstack, *src1);
1991-12-26 11:05:42 +01:00
src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
1991-12-26 11:05:42 +01:00
if (STACK_REG_P (*dest))
replace_reg (dest, FIRST_STACK_REG);
1991-12-26 11:05:42 +01:00
if (src1_note)
{
replace_reg (&XEXP (src1_note, 0), FIRST_STACK_REG);
regstack->top--;
CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (*src1));
}
1991-12-26 11:05:42 +01:00
replace_reg (src1, FIRST_STACK_REG);
break;
1991-12-26 11:05:42 +01:00
case MINUS:
case DIV:
/* On i386, reversed forms of subM3 and divM3 exist for
MODE_FLOAT, so the same code that works for addM3 and mulM3
can be used. */
case MULT:
case PLUS:
/* These insns can accept the top of stack as a destination
from a stack reg or mem, or can use the top of stack as a
source and some other stack register (possibly top of stack)
as a destination. */
src1 = get_true_reg (&XEXP (pat_src, 0));
src2 = get_true_reg (&XEXP (pat_src, 1));
/* We will fix any death note later. */
if (STACK_REG_P (*src1))
src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
else
src1_note = NULL_RTX;
if (STACK_REG_P (*src2))
src2_note = find_regno_note (insn, REG_DEAD, REGNO (*src2));
else
src2_note = NULL_RTX;
1991-12-26 11:05:42 +01:00
/* If either operand is not a stack register, then the dest
must be top of stack. */
1991-12-26 11:05:42 +01:00
if (! STACK_REG_P (*src1) || ! STACK_REG_P (*src2))
emit_swap_insn (insn, regstack, *dest);
else
{
/* Both operands are REG. If neither operand is already
at the top of stack, choose to make the one that is the dest
the new top of stack. */
1991-12-26 11:05:42 +01:00
int src1_hard_regnum, src2_hard_regnum;
1991-12-26 11:05:42 +01:00
src1_hard_regnum = get_hard_regnum (regstack, *src1);
src2_hard_regnum = get_hard_regnum (regstack, *src2);
if (src1_hard_regnum == -1 || src2_hard_regnum == -1)
abort ();
1991-12-26 11:05:42 +01:00
if (src1_hard_regnum != FIRST_STACK_REG
&& src2_hard_regnum != FIRST_STACK_REG)
emit_swap_insn (insn, regstack, *dest);
1991-12-26 11:05:42 +01:00
}
if (STACK_REG_P (*src1))
replace_reg (src1, get_hard_regnum (regstack, *src1));
if (STACK_REG_P (*src2))
replace_reg (src2, get_hard_regnum (regstack, *src2));
if (src1_note)
1991-12-26 11:05:42 +01:00
{
rtx src1_reg = XEXP (src1_note, 0);
1991-12-26 11:05:42 +01:00
/* If the register that dies is at the top of stack, then
the destination is somewhere else - merely substitute it.
But if the reg that dies is not at top of stack, then
move the top of stack to the dead reg, as though we had
done the insn and then a store-with-pop. */
1991-12-26 11:05:42 +01:00
if (REGNO (src1_reg) == regstack->reg[regstack->top])
{
SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
replace_reg (dest, get_hard_regnum (regstack, *dest));
}
else
{
int regno = get_hard_regnum (regstack, src1_reg);
1991-12-26 11:05:42 +01:00
SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
replace_reg (dest, regno);
regstack->reg[regstack->top - (regno - FIRST_STACK_REG)]
= regstack->reg[regstack->top];
}
CLEAR_HARD_REG_BIT (regstack->reg_set,
REGNO (XEXP (src1_note, 0)));
replace_reg (&XEXP (src1_note, 0), FIRST_STACK_REG);
regstack->top--;
}
else if (src2_note)
1991-12-26 11:05:42 +01:00
{
rtx src2_reg = XEXP (src2_note, 0);
if (REGNO (src2_reg) == regstack->reg[regstack->top])
{
SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
replace_reg (dest, get_hard_regnum (regstack, *dest));
}
else
{
int regno = get_hard_regnum (regstack, src2_reg);
SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
replace_reg (dest, regno);
regstack->reg[regstack->top - (regno - FIRST_STACK_REG)]
= regstack->reg[regstack->top];
}
CLEAR_HARD_REG_BIT (regstack->reg_set,
REGNO (XEXP (src2_note, 0)));
replace_reg (&XEXP (src2_note, 0), FIRST_STACK_REG);
regstack->top--;
1991-12-26 11:05:42 +01:00
}
else
{
SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
replace_reg (dest, get_hard_regnum (regstack, *dest));
1991-12-26 11:05:42 +01:00
}
/* Keep operand 1 matching with destination. */
if (GET_RTX_CLASS (GET_CODE (pat_src)) == 'c'
&& REG_P (*src1) && REG_P (*src2)
&& REGNO (*src1) != REGNO (*dest))
{
int tmp = REGNO (*src1);
replace_reg (src1, REGNO (*src2));
replace_reg (src2, tmp);
}
break;
1991-12-26 11:05:42 +01:00
case UNSPEC:
switch (XINT (pat_src, 1))
{
case UNSPEC_SIN:
case UNSPEC_COS:
case UNSPEC_FRNDINT:
case UNSPEC_F2XM1:
/* These insns only operate on the top of the stack. */
src1 = get_true_reg (&XVECEXP (pat_src, 0, 0));
emit_swap_insn (insn, regstack, *src1);
src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
if (STACK_REG_P (*dest))
replace_reg (dest, FIRST_STACK_REG);
if (src1_note)
{
replace_reg (&XEXP (src1_note, 0), FIRST_STACK_REG);
regstack->top--;
CLEAR_HARD_REG_BIT (regstack->reg_set, REGNO (*src1));
}
replace_reg (src1, FIRST_STACK_REG);
break;
case UNSPEC_FPATAN:
case UNSPEC_FYL2X:
case UNSPEC_FSCALE:
/* These insns operate on the top two stack slots. */
src1 = get_true_reg (&XVECEXP (pat_src, 0, 0));
src2 = get_true_reg (&XVECEXP (pat_src, 0, 1));
src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
src2_note = find_regno_note (insn, REG_DEAD, REGNO (*src2));
{
struct stack_def temp_stack;
int regno, j, k, temp;
temp_stack = *regstack;
/* Place operand 1 at the top of stack. */
regno = get_hard_regnum (&temp_stack, *src1);
if (regno < 0)
abort ();
if (regno != FIRST_STACK_REG)
{
k = temp_stack.top - (regno - FIRST_STACK_REG);
j = temp_stack.top;
temp = temp_stack.reg[k];
temp_stack.reg[k] = temp_stack.reg[j];
temp_stack.reg[j] = temp;
}
/* Place operand 2 next on the stack. */
regno = get_hard_regnum (&temp_stack, *src2);
if (regno < 0)
abort ();
if (regno != FIRST_STACK_REG + 1)
{
k = temp_stack.top - (regno - FIRST_STACK_REG);
j = temp_stack.top - 1;
temp = temp_stack.reg[k];
temp_stack.reg[k] = temp_stack.reg[j];
temp_stack.reg[j] = temp;
}
change_stack (insn, regstack, &temp_stack, EMIT_BEFORE);
}
replace_reg (src1, FIRST_STACK_REG);
replace_reg (src2, FIRST_STACK_REG + 1);
if (src1_note)
replace_reg (&XEXP (src1_note, 0), FIRST_STACK_REG);
if (src2_note)
replace_reg (&XEXP (src2_note, 0), FIRST_STACK_REG + 1);
/* Pop both input operands from the stack. */
CLEAR_HARD_REG_BIT (regstack->reg_set,
regstack->reg[regstack->top]);
CLEAR_HARD_REG_BIT (regstack->reg_set,
regstack->reg[regstack->top - 1]);
regstack->top -= 2;
/* Push the result back onto the stack. */
regstack->reg[++regstack->top] = REGNO (*dest);
SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
replace_reg (dest, FIRST_STACK_REG);
break;
case UNSPEC_SAHF:
/* (unspec [(unspec [(compare)] UNSPEC_FNSTSW)] UNSPEC_SAHF)
The combination matches the PPRO fcomi instruction. */
pat_src = XVECEXP (pat_src, 0, 0);
if (GET_CODE (pat_src) != UNSPEC
|| XINT (pat_src, 1) != UNSPEC_FNSTSW)
abort ();
/* FALLTHRU */
case UNSPEC_FNSTSW:
/* Combined fcomp+fnstsw generated for doing well with
CSE. When optimizing this would have been broken
up before now. */
pat_src = XVECEXP (pat_src, 0, 0);
if (GET_CODE (pat_src) != COMPARE)
abort ();
compare_for_stack_reg (insn, regstack, pat_src);
break;
default:
abort ();
}
break;
case IF_THEN_ELSE:
/* This insn requires the top of stack to be the destination. */
src1 = get_true_reg (&XEXP (pat_src, 1));
src2 = get_true_reg (&XEXP (pat_src, 2));
src1_note = find_regno_note (insn, REG_DEAD, REGNO (*src1));
src2_note = find_regno_note (insn, REG_DEAD, REGNO (*src2));
/* If the comparison operator is an FP comparison operator,
it is handled correctly by compare_for_stack_reg () who
will move the destination to the top of stack. But if the
comparison operator is not an FP comparison operator, we
have to handle it here. */
if (get_hard_regnum (regstack, *dest) >= FIRST_STACK_REG
&& REGNO (*dest) != regstack->reg[regstack->top])
{
/* In case one of operands is the top of stack and the operands
dies, it is safe to make it the destination operand by
reversing the direction of cmove and avoid fxch. */
if ((REGNO (*src1) == regstack->reg[regstack->top]
&& src1_note)
|| (REGNO (*src2) == regstack->reg[regstack->top]
&& src2_note))
{
int idx1 = (get_hard_regnum (regstack, *src1)
- FIRST_STACK_REG);
int idx2 = (get_hard_regnum (regstack, *src2)
- FIRST_STACK_REG);
/* Make reg-stack believe that the operands are already
swapped on the stack */
regstack->reg[regstack->top - idx1] = REGNO (*src2);
regstack->reg[regstack->top - idx2] = REGNO (*src1);
/* Reverse condition to compensate the operand swap.
i386 do have comparison always reversible. */
PUT_CODE (XEXP (pat_src, 0),
reversed_comparison_code (XEXP (pat_src, 0), insn));
}
else
emit_swap_insn (insn, regstack, *dest);
}
{
rtx src_note [3];
int i;
src_note[0] = 0;
src_note[1] = src1_note;
src_note[2] = src2_note;
if (STACK_REG_P (*src1))
replace_reg (src1, get_hard_regnum (regstack, *src1));
if (STACK_REG_P (*src2))
replace_reg (src2, get_hard_regnum (regstack, *src2));
for (i = 1; i <= 2; i++)
if (src_note [i])
{
int regno = REGNO (XEXP (src_note[i], 0));
/* If the register that dies is not at the top of
stack, then move the top of stack to the dead reg */
if (regno != regstack->reg[regstack->top])
{
remove_regno_note (insn, REG_DEAD, regno);
emit_pop_insn (insn, regstack, XEXP (src_note[i], 0),
EMIT_AFTER);
}
else
/* Top of stack never dies, as it is the
destination. */
abort ();
}
}
/* Make dest the top of stack. Add dest to regstack if
not present. */
if (get_hard_regnum (regstack, *dest) < FIRST_STACK_REG)
regstack->reg[++regstack->top] = REGNO (*dest);
SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest));
replace_reg (dest, FIRST_STACK_REG);
break;
default:
abort ();
}
break;
1991-12-26 11:05:42 +01:00
}
default:
break;
}
1991-12-26 11:05:42 +01:00
}
/* Substitute hard regnums for any stack regs in INSN, which has
N_INPUTS inputs and N_OUTPUTS outputs. REGSTACK is the stack info
before the insn, and is updated with changes made here.
There are several requirements and assumptions about the use of
stack-like regs in asm statements. These rules are enforced by
record_asm_stack_regs; see comments there for details. Any
asm_operands left in the RTL at this point may be assume to meet the
requirements, since record_asm_stack_regs removes any problem asm. */
static void
subst_asm_stack_regs (rtx insn, stack regstack)
{
rtx body = PATTERN (insn);
int alt;
rtx *note_reg; /* Array of note contents */
rtx **note_loc; /* Address of REG field of each note */
enum reg_note *note_kind; /* The type of each note */
builtins.c (expand_builtin_strlen): Initialize variable `icode'. * builtins.c (expand_builtin_strlen): Initialize variable `icode'. * calls.c (expand_call): Likewise for `old_stack_arg_under_construction'. * cpphash.c (macroexpand): Likewise for `args' and `rest_zero'. * function.c (pad_to_arg_alignment): Likewise for `save_var' and `save_constant'. * gcc.c (execute): Likewise for `ut' and `st'. * genattrtab.c (attr_rtx): Likewise for `rt_val'. * genopinit.c (gen_insn): Likewise for `m1', `m2' and `op'. * jump.c (jump_optimize_1): Likewise for `temp2'. * local-alloc.c (block_alloc): Likewise for `r1'. * loop.c (recombine_givs): Likewise for `life_start' and `life_end'. * reg-stack.c (check_asm_stack_operands): Likewise for `clobber_reg'. (subst_asm_stack_regs): Likewise for `clobber_reg' and `clobber_loc'. * regmove.c (fixup_match_1): Likewise for `insn_const', `dst_node' and `set2'. * reload.c (find_reloads): Likewise for `goal_alternative_number' and `goal_earlyclobber'. * scan-decls.c (scan_decls): Likewise for `prev_id_end'. * sdbout.c (sdbout_one_type): Likewise for `member_scl'. * stupid.c (stupid_life_analysis): Likewise for `chain'. * unroll.c (copy_loop_body): Likewise for `copy'. * varasm.c (output_constructor): Likewise for `byte'. ch: * actions.c (update_else_range_for_int_const): Initialize variables `lowval' and `highval'. (update_else_range_for_range): Likewise for `low_range_val' and `high_range_val'. cp: * class.c (warn_hidden): Initialize variable `fndecl'. From-SVN: r31207
2000-01-04 17:29:41 +01:00
rtx *clobber_reg = 0;
rtx **clobber_loc = 0;
struct stack_def temp_stack;
int n_notes;
int n_clobbers;
rtx note;
int i;
int n_inputs, n_outputs;
if (! check_asm_stack_operands (insn))
return;
/* Find out what the constraints required. If no constraint
alternative matches, that is a compiler bug: we should have caught
such an insn in check_asm_stack_operands. */
extract_insn (insn);
constrain_operands (1);
alt = which_alternative;
preprocess_constraints ();
n_inputs = get_asm_operand_n_inputs (body);
n_outputs = recog_data.n_operands - n_inputs;
if (alt < 0)
abort ();
1996-07-04 00:07:53 +02:00
/* Strip SUBREGs here to make the following code simpler. */
for (i = 0; i < recog_data.n_operands; i++)
if (GET_CODE (recog_data.operand[i]) == SUBREG
&& GET_CODE (SUBREG_REG (recog_data.operand[i])) == REG)
{
recog_data.operand_loc[i] = & SUBREG_REG (recog_data.operand[i]);
recog_data.operand[i] = SUBREG_REG (recog_data.operand[i]);
}
/* Set up NOTE_REG, NOTE_LOC and NOTE_KIND. */
for (i = 0, note = REG_NOTES (insn); note; note = XEXP (note, 1))
i++;
note_reg = alloca (i * sizeof (rtx));
note_loc = alloca (i * sizeof (rtx *));
note_kind = alloca (i * sizeof (enum reg_note));
n_notes = 0;
for (note = REG_NOTES (insn); note; note = XEXP (note, 1))
{
rtx reg = XEXP (note, 0);
rtx *loc = & XEXP (note, 0);
if (GET_CODE (reg) == SUBREG && GET_CODE (SUBREG_REG (reg)) == REG)
{
loc = & SUBREG_REG (reg);
reg = SUBREG_REG (reg);
}
if (STACK_REG_P (reg)
&& (REG_NOTE_KIND (note) == REG_DEAD
|| REG_NOTE_KIND (note) == REG_UNUSED))
{
note_reg[n_notes] = reg;
note_loc[n_notes] = loc;
note_kind[n_notes] = REG_NOTE_KIND (note);
n_notes++;
}
}
/* Set up CLOBBER_REG and CLOBBER_LOC. */
n_clobbers = 0;
if (GET_CODE (body) == PARALLEL)
{
clobber_reg = alloca (XVECLEN (body, 0) * sizeof (rtx));
clobber_loc = alloca (XVECLEN (body, 0) * sizeof (rtx *));
for (i = 0; i < XVECLEN (body, 0); i++)
if (GET_CODE (XVECEXP (body, 0, i)) == CLOBBER)
{
rtx clobber = XVECEXP (body, 0, i);
rtx reg = XEXP (clobber, 0);
rtx *loc = & XEXP (clobber, 0);
if (GET_CODE (reg) == SUBREG && GET_CODE (SUBREG_REG (reg)) == REG)
{
loc = & SUBREG_REG (reg);
reg = SUBREG_REG (reg);
}
if (STACK_REG_P (reg))
{
clobber_reg[n_clobbers] = reg;
clobber_loc[n_clobbers] = loc;
n_clobbers++;
}
}
}
temp_stack = *regstack;
/* Put the input regs into the desired place in TEMP_STACK. */
for (i = n_outputs; i < n_outputs + n_inputs; i++)
if (STACK_REG_P (recog_data.operand[i])
&& reg_class_subset_p (recog_op_alt[i][alt].class,
FLOAT_REGS)
&& recog_op_alt[i][alt].class != FLOAT_REGS)
{
/* If an operand needs to be in a particular reg in
FLOAT_REGS, the constraint was either 't' or 'u'. Since
these constraints are for single register classes, and
reload guaranteed that operand[i] is already in that class,
we can just use REGNO (recog_data.operand[i]) to know which
actual reg this operand needs to be in. */
int regno = get_hard_regnum (&temp_stack, recog_data.operand[i]);
if (regno < 0)
abort ();
regmove.c (replace_in_call_usage): Fix warnings. 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * regmove.c (replace_in_call_usage): Fix warnings. * sched-deps.c (add_dependence): Fix warnings. * simplify-rtx.c (simplify_subreg): Likewise. Return NULL_RTX instead of NULL. * reg-stack.c (emit_swap_insn): Eliminate warnings. (subst_asm_stack_regs): Likewise. * combine.c (num_sign_bit_copies): Cast bitwidth to int to avoid warnings. * dwarf2out.c (output_call_frame_info): Declare i as int. (build_abbrev_table): Declare n_alloc as int. (dwarf2out_finish): Initialize die. * except.c: Declare sjlj_funcdef_number as unsigned. (connect_post_landing_pads): Declare j as unsigned. (convert_to_eh_region_ranges): Initialize call_site. (output_function_exception_table): Initialize tt_format_size. * expr.c (move_by_pieces_1): Initialize to1. (store_constructor): Initialize minelt and maxelt. * flow.c (mark_regs_live_at_end): Declare i as unsigned. * function.c (instantiate_decls): Avoid signed/unsigned warning. * c-decl.c (combine_parm_decls): Unused, remove. * c-tree.h: Remove prototype for combine_parm_decls. * reload.c (push_reload): Fix warning. (regno_clobbered_p): Likewise. * reload1.c (replace_pseudos_in_call_usage): Likewise. (reload_combine): Likewise. * bitmap.c: Rename bitmap_zero to bitmap_zero_bits to fix warnings. * bitmap.h: Rename bitmap_zero to bitmap_zero_bits to fix warnings. * bitmap.c (bitmap_operation): Change user. * bitmap.h (EXECUTE_IF_AND_COMPL_IN_BITMAP): Likewise. For cp/: 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * call.c (build_op_delete_call): Initialize fn. (convert_like_real): Delete conditional. (joust): Initialize *w and *l. * class.c: Add prototype for binfo_ctor_vtable. (get_primary_binfo): Initialize result. * init.c (build_java_class_ref): Initialize name. * typeck.c (unary_complex_lvalue): Do not duplicate the argument to modify, pre-, or post-increment when used as an lvalue and when the argument has side-effects. For ch/: 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * ch-tree.h: Remove prototype for combine_parm_decls, unused function. From-SVN: r43893
2001-07-10 12:38:10 +02:00
if ((unsigned int) regno != REGNO (recog_data.operand[i]))
{
/* recog_data.operand[i] is not in the right place. Find
it and swap it with whatever is already in I's place.
K is where recog_data.operand[i] is now. J is where it
should be. */
int j, k, temp;
k = temp_stack.top - (regno - FIRST_STACK_REG);
j = (temp_stack.top
- (REGNO (recog_data.operand[i]) - FIRST_STACK_REG));
temp = temp_stack.reg[k];
temp_stack.reg[k] = temp_stack.reg[j];
temp_stack.reg[j] = temp;
}
}
/* Emit insns before INSN to make sure the reg-stack is in the right
order. */
change_stack (insn, regstack, &temp_stack, EMIT_BEFORE);
/* Make the needed input register substitutions. Do death notes and
1996-07-04 00:07:53 +02:00
clobbers too, because these are for inputs, not outputs. */
for (i = n_outputs; i < n_outputs + n_inputs; i++)
if (STACK_REG_P (recog_data.operand[i]))
{
int regnum = get_hard_regnum (regstack, recog_data.operand[i]);
if (regnum < 0)
abort ();
replace_reg (recog_data.operand_loc[i], regnum);
}
for (i = 0; i < n_notes; i++)
if (note_kind[i] == REG_DEAD)
{
int regnum = get_hard_regnum (regstack, note_reg[i]);
if (regnum < 0)
abort ();
replace_reg (note_loc[i], regnum);
}
for (i = 0; i < n_clobbers; i++)
{
/* It's OK for a CLOBBER to reference a reg that is not live.
Don't try to replace it in that case. */
int regnum = get_hard_regnum (regstack, clobber_reg[i]);
if (regnum >= 0)
{
/* Sigh - clobbers always have QImode. But replace_reg knows
that these regs can't be MODE_INT and will abort. Just put
the right reg there without calling replace_reg. */
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
*clobber_loc[i] = FP_MODE_REG (regnum, DFmode);
}
}
1996-07-04 00:07:53 +02:00
/* Now remove from REGSTACK any inputs that the asm implicitly popped. */
for (i = n_outputs; i < n_outputs + n_inputs; i++)
if (STACK_REG_P (recog_data.operand[i]))
{
/* An input reg is implicitly popped if it is tied to an
1996-07-04 00:07:53 +02:00
output, or if there is a CLOBBER for it. */
int j;
for (j = 0; j < n_clobbers; j++)
if (operands_match_p (clobber_reg[j], recog_data.operand[i]))
break;
if (j < n_clobbers || recog_op_alt[i][alt].matches >= 0)
{
/* recog_data.operand[i] might not be at the top of stack.
But that's OK, because all we need to do is pop the
right number of regs off of the top of the reg-stack.
record_asm_stack_regs guaranteed that all implicitly
popped regs were grouped at the top of the reg-stack. */
CLEAR_HARD_REG_BIT (regstack->reg_set,
regstack->reg[regstack->top]);
regstack->top--;
}
}
/* Now add to REGSTACK any outputs that the asm implicitly pushed.
Note that there isn't any need to substitute register numbers.
1996-07-04 00:07:53 +02:00
??? Explain why this is true. */
for (i = LAST_STACK_REG; i >= FIRST_STACK_REG; i--)
{
/* See if there is an output for this hard reg. */
int j;
for (j = 0; j < n_outputs; j++)
if (STACK_REG_P (recog_data.operand[j])
regmove.c (replace_in_call_usage): Fix warnings. 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * regmove.c (replace_in_call_usage): Fix warnings. * sched-deps.c (add_dependence): Fix warnings. * simplify-rtx.c (simplify_subreg): Likewise. Return NULL_RTX instead of NULL. * reg-stack.c (emit_swap_insn): Eliminate warnings. (subst_asm_stack_regs): Likewise. * combine.c (num_sign_bit_copies): Cast bitwidth to int to avoid warnings. * dwarf2out.c (output_call_frame_info): Declare i as int. (build_abbrev_table): Declare n_alloc as int. (dwarf2out_finish): Initialize die. * except.c: Declare sjlj_funcdef_number as unsigned. (connect_post_landing_pads): Declare j as unsigned. (convert_to_eh_region_ranges): Initialize call_site. (output_function_exception_table): Initialize tt_format_size. * expr.c (move_by_pieces_1): Initialize to1. (store_constructor): Initialize minelt and maxelt. * flow.c (mark_regs_live_at_end): Declare i as unsigned. * function.c (instantiate_decls): Avoid signed/unsigned warning. * c-decl.c (combine_parm_decls): Unused, remove. * c-tree.h: Remove prototype for combine_parm_decls. * reload.c (push_reload): Fix warning. (regno_clobbered_p): Likewise. * reload1.c (replace_pseudos_in_call_usage): Likewise. (reload_combine): Likewise. * bitmap.c: Rename bitmap_zero to bitmap_zero_bits to fix warnings. * bitmap.h: Rename bitmap_zero to bitmap_zero_bits to fix warnings. * bitmap.c (bitmap_operation): Change user. * bitmap.h (EXECUTE_IF_AND_COMPL_IN_BITMAP): Likewise. For cp/: 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * call.c (build_op_delete_call): Initialize fn. (convert_like_real): Delete conditional. (joust): Initialize *w and *l. * class.c: Add prototype for binfo_ctor_vtable. (get_primary_binfo): Initialize result. * init.c (build_java_class_ref): Initialize name. * typeck.c (unary_complex_lvalue): Do not duplicate the argument to modify, pre-, or post-increment when used as an lvalue and when the argument has side-effects. For ch/: 2001-07-10 Jan van Male <jan.vanmale@fenk.wau.nl> * ch-tree.h: Remove prototype for combine_parm_decls, unused function. From-SVN: r43893
2001-07-10 12:38:10 +02:00
&& REGNO (recog_data.operand[j]) == (unsigned) i)
{
regstack->reg[++regstack->top] = i;
SET_HARD_REG_BIT (regstack->reg_set, i);
break;
}
}
/* Now emit a pop insn for any REG_UNUSED output, or any REG_DEAD
input that the asm didn't implicitly pop. If the asm didn't
implicitly pop an input reg, that reg will still be live.
Note that we can't use find_regno_note here: the register numbers
in the death notes have already been substituted. */
for (i = 0; i < n_outputs; i++)
if (STACK_REG_P (recog_data.operand[i]))
{
int j;
for (j = 0; j < n_notes; j++)
if (REGNO (recog_data.operand[i]) == REGNO (note_reg[j])
&& note_kind[j] == REG_UNUSED)
{
insn = emit_pop_insn (insn, regstack, recog_data.operand[i],
EMIT_AFTER);
break;
}
}
for (i = n_outputs; i < n_outputs + n_inputs; i++)
if (STACK_REG_P (recog_data.operand[i]))
{
int j;
for (j = 0; j < n_notes; j++)
if (REGNO (recog_data.operand[i]) == REGNO (note_reg[j])
&& note_kind[j] == REG_DEAD
&& TEST_HARD_REG_BIT (regstack->reg_set,
REGNO (recog_data.operand[i])))
{
insn = emit_pop_insn (insn, regstack, recog_data.operand[i],
EMIT_AFTER);
break;
}
}
}
1991-12-26 11:05:42 +01:00
/* Substitute stack hard reg numbers for stack virtual registers in
INSN. Non-stack register numbers are not changed. REGSTACK is the
current stack content. Insns may be emitted as needed to arrange the
stack for the 387 based on the contents of the insn. */
static void
subst_stack_regs (rtx insn, stack regstack)
1991-12-26 11:05:42 +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
rtx *note_link, note;
int i;
1991-12-26 11:05:42 +01:00
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
if (GET_CODE (insn) == CALL_INSN)
{
int top = regstack->top;
1991-12-26 11:05:42 +01:00
/* If there are any floating point parameters to be passed in
registers for this call, make sure they are in the right
order. */
1991-12-26 11:05:42 +01:00
if (top >= 0)
{
straighten_stack (PREV_INSN (insn), regstack);
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
/* Now mark the arguments as dead after the call. */
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
while (regstack->top >= 0)
{
CLEAR_HARD_REG_BIT (regstack->reg_set, FIRST_STACK_REG + regstack->top);
regstack->top--;
}
}
}
1991-12-26 11:05:42 +01:00
/* Do the actual substitution if any stack regs are mentioned.
Since we only record whether entire insn mentions stack regs, and
subst_stack_regs_pat only works for patterns that contain stack regs,
we must check each pattern in a parallel here. A call_value_pop could
1996-07-04 00:07:53 +02:00
fail otherwise. */
1991-12-26 11:05:42 +01:00
if (stack_regs_mentioned (insn))
1991-12-26 11:05:42 +01:00
{
int n_operands = asm_noperands (PATTERN (insn));
if (n_operands >= 0)
{
/* This insn is an `asm' with operands. Decode the operands,
decide how many are inputs, and do register substitution.
1996-07-04 00:07:53 +02:00
Any REG_UNUSED notes will be handled by subst_asm_stack_regs. */
subst_asm_stack_regs (insn, regstack);
return;
}
1991-12-26 11:05:42 +01:00
if (GET_CODE (PATTERN (insn)) == PARALLEL)
1992-07-06 22:15:06 +02:00
for (i = 0; i < XVECLEN (PATTERN (insn), 0); i++)
1991-12-26 11:05:42 +01:00
{
if (stack_regs_mentioned_p (XVECEXP (PATTERN (insn), 0, i)))
subst_stack_regs_pat (insn, regstack,
XVECEXP (PATTERN (insn), 0, i));
1991-12-26 11:05:42 +01:00
}
else
subst_stack_regs_pat (insn, regstack, PATTERN (insn));
}
/* subst_stack_regs_pat may have deleted a no-op insn. If so, any
1996-07-04 00:07:53 +02:00
REG_UNUSED will already have been dealt with, so just return. */
1991-12-26 11:05:42 +01:00
if (GET_CODE (insn) == NOTE || INSN_DELETED_P (insn))
return;
1991-12-26 11:05:42 +01:00
/* If there is a REG_UNUSED note on a stack register on this insn,
the indicated reg must be popped. The REG_UNUSED note is removed,
since the form of the newly emitted pop insn references the reg,
1996-07-04 00:07:53 +02:00
making it no longer `unset'. */
1991-12-26 11:05:42 +01:00
note_link = &REG_NOTES (insn);
1991-12-26 11:05:42 +01:00
for (note = *note_link; note; note = XEXP (note, 1))
if (REG_NOTE_KIND (note) == REG_UNUSED && STACK_REG_P (XEXP (note, 0)))
{
*note_link = XEXP (note, 1);
insn = emit_pop_insn (insn, regstack, XEXP (note, 0), EMIT_AFTER);
1991-12-26 11:05:42 +01:00
}
else
note_link = &XEXP (note, 1);
}
/* Change the organization of the stack so that it fits a new basic
block. Some registers might have to be popped, but there can never be
a register live in the new block that is not now live.
Insert any needed insns before or after INSN, as indicated by
WHERE. OLD is the original stack layout, and NEW is the desired
form. OLD is updated to reflect the code emitted, ie, it will be
the same as NEW upon return.
1991-12-26 11:05:42 +01:00
This function will not preserve block_end[]. But that information
1996-07-04 00:07:53 +02:00
is no longer needed once this has executed. */
1991-12-26 11:05:42 +01:00
static void
change_stack (rtx insn, stack old, stack new, enum emit_where where)
1991-12-26 11:05:42 +01:00
{
int reg;
int update_end = 0;
1991-12-26 11:05:42 +01:00
/* We will be inserting new insns "backwards". If we are to insert
after INSN, find the next insn, and insert before it. */
1991-12-26 11:05:42 +01:00
if (where == EMIT_AFTER)
{
if (current_block && current_block->end == insn)
update_end = 1;
insn = NEXT_INSN (insn);
}
1991-12-26 11:05:42 +01:00
1996-07-04 00:07:53 +02:00
/* Pop any registers that are not needed in the new block. */
1991-12-26 11:05:42 +01:00
for (reg = old->top; reg >= 0; reg--)
if (! TEST_HARD_REG_BIT (new->reg_set, old->reg[reg]))
(current_function_returns_real): Deleted (unused). (FP_mode_reg): Trimmed to a smaller size, less overhead. (FP_MODE_REG): New macro over which FP_mode_reg will be accessed. (mark_regs_pat, straighten_stack): New functions. (reg_to_stack): Amend initialisation of FP_mode_reg. Mark FP registers mentioned in USE insns before NOTE_INSN_FUNCTION_BEG. (get_true_reg): Eliminate FP subreg accesses in favour of the actual FP register in use. (record_reg_life_pat): Make it work on SUBREGs as well. Make use of the new mark_regs_pat function. Handle USE insns if called unnested. (record_reg_life): Don't check for QImode again, we know that it is there. Process CALL_INSNs like all other insns, they might `use' some FP argument registers if register passing. (stack_result_p): Changed in stack_result and returning an rtx. (stack_reg_life_analysis): Take a new stackentry state argument. Use stack_result and the rtx to mark using mark_regs_pat. This ensures that types that need multiple FP registers are handled correctly Delete the no_live_regs shortcut to save space. Use stackentry state to determine filled registers. (replace_reg): Accept COMPLEX_FLOAT as well. (move_for_stack_reg): Optimise away some pointer dereferencing. (subst_stack_regs): Make sure the stack is in the right order and of the right size for register passing. (goto_block_pat): Make sure the stack is in the right order to return possible multi-register values from the function. (convert_regs): Fix comment about CALL_INSN, it's no longer valid. Make sure the stack is of the right size and in the right order to return possible multi-register values from the function. From-SVN: r9459
1995-04-26 01:06:57 +02:00
emit_pop_insn (insn, old, FP_MODE_REG (old->reg[reg], DFmode),
EMIT_BEFORE);
1991-12-26 11:05:42 +01:00
if (new->top == -2)
{
/* If the new block has never been processed, then it can inherit
1996-07-04 00:07:53 +02:00
the old stack order. */
1991-12-26 11:05:42 +01:00
new->top = old->top;
memcpy (new->reg, old->reg, sizeof (new->reg));
1991-12-26 11:05:42 +01:00
}
else
{
/* This block has been entered before, and we must match the
1996-07-04 00:07:53 +02:00
previously selected stack order. */
1991-12-26 11:05:42 +01:00
/* By now, the only difference should be the order of the stack,
1996-07-04 00:07:53 +02:00
not their depth or liveliness. */
1991-12-26 11:05:42 +01:00
GO_IF_HARD_REG_EQUAL (old->reg_set, new->reg_set, win);
abort ();
win:
if (old->top != new->top)
abort ();
/* If the stack is not empty (new->top != -1), loop here emitting
swaps until the stack is correct.
The worst case number of swaps emitted is N + 2, where N is the
1991-12-26 11:05:42 +01:00
depth of the stack. In some cases, the reg at the top of
stack may be correct, but swapped anyway in order to fix
other regs. But since we never swap any other reg away from
1996-07-04 00:07:53 +02:00
its correct slot, this algorithm will converge. */
1991-12-26 11:05:42 +01:00
if (new->top != -1)
do
{
/* Swap the reg at top of stack into the position it is
supposed to be in, until the correct top of stack appears. */
1991-12-26 11:05:42 +01:00
while (old->reg[old->top] != new->reg[new->top])
{
for (reg = new->top; reg >= 0; reg--)
if (new->reg[reg] == old->reg[old->top])
break;
1991-12-26 11:05:42 +01:00
if (reg == -1)
abort ();
1991-12-26 11:05:42 +01:00
emit_swap_insn (insn, old,
FP_MODE_REG (old->reg[reg], DFmode));
}
1991-12-26 11:05:42 +01:00
/* See if any regs remain incorrect. If so, bring an
1991-12-26 11:05:42 +01:00
incorrect reg to the top of stack, and let the while loop
1996-07-04 00:07:53 +02:00
above fix it. */
1991-12-26 11:05:42 +01:00
for (reg = new->top; reg >= 0; reg--)
if (new->reg[reg] != old->reg[reg])
{
emit_swap_insn (insn, old,
FP_MODE_REG (old->reg[reg], DFmode));
break;
}
} while (reg >= 0);
1991-12-26 11:05:42 +01:00
1996-07-04 00:07:53 +02:00
/* At this point there must be no differences. */
1991-12-26 11:05:42 +01:00
for (reg = old->top; reg >= 0; reg--)
if (old->reg[reg] != new->reg[reg])
abort ();
}
if (update_end)
current_block->end = PREV_INSN (insn);
1991-12-26 11:05:42 +01:00
}
/* Print stack configuration. */
1991-12-26 11:05:42 +01:00
static void
print_stack (FILE *file, stack s)
1991-12-26 11:05:42 +01:00
{
if (! file)
return;
1991-12-26 11:05:42 +01:00
if (s->top == -2)
fprintf (file, "uninitialized\n");
else if (s->top == -1)
fprintf (file, "empty\n");
else
{
int i;
fputs ("[ ", file);
for (i = 0; i <= s->top; ++i)
fprintf (file, "%d ", s->reg[i]);
fputs ("]\n", file);
}
}
/* This function was doing life analysis. We now let the regular live
code do it's job, so we only need to check some extra invariants
that reg-stack expects. Primary among these being that all registers
are initialized before use.
1991-12-26 11:05:42 +01:00
The function returns true when code was emitted to CFG edges and
commit_edge_insertions needs to be called. */
1991-12-26 11:05:42 +01:00
static int
convert_regs_entry (void)
{
bb-reorder.c (make_reorder_chain, [...]): Use FOR_EACH_BB macros to iterate over basic block chain. * bb-reorder.c (make_reorder_chain, make_reorder_chain_1): Use FOR_EACH_BB macros to iterate over basic block chain. * cfg.c (clear_edges, clear_bb_flags, dump_flow_info, alloc_aux_for_blocks, clear_aux_for_blocks, alloc_aux_for_edges): Likewise. * cfganal.c (set_edge_can_fallthru_flag, flow_call_edges_add, find_unreachable_blocks, create_edge_list, verify_edge_list, remove_fake_edges, add_noreturn_fake_exit_edges, flow_preorder_transversal_compute, flow_dfs_compute_reverse_execute): Likewise. * cfgbuild.c (make_edges, find_basic_blocks, find_many_sub_basic_blocks, find_sub_basic_blocks): Likewise. * cfgcleanup.c (try_optimize_cfg, delete_unreachable_blocks): Likewise. * cfglayout.c (record_effective_endpoints, cleanup_unconditional_jumps): Likewise. * cfgloop.c (flow_loops_cfg_dump, flow_loops_find): Likewise. * cfgrtl.c (compute_bb_for_insn, tidy_fallthru_edges, commit_edge_insertions, commit_edge_insertions_watch_calls, print_rtl_with_bb, verify_flow_info, purge_all_dead_edges): Likewise. * combine.c (combine_instructions, reg_dead_at_p): Likewise. * conflict.c (conflict_graph_compute): Likewise. * df.c (df_bitmaps_alloc, df_bitmaps_free, df_alloc, df_analyse_1, df_modified_p, df_refs_unlink, df_dump): Likewise. * dominance.c (calc_dfs_tree, calculate_dominance_info): Likewise. * final.c (compute_alignments): Likewise. * flow.c (update_life_info, update_life_info_in_dirty_blocks, delete_noop_moves, calculate_global_regs_live, allocate_bb_life_data, count_or_remove_death_notes): Likewise. * gcse.c (oprs_unchanged_p, record_last_reg_set_info, compute_hash_table, compute_kill_rd, compute_rd, compute_ae_kill, classic_gcse, compute_transp, cprop, compute_pre_data, compute_transpout, invalidate_nonnull_info, delete_null_pointer_checks_1, delete_null_pointer_checks, compute_code_hoist_vbeinout, hoist_code, compute_ld_motion_mems, compute_store_table, build_store_vectors, store_motion): Likewise. * global.c (global_conflicts, mark_elimination): Likewise. * graph.c (print_rtl_graph_with_bb): Likewise. * haifa-sched.c (sched_init): Likewise. * ifcvt.c (if_convert): Likewise. * lcm.c (compute_antinout_edge, compute_laterin, compute_insert_delete, compute_available, compute_nearerout, compute_rev_insert_delete, optimize_mode_switching): Likewise. * local-alloc.c (local_alloc, update_equiv_regs): Likewise. * predict.c (estimate_probability, note_prediction_to_br_prob, propagate_freq, counts_to_freqs, expensive_function_p, estimate_bb_frequencies): Likewise. * profile.c (instrument_edges, get_exec_counts, compute_branch_probabilities, compute_checksum, branch_prob, find_spanning_tree): Likewise. * recog.c (split_all_insns, peephole2_optimize): Likewise. * reg-stack.c (reg_to_stack, convert_regs_entry, convert_regs): Likewise. * regclass.c (scan_one_insn, regclass): Likewise. * regmove.c (mark_flags_life_zones, regmove_optimize, record_stack_memrefs): Likewise. * regrename.c (regrename_optimize, copyprop_hardreg_forward): Likewise. * reload1.c (reload, reload_combine, fixup_abnormal_edges): Likewise. * resource.c (find_basic_block): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (is_cfg_nonregular, build_control_flow, find_single_block_region, find_rgns, schedule_insns) * sibcall.c (optimize_sibling_and_tail_recursive_call) * ssa-ccp.c (optimize_unexecutable_edges, ssa_ccp_df_delete_unreachable_insns): Likewise. * ssa-dce.c (ssa_eliminate_dead_code): Likewise. * ssa.c (find_evaluations, compute_dominance_frontiers_1, rename_block, convert_to_ssa, compute_conservative_reg_partition, compute_coalesced_reg_partition, rename_equivalent_regs, convert_from_ssa): Likewise. * config/ia64/ia64.c (emit_predicate_relation_info, process_epilogue, process_for_unwind_directive): Likewise. * df.c (FOR_ALL_BBS): Removed. * gcse.c (struct null_pointer_info): Type of current_block field changed. (struct reg_avail_info): Type of last_bb field changed. * config/ia64/ia64.c (block_num): Removed. (need_copy_state): Type changed. (last_block): New. From-SVN: r53804
2002-05-23 21:23:51 +02:00
int inserted = 0;
edge e;
bb-reorder.c (make_reorder_chain, [...]): Use FOR_EACH_BB macros to iterate over basic block chain. * bb-reorder.c (make_reorder_chain, make_reorder_chain_1): Use FOR_EACH_BB macros to iterate over basic block chain. * cfg.c (clear_edges, clear_bb_flags, dump_flow_info, alloc_aux_for_blocks, clear_aux_for_blocks, alloc_aux_for_edges): Likewise. * cfganal.c (set_edge_can_fallthru_flag, flow_call_edges_add, find_unreachable_blocks, create_edge_list, verify_edge_list, remove_fake_edges, add_noreturn_fake_exit_edges, flow_preorder_transversal_compute, flow_dfs_compute_reverse_execute): Likewise. * cfgbuild.c (make_edges, find_basic_blocks, find_many_sub_basic_blocks, find_sub_basic_blocks): Likewise. * cfgcleanup.c (try_optimize_cfg, delete_unreachable_blocks): Likewise. * cfglayout.c (record_effective_endpoints, cleanup_unconditional_jumps): Likewise. * cfgloop.c (flow_loops_cfg_dump, flow_loops_find): Likewise. * cfgrtl.c (compute_bb_for_insn, tidy_fallthru_edges, commit_edge_insertions, commit_edge_insertions_watch_calls, print_rtl_with_bb, verify_flow_info, purge_all_dead_edges): Likewise. * combine.c (combine_instructions, reg_dead_at_p): Likewise. * conflict.c (conflict_graph_compute): Likewise. * df.c (df_bitmaps_alloc, df_bitmaps_free, df_alloc, df_analyse_1, df_modified_p, df_refs_unlink, df_dump): Likewise. * dominance.c (calc_dfs_tree, calculate_dominance_info): Likewise. * final.c (compute_alignments): Likewise. * flow.c (update_life_info, update_life_info_in_dirty_blocks, delete_noop_moves, calculate_global_regs_live, allocate_bb_life_data, count_or_remove_death_notes): Likewise. * gcse.c (oprs_unchanged_p, record_last_reg_set_info, compute_hash_table, compute_kill_rd, compute_rd, compute_ae_kill, classic_gcse, compute_transp, cprop, compute_pre_data, compute_transpout, invalidate_nonnull_info, delete_null_pointer_checks_1, delete_null_pointer_checks, compute_code_hoist_vbeinout, hoist_code, compute_ld_motion_mems, compute_store_table, build_store_vectors, store_motion): Likewise. * global.c (global_conflicts, mark_elimination): Likewise. * graph.c (print_rtl_graph_with_bb): Likewise. * haifa-sched.c (sched_init): Likewise. * ifcvt.c (if_convert): Likewise. * lcm.c (compute_antinout_edge, compute_laterin, compute_insert_delete, compute_available, compute_nearerout, compute_rev_insert_delete, optimize_mode_switching): Likewise. * local-alloc.c (local_alloc, update_equiv_regs): Likewise. * predict.c (estimate_probability, note_prediction_to_br_prob, propagate_freq, counts_to_freqs, expensive_function_p, estimate_bb_frequencies): Likewise. * profile.c (instrument_edges, get_exec_counts, compute_branch_probabilities, compute_checksum, branch_prob, find_spanning_tree): Likewise. * recog.c (split_all_insns, peephole2_optimize): Likewise. * reg-stack.c (reg_to_stack, convert_regs_entry, convert_regs): Likewise. * regclass.c (scan_one_insn, regclass): Likewise. * regmove.c (mark_flags_life_zones, regmove_optimize, record_stack_memrefs): Likewise. * regrename.c (regrename_optimize, copyprop_hardreg_forward): Likewise. * reload1.c (reload, reload_combine, fixup_abnormal_edges): Likewise. * resource.c (find_basic_block): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (is_cfg_nonregular, build_control_flow, find_single_block_region, find_rgns, schedule_insns) * sibcall.c (optimize_sibling_and_tail_recursive_call) * ssa-ccp.c (optimize_unexecutable_edges, ssa_ccp_df_delete_unreachable_insns): Likewise. * ssa-dce.c (ssa_eliminate_dead_code): Likewise. * ssa.c (find_evaluations, compute_dominance_frontiers_1, rename_block, convert_to_ssa, compute_conservative_reg_partition, compute_coalesced_reg_partition, rename_equivalent_regs, convert_from_ssa): Likewise. * config/ia64/ia64.c (emit_predicate_relation_info, process_epilogue, process_for_unwind_directive): Likewise. * df.c (FOR_ALL_BBS): Removed. * gcse.c (struct null_pointer_info): Type of current_block field changed. (struct reg_avail_info): Type of last_bb field changed. * config/ia64/ia64.c (block_num): Removed. (need_copy_state): Type changed. (last_block): New. From-SVN: r53804
2002-05-23 21:23:51 +02:00
basic_block block;
1991-12-26 11:05:42 +01:00
bb-reorder.c (make_reorder_chain, [...]): Use FOR_EACH_BB macros to iterate over basic block chain. * bb-reorder.c (make_reorder_chain, make_reorder_chain_1): Use FOR_EACH_BB macros to iterate over basic block chain. * cfg.c (clear_edges, clear_bb_flags, dump_flow_info, alloc_aux_for_blocks, clear_aux_for_blocks, alloc_aux_for_edges): Likewise. * cfganal.c (set_edge_can_fallthru_flag, flow_call_edges_add, find_unreachable_blocks, create_edge_list, verify_edge_list, remove_fake_edges, add_noreturn_fake_exit_edges, flow_preorder_transversal_compute, flow_dfs_compute_reverse_execute): Likewise. * cfgbuild.c (make_edges, find_basic_blocks, find_many_sub_basic_blocks, find_sub_basic_blocks): Likewise. * cfgcleanup.c (try_optimize_cfg, delete_unreachable_blocks): Likewise. * cfglayout.c (record_effective_endpoints, cleanup_unconditional_jumps): Likewise. * cfgloop.c (flow_loops_cfg_dump, flow_loops_find): Likewise. * cfgrtl.c (compute_bb_for_insn, tidy_fallthru_edges, commit_edge_insertions, commit_edge_insertions_watch_calls, print_rtl_with_bb, verify_flow_info, purge_all_dead_edges): Likewise. * combine.c (combine_instructions, reg_dead_at_p): Likewise. * conflict.c (conflict_graph_compute): Likewise. * df.c (df_bitmaps_alloc, df_bitmaps_free, df_alloc, df_analyse_1, df_modified_p, df_refs_unlink, df_dump): Likewise. * dominance.c (calc_dfs_tree, calculate_dominance_info): Likewise. * final.c (compute_alignments): Likewise. * flow.c (update_life_info, update_life_info_in_dirty_blocks, delete_noop_moves, calculate_global_regs_live, allocate_bb_life_data, count_or_remove_death_notes): Likewise. * gcse.c (oprs_unchanged_p, record_last_reg_set_info, compute_hash_table, compute_kill_rd, compute_rd, compute_ae_kill, classic_gcse, compute_transp, cprop, compute_pre_data, compute_transpout, invalidate_nonnull_info, delete_null_pointer_checks_1, delete_null_pointer_checks, compute_code_hoist_vbeinout, hoist_code, compute_ld_motion_mems, compute_store_table, build_store_vectors, store_motion): Likewise. * global.c (global_conflicts, mark_elimination): Likewise. * graph.c (print_rtl_graph_with_bb): Likewise. * haifa-sched.c (sched_init): Likewise. * ifcvt.c (if_convert): Likewise. * lcm.c (compute_antinout_edge, compute_laterin, compute_insert_delete, compute_available, compute_nearerout, compute_rev_insert_delete, optimize_mode_switching): Likewise. * local-alloc.c (local_alloc, update_equiv_regs): Likewise. * predict.c (estimate_probability, note_prediction_to_br_prob, propagate_freq, counts_to_freqs, expensive_function_p, estimate_bb_frequencies): Likewise. * profile.c (instrument_edges, get_exec_counts, compute_branch_probabilities, compute_checksum, branch_prob, find_spanning_tree): Likewise. * recog.c (split_all_insns, peephole2_optimize): Likewise. * reg-stack.c (reg_to_stack, convert_regs_entry, convert_regs): Likewise. * regclass.c (scan_one_insn, regclass): Likewise. * regmove.c (mark_flags_life_zones, regmove_optimize, record_stack_memrefs): Likewise. * regrename.c (regrename_optimize, copyprop_hardreg_forward): Likewise. * reload1.c (reload, reload_combine, fixup_abnormal_edges): Likewise. * resource.c (find_basic_block): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (is_cfg_nonregular, build_control_flow, find_single_block_region, find_rgns, schedule_insns) * sibcall.c (optimize_sibling_and_tail_recursive_call) * ssa-ccp.c (optimize_unexecutable_edges, ssa_ccp_df_delete_unreachable_insns): Likewise. * ssa-dce.c (ssa_eliminate_dead_code): Likewise. * ssa.c (find_evaluations, compute_dominance_frontiers_1, rename_block, convert_to_ssa, compute_conservative_reg_partition, compute_coalesced_reg_partition, rename_equivalent_regs, convert_from_ssa): Likewise. * config/ia64/ia64.c (emit_predicate_relation_info, process_epilogue, process_for_unwind_directive): Likewise. * df.c (FOR_ALL_BBS): Removed. * gcse.c (struct null_pointer_info): Type of current_block field changed. (struct reg_avail_info): Type of last_bb field changed. * config/ia64/ia64.c (block_num): Removed. (need_copy_state): Type changed. (last_block): New. From-SVN: r53804
2002-05-23 21:23:51 +02:00
FOR_EACH_BB_REVERSE (block)
1991-12-26 11:05:42 +01:00
{
block_info bi = BLOCK_INFO (block);
int reg;
/* Set current register status at last instruction `uninitialized'. */
bi->stack_in.top = -2;
/* Copy live_at_end and live_at_start into temporaries. */
for (reg = FIRST_STACK_REG; reg <= LAST_STACK_REG; reg++)
1991-12-26 11:05:42 +01:00
{
if (REGNO_REG_SET_P (block->global_live_at_end, reg))
SET_HARD_REG_BIT (bi->out_reg_set, reg);
if (REGNO_REG_SET_P (block->global_live_at_start, reg))
SET_HARD_REG_BIT (bi->stack_in.reg_set, reg);
1991-12-26 11:05:42 +01:00
}
}
/* Load something into each stack register live at function entry.
Such live registers can be caused by uninitialized variables or
functions not returning values on all paths. In order to keep
the push/pop code happy, and to not scrog the register stack, we
must put something in these registers. Use a QNaN.
1991-12-26 11:05:42 +01:00
Note that we are inserting converted code here. This code is
never seen by the convert_regs pass. */
1991-12-26 11:05:42 +01:00
for (e = ENTRY_BLOCK_PTR->succ; e ; e = e->succ_next)
{
basic_block block = e->dest;
block_info bi = BLOCK_INFO (block);
int reg, top = -1;
1991-12-26 11:05:42 +01:00
for (reg = LAST_STACK_REG; reg >= FIRST_STACK_REG; --reg)
if (TEST_HARD_REG_BIT (bi->stack_in.reg_set, reg))
{
rtx init;
1991-12-26 11:05:42 +01:00
bi->stack_in.reg[++top] = reg;
1991-12-26 11:05:42 +01:00
init = gen_rtx_SET (VOIDmode,
FP_MODE_REG (FIRST_STACK_REG, SFmode),
nan);
insert_insn_on_edge (init, e);
inserted = 1;
}
1991-12-26 11:05:42 +01:00
bi->stack_in.top = top;
}
1991-12-26 11:05:42 +01:00
return inserted;
}
1991-12-26 11:05:42 +01:00
/* Construct the desired stack for function exit. This will either
be `empty', or the function return value at top-of-stack. */
1991-12-26 11:05:42 +01:00
static void
convert_regs_exit (void)
{
int value_reg_low, value_reg_high;
stack output_stack;
rtx retvalue;
1991-12-26 11:05:42 +01:00
retvalue = stack_result (current_function_decl);
value_reg_low = value_reg_high = -1;
if (retvalue)
{
value_reg_low = REGNO (retvalue);
value_reg_high = value_reg_low
+ HARD_REGNO_NREGS (value_reg_low, GET_MODE (retvalue)) - 1;
}
1991-12-26 11:05:42 +01:00
output_stack = &BLOCK_INFO (EXIT_BLOCK_PTR)->stack_in;
if (value_reg_low == -1)
output_stack->top = -1;
else
{
int reg;
1991-12-26 11:05:42 +01:00
output_stack->top = value_reg_high - value_reg_low;
for (reg = value_reg_low; reg <= value_reg_high; ++reg)
{
output_stack->reg[value_reg_high - reg] = reg;
SET_HARD_REG_BIT (output_stack->reg_set, reg);
}
}
1991-12-26 11:05:42 +01:00
}
/* Adjust the stack of this block on exit to match the stack of the
target block, or copy stack info into the stack of the successor
of the successor hasn't been processed yet. */
static bool
compensate_edge (edge e, FILE *file)
{
basic_block block = e->src, target = e->dest;
block_info bi = BLOCK_INFO (block);
struct stack_def regstack, tmpstack;
stack target_stack = &BLOCK_INFO (target)->stack_in;
int reg;
current_block = block;
regstack = bi->stack_out;
if (file)
fprintf (file, "Edge %d->%d: ", block->index, target->index);
if (target_stack->top == -2)
{
/* The target block hasn't had a stack order selected.
We need merely ensure that no pops are needed. */
for (reg = regstack.top; reg >= 0; --reg)
if (!TEST_HARD_REG_BIT (target_stack->reg_set, regstack.reg[reg]))
break;
if (reg == -1)
{
if (file)
fprintf (file, "new block; copying stack position\n");
/* change_stack kills values in regstack. */
tmpstack = regstack;
change_stack (block->end, &tmpstack, target_stack, EMIT_AFTER);
return false;
}
if (file)
fprintf (file, "new block; pops needed\n");
}
else
{
if (target_stack->top == regstack.top)
{
for (reg = target_stack->top; reg >= 0; --reg)
if (target_stack->reg[reg] != regstack.reg[reg])
break;
if (reg == -1)
{
if (file)
fprintf (file, "no changes needed\n");
return false;
}
}
if (file)
{
fprintf (file, "correcting stack to ");
print_stack (file, target_stack);
}
}
/* Care for non-call EH edges specially. The normal return path have
values in registers. These will be popped en masse by the unwind
library. */
if ((e->flags & (EDGE_EH | EDGE_ABNORMAL_CALL)) == EDGE_EH)
target_stack->top = -1;
/* Other calls may appear to have values live in st(0), but the
abnormal return path will not have actually loaded the values. */
else if (e->flags & EDGE_ABNORMAL_CALL)
{
/* Assert that the lifetimes are as we expect -- one value
live at st(0) on the end of the source block, and no
values live at the beginning of the destination block. */
HARD_REG_SET tmp;
CLEAR_HARD_REG_SET (tmp);
GO_IF_HARD_REG_EQUAL (target_stack->reg_set, tmp, eh1);
abort ();
eh1:
/* We are sure that there is st(0) live, otherwise we won't compensate.
For complex return values, we may have st(1) live as well. */
SET_HARD_REG_BIT (tmp, FIRST_STACK_REG);
if (TEST_HARD_REG_BIT (regstack.reg_set, FIRST_STACK_REG + 1))
SET_HARD_REG_BIT (tmp, FIRST_STACK_REG + 1);
GO_IF_HARD_REG_EQUAL (regstack.reg_set, tmp, eh2);
abort ();
eh2:
target_stack->top = -1;
}
/* It is better to output directly to the end of the block
instead of to the edge, because emit_swap can do minimal
insn scheduling. We can do this when there is only one
edge out, and it is not abnormal. */
else if (block->succ->succ_next == NULL && !(e->flags & EDGE_ABNORMAL))
{
/* change_stack kills values in regstack. */
tmpstack = regstack;
change_stack (block->end, &tmpstack, target_stack,
(GET_CODE (block->end) == JUMP_INSN
? EMIT_BEFORE : EMIT_AFTER));
}
else
{
rtx seq, after;
/* We don't support abnormal edges. Global takes care to
avoid any live register across them, so we should never
have to insert instructions on such edges. */
if (e->flags & EDGE_ABNORMAL)
abort ();
current_block = NULL;
start_sequence ();
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
/* ??? change_stack needs some point to emit insns after. */
rtl.h (emit_note): Remove FILE parameter. * rtl.h (emit_note): Remove FILE parameter. * emit-rtl.c (emit_line_note): Adjust emit_note call. (emit_note): Remove FILE parameter. Adjust. * builtins.c (expand_builtin_expect): Adjust emit_note call. * c-semantics.c (genrtl_scope_stmt): Likewise. (expand_stmt): Likewise. * cfglayout.c (reemit_insn_block_notes): Likewise. (duplicate_insn_chain): Likewise. * except.c (expand_eh_region_start, expand_eh_region_end, sjlj_emit_function_enter): Likewise. * explow.c (probe_stack_range): Likewise. * expr.c (emit_block_move_via_loop): Likewise. * function.c (init_function_start, expand_function_start, expand_function_end, thread_prologue_and_epilogue_insns): Likewise. * integrate.c (expand_inline_function, copy_insn_list): Likewise. * reg-stack.c (compensate_edge): Likewise. * reload1.c (reload): Likewise. * rtlanal.c (hoist_insn_to_edge): Likewise. * stmt.c (expand_fixup, expand_start_loop, expand_start_null_loop, expand_loop_continue_here, expand_end_loop, expand_continue_loop, expand_exit_loop_top_cond, expand_value_return, expand_start_bindings_and_block, expand_end_bindings, expand_decl_cleanup, expand_start_case): Likewise. * unroll.c (copy_loop_body * config/alpha/alpha.c (alpha_output_mi_thunk_osf): Likewise. * config/ia64/ia64.c (ia64_output_mi_thunk): Likewise. * config/rs6000/rs6000.c (rs6000_emit_eh_toc_restore, rs6000_emit_allocate_stack, rs6000_output_function_prologue, rs6000_output_function_epilogue, rs6000_output_mi_thunk): Likewise. * config/sh/sh.c (sh_output_mi_thunk): Likewise. * config/sparc/sparc.c (sparc_output_mi_thunk): Likewise. * ada/misc.c (record_code_position): Likewise. From-SVN: r68561
2003-06-27 11:49:44 +02:00
after = emit_note (NOTE_INSN_DELETED);
tmpstack = regstack;
change_stack (after, &tmpstack, target_stack, EMIT_BEFORE);
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
seq = get_insns ();
end_sequence ();
insert_insn_on_edge (seq, e);
return true;
}
return false;
}
/* Convert stack register references in one block. */
static int
convert_regs_1 (FILE *file, basic_block block)
1991-12-26 11:05:42 +01:00
{
struct stack_def regstack;
block_info bi = BLOCK_INFO (block);
int deleted, inserted, reg;
rtx insn, next;
edge e, beste = NULL;
1991-12-26 11:05:42 +01:00
inserted = 0;
deleted = 0;
any_malformed_asm = false;
/* Find the edge we will copy stack from. It should be the most frequent
one as it will get cheapest after compensation code is generated,
if multiple such exists, take one with largest count, prefer critical
one (as splitting critical edges is more expensive), or one with lowest
index, to avoid random changes with different orders of the edges. */
for (e = block->pred; e ; e = e->pred_next)
{
if (e->flags & EDGE_DFS_BACK)
;
else if (! beste)
beste = e;
else if (EDGE_FREQUENCY (beste) < EDGE_FREQUENCY (e))
beste = e;
else if (EDGE_FREQUENCY (beste) > EDGE_FREQUENCY (e))
;
else if (beste->count < e->count)
beste = e;
else if (beste->count > e->count)
;
basic-block.h (EDGE_CRITICAL): Remove; renumber other flags. * basic-block.h (EDGE_CRITICAL): Remove; renumber other flags. (EDGE_CRITICAL_P): New predicate. * cfg.c (force_nonfallthru_and_redirect, split_edge): Kill EDGE_CRITICAL handling. (insert_insn_on_edge): Use EDGE_CRITICAL_P. (dump_edge_info): Remove "crit". * cfganal.c (mark_critical_edges): Kill. * cfgbuild.c (find_basic_blocks): Remove mark_critical_edges call. * cfgcleanup.c (cleanup_cfg): Likewise. * profile.c (instrument_edges): Use EDGE_CRITICAL_P. (find_spanning_tree): Likewise. * reg-stack.c (convert_regs_1): Likewise. * ssa.c (mark_regs_equivalent_over_bad_edges): Likewise. * basic-block.h (create_basic_block_structure): New. (create_basic_block): Update prototype. (force_nonfallthru): New. * bb-reorder.c (fixup_reorder_chain): Fixup use force_nonfallthru. * cfg.c (create_basic_block_structure): Rename from create_basic_block; handle updating of block_for_insn, creating of empty BBs and BBs at the end of INSN chain. (create_basic_block): New function. (split_block): Use create_basic_block. (force_nonfallthru_and_redirect): Break out from ...; cleanup (redirect_edge_and_branch_force): ... here. (force_nonfallthru): New. (split_edge): Rewrite to use force_nonfallthru and create_block. * cfgbuild.c (find_basic_blocks_1): Use create_basic_block_structure. (find_basic_blocks): Free basic_block_for_insn. * cfgcleanup.c (merge_blocks): Use force_nonfallthru. * cfg.c: Fix formating. * cfgcleanup.c: Fix formating. (merge_blocks, tail_recursion_label_p): Return bool. (merge_blocks_move_predecessor_nojumps, merge_blocks_move_successor_nojumps): Return void. From-SVN: r45549
2001-09-11 18:58:57 +02:00
else if ((EDGE_CRITICAL_P (e) != 0)
!= (EDGE_CRITICAL_P (beste) != 0))
{
basic-block.h (EDGE_CRITICAL): Remove; renumber other flags. * basic-block.h (EDGE_CRITICAL): Remove; renumber other flags. (EDGE_CRITICAL_P): New predicate. * cfg.c (force_nonfallthru_and_redirect, split_edge): Kill EDGE_CRITICAL handling. (insert_insn_on_edge): Use EDGE_CRITICAL_P. (dump_edge_info): Remove "crit". * cfganal.c (mark_critical_edges): Kill. * cfgbuild.c (find_basic_blocks): Remove mark_critical_edges call. * cfgcleanup.c (cleanup_cfg): Likewise. * profile.c (instrument_edges): Use EDGE_CRITICAL_P. (find_spanning_tree): Likewise. * reg-stack.c (convert_regs_1): Likewise. * ssa.c (mark_regs_equivalent_over_bad_edges): Likewise. * basic-block.h (create_basic_block_structure): New. (create_basic_block): Update prototype. (force_nonfallthru): New. * bb-reorder.c (fixup_reorder_chain): Fixup use force_nonfallthru. * cfg.c (create_basic_block_structure): Rename from create_basic_block; handle updating of block_for_insn, creating of empty BBs and BBs at the end of INSN chain. (create_basic_block): New function. (split_block): Use create_basic_block. (force_nonfallthru_and_redirect): Break out from ...; cleanup (redirect_edge_and_branch_force): ... here. (force_nonfallthru): New. (split_edge): Rewrite to use force_nonfallthru and create_block. * cfgbuild.c (find_basic_blocks_1): Use create_basic_block_structure. (find_basic_blocks): Free basic_block_for_insn. * cfgcleanup.c (merge_blocks): Use force_nonfallthru. * cfg.c: Fix formating. * cfgcleanup.c: Fix formating. (merge_blocks, tail_recursion_label_p): Return bool. (merge_blocks_move_predecessor_nojumps, merge_blocks_move_successor_nojumps): Return void. From-SVN: r45549
2001-09-11 18:58:57 +02:00
if (EDGE_CRITICAL_P (e))
beste = e;
}
else if (e->src->index < beste->src->index)
beste = e;
}
/* Entry block does have stack already initialized. */
if (bi->stack_in.top == -2)
inserted |= compensate_edge (beste, file);
else
beste = NULL;
current_block = block;
if (file)
1991-12-26 11:05:42 +01:00
{
fprintf (file, "\nBasic block %d\nInput stack: ", block->index);
print_stack (file, &bi->stack_in);
}
1991-12-26 11:05:42 +01:00
/* Process all insns in this block. Keep track of NEXT so that we
don't process insns emitted while substituting in INSN. */
next = block->head;
regstack = bi->stack_in;
do
{
insn = next;
next = NEXT_INSN (insn);
1991-12-26 11:05:42 +01:00
/* Ensure we have not missed a block boundary. */
if (next == NULL)
abort ();
if (insn == block->end)
next = NULL;
/* Don't bother processing unless there is a stack reg
mentioned or if it's a CALL_INSN. */
if (stack_regs_mentioned (insn)
|| GET_CODE (insn) == CALL_INSN)
{
if (file)
{
fprintf (file, " insn %d input stack: ",
INSN_UID (insn));
print_stack (file, &regstack);
}
subst_stack_regs (insn, &regstack);
deleted |= (GET_CODE (insn) == NOTE || INSN_DELETED_P (insn));
1991-12-26 11:05:42 +01:00
}
}
while (next);
1991-12-26 11:05:42 +01:00
if (file)
{
fprintf (file, "Expected live registers [");
for (reg = FIRST_STACK_REG; reg <= LAST_STACK_REG; ++reg)
if (TEST_HARD_REG_BIT (bi->out_reg_set, reg))
fprintf (file, " %d", reg);
fprintf (file, " ]\nOutput stack: ");
print_stack (file, &regstack);
}
1991-12-26 11:05:42 +01:00
insn = block->end;
if (GET_CODE (insn) == JUMP_INSN)
insn = PREV_INSN (insn);
/* If the function is declared to return a value, but it returns one
in only some cases, some registers might come live here. Emit
necessary moves for them. */
for (reg = FIRST_STACK_REG; reg <= LAST_STACK_REG; ++reg)
{
if (TEST_HARD_REG_BIT (bi->out_reg_set, reg)
&& ! TEST_HARD_REG_BIT (regstack.reg_set, reg))
1991-12-26 11:05:42 +01:00
{
rtx set;
1991-12-26 11:05:42 +01:00
if (file)
{
fprintf (file, "Emitting insn initializing reg %d\n",
reg);
}
1991-12-26 11:05:42 +01:00
set = gen_rtx_SET (VOIDmode, FP_MODE_REG (reg, SFmode),
nan);
basic-block.h (free_bb_for_insn): Declare. * basic-block.h (free_bb_for_insn): Declare. * bb-reorder.c (label_for_bb): Use block_label. (emit_jump_to_block_after): Remove. (insert_intra_1): Do not update block_for_insn. (insert_inter_bb_scope_notes): Likewise; update bb->end * cfg.c (free_bb_for_insn): New. (try_rediret_by_replacing_jump): Avoid set_block_for_new_insns call. (force_nonfallthru_and_redirect): Likewise; do not update BB boundaries. (commit_one_edge_insertion): Likewise. (commit_one_edge_insertion): Do not update BB boundary. (commit_edge_insertions): Do not call compute_bb_for_insn. * cfgbuild.c (find_basic_blocks): Do not free basic_block_for_insn. * cfgcleanup.c (merge_blocks_move_predecessor): Use reorder_insns_nobb. (merge_blocks_move_successor_nojumps): Likewise. (try_crossjump_to_edge): Do not update block_for_insn. * combine.c (combine_instructions): Remove compute_bb_for_insn call. * df.c (df_pattern_emit_later): Do not update BB boundary. (df_jump_pattern_emit_after): Likewise. (df_insn_move_before): Use emit_insn_before. * emit-rtl.c (try_split): Emit after trial to get bb boundary updated properly. (add_insn_after, add_insn_before, emit_insns_after): Update BB boundaries and basic_block_for_insn. (reorder_insns_nobb): Rename from reorder_insns. (reorder_insns): New. (emit_block_insn_before, emit_block_insn_after): Kill. * flow.c (check_function_return_warnings): Do not call compute_bb_for_insn; Do not free basic_block_for_insn. (attempt_auto_inc): Do not update basic_block_for_insn. * function.c (emit_return_into_block): Likewise; do not update BB boundaries. * gcse.c (handle_avail_expr): Do not update basic_block_for_insn. (insert_insn_end_bb): Use emit_insn_before; Likewise. (pre_insert_copy_insn): Likewise. (update_ld_motion_notes): Likewise. (insert_insn_start_bb): Likewise. (replace_store_insn): Likewise. * ifcvt.c (noce_process_if_block): Likewise. (if_convert): Do not call compute_bb_for_insn. * lcm.c (optimize_mode_switching): Do not update BB boundaries. Use emit_insn_before and emit_insn_after. * recog.c (split_all_insns): Do not update BB boundaries; Do not call compute_bb_for_insn. (peephole2_optimize): Do not update BB boundaries. * reg-stack.c (emit_pop_insn): Use emit_insn_after and emit_insn_before. (emit_swap_insn): Likewise. (convert_regs_1): Likewise. * reload1.c (reload): Call compute_bb_for_insn. * rtl.h (reorder_insns_nobb): Declare. * ssa.c (rename_equivalent_regs): Use emit_insn_before. * toplev.c (rest_of_compilation): Call free_bb_for_insn at places CFG is invalidated; do not call compute_bb_for_insn. * cfg.c (expunge_block): Invalidate BB structure. * (merge_blocks_nomove): Update properly BLOCK_FOR_INSN array. * cfg.c (verify_flow_info): Verify the basic_block_for_insn array. From-SVN: r45647
2001-09-16 22:21:30 +02:00
insn = emit_insn_after (set, insn);
subst_stack_regs (insn, &regstack);
deleted |= (GET_CODE (insn) == NOTE || INSN_DELETED_P (insn));
}
}
/* Amongst the insns possibly deleted during the substitution process above,
might have been the only trapping insn in the block. We purge the now
possibly dead EH edges here to avoid an ICE from fixup_abnormal_edges,
called at the end of convert_regs. The order in which we process the
blocks ensures that we never delete an already processed edge.
??? We are normally supposed not to delete trapping insns, so we pretend
that the insns deleted above don't actually trap. It would have been
better to detect this earlier and avoid creating the EH edge in the first
place, still, but we don't have enough information at that time. */
if (deleted)
purge_dead_edges (block);
1991-12-26 11:05:42 +01:00
/* Something failed if the stack lives don't match. If we had malformed
asms, we zapped the instruction itself, but that didn't produce the
same pattern of register kills as before. */
GO_IF_HARD_REG_EQUAL (regstack.reg_set, bi->out_reg_set, win);
if (!any_malformed_asm)
abort ();
win:
bi->stack_out = regstack;
1991-12-26 11:05:42 +01:00
/* Compensate the back edges, as those wasn't visited yet. */
for (e = block->succ; e ; e = e->succ_next)
{
if (e->flags & EDGE_DFS_BACK
|| (e->dest == EXIT_BLOCK_PTR))
{
if (!BLOCK_INFO (e->dest)->done
&& e->dest != block)
abort ();
inserted |= compensate_edge (e, file);
}
}
for (e = block->pred; e ; e = e->pred_next)
{
if (e != beste && !(e->flags & EDGE_DFS_BACK)
&& e->src != ENTRY_BLOCK_PTR)
{
if (!BLOCK_INFO (e->src)->done)
abort ();
inserted |= compensate_edge (e, file);
}
}
return inserted;
1991-12-26 11:05:42 +01:00
}
/* Convert registers in all blocks reachable from BLOCK. */
static int
convert_regs_2 (FILE *file, basic_block block)
1991-12-26 11:05:42 +01:00
{
basic_block *stack, *sp;
int inserted;
1991-12-26 11:05:42 +01:00
/* We process the blocks in a top-down manner, in a way such that one block
is only processed after all its predecessors. The number of predecessors
of every block has already been computed. */
stack = xmalloc (sizeof (*stack) * n_basic_blocks);
sp = stack;
1991-12-26 11:05:42 +01:00
*sp++ = block;
1991-12-26 11:05:42 +01:00
inserted = 0;
do
{
edge e;
1991-12-26 11:05:42 +01:00
block = *--sp;
1991-12-26 11:05:42 +01:00
/* Processing "block" is achieved by convert_regs_1, which may purge
some dead EH outgoing edge after the possible deletion of the
trapping insn inside the block. Since the number of predecessors of
"block"'s successors has been computed based on the initial edge set,
we check for the possibility to process some of these successors
before such an edge deletion may happen. */
for (e = block->succ; e ; e = e->succ_next)
if (! (e->flags & EDGE_DFS_BACK))
{
BLOCK_INFO (e->dest)->predecessors--;
if (!BLOCK_INFO (e->dest)->predecessors)
*sp++ = e->dest;
}
inserted |= convert_regs_1 (file, block);
BLOCK_INFO (block)->done = 1;
1991-12-26 11:05:42 +01:00
}
while (sp != stack);
return inserted;
1991-12-26 11:05:42 +01:00
}
/* Traverse all basic blocks in a function, converting the register
references in each insn from the "flat" register file that gcc uses,
to the stack-like registers the 387 uses. */
static int
convert_regs (FILE *file)
1991-12-26 11:05:42 +01:00
{
bb-reorder.c (make_reorder_chain, [...]): Use FOR_EACH_BB macros to iterate over basic block chain. * bb-reorder.c (make_reorder_chain, make_reorder_chain_1): Use FOR_EACH_BB macros to iterate over basic block chain. * cfg.c (clear_edges, clear_bb_flags, dump_flow_info, alloc_aux_for_blocks, clear_aux_for_blocks, alloc_aux_for_edges): Likewise. * cfganal.c (set_edge_can_fallthru_flag, flow_call_edges_add, find_unreachable_blocks, create_edge_list, verify_edge_list, remove_fake_edges, add_noreturn_fake_exit_edges, flow_preorder_transversal_compute, flow_dfs_compute_reverse_execute): Likewise. * cfgbuild.c (make_edges, find_basic_blocks, find_many_sub_basic_blocks, find_sub_basic_blocks): Likewise. * cfgcleanup.c (try_optimize_cfg, delete_unreachable_blocks): Likewise. * cfglayout.c (record_effective_endpoints, cleanup_unconditional_jumps): Likewise. * cfgloop.c (flow_loops_cfg_dump, flow_loops_find): Likewise. * cfgrtl.c (compute_bb_for_insn, tidy_fallthru_edges, commit_edge_insertions, commit_edge_insertions_watch_calls, print_rtl_with_bb, verify_flow_info, purge_all_dead_edges): Likewise. * combine.c (combine_instructions, reg_dead_at_p): Likewise. * conflict.c (conflict_graph_compute): Likewise. * df.c (df_bitmaps_alloc, df_bitmaps_free, df_alloc, df_analyse_1, df_modified_p, df_refs_unlink, df_dump): Likewise. * dominance.c (calc_dfs_tree, calculate_dominance_info): Likewise. * final.c (compute_alignments): Likewise. * flow.c (update_life_info, update_life_info_in_dirty_blocks, delete_noop_moves, calculate_global_regs_live, allocate_bb_life_data, count_or_remove_death_notes): Likewise. * gcse.c (oprs_unchanged_p, record_last_reg_set_info, compute_hash_table, compute_kill_rd, compute_rd, compute_ae_kill, classic_gcse, compute_transp, cprop, compute_pre_data, compute_transpout, invalidate_nonnull_info, delete_null_pointer_checks_1, delete_null_pointer_checks, compute_code_hoist_vbeinout, hoist_code, compute_ld_motion_mems, compute_store_table, build_store_vectors, store_motion): Likewise. * global.c (global_conflicts, mark_elimination): Likewise. * graph.c (print_rtl_graph_with_bb): Likewise. * haifa-sched.c (sched_init): Likewise. * ifcvt.c (if_convert): Likewise. * lcm.c (compute_antinout_edge, compute_laterin, compute_insert_delete, compute_available, compute_nearerout, compute_rev_insert_delete, optimize_mode_switching): Likewise. * local-alloc.c (local_alloc, update_equiv_regs): Likewise. * predict.c (estimate_probability, note_prediction_to_br_prob, propagate_freq, counts_to_freqs, expensive_function_p, estimate_bb_frequencies): Likewise. * profile.c (instrument_edges, get_exec_counts, compute_branch_probabilities, compute_checksum, branch_prob, find_spanning_tree): Likewise. * recog.c (split_all_insns, peephole2_optimize): Likewise. * reg-stack.c (reg_to_stack, convert_regs_entry, convert_regs): Likewise. * regclass.c (scan_one_insn, regclass): Likewise. * regmove.c (mark_flags_life_zones, regmove_optimize, record_stack_memrefs): Likewise. * regrename.c (regrename_optimize, copyprop_hardreg_forward): Likewise. * reload1.c (reload, reload_combine, fixup_abnormal_edges): Likewise. * resource.c (find_basic_block): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (is_cfg_nonregular, build_control_flow, find_single_block_region, find_rgns, schedule_insns) * sibcall.c (optimize_sibling_and_tail_recursive_call) * ssa-ccp.c (optimize_unexecutable_edges, ssa_ccp_df_delete_unreachable_insns): Likewise. * ssa-dce.c (ssa_eliminate_dead_code): Likewise. * ssa.c (find_evaluations, compute_dominance_frontiers_1, rename_block, convert_to_ssa, compute_conservative_reg_partition, compute_coalesced_reg_partition, rename_equivalent_regs, convert_from_ssa): Likewise. * config/ia64/ia64.c (emit_predicate_relation_info, process_epilogue, process_for_unwind_directive): Likewise. * df.c (FOR_ALL_BBS): Removed. * gcse.c (struct null_pointer_info): Type of current_block field changed. (struct reg_avail_info): Type of last_bb field changed. * config/ia64/ia64.c (block_num): Removed. (need_copy_state): Type changed. (last_block): New. From-SVN: r53804
2002-05-23 21:23:51 +02:00
int inserted;
basic_block b;
edge e;
1991-12-26 11:05:42 +01:00
/* Initialize uninitialized registers on function entry. */
inserted = convert_regs_entry ();
1991-12-26 11:05:42 +01:00
/* Construct the desired stack for function exit. */
convert_regs_exit ();
BLOCK_INFO (EXIT_BLOCK_PTR)->done = 1;
1991-12-26 11:05:42 +01:00
/* ??? Future: process inner loops first, and give them arbitrary
initial stacks which emit_swap_insn can modify. This ought to
prevent double fxch that aften appears at the head of a loop. */
1991-12-26 11:05:42 +01:00
/* Process all blocks reachable from all entry points. */
for (e = ENTRY_BLOCK_PTR->succ; e ; e = e->succ_next)
inserted |= convert_regs_2 (file, e->dest);
/* ??? Process all unreachable blocks. Though there's no excuse
for keeping these even when not optimizing. */
bb-reorder.c (make_reorder_chain, [...]): Use FOR_EACH_BB macros to iterate over basic block chain. * bb-reorder.c (make_reorder_chain, make_reorder_chain_1): Use FOR_EACH_BB macros to iterate over basic block chain. * cfg.c (clear_edges, clear_bb_flags, dump_flow_info, alloc_aux_for_blocks, clear_aux_for_blocks, alloc_aux_for_edges): Likewise. * cfganal.c (set_edge_can_fallthru_flag, flow_call_edges_add, find_unreachable_blocks, create_edge_list, verify_edge_list, remove_fake_edges, add_noreturn_fake_exit_edges, flow_preorder_transversal_compute, flow_dfs_compute_reverse_execute): Likewise. * cfgbuild.c (make_edges, find_basic_blocks, find_many_sub_basic_blocks, find_sub_basic_blocks): Likewise. * cfgcleanup.c (try_optimize_cfg, delete_unreachable_blocks): Likewise. * cfglayout.c (record_effective_endpoints, cleanup_unconditional_jumps): Likewise. * cfgloop.c (flow_loops_cfg_dump, flow_loops_find): Likewise. * cfgrtl.c (compute_bb_for_insn, tidy_fallthru_edges, commit_edge_insertions, commit_edge_insertions_watch_calls, print_rtl_with_bb, verify_flow_info, purge_all_dead_edges): Likewise. * combine.c (combine_instructions, reg_dead_at_p): Likewise. * conflict.c (conflict_graph_compute): Likewise. * df.c (df_bitmaps_alloc, df_bitmaps_free, df_alloc, df_analyse_1, df_modified_p, df_refs_unlink, df_dump): Likewise. * dominance.c (calc_dfs_tree, calculate_dominance_info): Likewise. * final.c (compute_alignments): Likewise. * flow.c (update_life_info, update_life_info_in_dirty_blocks, delete_noop_moves, calculate_global_regs_live, allocate_bb_life_data, count_or_remove_death_notes): Likewise. * gcse.c (oprs_unchanged_p, record_last_reg_set_info, compute_hash_table, compute_kill_rd, compute_rd, compute_ae_kill, classic_gcse, compute_transp, cprop, compute_pre_data, compute_transpout, invalidate_nonnull_info, delete_null_pointer_checks_1, delete_null_pointer_checks, compute_code_hoist_vbeinout, hoist_code, compute_ld_motion_mems, compute_store_table, build_store_vectors, store_motion): Likewise. * global.c (global_conflicts, mark_elimination): Likewise. * graph.c (print_rtl_graph_with_bb): Likewise. * haifa-sched.c (sched_init): Likewise. * ifcvt.c (if_convert): Likewise. * lcm.c (compute_antinout_edge, compute_laterin, compute_insert_delete, compute_available, compute_nearerout, compute_rev_insert_delete, optimize_mode_switching): Likewise. * local-alloc.c (local_alloc, update_equiv_regs): Likewise. * predict.c (estimate_probability, note_prediction_to_br_prob, propagate_freq, counts_to_freqs, expensive_function_p, estimate_bb_frequencies): Likewise. * profile.c (instrument_edges, get_exec_counts, compute_branch_probabilities, compute_checksum, branch_prob, find_spanning_tree): Likewise. * recog.c (split_all_insns, peephole2_optimize): Likewise. * reg-stack.c (reg_to_stack, convert_regs_entry, convert_regs): Likewise. * regclass.c (scan_one_insn, regclass): Likewise. * regmove.c (mark_flags_life_zones, regmove_optimize, record_stack_memrefs): Likewise. * regrename.c (regrename_optimize, copyprop_hardreg_forward): Likewise. * reload1.c (reload, reload_combine, fixup_abnormal_edges): Likewise. * resource.c (find_basic_block): Likewise. * sched-ebb.c (schedule_ebbs): Likewise. * sched-rgn.c (is_cfg_nonregular, build_control_flow, find_single_block_region, find_rgns, schedule_insns) * sibcall.c (optimize_sibling_and_tail_recursive_call) * ssa-ccp.c (optimize_unexecutable_edges, ssa_ccp_df_delete_unreachable_insns): Likewise. * ssa-dce.c (ssa_eliminate_dead_code): Likewise. * ssa.c (find_evaluations, compute_dominance_frontiers_1, rename_block, convert_to_ssa, compute_conservative_reg_partition, compute_coalesced_reg_partition, rename_equivalent_regs, convert_from_ssa): Likewise. * config/ia64/ia64.c (emit_predicate_relation_info, process_epilogue, process_for_unwind_directive): Likewise. * df.c (FOR_ALL_BBS): Removed. * gcse.c (struct null_pointer_info): Type of current_block field changed. (struct reg_avail_info): Type of last_bb field changed. * config/ia64/ia64.c (block_num): Removed. (need_copy_state): Type changed. (last_block): New. From-SVN: r53804
2002-05-23 21:23:51 +02:00
FOR_EACH_BB (b)
{
block_info bi = BLOCK_INFO (b);
1991-12-26 11:05:42 +01:00
if (! bi->done)
1991-12-26 11:05:42 +01:00
{
int reg;
1991-12-26 11:05:42 +01:00
/* Create an arbitrary input stack. */
bi->stack_in.top = -1;
for (reg = LAST_STACK_REG; reg >= FIRST_STACK_REG; --reg)
if (TEST_HARD_REG_BIT (bi->stack_in.reg_set, reg))
bi->stack_in.reg[++bi->stack_in.top] = reg;
1991-12-26 11:05:42 +01:00
inserted |= convert_regs_2 (file, b);
}
}
clear_aux_for_blocks ();
1991-12-26 11:05:42 +01:00
fixup_abnormal_edges ();
if (inserted)
commit_edge_insertions ();
1991-12-26 11:05:42 +01:00
if (file)
fputc ('\n', file);
1991-12-26 11:05:42 +01:00
return inserted;
1991-12-26 11:05:42 +01:00
}
#endif /* STACK_REGS */
#include "gt-reg-stack.h"