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