118334Speter/* Definitions for condition code handling in final.c and output routines.
218334Speter   Copyright (C) 1987 Free Software Foundation, Inc.
318334Speter
490075SobrienThis file is part of GCC.
518334Speter
690075SobrienGCC is free software; you can redistribute it and/or modify it under
790075Sobrienthe terms of the GNU General Public License as published by the Free
890075SobrienSoftware Foundation; either version 2, or (at your option) any later
990075Sobrienversion.
1018334Speter
1190075SobrienGCC is distributed in the hope that it will be useful, but WITHOUT ANY
1290075SobrienWARRANTY; without even the implied warranty of MERCHANTABILITY or
1390075SobrienFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1490075Sobrienfor more details.
1518334Speter
1618334SpeterYou should have received a copy of the GNU General Public License
1790075Sobrienalong with GCC; see the file COPYING.  If not, write to the Free
18169689SkanSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
19169689Skan02110-1301, USA.  */
2018334Speter
2118334Speter/* None of the things in the files exist if we don't use CC0.  */
2218334Speter
2318334Speter#ifdef HAVE_cc0
2418334Speter
2518334Speter/* The variable cc_status says how to interpret the condition code.
2618334Speter   It is set by output routines for an instruction that sets the cc's
2718334Speter   and examined by output routines for jump instructions.
2818334Speter
2918334Speter   cc_status contains two components named `value1' and `value2'
3018334Speter   that record two equivalent expressions for the values that the
3118334Speter   condition codes were set from.  (Either or both may be null if
3218334Speter   there is no useful expression to record.)  These fields are
3318334Speter   used for eliminating redundant test and compare instructions
3418334Speter   in the cases where the condition codes were already set by the
3518334Speter   previous instruction.
3618334Speter
3718334Speter   cc_status.flags contains flags which say that the condition codes
3818334Speter   were set in a nonstandard manner.  The output of jump instructions
3918334Speter   uses these flags to compensate and produce the standard result
4018334Speter   with the nonstandard condition codes.  Standard flags are defined here.
4118334Speter   The tm.h file can also define other machine-dependent flags.
4218334Speter
4318334Speter   cc_status also contains a machine-dependent component `mdep'
4418334Speter   whose type, `CC_STATUS_MDEP', may be defined as a macro in the
4518334Speter   tm.h file.  */
4618334Speter
4718334Speter#ifndef CC_STATUS_MDEP
4818334Speter#define CC_STATUS_MDEP int
4918334Speter#endif
5018334Speter
5118334Speter#ifndef CC_STATUS_MDEP_INIT
5218334Speter#define CC_STATUS_MDEP_INIT 0
5318334Speter#endif
5418334Speter
5518334Spetertypedef struct {int flags; rtx value1, value2; CC_STATUS_MDEP mdep;} CC_STATUS;
5618334Speter
5718334Speter/* While outputting an insn as assembler code,
5818334Speter   this is the status BEFORE that insn.  */
5918334Speterextern CC_STATUS cc_prev_status;
6018334Speter
6118334Speter/* While outputting an insn as assembler code,
6218334Speter   this is being altered to the status AFTER that insn.  */
6318334Speterextern CC_STATUS cc_status;
6418334Speter
6518334Speter/* These are the machine-independent flags:  */
6618334Speter
6718334Speter/* Set if the sign of the cc value is inverted:
6818334Speter   output a following jump-if-less as a jump-if-greater, etc.  */
6918334Speter#define CC_REVERSED 1
7018334Speter
7118334Speter/* This bit means that the current setting of the N bit is bogus
7218334Speter   and conditional jumps should use the Z bit in its place.
7318334Speter   This state obtains when an extraction of a signed single-bit field
7418334Speter   or an arithmetic shift right of a byte by 7 bits
7518334Speter   is turned into a btst, because btst does not set the N bit.  */
7618334Speter#define CC_NOT_POSITIVE 2
7718334Speter
7818334Speter/* This bit means that the current setting of the N bit is bogus
7918334Speter   and conditional jumps should pretend that the N bit is clear.
8018334Speter   Used after extraction of an unsigned bit
8118334Speter   or logical shift right of a byte by 7 bits is turned into a btst.
8218334Speter   The btst does not alter the N bit, but the result of that shift
8318334Speter   or extract is never negative.  */
8418334Speter#define CC_NOT_NEGATIVE 4
8518334Speter
8618334Speter/* This bit means that the current setting of the overflow flag
8718334Speter   is bogus and conditional jumps should pretend there is no overflow.  */
8850397Sobrien/* ??? Note that for most targets this macro is misnamed as it applies
8950397Sobrien   to the carry flag, not the overflow flag.  */
9018334Speter#define CC_NO_OVERFLOW 010
9118334Speter
9218334Speter/* This bit means that what ought to be in the Z bit
9318334Speter   should be tested as the complement of the N bit.  */
9418334Speter#define CC_Z_IN_NOT_N 020
9518334Speter
9618334Speter/* This bit means that what ought to be in the Z bit
9718334Speter   should be tested as the N bit.  */
9818334Speter#define CC_Z_IN_N 040
9918334Speter
10018334Speter/* Nonzero if we must invert the sense of the following branch, i.e.
10118334Speter   change EQ to NE.  This is not safe for IEEE floating point operations!
10218334Speter   It is intended for use only when a combination of arithmetic
10318334Speter   or logical insns can leave the condition codes set in a fortuitous
10418334Speter   (though inverted) state.  */
10518334Speter#define CC_INVERTED 0100
10618334Speter
10718334Speter/* Nonzero if we must convert signed condition operators to unsigned.
10890075Sobrien   This is only used by machine description files.  */
10918334Speter#define CC_NOT_SIGNED 0200
11018334Speter
11118334Speter/* This is how to initialize the variable cc_status.
11218334Speter   final does this at appropriate moments.  */
11318334Speter
11418334Speter#define CC_STATUS_INIT  \
11518334Speter (cc_status.flags = 0, cc_status.value1 = 0, cc_status.value2 = 0,  \
11618334Speter  CC_STATUS_MDEP_INIT)
11718334Speter
11818334Speter#endif
119