addresses.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Inline functions to test validity of reg classes for addressing modes.
  2. Copyright (C) 2006-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. /* Wrapper function to unify target macros MODE_CODE_BASE_REG_CLASS,
  16. MODE_BASE_REG_REG_CLASS, MODE_BASE_REG_CLASS and BASE_REG_CLASS.
  17. Arguments as for the MODE_CODE_BASE_REG_CLASS macro. */
  18. #ifndef GCC_ADDRESSES_H
  19. #define GCC_ADDRESSES_H
  20. static inline enum reg_class
  21. base_reg_class (machine_mode mode ATTRIBUTE_UNUSED,
  22. addr_space_t as ATTRIBUTE_UNUSED,
  23. enum rtx_code outer_code ATTRIBUTE_UNUSED,
  24. enum rtx_code index_code ATTRIBUTE_UNUSED)
  25. {
  26. #ifdef MODE_CODE_BASE_REG_CLASS
  27. return MODE_CODE_BASE_REG_CLASS (MACRO_MODE (mode), as, outer_code,
  28. index_code);
  29. #else
  30. #ifdef MODE_BASE_REG_REG_CLASS
  31. if (index_code == REG)
  32. return MODE_BASE_REG_REG_CLASS (MACRO_MODE (mode));
  33. #endif
  34. #ifdef MODE_BASE_REG_CLASS
  35. return MODE_BASE_REG_CLASS (MACRO_MODE (mode));
  36. #else
  37. return BASE_REG_CLASS;
  38. #endif
  39. #endif
  40. }
  41. /* Wrapper function to unify target macros REGNO_MODE_CODE_OK_FOR_BASE_P,
  42. REGNO_MODE_OK_FOR_REG_BASE_P, REGNO_MODE_OK_FOR_BASE_P and
  43. REGNO_OK_FOR_BASE_P.
  44. Arguments as for the REGNO_MODE_CODE_OK_FOR_BASE_P macro. */
  45. static inline bool
  46. ok_for_base_p_1 (unsigned regno ATTRIBUTE_UNUSED,
  47. machine_mode mode ATTRIBUTE_UNUSED,
  48. addr_space_t as ATTRIBUTE_UNUSED,
  49. enum rtx_code outer_code ATTRIBUTE_UNUSED,
  50. enum rtx_code index_code ATTRIBUTE_UNUSED)
  51. {
  52. #ifdef REGNO_MODE_CODE_OK_FOR_BASE_P
  53. return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode), as,
  54. outer_code, index_code);
  55. #else
  56. #ifdef REGNO_MODE_OK_FOR_REG_BASE_P
  57. if (index_code == REG)
  58. return REGNO_MODE_OK_FOR_REG_BASE_P (regno, MACRO_MODE (mode));
  59. #endif
  60. #ifdef REGNO_MODE_OK_FOR_BASE_P
  61. return REGNO_MODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode));
  62. #else
  63. return REGNO_OK_FOR_BASE_P (regno);
  64. #endif
  65. #endif
  66. }
  67. /* Wrapper around ok_for_base_p_1, for use after register allocation is
  68. complete. Arguments as for the called function. */
  69. static inline bool
  70. regno_ok_for_base_p (unsigned regno, machine_mode mode, addr_space_t as,
  71. enum rtx_code outer_code, enum rtx_code index_code)
  72. {
  73. if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0)
  74. regno = reg_renumber[regno];
  75. return ok_for_base_p_1 (regno, mode, as, outer_code, index_code);
  76. }
  77. #endif /* GCC_ADDRESSES_H */