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