arc-func.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /* Replace functions for the ARC relocs.
  2. Copyright 2015
  3. Free Software Foundation, Inc.
  4. This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and
  5. the GNU Binutils.
  6. GAS/GDB is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3, or (at your option)
  9. any later version.
  10. GAS/GDB is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GAS or GDB; see the file COPYING3. If not, write to
  16. the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
  17. MA 02110-1301, USA. */
  18. /* mask = 00000000000000000000000000000000. */
  19. #ifndef REPLACE_none
  20. #define REPLACE_none
  21. ATTRIBUTE_UNUSED static unsigned
  22. replace_none (unsigned insn, int value ATTRIBUTE_UNUSED)
  23. {
  24. return insn;
  25. }
  26. #endif /* REPLACE_none */
  27. /* mask = 11111111. */
  28. #ifndef REPLACE_bits8
  29. #define REPLACE_bits8
  30. ATTRIBUTE_UNUSED static unsigned
  31. replace_bits8 (unsigned insn, int value ATTRIBUTE_UNUSED)
  32. {
  33. insn |= ((value >> 0) & 0x00ff) << 0;
  34. return insn;
  35. }
  36. #endif /* REPLACE_bits8 */
  37. /* mask = 1111111111111111. */
  38. #ifndef REPLACE_bits16
  39. #define REPLACE_bits16
  40. ATTRIBUTE_UNUSED static unsigned
  41. replace_bits16 (unsigned insn, int value ATTRIBUTE_UNUSED)
  42. {
  43. insn |= ((value >> 0) & 0xffff) << 0;
  44. return insn;
  45. }
  46. #endif /* REPLACE_bits16 */
  47. /* mask = 111111111111111111111111. */
  48. #ifndef REPLACE_bits24
  49. #define REPLACE_bits24
  50. ATTRIBUTE_UNUSED static unsigned
  51. replace_bits24 (unsigned insn, int value ATTRIBUTE_UNUSED)
  52. {
  53. insn |= ((value >> 0) & 0xffffff) << 0;
  54. return insn;
  55. }
  56. #endif /* REPLACE_bits24 */
  57. /* mask = 11111111111111111111111111111111. */
  58. #ifndef REPLACE_word32
  59. #define REPLACE_word32
  60. ATTRIBUTE_UNUSED static unsigned
  61. replace_word32 (unsigned insn, int value ATTRIBUTE_UNUSED)
  62. {
  63. insn |= ((value >> 0) & 0xffffffff) << 0;
  64. return insn;
  65. }
  66. #endif /* REPLACE_word32 */
  67. /* mask = 0000000000000000000000000000000011111111111111111111111111111111. */
  68. #ifndef REPLACE_limm
  69. #define REPLACE_limm
  70. ATTRIBUTE_UNUSED static unsigned
  71. replace_limm (unsigned insn, int value ATTRIBUTE_UNUSED)
  72. {
  73. insn |= ((value >> 0) & 0xffffffff) << 0;
  74. return insn;
  75. }
  76. #endif /* REPLACE_limm */
  77. /* mask = 000000000000000011111111111111111111111111111111. */
  78. #ifndef REPLACE_limms
  79. #define REPLACE_limms
  80. ATTRIBUTE_UNUSED static unsigned
  81. replace_limms (unsigned insn, int value ATTRIBUTE_UNUSED)
  82. {
  83. insn |= ((value >> 0) & 0xffffffff) << 0;
  84. return insn;
  85. }
  86. #endif /* REPLACE_limms */
  87. /* mask = 00000111111111102222222222000000. */
  88. #ifndef REPLACE_disp21h
  89. #define REPLACE_disp21h
  90. ATTRIBUTE_UNUSED static unsigned
  91. replace_disp21h (unsigned insn, int value ATTRIBUTE_UNUSED)
  92. {
  93. insn |= ((value >> 0) & 0x03ff) << 17;
  94. insn |= ((value >> 10) & 0x03ff) << 6;
  95. return insn;
  96. }
  97. #endif /* REPLACE_disp21h */
  98. /* mask = 00000111111111002222222222000000. */
  99. #ifndef REPLACE_disp21w
  100. #define REPLACE_disp21w
  101. ATTRIBUTE_UNUSED static unsigned
  102. replace_disp21w (unsigned insn, int value ATTRIBUTE_UNUSED)
  103. {
  104. insn |= ((value >> 0) & 0x01ff) << 18;
  105. insn |= ((value >> 9) & 0x03ff) << 6;
  106. return insn;
  107. }
  108. #endif /* REPLACE_disp21w */
  109. /* mask = 00000111111111102222222222003333. */
  110. #ifndef REPLACE_disp25h
  111. #define REPLACE_disp25h
  112. ATTRIBUTE_UNUSED static unsigned
  113. replace_disp25h (unsigned insn, int value ATTRIBUTE_UNUSED)
  114. {
  115. insn |= ((value >> 0) & 0x03ff) << 17;
  116. insn |= ((value >> 10) & 0x03ff) << 6;
  117. insn |= ((value >> 20) & 0x000f) << 0;
  118. return insn;
  119. }
  120. #endif /* REPLACE_disp25h */
  121. /* mask = 00000111111111002222222222003333. */
  122. #ifndef REPLACE_disp25w
  123. #define REPLACE_disp25w
  124. ATTRIBUTE_UNUSED static unsigned
  125. replace_disp25w (unsigned insn, int value ATTRIBUTE_UNUSED)
  126. {
  127. insn |= ((value >> 0) & 0x01ff) << 18;
  128. insn |= ((value >> 9) & 0x03ff) << 6;
  129. insn |= ((value >> 19) & 0x000f) << 0;
  130. return insn;
  131. }
  132. #endif /* REPLACE_disp25w */
  133. /* mask = 00000000000000000000000111111111. */
  134. #ifndef REPLACE_disp9
  135. #define REPLACE_disp9
  136. ATTRIBUTE_UNUSED static unsigned
  137. replace_disp9 (unsigned insn, int value ATTRIBUTE_UNUSED)
  138. {
  139. insn |= ((value >> 0) & 0x01ff) << 0;
  140. return insn;
  141. }
  142. #endif /* REPLACE_disp9 */
  143. /* mask = 00000000111111112000000000000000. */
  144. #ifndef REPLACE_disp9ls
  145. #define REPLACE_disp9ls
  146. ATTRIBUTE_UNUSED static unsigned
  147. replace_disp9ls (unsigned insn, int value ATTRIBUTE_UNUSED)
  148. {
  149. insn |= ((value >> 0) & 0x00ff) << 16;
  150. insn |= ((value >> 8) & 0x0001) << 15;
  151. return insn;
  152. }
  153. #endif /* REPLACE_disp9ls */
  154. /* mask = 0000000111111111. */
  155. #ifndef REPLACE_disp9s
  156. #define REPLACE_disp9s
  157. ATTRIBUTE_UNUSED static unsigned
  158. replace_disp9s (unsigned insn, int value ATTRIBUTE_UNUSED)
  159. {
  160. insn |= ((value >> 0) & 0x01ff) << 0;
  161. return insn;
  162. }
  163. #endif /* REPLACE_disp9s */
  164. /* mask = 0000011111111111. */
  165. #ifndef REPLACE_disp13s
  166. #define REPLACE_disp13s
  167. ATTRIBUTE_UNUSED static unsigned
  168. replace_disp13s (unsigned insn, int value ATTRIBUTE_UNUSED)
  169. {
  170. insn |= ((value >> 0) & 0x07ff) << 0;
  171. return insn;
  172. }
  173. #endif /* REPLACE_disp13s */
  174. /* mask = 0000022222200111. */
  175. #ifndef REPLACE_disp9s1
  176. #define REPLACE_disp9s1
  177. ATTRIBUTE_UNUSED static unsigned
  178. replace_disp9s1 (unsigned insn, int value ATTRIBUTE_UNUSED)
  179. {
  180. insn |= ((value >> 0) & 0x0007) << 0;
  181. insn |= ((value >> 3) & 0x003f) << 5;
  182. return insn;
  183. }
  184. #endif /* REPLACE_disp9s1 */