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