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