regset.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Define regsets.
  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_REGSET_H
  16. #define GCC_REGSET_H
  17. /* TODO: regset is just a bitmap in its implementation. The compiler does
  18. not consistently use one or the other, i.e. sometimes variables are
  19. declared as bitmap but they are actually regsets and regset accessors
  20. are used, and vice versa, or mixed (see e.g. spilled_regs in IRA).
  21. This should be cleaned up, either by just dropping the regset type, or
  22. by changing all bitmaps that are really regsets to the regset type. For
  23. the latter option, a good start would be to change everything allocated
  24. on the reg_obstack to regset. */
  25. #include "bitmap.h" /* For bitmap_iterator. */
  26. #include "hard-reg-set.h"
  27. /* Head of register set linked list. */
  28. typedef bitmap_head regset_head;
  29. /* A pointer to a regset_head. */
  30. typedef bitmap regset;
  31. /* Allocate a register set with oballoc. */
  32. #define ALLOC_REG_SET(OBSTACK) BITMAP_ALLOC (OBSTACK)
  33. /* Do any cleanup needed on a regset when it is no longer used. */
  34. #define FREE_REG_SET(REGSET) BITMAP_FREE (REGSET)
  35. /* Initialize a new regset. */
  36. #define INIT_REG_SET(HEAD) bitmap_initialize (HEAD, &reg_obstack)
  37. /* Clear a register set by freeing up the linked list. */
  38. #define CLEAR_REG_SET(HEAD) bitmap_clear (HEAD)
  39. /* Copy a register set to another register set. */
  40. #define COPY_REG_SET(TO, FROM) bitmap_copy (TO, FROM)
  41. /* Compare two register sets. */
  42. #define REG_SET_EQUAL_P(A, B) bitmap_equal_p (A, B)
  43. /* `and' a register set with a second register set. */
  44. #define AND_REG_SET(TO, FROM) bitmap_and_into (TO, FROM)
  45. /* `and' the complement of a register set with a register set. */
  46. #define AND_COMPL_REG_SET(TO, FROM) bitmap_and_compl_into (TO, FROM)
  47. /* Inclusive or a register set with a second register set. */
  48. #define IOR_REG_SET(TO, FROM) bitmap_ior_into (TO, FROM)
  49. /* Exclusive or a register set with a second register set. */
  50. #define XOR_REG_SET(TO, FROM) bitmap_xor_into (TO, FROM)
  51. /* Or into TO the register set FROM1 `and'ed with the complement of FROM2. */
  52. #define IOR_AND_COMPL_REG_SET(TO, FROM1, FROM2) \
  53. bitmap_ior_and_compl_into (TO, FROM1, FROM2)
  54. /* Clear a single register in a register set. */
  55. #define CLEAR_REGNO_REG_SET(HEAD, REG) bitmap_clear_bit (HEAD, REG)
  56. /* Set a single register in a register set. */
  57. #define SET_REGNO_REG_SET(HEAD, REG) bitmap_set_bit (HEAD, REG)
  58. /* Return true if a register is set in a register set. */
  59. #define REGNO_REG_SET_P(TO, REG) bitmap_bit_p (TO, REG)
  60. /* Copy the hard registers in a register set to the hard register set. */
  61. extern void reg_set_to_hard_reg_set (HARD_REG_SET *, const_bitmap);
  62. #define REG_SET_TO_HARD_REG_SET(TO, FROM) \
  63. do { \
  64. CLEAR_HARD_REG_SET (TO); \
  65. reg_set_to_hard_reg_set (&TO, FROM); \
  66. } while (0)
  67. typedef bitmap_iterator reg_set_iterator;
  68. /* Loop over all registers in REGSET, starting with MIN, setting REGNUM to the
  69. register number and executing CODE for all registers that are set. */
  70. #define EXECUTE_IF_SET_IN_REG_SET(REGSET, MIN, REGNUM, RSI) \
  71. EXECUTE_IF_SET_IN_BITMAP (REGSET, MIN, REGNUM, RSI)
  72. /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
  73. REGNUM to the register number and executing CODE for all registers that are
  74. set in the first regset and not set in the second. */
  75. #define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \
  76. EXECUTE_IF_AND_COMPL_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI)
  77. /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
  78. REGNUM to the register number and executing CODE for all registers that are
  79. set in both regsets. */
  80. #define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \
  81. EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI) \
  82. /* Same information as REGS_INVALIDATED_BY_CALL but in regset form to be used
  83. in dataflow more conveniently. */
  84. extern regset regs_invalidated_by_call_regset;
  85. /* Same information as FIXED_REG_SET but in regset form. */
  86. extern regset fixed_reg_set_regset;
  87. /* An obstack for regsets. */
  88. extern bitmap_obstack reg_obstack;
  89. /* In df-core.c (which should use regset consistently instead of bitmap...) */
  90. extern void dump_regset (regset, FILE *);
  91. #endif /* GCC_REGSET_H */