ext.S 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /* Tests the l.ext{b,h}{s,z} instructions.
  2. Copyright (C) 2017-2022 Free Software Foundation, Inc.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  13. # mach: or1k
  14. # output: report(0x0000007f);\n
  15. # output: report(0x0000007f);\n
  16. # output: report(0x00000053);\n
  17. # output: report(0x00000053);\n
  18. # output: report(0x0000ff53);\n
  19. # output: report(0x00000053);\n
  20. # output: report(0x00001234);\n
  21. # output: report(0x00000034);\n
  22. # output: report(0x000000ff);\n
  23. # output: report(0xffffffff);\n
  24. # output: report(0x00000080);\n
  25. # output: report(0xffffff80);\n
  26. # output: report(0x0000ff80);\n
  27. # output: report(0xffffff80);\n
  28. # output: report(0x00007f80);\n
  29. # output: report(0xffffff80);\n
  30. # output: report(0x00007fff);\n
  31. # output: report(0xffffffff);\n
  32. # output: report(0x0000007f);\n
  33. # output: report(0x0000007f);\n
  34. # output: report(0x00000053);\n
  35. # output: report(0x00000053);\n
  36. # output: report(0x0000ff53);\n
  37. # output: report(0x00000053);\n
  38. # output: report(0x00001234);\n
  39. # output: report(0x00000034);\n
  40. # output: report(0x000000ff);\n
  41. # output: report(0x000000ff);\n
  42. # output: report(0x00000080);\n
  43. # output: report(0x00000080);\n
  44. # output: report(0x0000ff80);\n
  45. # output: report(0x00000080);\n
  46. # output: report(0x00007f80);\n
  47. # output: report(0x00000080);\n
  48. # output: report(0x00007fff);\n
  49. # output: report(0x000000ff);\n
  50. # output: report(0x00007fff);\n
  51. # output: report(0x00007fff);\n
  52. # output: report(0x00005233);\n
  53. # output: report(0x00005233);\n
  54. # output: report(0xffff2f53);\n
  55. # output: report(0x00002f53);\n
  56. # output: report(0x12345678);\n
  57. # output: report(0x00005678);\n
  58. # output: report(0x0000ffff);\n
  59. # output: report(0xffffffff);\n
  60. # output: report(0x00008000);\n
  61. # output: report(0xffff8000);\n
  62. # output: report(0x0000ff80);\n
  63. # output: report(0xffffff80);\n
  64. # output: report(0x80008000);\n
  65. # output: report(0xffff8000);\n
  66. # output: report(0x7fffffff);\n
  67. # output: report(0xffffffff);\n
  68. # output: report(0x00007fff);\n
  69. # output: report(0x00007fff);\n
  70. # output: report(0x00005233);\n
  71. # output: report(0x00005233);\n
  72. # output: report(0xffff2f53);\n
  73. # output: report(0x00002f53);\n
  74. # output: report(0x12345678);\n
  75. # output: report(0x00005678);\n
  76. # output: report(0x0000ffff);\n
  77. # output: report(0x0000ffff);\n
  78. # output: report(0x00008000);\n
  79. # output: report(0x00008000);\n
  80. # output: report(0x0000ff80);\n
  81. # output: report(0x0000ff80);\n
  82. # output: report(0x80008000);\n
  83. # output: report(0x00008000);\n
  84. # output: report(0x7fffffff);\n
  85. # output: report(0x0000ffff);\n
  86. # output: report(0xffffffff);\n
  87. # output: report(0xffffffff);\n
  88. # output: report(0x7fffffff);\n
  89. # output: report(0x7fffffff);\n
  90. # output: report(0x7fff7fff);\n
  91. # output: report(0x7fff7fff);\n
  92. # output: report(0xffff7f7f);\n
  93. # output: report(0xffff7f7f);\n
  94. # output: report(0xffffff7f);\n
  95. # output: report(0xffffff7f);\n
  96. # output: report(0xffff7fff);\n
  97. # output: report(0xffff7fff);\n
  98. # output: report(0x7fff7f7f);\n
  99. # output: report(0x7fff7f7f);\n
  100. # output: report(0x12345678);\n
  101. # output: report(0x12345678);\n
  102. # output: report(0xffffffff);\n
  103. # output: report(0xffffffff);\n
  104. # output: report(0x7fffffff);\n
  105. # output: report(0x7fffffff);\n
  106. # output: report(0x7fff7fff);\n
  107. # output: report(0x7fff7fff);\n
  108. # output: report(0xffff7f7f);\n
  109. # output: report(0xffff7f7f);\n
  110. # output: report(0xffffff7f);\n
  111. # output: report(0xffffff7f);\n
  112. # output: report(0xffff7fff);\n
  113. # output: report(0xffff7fff);\n
  114. # output: report(0x7fff7f7f);\n
  115. # output: report(0x7fff7f7f);\n
  116. # output: report(0x12345678);\n
  117. # output: report(0x12345678);\n
  118. # output: exit(0)\n
  119. #include "or1k-asm-test-env.h"
  120. .macro CHECK_EXT insn, val, mask, high_mask
  121. LOAD_IMMEDIATE r4, \val
  122. REPORT_REG_TO_CONSOLE r4
  123. \insn r5, r4
  124. REPORT_REG_TO_CONSOLE r5
  125. LOAD_IMMEDIATE r6, \mask
  126. l.xori r7, r6, -1
  127. l.and r8, r4, r6
  128. l.and r9, r5, r6
  129. l.sfne r8, r9
  130. OR1K_DELAYED_NOP (l.bf ext_fail)
  131. l.and r8, r5, r7
  132. LOAD_IMMEDIATE r7, \high_mask
  133. l.sfne r8, r7
  134. OR1K_DELAYED_NOP (l.bf ext_fail)
  135. .endm
  136. #define CHECK_HIGH3_CLEAR(insn, val) CHECK_EXT insn, val, 0x000000ff, 0
  137. #define CHECK_HIGH3_SET(val) CHECK_EXT l.extbs, val, 0x000000ff, 0xffffff00
  138. #define CHECK_HIGH2_CLEAR(insn, val) CHECK_EXT insn, val, 0x0000ffff, 0
  139. #define CHECK_HIGH2_SET(val) CHECK_EXT l.exths, val, 0x0000ffff, 0xffff0000
  140. .macro CHECK_MOVE insn, val
  141. LOAD_IMMEDIATE r4, \val
  142. REPORT_REG_TO_CONSOLE r4
  143. \insn r5, r4
  144. REPORT_REG_TO_CONSOLE r5
  145. l.sfne r5, r4
  146. OR1K_DELAYED_NOP (l.bf ext_fail)
  147. .endm
  148. STANDARD_TEST_ENVIRONMENT
  149. .section .text
  150. start_tests:
  151. PUSH LINK_REGISTER_R9
  152. /* Test l.extbs */
  153. CHECK_HIGH3_CLEAR ( l.extbs, 0x7f )
  154. CHECK_HIGH3_CLEAR ( l.extbs, 0x53 )
  155. CHECK_HIGH3_CLEAR ( l.extbs, 0xff53 )
  156. CHECK_HIGH3_CLEAR ( l.extbs, 0x1234 )
  157. CHECK_HIGH3_SET (0xff)
  158. CHECK_HIGH3_SET (0x80)
  159. CHECK_HIGH3_SET (0xff80)
  160. CHECK_HIGH3_SET (0x7f80)
  161. CHECK_HIGH3_SET (0x7fff)
  162. /* Test l.extbz */
  163. CHECK_HIGH3_CLEAR (l.extbz, 0x7f)
  164. CHECK_HIGH3_CLEAR (l.extbz, 0x53)
  165. CHECK_HIGH3_CLEAR (l.extbz, 0xff53)
  166. CHECK_HIGH3_CLEAR (l.extbz, 0x1234)
  167. CHECK_HIGH3_CLEAR (l.extbz, 0xff)
  168. CHECK_HIGH3_CLEAR (l.extbz, 0x80)
  169. CHECK_HIGH3_CLEAR (l.extbz, 0xff80)
  170. CHECK_HIGH3_CLEAR (l.extbz, 0x7f80)
  171. CHECK_HIGH3_CLEAR (l.extbz, 0x7fff)
  172. /* Test l.exths */
  173. CHECK_HIGH2_CLEAR (l.exths, 0x7fff)
  174. CHECK_HIGH2_CLEAR (l.exths, 0x5233)
  175. CHECK_HIGH2_CLEAR (l.exths, 0xffff2f53)
  176. CHECK_HIGH2_CLEAR (l.exths, 0x12345678)
  177. CHECK_HIGH2_SET (0xffff)
  178. CHECK_HIGH2_SET (0x8000)
  179. CHECK_HIGH2_SET (0xff80)
  180. CHECK_HIGH2_SET (0x80008000)
  181. CHECK_HIGH2_SET (0x7fffffff)
  182. /* Test l.exthz */
  183. CHECK_HIGH2_CLEAR (l.exthz, 0x7fff)
  184. CHECK_HIGH2_CLEAR (l.exthz, 0x5233)
  185. CHECK_HIGH2_CLEAR (l.exthz, 0xffff2f53)
  186. CHECK_HIGH2_CLEAR (l.exthz, 0x12345678)
  187. CHECK_HIGH2_CLEAR (l.exthz, 0xffff)
  188. CHECK_HIGH2_CLEAR (l.exthz, 0x8000)
  189. CHECK_HIGH2_CLEAR (l.exthz, 0xff80)
  190. CHECK_HIGH2_CLEAR (l.exthz, 0x80008000)
  191. CHECK_HIGH2_CLEAR (l.exthz, 0x7fffffff)
  192. /* Test l.extws */
  193. CHECK_MOVE l.extws, 0xffffffff
  194. CHECK_MOVE l.extws, 0x7fffffff
  195. CHECK_MOVE l.extws, 0x7fff7fff
  196. CHECK_MOVE l.extws, 0xffff7f7f
  197. CHECK_MOVE l.extws, 0xffffff7f
  198. CHECK_MOVE l.extws, 0xffff7fff
  199. CHECK_MOVE l.extws, 0x7fff7f7f
  200. CHECK_MOVE l.extws, 0x12345678
  201. /* Test l.extwz */
  202. CHECK_MOVE l.extwz, 0xffffffff
  203. CHECK_MOVE l.extwz, 0x7fffffff
  204. CHECK_MOVE l.extwz, 0x7fff7fff
  205. CHECK_MOVE l.extwz, 0xffff7f7f
  206. CHECK_MOVE l.extwz, 0xffffff7f
  207. CHECK_MOVE l.extwz, 0xffff7fff
  208. CHECK_MOVE l.extwz, 0x7fff7f7f
  209. CHECK_MOVE l.extwz, 0x12345678
  210. POP LINK_REGISTER_R9
  211. RETURN_TO_LINK_REGISTER_R9
  212. ext_fail:
  213. EXIT_SIMULATION_WITH_IMMEDIATE_EXIT_CODE SEC_GENERIC_ERROR