conditions.h 4.5 KB

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