addresses.h 2.8 KB

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