xref: /dflybsd-src/contrib/gcc-4.7/gcc/conditions.h (revision 04febcfb30580676d3e95f58a16c5137ee478b32)
1*e4b17023SJohn Marino /* Definitions for condition code handling in final.c and output routines.
2*e4b17023SJohn Marino    Copyright (C) 1987, 2007 Free Software Foundation, Inc.
3*e4b17023SJohn Marino 
4*e4b17023SJohn Marino This file is part of GCC.
5*e4b17023SJohn Marino 
6*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under
7*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free
8*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later
9*e4b17023SJohn Marino version.
10*e4b17023SJohn Marino 
11*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14*e4b17023SJohn Marino for more details.
15*e4b17023SJohn Marino 
16*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
17*e4b17023SJohn Marino along with GCC; see the file COPYING3.  If not see
18*e4b17023SJohn Marino <http://www.gnu.org/licenses/>.  */
19*e4b17023SJohn Marino 
20*e4b17023SJohn Marino /* None of the things in the files exist if we don't use CC0.  */
21*e4b17023SJohn Marino 
22*e4b17023SJohn Marino #ifdef HAVE_cc0
23*e4b17023SJohn Marino 
24*e4b17023SJohn Marino /* The variable cc_status says how to interpret the condition code.
25*e4b17023SJohn Marino    It is set by output routines for an instruction that sets the cc's
26*e4b17023SJohn Marino    and examined by output routines for jump instructions.
27*e4b17023SJohn Marino 
28*e4b17023SJohn Marino    cc_status contains two components named `value1' and `value2'
29*e4b17023SJohn Marino    that record two equivalent expressions for the values that the
30*e4b17023SJohn Marino    condition codes were set from.  (Either or both may be null if
31*e4b17023SJohn Marino    there is no useful expression to record.)  These fields are
32*e4b17023SJohn Marino    used for eliminating redundant test and compare instructions
33*e4b17023SJohn Marino    in the cases where the condition codes were already set by the
34*e4b17023SJohn Marino    previous instruction.
35*e4b17023SJohn Marino 
36*e4b17023SJohn Marino    cc_status.flags contains flags which say that the condition codes
37*e4b17023SJohn Marino    were set in a nonstandard manner.  The output of jump instructions
38*e4b17023SJohn Marino    uses these flags to compensate and produce the standard result
39*e4b17023SJohn Marino    with the nonstandard condition codes.  Standard flags are defined here.
40*e4b17023SJohn Marino    The tm.h file can also define other machine-dependent flags.
41*e4b17023SJohn Marino 
42*e4b17023SJohn Marino    cc_status also contains a machine-dependent component `mdep'
43*e4b17023SJohn Marino    whose type, `CC_STATUS_MDEP', may be defined as a macro in the
44*e4b17023SJohn Marino    tm.h file.  */
45*e4b17023SJohn Marino 
46*e4b17023SJohn Marino #ifndef CC_STATUS_MDEP
47*e4b17023SJohn Marino #define CC_STATUS_MDEP int
48*e4b17023SJohn Marino #endif
49*e4b17023SJohn Marino 
50*e4b17023SJohn Marino #ifndef CC_STATUS_MDEP_INIT
51*e4b17023SJohn Marino #define CC_STATUS_MDEP_INIT 0
52*e4b17023SJohn Marino #endif
53*e4b17023SJohn Marino 
54*e4b17023SJohn Marino typedef struct {int flags; rtx value1, value2; CC_STATUS_MDEP mdep;} CC_STATUS;
55*e4b17023SJohn Marino 
56*e4b17023SJohn Marino /* While outputting an insn as assembler code,
57*e4b17023SJohn Marino    this is the status BEFORE that insn.  */
58*e4b17023SJohn Marino extern CC_STATUS cc_prev_status;
59*e4b17023SJohn Marino 
60*e4b17023SJohn Marino /* While outputting an insn as assembler code,
61*e4b17023SJohn Marino    this is being altered to the status AFTER that insn.  */
62*e4b17023SJohn Marino extern CC_STATUS cc_status;
63*e4b17023SJohn Marino 
64*e4b17023SJohn Marino /* These are the machine-independent flags:  */
65*e4b17023SJohn Marino 
66*e4b17023SJohn Marino /* Set if the sign of the cc value is inverted:
67*e4b17023SJohn Marino    output a following jump-if-less as a jump-if-greater, etc.  */
68*e4b17023SJohn Marino #define CC_REVERSED 1
69*e4b17023SJohn Marino 
70*e4b17023SJohn Marino /* This bit means that the current setting of the N bit is bogus
71*e4b17023SJohn Marino    and conditional jumps should use the Z bit in its place.
72*e4b17023SJohn Marino    This state obtains when an extraction of a signed single-bit field
73*e4b17023SJohn Marino    or an arithmetic shift right of a byte by 7 bits
74*e4b17023SJohn Marino    is turned into a btst, because btst does not set the N bit.  */
75*e4b17023SJohn Marino #define CC_NOT_POSITIVE 2
76*e4b17023SJohn Marino 
77*e4b17023SJohn Marino /* This bit means that the current setting of the N bit is bogus
78*e4b17023SJohn Marino    and conditional jumps should pretend that the N bit is clear.
79*e4b17023SJohn Marino    Used after extraction of an unsigned bit
80*e4b17023SJohn Marino    or logical shift right of a byte by 7 bits is turned into a btst.
81*e4b17023SJohn Marino    The btst does not alter the N bit, but the result of that shift
82*e4b17023SJohn Marino    or extract is never negative.  */
83*e4b17023SJohn Marino #define CC_NOT_NEGATIVE 4
84*e4b17023SJohn Marino 
85*e4b17023SJohn Marino /* This bit means that the current setting of the overflow flag
86*e4b17023SJohn Marino    is bogus and conditional jumps should pretend there is no overflow.  */
87*e4b17023SJohn Marino /* ??? Note that for most targets this macro is misnamed as it applies
88*e4b17023SJohn Marino    to the carry flag, not the overflow flag.  */
89*e4b17023SJohn Marino #define CC_NO_OVERFLOW 010
90*e4b17023SJohn Marino 
91*e4b17023SJohn Marino /* This bit means that what ought to be in the Z bit
92*e4b17023SJohn Marino    should be tested as the complement of the N bit.  */
93*e4b17023SJohn Marino #define CC_Z_IN_NOT_N 020
94*e4b17023SJohn Marino 
95*e4b17023SJohn Marino /* This bit means that what ought to be in the Z bit
96*e4b17023SJohn Marino    should be tested as the N bit.  */
97*e4b17023SJohn Marino #define CC_Z_IN_N 040
98*e4b17023SJohn Marino 
99*e4b17023SJohn Marino /* Nonzero if we must invert the sense of the following branch, i.e.
100*e4b17023SJohn Marino    change EQ to NE.  This is not safe for IEEE floating point operations!
101*e4b17023SJohn Marino    It is intended for use only when a combination of arithmetic
102*e4b17023SJohn Marino    or logical insns can leave the condition codes set in a fortuitous
103*e4b17023SJohn Marino    (though inverted) state.  */
104*e4b17023SJohn Marino #define CC_INVERTED 0100
105*e4b17023SJohn Marino 
106*e4b17023SJohn Marino /* Nonzero if we must convert signed condition operators to unsigned.
107*e4b17023SJohn Marino    This is only used by machine description files.  */
108*e4b17023SJohn Marino #define CC_NOT_SIGNED 0200
109*e4b17023SJohn Marino 
110*e4b17023SJohn Marino /* This is how to initialize the variable cc_status.
111*e4b17023SJohn Marino    final does this at appropriate moments.  */
112*e4b17023SJohn Marino 
113*e4b17023SJohn Marino #define CC_STATUS_INIT  \
114*e4b17023SJohn Marino  (cc_status.flags = 0, cc_status.value1 = 0, cc_status.value2 = 0,  \
115*e4b17023SJohn Marino   CC_STATUS_MDEP_INIT)
116*e4b17023SJohn Marino 
117*e4b17023SJohn Marino #endif
118