conditions.h revision 50397
116125Swpaul/* Definitions for condition code handling in final.c and output routines.
216125Swpaul   Copyright (C) 1987 Free Software Foundation, Inc.
316125Swpaul
416125SwpaulThis file is part of GNU CC.
516125Swpaul
616125SwpaulGNU CC is free software; you can redistribute it and/or modify
716125Swpaulit under the terms of the GNU General Public License as published by
816125Swpaulthe Free Software Foundation; either version 2, or (at your option)
916125Swpaulany later version.
1016125Swpaul
1116125SwpaulGNU CC is distributed in the hope that it will be useful,
1216125Swpaulbut WITHOUT ANY WARRANTY; without even the implied warranty of
1316125SwpaulMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1416125SwpaulGNU General Public License for more details.
1516125Swpaul
1616125SwpaulYou should have received a copy of the GNU General Public License
1716125Swpaulalong with GNU CC; see the file COPYING.  If not, write to
1816125Swpaulthe Free Software Foundation, 59 Temple Place - Suite 330,
1916125SwpaulBoston, MA 02111-1307, USA.  */
2016125Swpaul
2116125Swpaul/* None of the things in the files exist if we don't use CC0.  */
2216125Swpaul
2316125Swpaul#ifdef HAVE_cc0
2416125Swpaul
2516125Swpaul/* The variable cc_status says how to interpret the condition code.
2616125Swpaul   It is set by output routines for an instruction that sets the cc's
2716125Swpaul   and examined by output routines for jump instructions.
2816125Swpaul
2916125Swpaul   cc_status contains two components named `value1' and `value2'
3016125Swpaul   that record two equivalent expressions for the values that the
3150479Speter   condition codes were set from.  (Either or both may be null if
3216125Swpaul   there is no useful expression to record.)  These fields are
3316125Swpaul   used for eliminating redundant test and compare instructions
3416125Swpaul   in the cases where the condition codes were already set by the
3516125Swpaul   previous instruction.
3616125Swpaul
3716125Swpaul   cc_status.flags contains flags which say that the condition codes
3816125Swpaul   were set in a nonstandard manner.  The output of jump instructions
3916125Swpaul   uses these flags to compensate and produce the standard result
4068965Sru   with the nonstandard condition codes.  Standard flags are defined here.
4116125Swpaul   The tm.h file can also define other machine-dependent flags.
4216125Swpaul
4316125Swpaul   cc_status also contains a machine-dependent component `mdep'
4430378Scharnier   whose type, `CC_STATUS_MDEP', may be defined as a macro in the
45108317Sschweikh   tm.h file.  */
4657673Ssheldonh
47210723Sjoel#ifndef CC_STATUS_MDEP
4816125Swpaul#define CC_STATUS_MDEP int
4916125Swpaul#endif
5016125Swpaul
5116125Swpaul#ifndef CC_STATUS_MDEP_INIT
5216125Swpaul#define CC_STATUS_MDEP_INIT 0
5316125Swpaul#endif
5416125Swpaul
5516125Swpaultypedef struct {int flags; rtx value1, value2; CC_STATUS_MDEP mdep;} CC_STATUS;
5616125Swpaul
5716125Swpaul/* While outputting an insn as assembler code,
5816125Swpaul   this is the status BEFORE that insn.  */
5916125Swpaulextern CC_STATUS cc_prev_status;
6016125Swpaul
6116125Swpaul/* While outputting an insn as assembler code,
6216125Swpaul   this is being altered to the status AFTER that insn.  */
6316125Swpaulextern CC_STATUS cc_status;
6416125Swpaul
6516125Swpaul/* These are the machine-independent flags:  */
6616125Swpaul
6716125Swpaul/* Set if the sign of the cc value is inverted:
6816125Swpaul   output a following jump-if-less as a jump-if-greater, etc.  */
6916125Swpaul#define CC_REVERSED 1
7016125Swpaul
7116125Swpaul/* This bit means that the current setting of the N bit is bogus
7216125Swpaul   and conditional jumps should use the Z bit in its place.
7316125Swpaul   This state obtains when an extraction of a signed single-bit field
7416125Swpaul   or an arithmetic shift right of a byte by 7 bits
7557673Ssheldonh   is turned into a btst, because btst does not set the N bit.  */
7657673Ssheldonh#define CC_NOT_POSITIVE 2
7716125Swpaul
7816125Swpaul/* This bit means that the current setting of the N bit is bogus
7916125Swpaul   and conditional jumps should pretend that the N bit is clear.
8016125Swpaul   Used after extraction of an unsigned bit
8157673Ssheldonh   or logical shift right of a byte by 7 bits is turned into a btst.
8257673Ssheldonh   The btst does not alter the N bit, but the result of that shift
8316125Swpaul   or extract is never negative.  */
8416125Swpaul#define CC_NOT_NEGATIVE 4
8516125Swpaul
8616125Swpaul/* This bit means that the current setting of the overflow flag
8716125Swpaul   is bogus and conditional jumps should pretend there is no overflow.  */
8816125Swpaul/* ??? Note that for most targets this macro is misnamed as it applies
8930378Scharnier   to the carry flag, not the overflow flag.  */
9099968Scharnier#define CC_NO_OVERFLOW 010
9116125Swpaul
9257673Ssheldonh/* This bit means that what ought to be in the Z bit
9357673Ssheldonh   should be tested as the complement of the N bit.  */
9430378Scharnier#define CC_Z_IN_NOT_N 020
9557673Ssheldonh
96210723Sjoel/* This bit means that what ought to be in the Z bit
9716125Swpaul   should be tested as the N bit.  */
9816125Swpaul#define CC_Z_IN_N 040
9916125Swpaul
10016125Swpaul/* Nonzero if we must invert the sense of the following branch, i.e.
10116125Swpaul   change EQ to NE.  This is not safe for IEEE floating point operations!
10230378Scharnier   It is intended for use only when a combination of arithmetic
10399968Scharnier   or logical insns can leave the condition codes set in a fortuitous
10416125Swpaul   (though inverted) state.  */
10516125Swpaul#define CC_INVERTED 0100
10616125Swpaul
107163902Smaxim/* Nonzero if we must convert signed condition operators to unsigned.
108163902Smaxim   This is only used by machine description files. */
109163902Smaxim#define CC_NOT_SIGNED 0200
110163902Smaxim
111163902Smaxim/* This is how to initialize the variable cc_status.
11257673Ssheldonh   final does this at appropriate moments.  */
11316125Swpaul
11416125Swpaul#define CC_STATUS_INIT  \
11516125Swpaul (cc_status.flags = 0, cc_status.value1 = 0, cc_status.value2 = 0,  \
11616125Swpaul  CC_STATUS_MDEP_INIT)
11730378Scharnier
11830378Scharnier#endif
11916125Swpaul