conditions.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* Definitions for condition code handling in final.c and output routines.
  2. Copyright (C) 1987-2015 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. /* None of the things in the files exist if we don't use CC0. */
  18. #ifdef HAVE_cc0
  19. /* The variable cc_status says how to interpret the condition code.
  20. It is set by output routines for an instruction that sets the cc's
  21. and examined by output routines for jump instructions.
  22. cc_status contains two components named `value1' and `value2'
  23. that record two equivalent expressions for the values that the
  24. condition codes were set from. (Either or both may be null if
  25. there is no useful expression to record.) These fields are
  26. used for eliminating redundant test and compare instructions
  27. in the cases where the condition codes were already set by the
  28. previous instruction.
  29. cc_status.flags contains flags which say that the condition codes
  30. were set in a nonstandard manner. The output of jump instructions
  31. uses these flags to compensate and produce the standard result
  32. with the nonstandard condition codes. Standard flags are defined here.
  33. The tm.h file can also define other machine-dependent flags.
  34. cc_status also contains a machine-dependent component `mdep'
  35. whose type, `CC_STATUS_MDEP', may be defined as a macro in the
  36. tm.h file. */
  37. #ifndef CC_STATUS_MDEP
  38. #define CC_STATUS_MDEP int
  39. #endif
  40. #ifndef CC_STATUS_MDEP_INIT
  41. #define CC_STATUS_MDEP_INIT 0
  42. #endif
  43. struct CC_STATUS {int flags; rtx value1, value2; CC_STATUS_MDEP mdep;};
  44. /* While outputting an insn as assembler code,
  45. this is the status BEFORE that insn. */
  46. extern CC_STATUS cc_prev_status;
  47. /* While outputting an insn as assembler code,
  48. this is being altered to the status AFTER that insn. */
  49. extern CC_STATUS cc_status;
  50. /* These are the machine-independent flags: */
  51. /* Set if the sign of the cc value is inverted:
  52. output a following jump-if-less as a jump-if-greater, etc. */
  53. #define CC_REVERSED 1
  54. /* This bit means that the current setting of the N bit is bogus
  55. and conditional jumps should use the Z bit in its place.
  56. This state obtains when an extraction of a signed single-bit field
  57. or an arithmetic shift right of a byte by 7 bits
  58. is turned into a btst, because btst does not set the N bit. */
  59. #define CC_NOT_POSITIVE 2
  60. /* This bit means that the current setting of the N bit is bogus
  61. and conditional jumps should pretend that the N bit is clear.
  62. Used after extraction of an unsigned bit
  63. or logical shift right of a byte by 7 bits is turned into a btst.
  64. The btst does not alter the N bit, but the result of that shift
  65. or extract is never negative. */
  66. #define CC_NOT_NEGATIVE 4
  67. /* This bit means that the current setting of the overflow flag
  68. is bogus and conditional jumps should pretend there is no overflow. */
  69. /* ??? Note that for most targets this macro is misnamed as it applies
  70. to the carry flag, not the overflow flag. */
  71. #define CC_NO_OVERFLOW 010
  72. /* This bit means that what ought to be in the Z bit
  73. should be tested as the complement of the N bit. */
  74. #define CC_Z_IN_NOT_N 020
  75. /* This bit means that what ought to be in the Z bit
  76. should be tested as the N bit. */
  77. #define CC_Z_IN_N 040
  78. /* Nonzero if we must invert the sense of the following branch, i.e.
  79. change EQ to NE. This is not safe for IEEE floating point operations!
  80. It is intended for use only when a combination of arithmetic
  81. or logical insns can leave the condition codes set in a fortuitous
  82. (though inverted) state. */
  83. #define CC_INVERTED 0100
  84. /* Nonzero if we must convert signed condition operators to unsigned.
  85. This is only used by machine description files. */
  86. #define CC_NOT_SIGNED 0200
  87. /* This is how to initialize the variable cc_status.
  88. final does this at appropriate moments. */
  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 */