aarch64 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +37 -0
  4. data/aarch64.gemspec +1 -0
  5. data/lib/aarch64/instructions/adc.rb +10 -10
  6. data/lib/aarch64/instructions/adcs.rb +10 -10
  7. data/lib/aarch64/instructions/add_addsub_ext.rb +14 -14
  8. data/lib/aarch64/instructions/add_addsub_imm.rb +12 -12
  9. data/lib/aarch64/instructions/add_addsub_shift.rb +14 -14
  10. data/lib/aarch64/instructions/addg.rb +10 -10
  11. data/lib/aarch64/instructions/adds_addsub_ext.rb +14 -14
  12. data/lib/aarch64/instructions/adds_addsub_imm.rb +12 -12
  13. data/lib/aarch64/instructions/adds_addsub_shift.rb +14 -14
  14. data/lib/aarch64/instructions/adr.rb +7 -7
  15. data/lib/aarch64/instructions/adrp.rb +7 -7
  16. data/lib/aarch64/instructions/and_log_imm.rb +14 -14
  17. data/lib/aarch64/instructions/and_log_shift.rb +14 -14
  18. data/lib/aarch64/instructions/ands_log_imm.rb +14 -14
  19. data/lib/aarch64/instructions/ands_log_shift.rb +14 -14
  20. data/lib/aarch64/instructions/asrv.rb +10 -10
  21. data/lib/aarch64/instructions/autda.rb +9 -12
  22. data/lib/aarch64/instructions/autdb.rb +9 -12
  23. data/lib/aarch64/instructions/autia.rb +9 -12
  24. data/lib/aarch64/instructions/autib.rb +9 -12
  25. data/lib/aarch64/instructions/axflag.rb +1 -1
  26. data/lib/aarch64/instructions/b_cond.rb +5 -5
  27. data/lib/aarch64/instructions/b_uncond.rb +3 -3
  28. data/lib/aarch64/instructions/bc_cond.rb +5 -5
  29. data/lib/aarch64/instructions/bfm.rb +13 -13
  30. data/lib/aarch64/instructions/bic_log_shift.rb +14 -14
  31. data/lib/aarch64/instructions/bics.rb +14 -14
  32. data/lib/aarch64/instructions/bl.rb +3 -3
  33. data/lib/aarch64/instructions/blr.rb +4 -4
  34. data/lib/aarch64/instructions/blra.rb +10 -10
  35. data/lib/aarch64/instructions/br.rb +4 -4
  36. data/lib/aarch64/instructions/bra.rb +10 -10
  37. data/lib/aarch64/instructions/brk.rb +3 -3
  38. data/lib/aarch64/instructions/bti.rb +3 -3
  39. data/lib/aarch64/instructions/cas.rb +14 -14
  40. data/lib/aarch64/instructions/casb.rb +12 -12
  41. data/lib/aarch64/instructions/cash.rb +12 -12
  42. data/lib/aarch64/instructions/casp.rb +14 -14
  43. data/lib/aarch64/instructions/cbnz.rb +7 -7
  44. data/lib/aarch64/instructions/cbz.rb +7 -7
  45. data/lib/aarch64/instructions/ccmn_imm.rb +12 -12
  46. data/lib/aarch64/instructions/ccmn_reg.rb +12 -12
  47. data/lib/aarch64/instructions/ccmp_imm.rb +12 -12
  48. data/lib/aarch64/instructions/ccmp_reg.rb +12 -12
  49. data/lib/aarch64/instructions/cfinv.rb +2 -9
  50. data/lib/aarch64/instructions/clrex.rb +3 -3
  51. data/lib/aarch64/instructions/cls_int.rb +8 -8
  52. data/lib/aarch64/instructions/clz_int.rb +8 -8
  53. data/lib/aarch64/instructions/crc32.rb +12 -12
  54. data/lib/aarch64/instructions/crc32c.rb +12 -12
  55. data/lib/aarch64/instructions/csdb.rb +1 -1
  56. data/lib/aarch64/instructions/csel.rb +12 -12
  57. data/lib/aarch64/instructions/csinc.rb +12 -12
  58. data/lib/aarch64/instructions/csinv.rb +12 -12
  59. data/lib/aarch64/instructions/csneg.rb +12 -12
  60. data/lib/aarch64/instructions/dcps.rb +5 -5
  61. data/lib/aarch64/instructions/dgh.rb +1 -1
  62. data/lib/aarch64/instructions/dmb.rb +3 -3
  63. data/lib/aarch64/instructions/drps.rb +2 -9
  64. data/lib/aarch64/instructions/dsb.rb +3 -3
  65. data/lib/aarch64/instructions/eon.rb +14 -14
  66. data/lib/aarch64/instructions/eor_log_imm.rb +14 -14
  67. data/lib/aarch64/instructions/eor_log_shift.rb +14 -14
  68. data/lib/aarch64/instructions/eret.rb +2 -9
  69. data/lib/aarch64/instructions/ereta.rb +3 -3
  70. data/lib/aarch64/instructions/esb.rb +1 -1
  71. data/lib/aarch64/instructions/extr.rb +13 -13
  72. data/lib/aarch64/instructions/gmi.rb +8 -8
  73. data/lib/aarch64/instructions/hint.rb +5 -5
  74. data/lib/aarch64/instructions/hlt.rb +3 -3
  75. data/lib/aarch64/instructions/hvc.rb +3 -3
  76. data/lib/aarch64/instructions/irg.rb +8 -8
  77. data/lib/aarch64/instructions/isb.rb +3 -3
  78. data/lib/aarch64/instructions/ld64b.rb +6 -6
  79. data/lib/aarch64/instructions/ldadd.rb +14 -14
  80. data/lib/aarch64/instructions/ldaddb.rb +12 -12
  81. data/lib/aarch64/instructions/ldaddh.rb +12 -12
  82. data/lib/aarch64/instructions/ldapr.rb +8 -8
  83. data/lib/aarch64/instructions/ldaprb.rb +6 -6
  84. data/lib/aarch64/instructions/ldaprh.rb +6 -6
  85. data/lib/aarch64/instructions/ldapur_gen.rb +12 -12
  86. data/lib/aarch64/instructions/ldar.rb +8 -8
  87. data/lib/aarch64/instructions/ldaxp.rb +10 -10
  88. data/lib/aarch64/instructions/ldaxr.rb +8 -8
  89. data/lib/aarch64/instructions/ldclr.rb +14 -14
  90. data/lib/aarch64/instructions/ldclrb.rb +14 -14
  91. data/lib/aarch64/instructions/ldeor.rb +14 -14
  92. data/lib/aarch64/instructions/ldg.rb +8 -8
  93. data/lib/aarch64/instructions/ldgm.rb +6 -6
  94. data/lib/aarch64/instructions/ldlar.rb +8 -8
  95. data/lib/aarch64/instructions/ldnp_gen.rb +12 -12
  96. data/lib/aarch64/instructions/ldp_gen.rb +14 -14
  97. data/lib/aarch64/instructions/ldpsw.rb +12 -12
  98. data/lib/aarch64/instructions/ldr_imm_gen.rb +12 -12
  99. data/lib/aarch64/instructions/ldr_imm_unsigned.rb +10 -10
  100. data/lib/aarch64/instructions/ldr_lit_gen.rb +7 -7
  101. data/lib/aarch64/instructions/ldr_reg_gen.rb +14 -14
  102. data/lib/aarch64/instructions/ldra.rb +14 -14
  103. data/lib/aarch64/instructions/ldrb_imm.rb +10 -10
  104. data/lib/aarch64/instructions/ldrb_reg.rb +12 -12
  105. data/lib/aarch64/instructions/ldrb_unsigned.rb +8 -8
  106. data/lib/aarch64/instructions/ldrh_imm.rb +10 -10
  107. data/lib/aarch64/instructions/ldrh_reg.rb +12 -12
  108. data/lib/aarch64/instructions/ldrh_unsigned.rb +8 -8
  109. data/lib/aarch64/instructions/ldrsb_imm.rb +12 -12
  110. data/lib/aarch64/instructions/ldrsb_reg.rb +14 -14
  111. data/lib/aarch64/instructions/ldrsb_unsigned.rb +10 -10
  112. data/lib/aarch64/instructions/ldrsh_imm.rb +12 -12
  113. data/lib/aarch64/instructions/ldrsh_reg.rb +14 -14
  114. data/lib/aarch64/instructions/ldrsh_unsigned.rb +10 -10
  115. data/lib/aarch64/instructions/ldrsw_imm.rb +10 -10
  116. data/lib/aarch64/instructions/ldrsw_lit.rb +5 -5
  117. data/lib/aarch64/instructions/ldrsw_reg.rb +12 -12
  118. data/lib/aarch64/instructions/ldrsw_unsigned.rb +8 -8
  119. data/lib/aarch64/instructions/ldset.rb +14 -14
  120. data/lib/aarch64/instructions/ldsetb.rb +12 -12
  121. data/lib/aarch64/instructions/ldseth.rb +12 -12
  122. data/lib/aarch64/instructions/ldsmax.rb +14 -14
  123. data/lib/aarch64/instructions/ldsmaxb.rb +12 -12
  124. data/lib/aarch64/instructions/ldsmaxh.rb +12 -12
  125. data/lib/aarch64/instructions/ldsmin.rb +14 -14
  126. data/lib/aarch64/instructions/ldsminb.rb +12 -12
  127. data/lib/aarch64/instructions/ldsminh.rb +12 -12
  128. data/lib/aarch64/instructions/ldtr.rb +10 -10
  129. data/lib/aarch64/instructions/ldtrb.rb +8 -8
  130. data/lib/aarch64/instructions/ldtrh.rb +8 -8
  131. data/lib/aarch64/instructions/ldtrsb.rb +10 -10
  132. data/lib/aarch64/instructions/ldtrsh.rb +10 -10
  133. data/lib/aarch64/instructions/ldtrsw.rb +8 -8
  134. data/lib/aarch64/instructions/ldumax.rb +14 -14
  135. data/lib/aarch64/instructions/ldumaxb.rb +12 -12
  136. data/lib/aarch64/instructions/ldumaxh.rb +12 -12
  137. data/lib/aarch64/instructions/ldumin.rb +14 -14
  138. data/lib/aarch64/instructions/lduminb.rb +12 -12
  139. data/lib/aarch64/instructions/lduminh.rb +12 -12
  140. data/lib/aarch64/instructions/ldur_gen.rb +10 -10
  141. data/lib/aarch64/instructions/ldursb.rb +10 -10
  142. data/lib/aarch64/instructions/ldursh.rb +10 -10
  143. data/lib/aarch64/instructions/ldursw.rb +8 -8
  144. data/lib/aarch64/instructions/ldxp.rb +10 -10
  145. data/lib/aarch64/instructions/ldxr.rb +8 -8
  146. data/lib/aarch64/instructions/lslv.rb +10 -10
  147. data/lib/aarch64/instructions/lsrv.rb +10 -10
  148. data/lib/aarch64/instructions/madd.rb +12 -12
  149. data/lib/aarch64/instructions/movk.rb +10 -10
  150. data/lib/aarch64/instructions/movn.rb +10 -10
  151. data/lib/aarch64/instructions/movz.rb +10 -10
  152. data/lib/aarch64/instructions/mrs.rb +14 -14
  153. data/lib/aarch64/instructions/msr_imm.rb +7 -7
  154. data/lib/aarch64/instructions/msr_reg.rb +14 -14
  155. data/lib/aarch64/instructions/msub.rb +12 -12
  156. data/lib/aarch64/instructions/nop.rb +1 -1
  157. data/lib/aarch64/instructions/orn_log_shift.rb +14 -14
  158. data/lib/aarch64/instructions/orr_log_imm.rb +14 -14
  159. data/lib/aarch64/instructions/orr_log_shift.rb +14 -14
  160. data/lib/aarch64/instructions/pacda.rb +8 -8
  161. data/lib/aarch64/instructions/pacdb.rb +8 -8
  162. data/lib/aarch64/instructions/pacga.rb +8 -8
  163. data/lib/aarch64/instructions/pacia.rb +8 -8
  164. data/lib/aarch64/instructions/pacia2.rb +5 -5
  165. data/lib/aarch64/instructions/pacib.rb +8 -8
  166. data/lib/aarch64/instructions/prfm_imm.rb +8 -8
  167. data/lib/aarch64/instructions/prfm_lit.rb +8 -8
  168. data/lib/aarch64/instructions/prfm_reg.rb +12 -12
  169. data/lib/aarch64/instructions/prfum.rb +8 -8
  170. data/lib/aarch64/instructions/psb.rb +2 -9
  171. data/lib/aarch64/instructions/rbit_int.rb +8 -8
  172. data/lib/aarch64/instructions/ret.rb +4 -4
  173. data/lib/aarch64/instructions/reta.rb +3 -3
  174. data/lib/aarch64/instructions/rev.rb +10 -10
  175. data/lib/aarch64/instructions/rmif.rb +8 -8
  176. data/lib/aarch64/instructions/rorv.rb +10 -10
  177. data/lib/aarch64/instructions/sb.rb +1 -1
  178. data/lib/aarch64/instructions/sbc.rb +10 -10
  179. data/lib/aarch64/instructions/sbcs.rb +10 -10
  180. data/lib/aarch64/instructions/sbfm.rb +13 -13
  181. data/lib/aarch64/instructions/sdiv.rb +10 -10
  182. data/lib/aarch64/instructions/setf.rb +6 -6
  183. data/lib/aarch64/instructions/sev.rb +1 -7
  184. data/lib/aarch64/instructions/sevl.rb +1 -1
  185. data/lib/aarch64/instructions/smaddl.rb +10 -10
  186. data/lib/aarch64/instructions/smc.rb +3 -3
  187. data/lib/aarch64/instructions/smsubl.rb +10 -10
  188. data/lib/aarch64/instructions/smulh.rb +8 -8
  189. data/lib/aarch64/instructions/st2g.rb +10 -10
  190. data/lib/aarch64/instructions/st64b.rb +6 -6
  191. data/lib/aarch64/instructions/st64bv.rb +8 -8
  192. data/lib/aarch64/instructions/st64bv0.rb +8 -8
  193. data/lib/aarch64/instructions/stg.rb +10 -10
  194. data/lib/aarch64/instructions/stgm.rb +6 -6
  195. data/lib/aarch64/instructions/stgp.rb +12 -12
  196. data/lib/aarch64/instructions/stllr.rb +8 -8
  197. data/lib/aarch64/instructions/stllrb.rb +6 -6
  198. data/lib/aarch64/instructions/stllrh.rb +6 -6
  199. data/lib/aarch64/instructions/stlr.rb +8 -8
  200. data/lib/aarch64/instructions/stlrb.rb +6 -6
  201. data/lib/aarch64/instructions/stlrh.rb +6 -6
  202. data/lib/aarch64/instructions/stlur_gen.rb +10 -10
  203. data/lib/aarch64/instructions/stlxp.rb +12 -12
  204. data/lib/aarch64/instructions/stlxr.rb +10 -10
  205. data/lib/aarch64/instructions/stlxrb.rb +8 -8
  206. data/lib/aarch64/instructions/stlxrh.rb +8 -8
  207. data/lib/aarch64/instructions/stnp_gen.rb +12 -12
  208. data/lib/aarch64/instructions/stp_gen.rb +14 -14
  209. data/lib/aarch64/instructions/str_imm_gen.rb +12 -12
  210. data/lib/aarch64/instructions/str_imm_unsigned.rb +10 -10
  211. data/lib/aarch64/instructions/str_reg_gen.rb +14 -14
  212. data/lib/aarch64/instructions/strb_imm.rb +10 -10
  213. data/lib/aarch64/instructions/strb_imm_unsigned.rb +8 -8
  214. data/lib/aarch64/instructions/strb_reg.rb +12 -12
  215. data/lib/aarch64/instructions/strh_imm.rb +10 -10
  216. data/lib/aarch64/instructions/strh_imm_unsigned.rb +8 -8
  217. data/lib/aarch64/instructions/strh_reg.rb +12 -12
  218. data/lib/aarch64/instructions/sttr.rb +10 -10
  219. data/lib/aarch64/instructions/stur_gen.rb +10 -10
  220. data/lib/aarch64/instructions/stxp.rb +12 -12
  221. data/lib/aarch64/instructions/stxr.rb +10 -10
  222. data/lib/aarch64/instructions/stxrb.rb +8 -8
  223. data/lib/aarch64/instructions/stxrh.rb +8 -8
  224. data/lib/aarch64/instructions/stz2g.rb +10 -10
  225. data/lib/aarch64/instructions/stzg.rb +10 -10
  226. data/lib/aarch64/instructions/stzgm.rb +6 -6
  227. data/lib/aarch64/instructions/sub_addsub_ext.rb +14 -14
  228. data/lib/aarch64/instructions/sub_addsub_imm.rb +12 -12
  229. data/lib/aarch64/instructions/sub_addsub_shift.rb +14 -14
  230. data/lib/aarch64/instructions/subg.rb +10 -10
  231. data/lib/aarch64/instructions/subp.rb +8 -8
  232. data/lib/aarch64/instructions/subps.rb +8 -8
  233. data/lib/aarch64/instructions/subs_addsub_ext.rb +14 -14
  234. data/lib/aarch64/instructions/subs_addsub_imm.rb +12 -12
  235. data/lib/aarch64/instructions/subs_addsub_shift.rb +14 -14
  236. data/lib/aarch64/instructions/svc.rb +3 -3
  237. data/lib/aarch64/instructions/swp.rb +14 -14
  238. data/lib/aarch64/instructions/swpb.rb +12 -12
  239. data/lib/aarch64/instructions/swph.rb +12 -12
  240. data/lib/aarch64/instructions/sys.rb +12 -12
  241. data/lib/aarch64/instructions/sysl.rb +12 -12
  242. data/lib/aarch64/instructions/tbnz.rb +9 -9
  243. data/lib/aarch64/instructions/tbz.rb +9 -9
  244. data/lib/aarch64/instructions/tsb.rb +1 -7
  245. data/lib/aarch64/instructions/ubfm.rb +13 -13
  246. data/lib/aarch64/instructions/udf_perm_undef.rb +3 -3
  247. data/lib/aarch64/instructions/udiv.rb +10 -10
  248. data/lib/aarch64/instructions/umaddl.rb +10 -10
  249. data/lib/aarch64/instructions/umsubl.rb +10 -10
  250. data/lib/aarch64/instructions/umulh.rb +8 -8
  251. data/lib/aarch64/instructions/wfe.rb +2 -9
  252. data/lib/aarch64/instructions/wfet.rb +4 -4
  253. data/lib/aarch64/instructions/wfi.rb +1 -1
  254. data/lib/aarch64/instructions/wfit.rb +4 -4
  255. data/lib/aarch64/instructions/xaflag.rb +1 -1
  256. data/lib/aarch64/instructions/xpac.rb +6 -6
  257. data/lib/aarch64/instructions/xpaclri.rb +1 -1
  258. data/lib/aarch64/instructions/yield.rb +2 -9
  259. data/lib/aarch64/instructions.rb +26 -8
  260. data/lib/aarch64/parser.rb +227 -0
  261. data/lib/aarch64/parser.tab.rb +6534 -0
  262. data/lib/aarch64/parser.y +1394 -0
  263. data/lib/aarch64/utils.rb +34 -0
  264. data/lib/aarch64/version.rb +1 -1
  265. data/lib/aarch64.rb +128 -58
  266. data/test/base_instructions_test.rb +34 -4
  267. data/test/helper.rb +48 -8
  268. data/test/parser_test.rb +1820 -0
  269. metadata +25 -14
  270. data/lib/aarch64/instructions/setgp.rb +0 -25
  271. data/lib/aarch64/instructions/setgpn.rb +0 -25
  272. data/lib/aarch64/instructions/setgpt.rb +0 -25
  273. data/lib/aarch64/instructions/setgptn.rb +0 -25
  274. data/lib/aarch64/instructions/setp.rb +0 -25
  275. data/lib/aarch64/instructions/setpn.rb +0 -25
  276. data/lib/aarch64/instructions/setpt.rb +0 -25
  277. data/lib/aarch64/instructions/setptn.rb +0 -25
@@ -0,0 +1,1820 @@
1
+ require "helper"
2
+ require "aarch64/parser"
3
+
4
+ class ParserTest < AArch64::Test
5
+ def test_parse
6
+ assert_round_trip "movz x0, 0xCAFE", output: ["movz x0, #0xcafe"]
7
+ assert_round_trip "movz x0, #0xcafe"
8
+ assert_round_trip "movz x0, #0xcafe, lsl #16"
9
+ assert_round_trip "movz w0, #0xcafe"
10
+ assert_round_trip "movz w0, #0xcafe, lsl #16"
11
+ end
12
+
13
+ def test_autda
14
+ # autda x1, sp
15
+ assert_bytes "autda x1, sp", [0xe1, 0x1b, 0xc1, 0xda]
16
+ assert_bytes "autda x1, x2", [0x41, 0x18, 0xc1, 0xda]
17
+ end
18
+
19
+ def assert_bytes input, bytes
20
+ parser = AArch64::Parser.new
21
+ begin
22
+ asm = parser.parse input
23
+ rescue Racc::ParseError
24
+ puts input
25
+ raise
26
+ end
27
+ io = StringIO.new
28
+ asm.write_to io
29
+ assert_equal bytes, io.string.bytes, ->() {
30
+ pos = 32.times.map { |i| (i % 0x10).to_s(16) }.join.reverse
31
+ actual_bin = sprintf("%032b", io.string.unpack1("L<"))
32
+ expected_bin = sprintf("%032b", bytes.pack("C4").unpack1("L<"))
33
+ broken = []
34
+ actual_bin.bytes.zip(expected_bin.bytes).each_with_index { |(a, b), i|
35
+ broken << (31 - i) unless a == b
36
+ }
37
+ expected_bin, actual_bin = color_diff(expected_bin, actual_bin)
38
+ "idx: #{pos}\nexp: #{expected_bin}\nact: #{actual_bin}\n" +
39
+ broken.reverse.map { |idx| "Bit #{idx} differs" }.join("\n") +
40
+ "\n#{input}"
41
+ }
42
+ end
43
+
44
+ def assert_round_trip input, output: [input]
45
+ parser = AArch64::Parser.new
46
+ asm = parser.parse input
47
+ io = StringIO.new
48
+ asm.write_to io
49
+ assert_equal output, disasm(io.string).map { |x|
50
+ "#{x.mnemonic} #{x.op_str}"
51
+ }
52
+ end
53
+
54
+ def test_add
55
+ assert_bytes "add sp, sp, #0x40", [0xff, 0x03, 0x01, 0x91]
56
+ assert_bytes "add x8, sp, #1, lsl #12", [0xe8, 0x07, 0x40, 0x91]
57
+ assert_bytes "add sp, sp, #1, lsl #12", [0xff, 0x07, 0x40, 0x91]
58
+ assert_bytes "add x8, x10, #1", [0x48, 0x5, 00, 0x91]
59
+ end
60
+
61
+ def test_bls
62
+ assert_bytes "b.ls #0x10", [0x89, 0x00, 0000, 0x54]
63
+ end
64
+
65
+ def test_bhi
66
+ assert_bytes "b.hi #0x28", [0x48, 0x01, 0000, 0x54]
67
+ end
68
+
69
+ def test_bvc
70
+ assert_bytes "b.vc #0x2e8", [0x47, 0x17, 0000, 0x54]
71
+ assert_bytes "b.vc #0x10", [0x87, 0000, 0000, 0x54]
72
+ end
73
+
74
+ def test_bvs
75
+ assert_bytes "b.vs #0x64", [0x26, 0x03, 0000, 0x54]
76
+ assert_bytes "b.vs #0x1c", [0xe6, 0000, 0000, 0x54]
77
+ assert_bytes "b.vs #0xec", [0x66, 0x07, 0000, 0x54]
78
+ end
79
+
80
+ def test_brk
81
+ assert_bytes "brk #0x1", [0x20, 0000, 0x20, 0xd4]
82
+ end
83
+
84
+ def test_cmn
85
+ assert_bytes "cmn wsp, #0x555, lsl #12", [0xff, 0x57, 0x55, 0x31]
86
+ assert_bytes "cmn x18, #0x555", [0x5f, 0x56, 0x15, 0xb1]
87
+ end
88
+
89
+ def test_cmp
90
+ assert_bytes "cmp w0, #1", [0x1f, 0x04, 0000, 0x71]
91
+ end
92
+
93
+ def test_crc32
94
+ assert_bytes "crc32b w5, w7, w20", [0xe5, 0x40, 0xd4, 0x1a]
95
+ assert_bytes "crc32h w28, wzr, w30", [0xfc, 0x47, 0xde, 0x1a]
96
+ assert_bytes "crc32w w0, w1, w2", [0x20, 0x48, 0xc2, 0x1a]
97
+ assert_bytes "crc32x w7, w9, x20", [0x27, 0x4d, 0xd4, 0x9a]
98
+ end
99
+
100
+ def test_crc32c
101
+ assert_bytes "crc32cb w9, w5, w4", [0xa9, 0x50, 0xc4, 0x1a]
102
+ assert_bytes "crc32ch w13, w17, w25", [0x2d, 0x56, 0xd9, 0x1a]
103
+ assert_bytes "crc32cw wzr, w3, w5", [0x7f, 0x58, 0xc5, 0x1a]
104
+ assert_bytes "crc32cx w18, w16, xzr", [0x12, 0x5e, 0xdf, 0x9a]
105
+ end
106
+
107
+ def test_eon
108
+ assert_bytes "eon w1, w2, w3", [0x41, 0000, 0x23, 0x4a]
109
+ assert_bytes "eon x1, x2, x3", [0x41, 0000, 0x23, 0xca]
110
+ assert_bytes "eon w1, w2, w3, lsl #4", [0x41, 0x10, 0x23, 0x4a]
111
+ assert_bytes "eon x1, x2, x3, lsl #4", [0x41, 0x10, 0x23, 0xca]
112
+ assert_bytes "eon w1, w2, w3, lsr #4", [0x41, 0x10, 0x63, 0x4a]
113
+ assert_bytes "eon x1, x2, x3, lsr #4", [0x41, 0x10, 0x63, 0xca]
114
+ assert_bytes "eon w1, w2, w3, asr #4", [0x41, 0x10, 0xa3, 0x4a]
115
+ assert_bytes "eon x1, x2, x3, asr #4", [0x41, 0x10, 0xa3, 0xca]
116
+ assert_bytes "eon w1, w2, w3, ror #4", [0x41, 0x10, 0xe3, 0x4a]
117
+ assert_bytes "eon x1, x2, x3, ror #4", [0x41, 0x10, 0xe3, 0xca]
118
+ end
119
+
120
+ def test_eor
121
+ assert_bytes "eor w1, w2, w3", [0x41, 0000, 0x03, 0x4a]
122
+ assert_bytes "eor x1, x2, x3", [0x41, 0000, 0x03, 0xca]
123
+ assert_bytes "eor w1, w2, w3, lsl #5", [0x41, 0x14, 0x03, 0x4a]
124
+ assert_bytes "eor x1, x2, x3, lsl #5", [0x41, 0x14, 0x03, 0xca]
125
+ assert_bytes "eor w1, w2, w3, lsr #5", [0x41, 0x14, 0x43, 0x4a]
126
+ assert_bytes "eor x1, x2, x3, lsr #5", [0x41, 0x14, 0x43, 0xca]
127
+ assert_bytes "eor w1, w2, w3, asr #5", [0x41, 0x14, 0x83, 0x4a]
128
+ assert_bytes "eor x1, x2, x3, asr #5", [0x41, 0x14, 0x83, 0xca]
129
+ assert_bytes "eor w1, w2, w3, ror #5", [0x41, 0x14, 0xc3, 0x4a]
130
+ assert_bytes "eor x1, x2, x3, ror #5", [0x41, 0x14, 0xc3, 0xca]
131
+ end
132
+
133
+ def test_hlt
134
+ assert_bytes "hlt #0x7b", [0x60, 0x0f, 0x40, 0xd4]
135
+ end
136
+
137
+ def test_hvc
138
+ assert_bytes "hvc #0x1", [0x22, 0000, 0000, 0xd4]
139
+ end
140
+
141
+ def test_ldursh
142
+ assert_bytes "ldursh x17, [x19, #-0x100]", [0x71, 0x02, 0x90, 0x78]
143
+ assert_bytes "ldursh w15, [x21, #-0x100]", [0xaf, 0x02, 0xd0, 0x78]
144
+ end
145
+
146
+ def test_movz
147
+ assert_bytes "movz x0, #0x2a", [0x40, 0x05, 0x80, 0xd2]
148
+ end
149
+
150
+ def test_movk
151
+ assert_bytes "movk x0, #0x2a", [0x40, 0x05, 0x80, 0xf2]
152
+ assert_bytes "movk x0, #0x2a, lsl #16", [0x40, 0x05, 0xa0, 0xf2]
153
+ end
154
+
155
+ def test_movn
156
+ assert_bytes "movn w0, #0x2", [0x40, 0000, 0x80, 0x12]
157
+ assert_bytes "movn x0, #0x2", [0x40, 0000, 0x80, 0x92]
158
+ assert_bytes "movn w0, #0x2, lsl #16", [0x40, 0000, 0xa0, 0x12]
159
+ assert_bytes "movn x0, #0x2, lsl #16", [0x40, 0000, 0xa0, 0x92]
160
+ assert_bytes "movn w2, #0x4d2", [0x42, 0x9a, 0x80, 0x12]
161
+ end
162
+
163
+ def test_msr
164
+ assert_bytes "msr dbgdtrtx_el0, x3", [0x03, 0x05, 0x13, 0xd5]
165
+ assert_bytes "msr lorsa_el1, x0", [0000, 0xa4, 0x18, 0xd5]
166
+ assert_bytes "msr lorea_el1, x0", [0x20, 0xa4, 0x18, 0xd5]
167
+ assert_bytes "msr lorn_el1, x0", [0x40, 0xa4, 0x18, 0xd5]
168
+ assert_bytes "msr lorc_el1, x0", [0x60, 0xa4, 0x18, 0xd5]
169
+ assert_bytes "msr pan, x5", [0x65, 0x42, 0x18, 0xd5]
170
+ assert_bytes "msr ttbr1_el2, x0", [0x20, 0x20, 0x1c, 0xd5]
171
+ assert_bytes "msr s3_0_c5_c3_1, x0", [0x20, 0x53, 0x18, 0xd5]
172
+ end
173
+
174
+ def test_mrs
175
+ assert_bytes "mrs x3, afsr0_el1", [0x03, 0x51, 0x38, 0xd5]
176
+ assert_bytes "mrs x3, afsr0_el2", [0x03, 0x51, 0x3c, 0xd5]
177
+ assert_bytes "mrs x3, afsr0_el3", [0x03, 0x51, 0x3e, 0xd5]
178
+ assert_bytes "mrs x3, aidr_el1", [0xe3, 0000, 0x39, 0xd5]
179
+ assert_bytes "mrs x3, afsr1_el1", [0x23, 0x51, 0x38, 0xd5]
180
+ assert_bytes "mrs x3, afsr1_el2", [0x23, 0x51, 0x3c, 0xd5]
181
+ assert_bytes "mrs x3, afsr1_el3", [0x23, 0x51, 0x3e, 0xd5]
182
+ assert_bytes "mrs x3, amair_el1", [0x03, 0xa3, 0x38, 0xd5]
183
+ assert_bytes "mrs x3, amair_el2", [0x03, 0xa3, 0x3c, 0xd5]
184
+ assert_bytes "mrs x3, amair_el3", [0x03, 0xa3, 0x3e, 0xd5]
185
+ assert_bytes "mrs x3, ccsidr_el1", [0x03, 0000, 0x39, 0xd5]
186
+ assert_bytes "mrs x3, clidr_el1", [0x23, 0000, 0x39, 0xd5]
187
+ assert_bytes "mrs x6, s3_0_c12_c1_1", [0x26, 0xc1, 0x38, 0xd5]
188
+ assert_bytes "mrs x7, s3_4_c12_c1_1", [0x27, 0xc1, 0x3c, 0xd5]
189
+ end
190
+
191
+ def test_mvn
192
+ assert_bytes "mvn w4, w9", [0xe4, 0x03, 0x29, 0x2a]
193
+ assert_bytes "mvn x2, x3", [0xe2, 0x03, 0x23, 0xaa]
194
+ assert_bytes "mvn w4, w9", [0xe4, 0x03, 0x29, 0x2a]
195
+ assert_bytes "mvn w4, w9, lsl #1", [0xe4, 0x07, 0x29, 0x2a]
196
+ assert_bytes "mvn x2, x3, lsl #1", [0xe2, 0x07, 0x23, 0xaa]
197
+ assert_bytes "mvn w4, w9, lsl #1", [0xe4, 0x07, 0x29, 0x2a]
198
+ end
199
+
200
+ def test_orr
201
+ assert_bytes "orr w1, w2, w3", [0x41, 0000, 0x03, 0x2a]
202
+ assert_bytes "orr x1, x2, x3", [0x41, 0000, 0x03, 0xaa]
203
+ end
204
+
205
+ def test_prfm
206
+ assert_bytes "prfm plil2keep, #4", [0x2a, 0000, 0000, 0xd8]
207
+ assert_bytes "prfm #0x1f, [sp, #0x20]", [0xff, 0x13, 0x80, 0xf9]
208
+ assert_bytes "prfm pldl1keep, [x2]", [0x40, 0000, 0x80, 0xf9]
209
+ assert_bytes "prfm pldl1strm, [x2]", [0x41, 0000, 0x80, 0xf9]
210
+ assert_bytes "prfm pldl2keep, [x2]", [0x42, 0000, 0x80, 0xf9]
211
+ assert_bytes "prfm pldl2strm, [x2]", [0x43, 0000, 0x80, 0xf9]
212
+ assert_bytes "prfm pldl3keep, [x2]", [0x44, 0000, 0x80, 0xf9]
213
+ assert_bytes "prfm pldl3strm, [x2]", [0x45, 0000, 0x80, 0xf9]
214
+ assert_bytes "prfm pstl1keep, [x2]", [0x50, 0000, 0x80, 0xf9]
215
+ assert_bytes "prfm pstl1strm, [x2]", [0x51, 0000, 0x80, 0xf9]
216
+ assert_bytes "prfm pstl2keep, [x2]", [0x52, 0000, 0x80, 0xf9]
217
+ assert_bytes "prfm pstl2strm, [x2]", [0x53, 0000, 0x80, 0xf9]
218
+ assert_bytes "prfm pstl3keep, [x2]", [0x54, 0000, 0x80, 0xf9]
219
+ assert_bytes "prfm pstl3strm, [x2]", [0x55, 0000, 0x80, 0xf9]
220
+ end
221
+
222
+ def test_smc
223
+ assert_bytes "smc #0xf", [0xe3, 0x01, 0000, 0xd4]
224
+ end
225
+
226
+ def test_stnp
227
+ assert_bytes "stnp x4, x9, [sp, #-0x10]", [0xe4, 0x27, 0x3f, 0xa8]
228
+ end
229
+
230
+ def test_stp
231
+ assert_bytes "stp x0, x1, [sp]", [0xe0, 0x07, 0000, 0xa9]
232
+ end
233
+
234
+ def test_strh
235
+ assert_bytes "strh wzr, [x8, x9]", [0x1f, 0x69, 0x29, 0x78]
236
+ end
237
+
238
+ def test_hint
239
+ assert_bytes "hint #0xc", [0x9f, 0x21, 0x03, 0xd5]
240
+ end
241
+
242
+ def test_tbz
243
+ assert_bytes "tbz w3, #5, #4", [0x23, 0000, 0x28, 0x36]
244
+ end
245
+
246
+ def test_tbnz
247
+ assert_bytes "tbnz w3, #5, #4", [0x23, 0000, 0x28, 0x37]
248
+ end
249
+
250
+ def test_tst
251
+ assert_bytes "tst w1, w2", [0x3f, 0000, 0x02, 0x6a]
252
+ assert_bytes "tst x1, x2", [0x3f, 0000, 0x02, 0xea]
253
+ end
254
+
255
+ def test_generated_dc
256
+ assert_bytes "dc cisw, x30", [0x5e,0x7e,0x08,0xd5]
257
+ assert_bytes "dc civac, x3", [0x23,0x7e,0x0b,0xd5]
258
+ assert_bytes "dc csw, x10", [0x4a,0x7a,0x08,0xd5]
259
+ assert_bytes "dc cvac, x9", [0x29,0x7a,0x0b,0xd5]
260
+ assert_bytes "dc cvau, x0", [0x20,0x7b,0x0b,0xd5]
261
+ assert_bytes "dc isw, x2", [0x42,0x76,0x08,0xd5]
262
+ assert_bytes "dc ivac, xzr", [0x3f,0x76,0x08,0xd5]
263
+ assert_bytes "dc zva, x12", [0x2c,0x74,0x0b,0xd5]
264
+ end
265
+
266
+ def test_generated_ic
267
+ assert_bytes "ic iallu", [0x1f,0x75,0x08,0xd5]
268
+ assert_bytes "ic ialluis", [0x1f,0x71,0x08,0xd5]
269
+ assert_bytes "ic ivau, x9", [0x29,0x75,0x0b,0xd5]
270
+ end
271
+
272
+ def test_generated_adc
273
+ assert_bytes "adc w20, w0, wzr", [0x14,0x00,0x1f,0x1a]
274
+ assert_bytes "adc w29, w27, w25", [0x7d,0x03,0x19,0x1a]
275
+ assert_bytes "adc w9, wzr, w10", [0xe9,0x03,0x0a,0x1a]
276
+ assert_bytes "adc wzr, w3, w4", [0x7f,0x00,0x04,0x1a]
277
+ assert_bytes "adc x20, x0, xzr", [0x14,0x00,0x1f,0x9a]
278
+ assert_bytes "adc x29, x27, x25", [0x7d,0x03,0x19,0x9a]
279
+ assert_bytes "adc x9, xzr, x10", [0xe9,0x03,0x0a,0x9a]
280
+ assert_bytes "adc xzr, x3, x4", [0x7f,0x00,0x04,0x9a]
281
+ end
282
+
283
+ def test_generated_adcs
284
+ assert_bytes "adcs w20, w0, wzr", [0x14,0x00,0x1f,0x3a]
285
+ assert_bytes "adcs w29, w27, w25", [0x7d,0x03,0x19,0x3a]
286
+ assert_bytes "adcs w9, wzr, w10", [0xe9,0x03,0x0a,0x3a]
287
+ assert_bytes "adcs wzr, w3, w4", [0x7f,0x00,0x04,0x3a]
288
+ assert_bytes "adcs x20, x0, xzr", [0x14,0x00,0x1f,0xba]
289
+ assert_bytes "adcs x29, x27, x25", [0x7d,0x03,0x19,0xba]
290
+ assert_bytes "adcs x9, xzr, x10", [0xe9,0x03,0x0a,0xba]
291
+ assert_bytes "adcs xzr, x3, x4", [0x7f,0x00,0x04,0xba]
292
+ end
293
+
294
+ def test_generated_add
295
+ assert_bytes "add x17, x29, x20, asr #58", [0xb1,0xeb,0x94,0x8b]
296
+ assert_bytes "add x17, x29, x20, lsl #58", [0xb1,0xeb,0x14,0x8b]
297
+ assert_bytes "add x17, x29, x20, lsr #58", [0xb1,0xeb,0x54,0x8b]
298
+ assert_bytes "add sp, x2, w3, sxtw", [0x5f,0xc0,0x23,0x8b]
299
+ assert_bytes "add sp, x29, #3816", [0xbf,0xa3,0x3b,0x91]
300
+ assert_bytes "add w0, w2, w3, sxtw", [0x40,0xc0,0x23,0x0b]
301
+ assert_bytes "add w11, w13, w15", [0xab,0x01,0x0f,0x0b]
302
+ assert_bytes "add w13, w5, #4095, lsl #12", [0xad,0xfc,0x7f,0x11]
303
+ assert_bytes "add w17, w19, w23, uxtw #2", [0x71,0x4a,0x37,0x0b]
304
+ assert_bytes "add w17, w29, w20, lsl #29", [0xb1,0x77,0x14,0x0b]
305
+ assert_bytes "add w17, w29, w20, lsl #31", [0xb1,0x7f,0x14,0x0b]
306
+ assert_bytes "add w19, w17, w1, uxtx", [0x33,0x62,0x21,0x0b]
307
+ assert_bytes "add w2, w3, #4095", [0x62,0xfc,0x3f,0x11]
308
+ assert_bytes "add w2, w3, w4, asr #0", [0x62,0x00,0x84,0x0b]
309
+ assert_bytes "add w2, w3, w5, sxtx", [0x62,0xe0,0x25,0x0b]
310
+ assert_bytes "add w2, w5, w1, sxtb", [0xa2,0x80,0x21,0x0b]
311
+ assert_bytes "add w2, w5, w7, uxtb", [0xa2,0x00,0x27,0x0b]
312
+ assert_bytes "add w2, wsp, w3, lsl #1", [0xe2,0x47,0x23,0x0b]
313
+ assert_bytes "add w20, wsp, #801", [0xf4,0x87,0x0c,0x11]
314
+ assert_bytes "add w20, wzr, w4", [0xf4,0x03,0x04,0x0b]
315
+ assert_bytes "add w21, w15, w17, uxth", [0xf5,0x21,0x31,0x0b]
316
+ assert_bytes "add w21, w22, w23, lsr #0", [0xd5,0x02,0x57,0x0b]
317
+ assert_bytes "add w24, w25, w26, lsr #18", [0x38,0x4b,0x5a,0x0b]
318
+ assert_bytes "add w26, w17, w19, sxth", [0x3a,0xa2,0x33,0x0b]
319
+ assert_bytes "add w27, w28, w29, lsr #29", [0x9b,0x77,0x5d,0x0b]
320
+ assert_bytes "add w27, w28, w29, lsr #31", [0x9b,0x7f,0x5d,0x0b]
321
+ assert_bytes "add w29, w23, w17, uxtx #1", [0xfd,0x66,0x31,0x0b]
322
+ assert_bytes "add w3, w5, w7", [0xa3,0x00,0x07,0x0b]
323
+ assert_bytes "add w30, w29, #1, lsl #12", [0xbe,0x07,0x40,0x11]
324
+ assert_bytes "add w30, w29, wzr, uxtw", [0xbe,0x43,0x3f,0x0b]
325
+ assert_bytes "add w4, w5, #0", [0xa4,0x00,0x00,0x11]
326
+ assert_bytes "add w4, w6, wzr", [0xc4,0x00,0x1f,0x0b]
327
+ assert_bytes "add w5, w6, w7, asr #21", [0xc5,0x54,0x87,0x0b]
328
+ assert_bytes "add w8, w9, w10, asr #29", [0x28,0x75,0x8a,0x0b]
329
+ assert_bytes "add w8, w9, w10, asr #31", [0x28,0x7d,0x8a,0x0b]
330
+ assert_bytes "add w9, w3, wzr, lsl #10", [0x69,0x28,0x1f,0x0b]
331
+ assert_bytes "add wsp, w30, #4084", [0xdf,0xd3,0x3f,0x11]
332
+ assert_bytes "add wsp, wsp, #1104", [0xff,0x43,0x11,0x11]
333
+ assert_bytes "add wzr, w3, w5", [0x7f,0x00,0x05,0x0b]
334
+ assert_bytes "add x0, x24, #291", [0x00,0x8f,0x04,0x91]
335
+ assert_bytes "add x11, x13, x15", [0xab,0x01,0x0f,0x8b]
336
+ assert_bytes "add x12, x1, w20, uxtw", [0x2c,0x40,0x34,0x8b]
337
+ assert_bytes "add x17, x25, w20, sxtb", [0x31,0x83,0x34,0x8b]
338
+ assert_bytes "add x17, x29, x20, lsl #63", [0xb1,0xff,0x14,0x8b]
339
+ assert_bytes "add x18, x13, w19, sxth", [0xb2,0xa1,0x33,0x8b]
340
+ assert_bytes "add x2, x3, w5, sxtb", [0x62,0x80,0x25,0x8b]
341
+ assert_bytes "add x2, x3, x4, asr #0", [0x62,0x00,0x84,0x8b]
342
+ assert_bytes "add x2, x4, w5, uxtb", [0x82,0x00,0x25,0x8b]
343
+ assert_bytes "add x20, sp, w19, uxth", [0xf4,0x23,0x33,0x8b]
344
+ assert_bytes "add x20, x3, x13, uxtx", [0x74,0x60,0x2d,0x8b]
345
+ assert_bytes "add x20, xzr, x4", [0xf4,0x03,0x04,0x8b]
346
+ assert_bytes "add x21, x22, x23, lsr #0", [0xd5,0x02,0x57,0x8b]
347
+ assert_bytes "add x24, x25, x26, lsr #18", [0x38,0x4b,0x5a,0x8b]
348
+ assert_bytes "add x27, x28, x29, lsr #63", [0x9b,0xff,0x5d,0x8b]
349
+ assert_bytes "add x3, x24, #4095, lsl #12", [0x03,0xff,0x7f,0x91]
350
+ assert_bytes "add x3, x5, x7", [0xa3,0x00,0x07,0x8b]
351
+ assert_bytes "add x3, x5, x9, sxtx", [0xa3,0xe0,0x29,0x8b]
352
+ assert_bytes "add x4, x6, xzr", [0xc4,0x00,0x1f,0x8b]
353
+ assert_bytes "add x5, x6, x7, asr #21", [0xc5,0x54,0x87,0x8b]
354
+ assert_bytes "add x5, x7, #1638", [0xe5,0x98,0x19,0x91]
355
+ assert_bytes "add x7, x11, w13, uxth #4", [0x67,0x31,0x2d,0x8b]
356
+ assert_bytes "add x8, sp, #1074", [0xe8,0xcb,0x10,0x91]
357
+ assert_bytes "add x8, x9, x10, asr #63", [0x28,0xfd,0x8a,0x8b]
358
+ assert_bytes "add x9, x3, xzr, lsl #10", [0x69,0x28,0x1f,0x8b]
359
+ assert_bytes "add xzr, x3, x5", [0x7f,0x00,0x05,0x8b]
360
+ end
361
+
362
+ def test_generated_adds
363
+ assert_bytes "adds w11, w13, w15", [0xab,0x01,0x0f,0x2b]
364
+ assert_bytes "adds w13, w23, #291, lsl #12", [0xed,0x8e,0x44,0x31]
365
+ assert_bytes "adds w17, w29, w20, lsl #31", [0xb1,0x7f,0x14,0x2b]
366
+ assert_bytes "adds w19, w17, w1, uxtx", [0x33,0x62,0x21,0x2b]
367
+ assert_bytes "adds w2, w3, w4, asr #0", [0x62,0x00,0x84,0x2b]
368
+ assert_bytes "adds w2, w3, w5, sxtx", [0x62,0xe0,0x25,0x2b]
369
+ assert_bytes "adds w2, w5, w1, sxtb #1", [0xa2,0x84,0x21,0x2b]
370
+ assert_bytes "adds w2, w5, w7, uxtb", [0xa2,0x00,0x27,0x2b]
371
+ assert_bytes "adds w20, wsp, #0", [0xf4,0x03,0x00,0x31]
372
+ assert_bytes "adds w20, wzr, w4", [0xf4,0x03,0x04,0x2b]
373
+ assert_bytes "adds w21, w15, w17, uxth", [0xf5,0x21,0x31,0x2b]
374
+ assert_bytes "adds w21, w22, w23, lsr #0", [0xd5,0x02,0x57,0x2b]
375
+ assert_bytes "adds w24, w25, w26, lsr #18", [0x38,0x4b,0x5a,0x2b]
376
+ assert_bytes "adds w26, wsp, w19, sxth", [0xfa,0xa3,0x33,0x2b]
377
+ assert_bytes "adds w27, w28, w29, lsr #31", [0x9b,0x7f,0x5d,0x2b]
378
+ assert_bytes "adds w3, w5, w7", [0xa3,0x00,0x07,0x2b]
379
+ assert_bytes "adds w30, w29, wzr, uxtw", [0xbe,0x43,0x3f,0x2b]
380
+ assert_bytes "adds w4, w6, wzr", [0xc4,0x00,0x1f,0x2b]
381
+ assert_bytes "adds w5, w6, w7, asr #21", [0xc5,0x54,0x87,0x2b]
382
+ assert_bytes "adds w8, w9, w10, asr #31", [0x28,0x7d,0x8a,0x2b]
383
+ assert_bytes "adds w9, w3, wzr, lsl #10", [0x69,0x28,0x1f,0x2b]
384
+ assert_bytes "adds x11, x13, x15", [0xab,0x01,0x0f,0xab]
385
+ assert_bytes "adds x12, x1, w20, uxtw", [0x2c,0x40,0x34,0xab]
386
+ assert_bytes "adds x17, x29, x20, lsl #63", [0xb1,0xff,0x14,0xab]
387
+ assert_bytes "adds x18, sp, w19, sxth", [0xf2,0xa3,0x33,0xab]
388
+ assert_bytes "adds x2, x3, x4, asr #0", [0x62,0x00,0x84,0xab]
389
+ assert_bytes "adds x2, x4, w5, uxtb #2", [0x82,0x08,0x25,0xab]
390
+ assert_bytes "adds x20, sp, w19, uxth #4", [0xf4,0x33,0x33,0xab]
391
+ assert_bytes "adds x20, x3, x13, uxtx", [0x74,0x60,0x2d,0xab]
392
+ assert_bytes "adds x20, xzr, x4", [0xf4,0x03,0x04,0xab]
393
+ assert_bytes "adds x21, x22, x23, lsr #0", [0xd5,0x02,0x57,0xab]
394
+ assert_bytes "adds x24, x25, x26, lsr #18", [0x38,0x4b,0x5a,0xab]
395
+ assert_bytes "adds x27, x28, x29, lsr #63", [0x9b,0xff,0x5d,0xab]
396
+ assert_bytes "adds x3, x5, x7", [0xa3,0x00,0x07,0xab]
397
+ assert_bytes "adds x3, x5, x9, sxtx #2", [0xa3,0xe8,0x29,0xab]
398
+ assert_bytes "adds x4, x6, xzr", [0xc4,0x00,0x1f,0xab]
399
+ assert_bytes "adds x5, x6, x7, asr #21", [0xc5,0x54,0x87,0xab]
400
+ assert_bytes "adds x8, x9, x10, asr #63", [0x28,0xfd,0x8a,0xab]
401
+ assert_bytes "adds x9, x3, xzr, lsl #10", [0x69,0x28,0x1f,0xab]
402
+ end
403
+
404
+ def test_generated_adr
405
+ assert_bytes "adr x2, #-1048576", [0x02,0x00,0x80,0x10]
406
+ assert_bytes "adr x20, #0", [0x14,0x00,0x00,0x10]
407
+ assert_bytes "adr x5, #1048575", [0xe5,0xff,0x7f,0x70]
408
+ assert_bytes "adr x9, #-1", [0xe9,0xff,0xff,0x70]
409
+ assert_bytes "adr x9, #1048575", [0xe9,0xff,0x7f,0x70]
410
+ end
411
+
412
+ def test_generated_adrp
413
+ assert_bytes "adrp x20, #-4294967296", [0x14,0x00,0x80,0x90]
414
+ assert_bytes "adrp x30, #4096", [0x1e,0x00,0x00,0xb0]
415
+ assert_bytes "adrp x9, #4294963200", [0xe9,0xff,0x7f,0xf0]
416
+ end
417
+
418
+ def test_generated_and
419
+ assert_bytes "and w2, w3, #0xfffffffd", [0x62,0x78,0x1e,0x12]
420
+ assert_bytes "and w0, w2, wzr, lsr #17", [0x40,0x44,0x5f,0x0a]
421
+ assert_bytes "and w11, wzr, #0x30003", [0xeb,0x87,0x00,0x12]
422
+ assert_bytes "and w12, w13, #0xffc3ffc3", [0xac,0xad,0x0a,0x12]
423
+ assert_bytes "and w12, w23, w21", [0xec,0x02,0x15,0x0a]
424
+ assert_bytes "and w14, w15, #0x80008000", [0xee,0x81,0x01,0x12]
425
+ assert_bytes "and w16, w15, w1, lsl #1", [0xf0,0x05,0x01,0x0a]
426
+ assert_bytes "and w3, w17, w19, ror #31", [0x23,0x7e,0xd3,0x0a]
427
+ assert_bytes "and w3, w30, w11", [0xc3,0x03,0x0b,0x0a]
428
+ assert_bytes "and w3, w30, w11, asr #0", [0xc3,0x03,0x8b,0x0a]
429
+ assert_bytes "and w3, wzr, w20, ror #0", [0xe3,0x03,0xd4,0x0a]
430
+ assert_bytes "and w9, w4, w10, lsl #31", [0x89,0x7c,0x0a,0x0a]
431
+ assert_bytes "and x11, xzr, #0x3000300030003", [0xeb,0x87,0x00,0x92]
432
+ assert_bytes "and x12, x13, #0xffc3ffc3ffc3ffc3", [0xac,0xad,0x0a,0x92]
433
+ assert_bytes "and x14, x15, #0x8000800080008000", [0xee,0x81,0x01,0x92]
434
+ assert_bytes "and x3, x5, x7, lsl #63", [0xa3,0xfc,0x07,0x8a]
435
+ assert_bytes "and x5, x14, x19, asr #4", [0xc5,0x11,0x93,0x8a]
436
+ assert_bytes "and x7, x20, xzr, asr #63", [0x87,0xfe,0x9f,0x8a]
437
+ assert_bytes "and x9, x10, #0x7fffffffffff", [0x49,0xb9,0x40,0x92]
438
+ assert_bytes "and xzr, x4, x26", [0x9f,0x00,0x1a,0x8a]
439
+ end
440
+
441
+ def test_generated_ands
442
+ assert_bytes "ands w19, w20, #0xfffffff0", [0x93,0x6e,0x1c,0x72]
443
+ assert_bytes "ands w19, w20, #0x33333333", [0x93,0xe6,0x00,0x72]
444
+ assert_bytes "ands w21, w22, #0x99999999", [0xd5,0xe6,0x01,0x72]
445
+ assert_bytes "ands w7, wzr, w9, lsl #1", [0xe7,0x07,0x09,0x6a]
446
+ assert_bytes "ands x19, x20, #0x3333333333333333", [0x93,0xe6,0x00,0xf2]
447
+ assert_bytes "ands x21, x22, #0x9999999999999999", [0xd5,0xe6,0x01,0xf2]
448
+ assert_bytes "ands x3, x5, x20, ror #63", [0xa3,0xfc,0xd4,0xea]
449
+ end
450
+
451
+ def test_generated_asr
452
+ assert_bytes "asr w18, w19, w20", [0x72,0x2a,0xd4,0x1a]
453
+ assert_bytes "asr w23, w24, w25", [0x17,0x2b,0xd9,0x1a]
454
+ assert_bytes "asr x21, x22, x23", [0xd5,0x2a,0xd7,0x9a]
455
+ assert_bytes "asr x26, x27, x28", [0x7a,0x2b,0xdc,0x9a]
456
+ assert_bytes "asr w1, wzr, #3", [0xe1,0x7f,0x03,0x13]
457
+ assert_bytes "asr w3, w2, #0", [0x43,0x7c,0x00,0x13]
458
+ assert_bytes "asr w9, w10, #31", [0x49,0x7d,0x1f,0x13]
459
+ assert_bytes "asr wzr, wzr, #31", [0xff,0x7f,0x1f,0x13]
460
+ assert_bytes "asr x20, x21, #63", [0xb4,0xfe,0x7f,0x93]
461
+ assert_bytes "asr x3, x4, #63", [0x83,0xfc,0x7f,0x93]
462
+ assert_bytes "asr w11, w12, #31", [0x8b,0x7d,0x1f,0x13]
463
+ assert_bytes "asr w13, w14, #29", [0xcd,0x7d,0x1d,0x13]
464
+ assert_bytes "asr w9, w10, #0", [0x49,0x7d,0x00,0x13]
465
+ assert_bytes "asr x19, x20, #0", [0x93,0xfe,0x40,0x93]
466
+ assert_bytes "asr x2, x3, #63", [0x62,0xfc,0x7f,0x93]
467
+ assert_bytes "asr x9, x10, #5", [0x49,0xfd,0x45,0x93]
468
+ assert_bytes "asr w9, w10, #0", [0x49,0x7d,0x00,0x13]
469
+ assert_bytes "asr x19, x20, #0", [0x93,0xfe,0x40,0x93]
470
+ end
471
+
472
+ def test_generated_at
473
+ assert_bytes "at s12e0r, x20", [0xd4,0x78,0x0c,0xd5]
474
+ assert_bytes "at s12e0w, x20", [0xf4,0x78,0x0c,0xd5]
475
+ assert_bytes "at s12e1r, x20", [0x94,0x78,0x0c,0xd5]
476
+ assert_bytes "at s12e1w, x20", [0xb4,0x78,0x0c,0xd5]
477
+ assert_bytes "at s1e0r, x19", [0x53,0x78,0x08,0xd5]
478
+ assert_bytes "at s1e0w, x19", [0x73,0x78,0x08,0xd5]
479
+ assert_bytes "at s1e1r, x19", [0x13,0x78,0x08,0xd5]
480
+ assert_bytes "at s1e1w, x19", [0x33,0x78,0x08,0xd5]
481
+ assert_bytes "at s1e2r, x19", [0x13,0x78,0x0c,0xd5]
482
+ assert_bytes "at s1e2w, x19", [0x33,0x78,0x0c,0xd5]
483
+ assert_bytes "at s1e3r, x19", [0x13,0x78,0x0e,0xd5]
484
+ assert_bytes "at s1e3w, x19", [0x33,0x78,0x0e,0xd5]
485
+ end
486
+
487
+ def test_generated_b
488
+ assert_bytes "b #134217724", [0xff,0xff,0xff,0x15]
489
+ assert_bytes "b #4", [0x01,0x00,0x00,0x14]
490
+ assert_bytes "b.eq #0", [0x00,0x00,0x00,0x54]
491
+ assert_bytes "b.lo #1048572", [0xe3,0xff,0x7f,0x54]
492
+ assert_bytes "b.lt #-4", [0xeb,0xff,0xff,0x54]
493
+ end
494
+
495
+ def test_generated_bfi
496
+ assert_bytes "bfi w11, w12, #31, #1", [0x8b,0x01,0x01,0x33]
497
+ assert_bytes "bfi w13, w14, #29, #3", [0xcd,0x09,0x03,0x33]
498
+ assert_bytes "bfi x2, x3, #63, #1", [0x62,0x00,0x41,0xb3]
499
+ assert_bytes "bfi x4, x5, #52, #11", [0xa4,0x28,0x4c,0xb3]
500
+ assert_bytes "bfi x4, xzr, #1, #6", [0xe4,0x17,0x7f,0xb3]
501
+ assert_bytes "bfi x9, x10, #5, #59", [0x49,0xe9,0x7b,0xb3]
502
+ assert_bytes "bfi xzr, xzr, #10, #11", [0xff,0x2b,0x76,0xb3]
503
+ assert_bytes "bfi wzr, wzr, #31, #1", [0xff,0x03,0x01,0x33]
504
+ assert_bytes "bfi x0, xzr, #5, #9", [0xe0,0x23,0x7b,0xb3]
505
+ assert_bytes "bfi xzr, xzr, #63, #1", [0xff,0x03,0x41,0xb3]
506
+ end
507
+
508
+ def test_generated_bfxil
509
+ assert_bytes "bfxil w11, w12, #31, #1", [0x8b,0x7d,0x1f,0x33]
510
+ assert_bytes "bfxil w13, w14, #29, #3", [0xcd,0x7d,0x1d,0x33]
511
+ assert_bytes "bfxil w9, w10, #0, #1", [0x49,0x01,0x00,0x33]
512
+ assert_bytes "bfxil w9, w10, #0, #32", [0x49,0x7d,0x00,0x33]
513
+ assert_bytes "bfxil x19, x20, #0, #64", [0x93,0xfe,0x40,0xb3]
514
+ assert_bytes "bfxil x2, x3, #63, #1", [0x62,0xfc,0x7f,0xb3]
515
+ assert_bytes "bfxil x5, x6, #12, #52", [0xc5,0xfc,0x4c,0xb3]
516
+ assert_bytes "bfxil x9, x10, #5, #59", [0x49,0xfd,0x45,0xb3]
517
+ assert_bytes "bfxil xzr, x4, #0, #1", [0x9f,0x00,0x40,0xb3]
518
+ assert_bytes "bfxil xzr, xzr, #10, #11", [0xff,0x53,0x4a,0xb3]
519
+ assert_bytes "bfxil w3, wzr, #0, #32", [0xe3,0x7f,0x00,0x33]
520
+ end
521
+
522
+ def test_generated_bic
523
+ assert_bytes "bic w2, w7, w9", [0xe2,0x00,0x29,0x0a]
524
+ assert_bytes "bic x13, x20, x14, lsl #47", [0x8d,0xbe,0x2e,0x8a]
525
+ end
526
+
527
+ def test_generated_bics
528
+ assert_bytes "bics w3, w5, w7", [0xa3,0x00,0x27,0x6a]
529
+ assert_bytes "bics x3, xzr, x3, lsl #1", [0xe3,0x07,0x23,0xea]
530
+ end
531
+
532
+ def test_generated_bl
533
+ assert_bytes "bl #-134217728", [0x00,0x00,0x00,0x96]
534
+ assert_bytes "bl #0", [0x00,0x00,0x00,0x94]
535
+ end
536
+
537
+ def test_generated_blr
538
+ assert_bytes "blr xzr", [0xe0,0x03,0x3f,0xd6]
539
+ end
540
+
541
+ def test_generated_br
542
+ assert_bytes "br x20", [0x80,0x02,0x1f,0xd6]
543
+ end
544
+
545
+ def test_generated_cbnz
546
+ assert_bytes "cbnz x3, #-4", [0xe3,0xff,0xff,0xb5]
547
+ assert_bytes "cbnz xzr, #-1048576", [0x1f,0x00,0x80,0xb5]
548
+ end
549
+
550
+ def test_generated_cbz
551
+ assert_bytes "cbz w20, #1048572", [0xf4,0xff,0x7f,0x34]
552
+ assert_bytes "cbz w5, #0", [0x05,0x00,0x00,0x34]
553
+ end
554
+
555
+ def test_generated_ccmn
556
+ assert_bytes "ccmn w1, #31, #0, eq", [0x20,0x08,0x5f,0x3a]
557
+ assert_bytes "ccmn w1, wzr, #0, eq", [0x20,0x00,0x5f,0x3a]
558
+ assert_bytes "ccmn w3, #0, #15, hs", [0x6f,0x28,0x40,0x3a]
559
+ assert_bytes "ccmn w3, w0, #15, hs", [0x6f,0x20,0x40,0x3a]
560
+ assert_bytes "ccmn wzr, #15, #13, hs", [0xed,0x2b,0x4f,0x3a]
561
+ assert_bytes "ccmn wzr, w15, #13, hs", [0xed,0x23,0x4f,0x3a]
562
+ assert_bytes "ccmn x3, #0, #15, gt", [0x6f,0xc8,0x40,0xba]
563
+ assert_bytes "ccmn x3, x0, #15, gt", [0x6f,0xc0,0x40,0xba]
564
+ assert_bytes "ccmn x9, #31, #0, le", [0x20,0xd9,0x5f,0xba]
565
+ assert_bytes "ccmn x9, xzr, #0, le", [0x20,0xd1,0x5f,0xba]
566
+ assert_bytes "ccmn xzr, #5, #7, ne", [0xe7,0x1b,0x45,0xba]
567
+ assert_bytes "ccmn xzr, x5, #7, ne", [0xe7,0x13,0x45,0xba]
568
+ end
569
+
570
+ def test_generated_ccmp
571
+ assert_bytes "ccmp w1, #31, #0, eq", [0x20,0x08,0x5f,0x7a]
572
+ assert_bytes "ccmp w1, wzr, #0, eq", [0x20,0x00,0x5f,0x7a]
573
+ assert_bytes "ccmp w3, #0, #15, hs", [0x6f,0x28,0x40,0x7a]
574
+ assert_bytes "ccmp w3, w0, #15, hs", [0x6f,0x20,0x40,0x7a]
575
+ assert_bytes "ccmp wzr, #15, #13, hs", [0xed,0x2b,0x4f,0x7a]
576
+ assert_bytes "ccmp wzr, w15, #13, hs", [0xed,0x23,0x4f,0x7a]
577
+ assert_bytes "ccmp x3, #0, #15, gt", [0x6f,0xc8,0x40,0xfa]
578
+ assert_bytes "ccmp x3, x0, #15, gt", [0x6f,0xc0,0x40,0xfa]
579
+ assert_bytes "ccmp x9, #31, #0, le", [0x20,0xd9,0x5f,0xfa]
580
+ assert_bytes "ccmp x9, xzr, #0, le", [0x20,0xd1,0x5f,0xfa]
581
+ assert_bytes "ccmp xzr, #5, #7, ne", [0xe7,0x1b,0x45,0xfa]
582
+ assert_bytes "ccmp xzr, x5, #7, ne", [0xe7,0x13,0x45,0xfa]
583
+ end
584
+
585
+ def test_generated_cinc
586
+ assert_bytes "cinc x3, x5, gt", [0xa3,0xd4,0x85,0x9a]
587
+ assert_bytes "cinc xzr, x4, le", [0x9f,0xc4,0x84,0x9a]
588
+ assert_bytes "cinc w3, w5, gt", [0xa3,0xd4,0x85,0x1a]
589
+ assert_bytes "cinc wzr, w4, le", [0x9f,0xc4,0x84,0x1a]
590
+ end
591
+
592
+ def test_generated_cinv
593
+ assert_bytes "cinv w3, w5, gt", [0xa3,0xd0,0x85,0x5a]
594
+ assert_bytes "cinv wzr, w4, le", [0x9f,0xc0,0x84,0x5a]
595
+ assert_bytes "cinv x3, x5, gt", [0xa3,0xd0,0x85,0xda]
596
+ assert_bytes "cinv xzr, x4, le", [0x9f,0xc0,0x84,0xda]
597
+ end
598
+
599
+ def test_generated_clrex
600
+ assert_bytes "clrex", [0x5f,0x3f,0x03,0xd5]
601
+ assert_bytes "clrex #0", [0x5f,0x30,0x03,0xd5]
602
+ assert_bytes "clrex #7", [0x5f,0x37,0x03,0xd5]
603
+ end
604
+
605
+ def test_generated_cls
606
+ assert_bytes "cls w3, w5", [0xa3,0x14,0xc0,0x5a]
607
+ assert_bytes "cls x20, x5", [0xb4,0x14,0xc0,0xda]
608
+ end
609
+
610
+ def test_generated_clz
611
+ assert_bytes "clz w24, w3", [0x78,0x10,0xc0,0x5a]
612
+ assert_bytes "clz w24, wzr", [0xf8,0x13,0xc0,0x5a]
613
+ assert_bytes "clz x26, x4", [0x9a,0x10,0xc0,0xda]
614
+ end
615
+
616
+ def test_generated_cmn
617
+ assert_bytes "cmn sp, #1092, lsl #12", [0xff,0x13,0x51,0xb1]
618
+ assert_bytes "cmn sp, w19, sxth", [0xff,0xa3,0x33,0xab]
619
+ assert_bytes "cmn sp, w19, uxth #4", [0xff,0x33,0x33,0xab]
620
+ assert_bytes "cmn sp, x6", [0xff,0x63,0x26,0xab]
621
+ assert_bytes "cmn w0, w3", [0x1f,0x00,0x03,0x2b]
622
+ assert_bytes "cmn w10, w11, lsl #31", [0x5f,0x7d,0x0b,0x2b]
623
+ assert_bytes "cmn w12, w13, lsr #0", [0x9f,0x01,0x4d,0x2b]
624
+ assert_bytes "cmn w14, w15, lsr #21", [0xdf,0x55,0x4f,0x2b]
625
+ assert_bytes "cmn w16, w17, lsr #31", [0x1f,0x7e,0x51,0x2b]
626
+ assert_bytes "cmn w18, w19, asr #0", [0x5f,0x02,0x93,0x2b]
627
+ assert_bytes "cmn w20, w21, asr #22", [0x9f,0x5a,0x95,0x2b]
628
+ assert_bytes "cmn w22, w23, asr #31", [0xdf,0x7e,0x97,0x2b]
629
+ assert_bytes "cmn w3, #291, lsl #12", [0x7f,0x8c,0x44,0x31]
630
+ assert_bytes "cmn w5, wzr", [0xbf,0x00,0x1f,0x2b]
631
+ assert_bytes "cmn w6, w7", [0xdf,0x00,0x07,0x2b]
632
+ assert_bytes "cmn w8, w9, lsl #15", [0x1f,0x3d,0x09,0x2b]
633
+ assert_bytes "cmn wsp, #1365", [0xff,0x57,0x15,0x31]
634
+ assert_bytes "cmn wsp, w6", [0xff,0x43,0x26,0x2b]
635
+ assert_bytes "cmn wzr, w4", [0xff,0x03,0x04,0x2b]
636
+ assert_bytes "cmn x0, x3", [0x1f,0x00,0x03,0xab]
637
+ assert_bytes "cmn x1, w20, uxtw", [0x3f,0x40,0x34,0xab]
638
+ assert_bytes "cmn x10, x11, lsl #63", [0x5f,0xfd,0x0b,0xab]
639
+ assert_bytes "cmn x12, x13, lsr #0", [0x9f,0x01,0x4d,0xab]
640
+ assert_bytes "cmn x14, x15, lsr #41", [0xdf,0xa5,0x4f,0xab]
641
+ assert_bytes "cmn x16, x17, lsr #63", [0x1f,0xfe,0x51,0xab]
642
+ assert_bytes "cmn x18, x19, asr #0", [0x5f,0x02,0x93,0xab]
643
+ assert_bytes "cmn x2, w3, sxtw", [0x5f,0xc0,0x23,0xab]
644
+ assert_bytes "cmn x20, x21, asr #55", [0x9f,0xde,0x95,0xab]
645
+ assert_bytes "cmn x22, x23, asr #63", [0xdf,0xfe,0x97,0xab]
646
+ assert_bytes "cmn x25, w20, sxtb #3", [0x3f,0x8f,0x34,0xab]
647
+ assert_bytes "cmn x3, x13, uxtx", [0x7f,0x60,0x2d,0xab]
648
+ assert_bytes "cmn x4, w5, uxtb #2", [0x9f,0x08,0x25,0xab]
649
+ assert_bytes "cmn x5, x9, sxtx #2", [0xbf,0xe8,0x29,0xab]
650
+ assert_bytes "cmn x5, xzr", [0xbf,0x00,0x1f,0xab]
651
+ assert_bytes "cmn x6, x7", [0xdf,0x00,0x07,0xab]
652
+ assert_bytes "cmn x8, x9, lsl #15", [0x1f,0x3d,0x09,0xab]
653
+ assert_bytes "cmn xzr, x4", [0xff,0x03,0x04,0xab]
654
+ assert_bytes "cmn w2, w3, sxtw", [0x5f,0xc0,0x23,0x2b]
655
+ assert_bytes "cmn wsp, w3, lsl #4", [0xff,0x53,0x23,0x2b]
656
+ end
657
+
658
+ def test_generated_cmp
659
+ assert_bytes "cmp sp, #200", [0xff,0x23,0x03,0xf1]
660
+ assert_bytes "cmp sp, w19, sxth", [0xff,0xa3,0x33,0xeb]
661
+ assert_bytes "cmp sp, w19, uxth #4", [0xff,0x33,0x33,0xeb]
662
+ assert_bytes "cmp sp, x6", [0xff,0x63,0x26,0xeb]
663
+ assert_bytes "cmp w0, w3", [0x1f,0x00,0x03,0x6b]
664
+ assert_bytes "cmp w10, w11, lsl #31", [0x5f,0x7d,0x0b,0x6b]
665
+ assert_bytes "cmp w12, w13, lsr #0", [0x9f,0x01,0x4d,0x6b]
666
+ assert_bytes "cmp w14, w15, lsr #21", [0xdf,0x55,0x4f,0x6b]
667
+ assert_bytes "cmp w15, w17, uxth", [0xff,0x21,0x31,0x6b]
668
+ assert_bytes "cmp w16, w17, lsr #31", [0x1f,0x7e,0x51,0x6b]
669
+ assert_bytes "cmp w17, w1, uxtx", [0x3f,0x62,0x21,0x6b]
670
+ assert_bytes "cmp w18, w19, asr #0", [0x5f,0x02,0x93,0x6b]
671
+ assert_bytes "cmp w2, w3, sxtw", [0x5f,0xc0,0x23,0x6b]
672
+ assert_bytes "cmp w20, w21, asr #22", [0x9f,0x5a,0x95,0x6b]
673
+ assert_bytes "cmp w22, w23, asr #31", [0xdf,0x7e,0x97,0x6b]
674
+ assert_bytes "cmp w29, wzr, uxtw", [0xbf,0x43,0x3f,0x6b]
675
+ assert_bytes "cmp w3, w5, sxtx", [0x7f,0xe0,0x25,0x6b]
676
+ assert_bytes "cmp w5, w1, sxtb #1", [0xbf,0x84,0x21,0x6b]
677
+ assert_bytes "cmp w5, w7, uxtb", [0xbf,0x00,0x27,0x6b]
678
+ assert_bytes "cmp w5, wzr", [0xbf,0x00,0x1f,0x6b]
679
+ assert_bytes "cmp w6, w7", [0xdf,0x00,0x07,0x6b]
680
+ assert_bytes "cmp w8, w9, lsl #15", [0x1f,0x3d,0x09,0x6b]
681
+ assert_bytes "cmp wsp, #500", [0xff,0xd3,0x07,0x71]
682
+ assert_bytes "cmp wsp, w1, uxtb", [0xff,0x03,0x21,0x6b]
683
+ assert_bytes "cmp wsp, w19, sxth", [0xff,0xa3,0x33,0x6b]
684
+ assert_bytes "cmp wsp, w6", [0xff,0x43,0x26,0x6b]
685
+ assert_bytes "cmp wsp, w9", [0xff,0x43,0x29,0x6b]
686
+ assert_bytes "cmp wzr, w0", [0xff,0x03,0x00,0x6b]
687
+ assert_bytes "cmp wzr, w4", [0xff,0x03,0x04,0x6b]
688
+ assert_bytes "cmp x0, x3", [0x1f,0x00,0x03,0xeb]
689
+ assert_bytes "cmp x1, w20, uxtw", [0x3f,0x40,0x34,0xeb]
690
+ assert_bytes "cmp x10, x11, lsl #63", [0x5f,0xfd,0x0b,0xeb]
691
+ assert_bytes "cmp x12, x13, lsr #0", [0x9f,0x01,0x4d,0xeb]
692
+ assert_bytes "cmp x12, x13, uxtx #4", [0x9f,0x71,0x2d,0xeb]
693
+ assert_bytes "cmp x14, x15, lsr #41", [0xdf,0xa5,0x4f,0xeb]
694
+ assert_bytes "cmp x16, x17, lsr #63", [0x1f,0xfe,0x51,0xeb]
695
+ assert_bytes "cmp x18, x19, asr #0", [0x5f,0x02,0x93,0xeb]
696
+ assert_bytes "cmp x2, w3, sxtw", [0x5f,0xc0,0x23,0xeb]
697
+ assert_bytes "cmp x20, w29, uxtb #3", [0x9f,0x0e,0x3d,0xeb]
698
+ assert_bytes "cmp x20, x21, asr #55", [0x9f,0xde,0x95,0xeb]
699
+ assert_bytes "cmp x22, x23, asr #63", [0xdf,0xfe,0x97,0xeb]
700
+ assert_bytes "cmp x25, w20, sxtb #3", [0x3f,0x8f,0x34,0xeb]
701
+ assert_bytes "cmp x3, x13, uxtx", [0x7f,0x60,0x2d,0xeb]
702
+ assert_bytes "cmp x4, #300, lsl #12", [0x9f,0xb0,0x44,0xf1]
703
+ assert_bytes "cmp x4, w5, uxtb #2", [0x9f,0x08,0x25,0xeb]
704
+ assert_bytes "cmp x5, x9, sxtx #2", [0xbf,0xe8,0x29,0xeb]
705
+ assert_bytes "cmp x5, xzr", [0xbf,0x00,0x1f,0xeb]
706
+ assert_bytes "cmp x6, x7", [0xdf,0x00,0x07,0xeb]
707
+ assert_bytes "cmp x8, x9, lsl #15", [0x1f,0x3d,0x09,0xeb]
708
+ assert_bytes "cmp xzr, x4", [0xff,0x03,0x04,0xeb]
709
+ assert_bytes "cmp xzr, x0", [0xff,0x03,0x00,0xeb]
710
+ end
711
+
712
+ def test_generated_cneg
713
+ assert_bytes "cneg w3, w5, gt", [0xa3,0xd4,0x85,0x5a]
714
+ assert_bytes "cneg w9, wzr, lt", [0xe9,0xa7,0x9f,0x5a]
715
+ assert_bytes "cneg wzr, w4, le", [0x9f,0xc4,0x84,0x5a]
716
+ assert_bytes "cneg x3, x5, gt", [0xa3,0xd4,0x85,0xda]
717
+ assert_bytes "cneg x9, xzr, lt", [0xe9,0xa7,0x9f,0xda]
718
+ assert_bytes "cneg xzr, x4, le", [0x9f,0xc4,0x84,0xda]
719
+ end
720
+
721
+ def test_generated_csel
722
+ assert_bytes "csel w1, w0, w19, ne", [0x01,0x10,0x93,0x1a]
723
+ assert_bytes "csel w1, w28, wzr, mi", [0x81,0x43,0x9f,0x1a]
724
+ assert_bytes "csel w9, wzr, w30, gt", [0xe9,0xc3,0x9e,0x1a]
725
+ assert_bytes "csel wzr, w5, w9, eq", [0xbf,0x00,0x89,0x1a]
726
+ assert_bytes "csel x19, x23, x29, lt", [0xf3,0xb2,0x9d,0x9a]
727
+ assert_bytes "csel x5, xzr, x6, hs", [0xe5,0x23,0x86,0x9a]
728
+ assert_bytes "csel x7, x8, xzr, lo", [0x07,0x31,0x9f,0x9a]
729
+ assert_bytes "csel xzr, x3, x4, ge", [0x7f,0xa0,0x84,0x9a]
730
+ end
731
+
732
+ def test_generated_cset
733
+ assert_bytes "cset x9, lt", [0xe9,0xa7,0x9f,0x9a]
734
+ assert_bytes "cset w3, eq", [0xe3,0x17,0x9f,0x1a]
735
+ assert_bytes "cset w9, lt", [0xe9,0xa7,0x9f,0x1a]
736
+ assert_bytes "cset x9, pl", [0xe9,0x47,0x9f,0x9a]
737
+ end
738
+
739
+ def test_generated_csetm
740
+ assert_bytes "csetm w20, ne", [0xf4,0x03,0x9f,0x5a]
741
+ assert_bytes "csetm w9, lt", [0xe9,0xa3,0x9f,0x5a]
742
+ assert_bytes "csetm x30, ge", [0xfe,0xb3,0x9f,0xda]
743
+ assert_bytes "csetm x9, lt", [0xe9,0xa3,0x9f,0xda]
744
+ end
745
+
746
+ def test_generated_csinc
747
+ assert_bytes "csinc w1, w0, w19, ne", [0x01,0x14,0x93,0x1a]
748
+ assert_bytes "csinc w1, w28, wzr, mi", [0x81,0x47,0x9f,0x1a]
749
+ assert_bytes "csinc w9, wzr, w30, gt", [0xe9,0xc7,0x9e,0x1a]
750
+ assert_bytes "csinc wzr, w5, w9, eq", [0xbf,0x04,0x89,0x1a]
751
+ assert_bytes "csinc x19, x23, x29, lt", [0xf3,0xb6,0x9d,0x9a]
752
+ assert_bytes "csinc x5, xzr, x6, hs", [0xe5,0x27,0x86,0x9a]
753
+ assert_bytes "csinc x7, x8, xzr, lo", [0x07,0x35,0x9f,0x9a]
754
+ assert_bytes "csinc xzr, x3, x4, ge", [0x7f,0xa4,0x84,0x9a]
755
+ end
756
+
757
+ def test_generated_csinv
758
+ assert_bytes "csinv w1, w0, w19, ne", [0x01,0x10,0x93,0x5a]
759
+ assert_bytes "csinv w1, w28, wzr, mi", [0x81,0x43,0x9f,0x5a]
760
+ assert_bytes "csinv w9, wzr, w30, gt", [0xe9,0xc3,0x9e,0x5a]
761
+ assert_bytes "csinv wzr, w5, w9, eq", [0xbf,0x00,0x89,0x5a]
762
+ assert_bytes "csinv x19, x23, x29, lt", [0xf3,0xb2,0x9d,0xda]
763
+ assert_bytes "csinv x5, xzr, x6, hs", [0xe5,0x23,0x86,0xda]
764
+ assert_bytes "csinv x7, x8, xzr, lo", [0x07,0x31,0x9f,0xda]
765
+ assert_bytes "csinv xzr, x3, x4, ge", [0x7f,0xa0,0x84,0xda]
766
+ end
767
+
768
+ def test_generated_csneg
769
+ assert_bytes "csneg w1, w0, w19, ne", [0x01,0x14,0x93,0x5a]
770
+ assert_bytes "csneg w1, w28, wzr, mi", [0x81,0x47,0x9f,0x5a]
771
+ assert_bytes "csneg w9, wzr, w30, gt", [0xe9,0xc7,0x9e,0x5a]
772
+ assert_bytes "csneg wzr, w5, w9, eq", [0xbf,0x04,0x89,0x5a]
773
+ assert_bytes "csneg x19, x23, x29, lt", [0xf3,0xb6,0x9d,0xda]
774
+ assert_bytes "csneg x5, xzr, x6, hs", [0xe5,0x27,0x86,0xda]
775
+ assert_bytes "csneg x7, x8, xzr, lo", [0x07,0x35,0x9f,0xda]
776
+ assert_bytes "csneg xzr, x3, x4, ge", [0x7f,0xa4,0x84,0xda]
777
+ end
778
+
779
+ def test_generated_dcps1
780
+ assert_bytes "dcps1", [0x01,0x00,0xa0,0xd4]
781
+ end
782
+
783
+ def test_generated_dcps2
784
+ assert_bytes "dcps2", [0x02,0x00,0xa0,0xd4]
785
+ end
786
+
787
+ def test_generated_dcps3
788
+ assert_bytes "dcps3", [0x03,0x00,0xa0,0xd4]
789
+ end
790
+
791
+ def test_generated_dmb
792
+ assert_bytes "dmb #0", [0xbf,0x30,0x03,0xd5]
793
+ assert_bytes "dmb #12", [0xbf,0x3c,0x03,0xd5]
794
+ assert_bytes "dmb ish", [0xbf,0x3b,0x03,0xd5]
795
+ assert_bytes "dmb ishld", [0xbf,0x39,0x03,0xd5]
796
+ assert_bytes "dmb ishst", [0xbf,0x3a,0x03,0xd5]
797
+ assert_bytes "dmb ld", [0xbf,0x3d,0x03,0xd5]
798
+ assert_bytes "dmb nsh", [0xbf,0x37,0x03,0xd5]
799
+ assert_bytes "dmb nshld", [0xbf,0x35,0x03,0xd5]
800
+ assert_bytes "dmb nshst", [0xbf,0x36,0x03,0xd5]
801
+ assert_bytes "dmb osh", [0xbf,0x33,0x03,0xd5]
802
+ assert_bytes "dmb oshld", [0xbf,0x31,0x03,0xd5]
803
+ assert_bytes "dmb oshst", [0xbf,0x32,0x03,0xd5]
804
+ assert_bytes "dmb st", [0xbf,0x3e,0x03,0xd5]
805
+ assert_bytes "dmb sy", [0xbf,0x3f,0x03,0xd5]
806
+ end
807
+
808
+ def test_generated_drps
809
+ assert_bytes "drps", [0xe0,0x03,0xbf,0xd6]
810
+ end
811
+
812
+ def test_generated_dsb
813
+ assert_bytes "dsb #12", [0x9f,0x3c,0x03,0xd5]
814
+ assert_bytes "dsb ish", [0x9f,0x3b,0x03,0xd5]
815
+ assert_bytes "dsb ishld", [0x9f,0x39,0x03,0xd5]
816
+ assert_bytes "dsb ishst", [0x9f,0x3a,0x03,0xd5]
817
+ assert_bytes "dsb ld", [0x9f,0x3d,0x03,0xd5]
818
+ assert_bytes "dsb nsh", [0x9f,0x37,0x03,0xd5]
819
+ assert_bytes "dsb nshld", [0x9f,0x35,0x03,0xd5]
820
+ assert_bytes "dsb nshst", [0x9f,0x36,0x03,0xd5]
821
+ assert_bytes "dsb osh", [0x9f,0x33,0x03,0xd5]
822
+ assert_bytes "dsb oshld", [0x9f,0x31,0x03,0xd5]
823
+ assert_bytes "dsb oshst", [0x9f,0x32,0x03,0xd5]
824
+ assert_bytes "dsb st", [0x9f,0x3e,0x03,0xd5]
825
+ assert_bytes "dsb sy", [0x9f,0x3f,0x03,0xd5]
826
+ end
827
+
828
+ def test_generated_eor
829
+ assert_bytes "eor w16, w17, #0xfffffff9", [0x30,0x76,0x1d,0x52]
830
+ assert_bytes "eor sp, xzr, #0x303030303030303", [0xff,0xc7,0x00,0xd2]
831
+ assert_bytes "eor w16, w17, #0x81818181", [0x30,0xc6,0x01,0x52]
832
+ assert_bytes "eor w3, w6, #0xe0e0e0e0", [0xc3,0xc8,0x03,0x52]
833
+ assert_bytes "eor wsp, wzr, #0x3030303", [0xff,0xc7,0x00,0x52]
834
+ assert_bytes "eor x16, x17, #0x8181818181818181", [0x30,0xc6,0x01,0xd2]
835
+ assert_bytes "eor x3, x5, #0xffffffffc000000", [0xa3,0x84,0x66,0xd2]
836
+ assert_bytes "eor x3, x6, #0xe0e0e0e0e0e0e0e0", [0xc3,0xc8,0x03,0xd2]
837
+ end
838
+
839
+ def test_generated_eret
840
+ assert_bytes "eret", [0xe0,0x03,0x9f,0xd6]
841
+ end
842
+
843
+ def test_generated_extr
844
+ assert_bytes "extr w11, w13, w17, #31", [0xab,0x7d,0x91,0x13]
845
+ assert_bytes "extr w3, w5, w7, #0", [0xa3,0x00,0x87,0x13]
846
+ assert_bytes "extr x11, x13, x17, #63", [0xab,0xfd,0xd1,0x93]
847
+ assert_bytes "extr x3, x5, x7, #15", [0xa3,0x3c,0xc7,0x93]
848
+ end
849
+
850
+ def test_generated_isb
851
+ assert_bytes "isb", [0xdf,0x3f,0x03,0xd5]
852
+ assert_bytes "isb #12", [0xdf,0x3c,0x03,0xd5]
853
+ end
854
+
855
+ def test_generated_ldar
856
+ assert_bytes "ldar wzr, [x1]", [0x3f,0xfc,0xdf,0x88]
857
+ assert_bytes "ldar x1, [x2]", [0x41,0xfc,0xdf,0xc8]
858
+ end
859
+
860
+ def test_generated_ldarb
861
+ assert_bytes "ldarb w29, [sp]", [0xfd,0xff,0xdf,0x08]
862
+ end
863
+
864
+ def test_generated_ldarh
865
+ assert_bytes "ldarh w30, [x0]", [0x1e,0xfc,0xdf,0x48]
866
+ end
867
+
868
+ def test_generated_ldaxp
869
+ assert_bytes "ldaxp w26, wzr, [sp]", [0xfa,0xff,0x7f,0x88]
870
+ assert_bytes "ldaxp x27, x28, [x30]", [0xdb,0xf3,0x7f,0xc8]
871
+ end
872
+
873
+ def test_generated_ldaxr
874
+ assert_bytes "ldaxr wzr, [x22]", [0xdf,0xfe,0x5f,0x88]
875
+ assert_bytes "ldaxr x21, [x23]", [0xf5,0xfe,0x5f,0xc8]
876
+ end
877
+
878
+ def test_generated_ldaxrb
879
+ assert_bytes "ldaxrb w19, [x21]", [0xb3,0xfe,0x5f,0x08]
880
+ end
881
+
882
+ def test_generated_ldaxrh
883
+ assert_bytes "ldaxrh w20, [sp]", [0xf4,0xff,0x5f,0x48]
884
+ end
885
+
886
+ def test_generated_ldnp
887
+ assert_bytes "ldnp w2, wzr, [sp, #-256]", [0xe2,0x7f,0x60,0x28]
888
+ assert_bytes "ldnp w3, w5, [sp]", [0xe3,0x17,0x40,0x28]
889
+ assert_bytes "ldnp w9, w10, [sp, #4]", [0xe9,0xab,0x40,0x28]
890
+ assert_bytes "ldnp x21, x29, [x2, #504]", [0x55,0xf4,0x5f,0xa8]
891
+ assert_bytes "ldnp x22, x23, [x3, #-512]", [0x76,0x5c,0x60,0xa8]
892
+ assert_bytes "ldnp x24, x25, [x4, #8]", [0x98,0xe4,0x40,0xa8]
893
+ end
894
+
895
+ def test_generated_ldp
896
+ assert_bytes "ldp w2, wzr, [sp, #-256]", [0xe2,0x7f,0x60,0x29]
897
+ assert_bytes "ldp w2, wzr, [sp, #-256]!", [0xe2,0x7f,0xe0,0x29]
898
+ assert_bytes "ldp w2, wzr, [sp], #-256", [0xe2,0x7f,0xe0,0x28]
899
+ assert_bytes "ldp w3, w5, [sp, #0]!", [0xe3,0x17,0xc0,0x29]
900
+ assert_bytes "ldp w3, w5, [sp]", [0xe3,0x17,0x40,0x29]
901
+ assert_bytes "ldp w3, w5, [sp], #0", [0xe3,0x17,0xc0,0x28]
902
+ assert_bytes "ldp w9, w10, [sp, #4]", [0xe9,0xab,0x40,0x29]
903
+ assert_bytes "ldp w9, w10, [sp, #4]!", [0xe9,0xab,0xc0,0x29]
904
+ assert_bytes "ldp w9, w10, [sp], #4", [0xe9,0xab,0xc0,0x28]
905
+ assert_bytes "ldp x21, x29, [x2, #504]", [0x55,0xf4,0x5f,0xa9]
906
+ assert_bytes "ldp x21, x29, [x2, #504]!", [0x55,0xf4,0xdf,0xa9]
907
+ assert_bytes "ldp x21, x29, [x2], #504", [0x55,0xf4,0xdf,0xa8]
908
+ assert_bytes "ldp x22, x23, [x3, #-512]", [0x76,0x5c,0x60,0xa9]
909
+ assert_bytes "ldp x22, x23, [x3, #-512]!", [0x76,0x5c,0xe0,0xa9]
910
+ assert_bytes "ldp x22, x23, [x3], #-512", [0x76,0x5c,0xe0,0xa8]
911
+ assert_bytes "ldp x24, x25, [x4, #8]", [0x98,0xe4,0x40,0xa9]
912
+ assert_bytes "ldp x24, x25, [x4, #8]!", [0x98,0xe4,0xc0,0xa9]
913
+ assert_bytes "ldp x24, x25, [x4], #8", [0x98,0xe4,0xc0,0xa8]
914
+ end
915
+
916
+ def test_generated_ldpsw
917
+ assert_bytes "ldpsw x20, x30, [sp, #252]", [0xf4,0xfb,0x5f,0x69]
918
+ assert_bytes "ldpsw x20, x30, [sp, #252]!", [0xf4,0xfb,0xdf,0x69]
919
+ assert_bytes "ldpsw x20, x30, [sp], #252", [0xf4,0xfb,0xdf,0x68]
920
+ assert_bytes "ldpsw x9, x10, [sp, #4]", [0xe9,0xab,0x40,0x69]
921
+ assert_bytes "ldpsw x9, x10, [sp, #4]!", [0xe9,0xab,0xc0,0x69]
922
+ assert_bytes "ldpsw x9, x10, [sp], #4", [0xe9,0xab,0xc0,0x68]
923
+ assert_bytes "ldpsw x9, x10, [x2, #-256]", [0x49,0x28,0x60,0x69]
924
+ assert_bytes "ldpsw x9, x10, [x2, #-256]!", [0x49,0x28,0xe0,0x69]
925
+ assert_bytes "ldpsw x9, x10, [x2], #-256", [0x49,0x28,0xe0,0x68]
926
+ end
927
+
928
+ def test_generated_ldr
929
+ assert_bytes "ldr w10, [x30, x7, lsl #2]", [0xca,0x7b,0x67,0xb8]
930
+ assert_bytes "ldr w11, [x29, x3, sxtx]", [0xab,0xeb,0x63,0xb8]
931
+ assert_bytes "ldr w13, [x2, #4]", [0x4d,0x04,0x40,0xb9]
932
+ assert_bytes "ldr w15, [x25, w7, uxtw]", [0x2f,0x4b,0x67,0xb8]
933
+ assert_bytes "ldr w16, [x24, w8, uxtw #2]", [0x10,0x5b,0x68,0xb8]
934
+ assert_bytes "ldr w17, [sp, #16380]", [0xf1,0xff,0x7f,0xb9]
935
+ assert_bytes "ldr w18, [x22, w10, sxtw]", [0xd2,0xca,0x6a,0xb8]
936
+ assert_bytes "ldr w19, [sp, #255]!", [0xf3,0xff,0x4f,0xb8]
937
+ assert_bytes "ldr w19, [sp], #255", [0xf3,0xf7,0x4f,0xb8]
938
+ assert_bytes "ldr w2, [sp]", [0xe2,0x03,0x40,0xb9]
939
+ assert_bytes "ldr w20, [x30, #1]!", [0xd4,0x1f,0x40,0xb8]
940
+ assert_bytes "ldr w20, [x30], #1", [0xd4,0x17,0x40,0xb8]
941
+ assert_bytes "ldr w21, [x12, #-256]!", [0x95,0x0d,0x50,0xb8]
942
+ assert_bytes "ldr w21, [x12], #-256", [0x95,0x05,0x50,0xb8]
943
+ assert_bytes "ldr w3, [sp, x5]", [0xe3,0x6b,0x65,0xb8]
944
+ assert_bytes "ldr x0, [x0]", [0x00,0x00,0x40,0xf9]
945
+ assert_bytes "ldr x12, [x28, xzr, sxtx]", [0x8c,0xeb,0x7f,0xf8]
946
+ assert_bytes "ldr x13, [x27, x5, sxtx #3]", [0x6d,0xfb,0x65,0xf8]
947
+ assert_bytes "ldr x15, [x25, w7, uxtw]", [0x2f,0x4b,0x67,0xf8]
948
+ assert_bytes "ldr x16, [x24, w8, uxtw #3]", [0x10,0x5b,0x68,0xf8]
949
+ assert_bytes "ldr x17, [x23, w9, sxtw]", [0xf1,0xca,0x69,0xf8]
950
+ assert_bytes "ldr x18, [x22, w10, sxtw]", [0xd2,0xca,0x6a,0xf8]
951
+ assert_bytes "ldr x19, [x12, #-256]!", [0x93,0x0d,0x50,0xf8]
952
+ assert_bytes "ldr x19, [x12], #-256", [0x93,0x05,0x50,0xf8]
953
+ assert_bytes "ldr x2, [x3, #1]!", [0x62,0x1c,0x40,0xf8]
954
+ assert_bytes "ldr x2, [x3], #1", [0x62,0x14,0x40,0xf8]
955
+ assert_bytes "ldr x20, [sp, #8]", [0xf4,0x07,0x40,0xf9]
956
+ assert_bytes "ldr x3, [sp, x5]", [0xe3,0x6b,0x65,0xf8]
957
+ assert_bytes "ldr x3, [x4, #0]!", [0x83,0x0c,0x40,0xf8]
958
+ assert_bytes "ldr x30, [x12, #32760]", [0x9e,0xfd,0x7f,0xf9]
959
+ assert_bytes "ldr x4, [x29]", [0xa4,0x03,0x40,0xf9]
960
+ assert_bytes "ldr xzr, [sp, #0]!", [0xff,0x0f,0x40,0xf8]
961
+ assert_bytes "ldr xzr, [sp]", [0xff,0x03,0x40,0xf9]
962
+ assert_bytes "ldr xzr, [x9, #255]!", [0x3f,0xfd,0x4f,0xf8]
963
+ assert_bytes "ldr xzr, [x9], #255", [0x3f,0xf5,0x4f,0xf8]
964
+ assert_bytes "ldr w0, #1048572", [0xe0,0xff,0x7f,0x18]
965
+ assert_bytes "ldr x10, #-1048576", [0x0a,0x00,0x80,0x58]
966
+ end
967
+
968
+ def test_generated_ldrb
969
+ assert_bytes "ldrb w10, [x3, #-256]!", [0x6a,0x0c,0x50,0x38]
970
+ assert_bytes "ldrb w10, [x3, #1]!", [0x6a,0x1c,0x40,0x38]
971
+ assert_bytes "ldrb w10, [x3], #-256", [0x6a,0x04,0x50,0x38]
972
+ assert_bytes "ldrb w10, [x3], #1", [0x6a,0x14,0x40,0x38]
973
+ assert_bytes "ldrb w11, [x29, x3, sxtx]", [0xab,0xeb,0x63,0x38]
974
+ assert_bytes "ldrb w12, [x2]", [0x4c,0x00,0x40,0x39]
975
+ assert_bytes "ldrb w14, [x26, w6, uxtw]", [0x4e,0x4b,0x66,0x38]
976
+ assert_bytes "ldrb w17, [x23, w9, sxtw]", [0xf1,0xca,0x69,0x38]
977
+ assert_bytes "ldrb w26, [x3, #121]", [0x7a,0xe4,0x41,0x39]
978
+ assert_bytes "ldrb w3, [sp, x5]", [0xe3,0x6b,0x65,0x38]
979
+ assert_bytes "ldrb w9, [x2, #255]!", [0x49,0xfc,0x4f,0x38]
980
+ assert_bytes "ldrb w9, [x27, x6, lsl #0]", [0x69,0x7b,0x66,0x38]
981
+ assert_bytes "ldrb w9, [x2], #255", [0x49,0xf4,0x4f,0x38]
982
+ end
983
+
984
+ def test_generated_ldrh
985
+ assert_bytes "ldrh w10, [x3, #-256]!", [0x6a,0x0c,0x50,0x78]
986
+ assert_bytes "ldrh w10, [x30, x7, lsl #1]", [0xca,0x7b,0x67,0x78]
987
+ assert_bytes "ldrh w10, [x3], #-256", [0x6a,0x04,0x50,0x78]
988
+ assert_bytes "ldrh w12, [x28, xzr, sxtx]", [0x8c,0xeb,0x7f,0x78]
989
+ assert_bytes "ldrh w14, [x26, w6, uxtw]", [0x4e,0x4b,0x66,0x78]
990
+ assert_bytes "ldrh w15, [x25, w7, uxtw]", [0x2f,0x4b,0x67,0x78]
991
+ assert_bytes "ldrh w17, [x23, w9, sxtw]", [0xf1,0xca,0x69,0x78]
992
+ assert_bytes "ldrh w18, [x22, w10, sxtw]", [0xd2,0xca,0x6a,0x78]
993
+ assert_bytes "ldrh w2, [x4]", [0x82,0x00,0x40,0x79]
994
+ assert_bytes "ldrh w9, [x2, #1]!", [0x49,0x1c,0x40,0x78]
995
+ assert_bytes "ldrh w9, [x2, #255]!", [0x49,0xfc,0x4f,0x78]
996
+ assert_bytes "ldrh w9, [x2], #1", [0x49,0x14,0x40,0x78]
997
+ assert_bytes "ldrh w9, [x2], #255", [0x49,0xf4,0x4f,0x78]
998
+ end
999
+
1000
+ def test_generated_ldrsb
1001
+ assert_bytes "ldrsb w10, [x30, x7]", [0xca,0x6b,0xe7,0x38]
1002
+ assert_bytes "ldrsb w15, [x25, w7, uxtw #0]", [0x2f,0x5b,0xe7,0x38]
1003
+ assert_bytes "ldrsb w19, [x12, #-256]!", [0x93,0x0d,0xd0,0x38]
1004
+ assert_bytes "ldrsb w19, [x12], #-256", [0x93,0x05,0xd0,0x38]
1005
+ assert_bytes "ldrsb w2, [x3, #1]!", [0x62,0x1c,0xc0,0x38]
1006
+ assert_bytes "ldrsb w2, [x3], #1", [0x62,0x14,0xc0,0x38]
1007
+ assert_bytes "ldrsb w27, [sp, #4095]", [0xfb,0xff,0xff,0x39]
1008
+ assert_bytes "ldrsb wzr, [x9, #255]!", [0x3f,0xfd,0xcf,0x38]
1009
+ assert_bytes "ldrsb wzr, [x9], #255", [0x3f,0xf5,0xcf,0x38]
1010
+ assert_bytes "ldrsb x18, [x22, w10, sxtw #0]", [0xd2,0xda,0xaa,0x38]
1011
+ assert_bytes "ldrsb x19, [x12, #-256]!", [0x93,0x0d,0x90,0x38]
1012
+ assert_bytes "ldrsb x19, [x12], #-256", [0x93,0x05,0x90,0x38]
1013
+ assert_bytes "ldrsb x2, [x3, #1]!", [0x62,0x1c,0x80,0x38]
1014
+ assert_bytes "ldrsb x2, [x3], #1", [0x62,0x14,0x80,0x38]
1015
+ assert_bytes "ldrsb xzr, [x15]", [0xff,0x01,0x80,0x39]
1016
+ assert_bytes "ldrsb xzr, [x9, #255]!", [0x3f,0xfd,0x8f,0x38]
1017
+ assert_bytes "ldrsb xzr, [x9], #255", [0x3f,0xf5,0x8f,0x38]
1018
+ end
1019
+
1020
+ def test_generated_ldrsh
1021
+ assert_bytes "ldrsh w16, [x24, w8, uxtw #1]", [0x10,0x5b,0xe8,0x78]
1022
+ assert_bytes "ldrsh w19, [x12, #-256]!", [0x93,0x0d,0xd0,0x78]
1023
+ assert_bytes "ldrsh w19, [x12], #-256", [0x93,0x05,0xd0,0x78]
1024
+ assert_bytes "ldrsh w2, [x3, #1]!", [0x62,0x1c,0xc0,0x78]
1025
+ assert_bytes "ldrsh w2, [x3], #1", [0x62,0x14,0xc0,0x78]
1026
+ assert_bytes "ldrsh w23, [x6, #8190]", [0xd7,0xfc,0xff,0x79]
1027
+ assert_bytes "ldrsh w3, [sp, x5]", [0xe3,0x6b,0xe5,0x78]
1028
+ assert_bytes "ldrsh w9, [x27, x6]", [0x69,0x6b,0xe6,0x78]
1029
+ assert_bytes "ldrsh wzr, [sp, #2]", [0xff,0x07,0xc0,0x79]
1030
+ assert_bytes "ldrsh wzr, [x9, #255]!", [0x3f,0xfd,0xcf,0x78]
1031
+ assert_bytes "ldrsh wzr, [x9], #255", [0x3f,0xf5,0xcf,0x78]
1032
+ assert_bytes "ldrsh x13, [x27, x5, sxtx #1]", [0x6d,0xfb,0xa5,0x78]
1033
+ assert_bytes "ldrsh x19, [x12, #-256]!", [0x93,0x0d,0x90,0x78]
1034
+ assert_bytes "ldrsh x19, [x12], #-256", [0x93,0x05,0x90,0x78]
1035
+ assert_bytes "ldrsh x2, [x3, #1]!", [0x62,0x1c,0x80,0x78]
1036
+ assert_bytes "ldrsh x2, [x3], #1", [0x62,0x14,0x80,0x78]
1037
+ assert_bytes "ldrsh x29, [x2, #2]", [0x5d,0x04,0x80,0x79]
1038
+ assert_bytes "ldrsh xzr, [x9, #255]!", [0x3f,0xfd,0x8f,0x78]
1039
+ assert_bytes "ldrsh xzr, [x9], #255", [0x3f,0xf5,0x8f,0x78]
1040
+ end
1041
+
1042
+ def test_generated_ldrsw
1043
+ assert_bytes "ldrsw x17, [x23, w9, sxtw]", [0xf1,0xca,0xa9,0xb8]
1044
+ assert_bytes "ldrsw x19, [x12, #-256]!", [0x93,0x0d,0x90,0xb8]
1045
+ assert_bytes "ldrsw x19, [x12], #-256", [0x93,0x05,0x90,0xb8]
1046
+ assert_bytes "ldrsw x19, [x21, wzr, sxtw #2]", [0xb3,0xda,0xbf,0xb8]
1047
+ assert_bytes "ldrsw x2, [x3, #1]!", [0x62,0x1c,0x80,0xb8]
1048
+ assert_bytes "ldrsw x2, [x3], #1", [0x62,0x14,0x80,0xb8]
1049
+ assert_bytes "ldrsw x2, [x5, #4]", [0xa2,0x04,0x80,0xb9]
1050
+ assert_bytes "ldrsw x23, [sp, #16380]", [0xf7,0xff,0xbf,0xb9]
1051
+ assert_bytes "ldrsw xzr, [x9, #255]!", [0x3f,0xfd,0x8f,0xb8]
1052
+ assert_bytes "ldrsw xzr, [x9], #255", [0x3f,0xf5,0x8f,0xb8]
1053
+ end
1054
+
1055
+ def test_generated_ldtr
1056
+ assert_bytes "ldtr w12, [sp, #255]", [0xec,0xfb,0x4f,0xb8]
1057
+ assert_bytes "ldtr xzr, [x12, #255]", [0x9f,0xf9,0x4f,0xf8]
1058
+ end
1059
+
1060
+ def test_generated_ldtrb
1061
+ assert_bytes "ldtrb w1, [x20, #255]", [0x81,0xfa,0x4f,0x38]
1062
+ end
1063
+
1064
+ def test_generated_ldtrh
1065
+ assert_bytes "ldtrh w20, [x1, #255]", [0x34,0xf8,0x4f,0x78]
1066
+ end
1067
+
1068
+ def test_generated_ldtrsb
1069
+ assert_bytes "ldtrsb w19, [x1, #-256]", [0x33,0x08,0xd0,0x38]
1070
+ assert_bytes "ldtrsb x9, [x7, #-256]", [0xe9,0x08,0x90,0x38]
1071
+ end
1072
+
1073
+ def test_generated_ldtrsh
1074
+ assert_bytes "ldtrsh w15, [x21, #-256]", [0xaf,0x0a,0xd0,0x78]
1075
+ assert_bytes "ldtrsh x17, [x19, #-256]", [0x71,0x0a,0x90,0x78]
1076
+ end
1077
+
1078
+ def test_generated_ldtrsw
1079
+ assert_bytes "ldtrsw x20, [x15, #-256]", [0xf4,0x09,0x90,0xb8]
1080
+ end
1081
+
1082
+ def test_generated_ldur
1083
+ assert_bytes "ldur w12, [sp, #255]", [0xec,0xf3,0x4f,0xb8]
1084
+ assert_bytes "ldur xzr, [x12, #255]", [0x9f,0xf1,0x4f,0xf8]
1085
+ end
1086
+
1087
+ def test_generated_ldurb
1088
+ assert_bytes "ldurb w1, [x20, #255]", [0x81,0xf2,0x4f,0x38]
1089
+ end
1090
+
1091
+ def test_generated_ldurh
1092
+ assert_bytes "ldurh w20, [x1, #255]", [0x34,0xf0,0x4f,0x78]
1093
+ end
1094
+
1095
+ def test_generated_ldursb
1096
+ assert_bytes "ldursb w19, [x1, #-256]", [0x33,0x00,0xd0,0x38]
1097
+ assert_bytes "ldursb x9, [x7, #-256]", [0xe9,0x00,0x90,0x38]
1098
+ end
1099
+
1100
+ def test_generated_ldursh
1101
+ assert_bytes "ldursh w15, [x21, #-256]", [0xaf,0x02,0xd0,0x78]
1102
+ assert_bytes "ldursh x17, [x19, #-256]", [0x71,0x02,0x90,0x78]
1103
+ end
1104
+
1105
+ def test_generated_ldursw
1106
+ assert_bytes "ldursw x13, [x2]", [0x4d,0x00,0x80,0xb8]
1107
+ assert_bytes "ldursw x20, [x15, #-256]", [0xf4,0x01,0x90,0xb8]
1108
+ end
1109
+
1110
+ def test_generated_ldxp
1111
+ assert_bytes "ldxp w12, wzr, [sp]", [0xec,0x7f,0x7f,0x88]
1112
+ assert_bytes "ldxp x13, x14, [x15]", [0xed,0x39,0x7f,0xc8]
1113
+ end
1114
+
1115
+ def test_generated_ldxr
1116
+ assert_bytes "ldxr w9, [sp]", [0xe9,0x7f,0x5f,0x88]
1117
+ assert_bytes "ldxr x10, [x11]", [0x6a,0x7d,0x5f,0xc8]
1118
+ end
1119
+
1120
+ def test_generated_ldxrb
1121
+ assert_bytes "ldxrb w7, [x9]", [0x27,0x7d,0x5f,0x08]
1122
+ end
1123
+
1124
+ def test_generated_ldxrh
1125
+ assert_bytes "ldxrh wzr, [x10]", [0x5f,0x7d,0x5f,0x48]
1126
+ end
1127
+
1128
+ def test_generated_lsl
1129
+ assert_bytes "lsl w11, w12, w13", [0x8b,0x21,0xcd,0x1a]
1130
+ assert_bytes "lsl w6, w7, w8", [0xe6,0x20,0xc8,0x1a]
1131
+ assert_bytes "lsl x14, x15, x16", [0xee,0x21,0xd0,0x9a]
1132
+ assert_bytes "lsl x9, x10, x11", [0x49,0x21,0xcb,0x9a]
1133
+ assert_bytes "lsl w1, wzr, #3", [0xe1,0x73,0x1d,0x53]
1134
+ assert_bytes "lsl w11, w12, #31", [0x8b,0x01,0x01,0x53]
1135
+ assert_bytes "lsl w13, w14, #29", [0xcd,0x09,0x03,0x53]
1136
+ assert_bytes "lsl w9, w10, #31", [0x49,0x01,0x01,0x53]
1137
+ assert_bytes "lsl x2, x3, #63", [0x62,0x00,0x41,0xd3]
1138
+ assert_bytes "lsl x20, x21, #63", [0xb4,0x02,0x41,0xd3]
1139
+ assert_bytes "lsl x9, x10, #5", [0x49,0xe9,0x7b,0xd3]
1140
+ end
1141
+
1142
+ def test_generated_lsr
1143
+ assert_bytes "lsr w12, w13, w14", [0xac,0x25,0xce,0x1a]
1144
+ assert_bytes "lsr w17, w18, w19", [0x51,0x26,0xd3,0x1a]
1145
+ assert_bytes "lsr x15, x16, x17", [0x0f,0x26,0xd1,0x9a]
1146
+ assert_bytes "lsr x20, x21, x22", [0xb4,0x26,0xd6,0x9a]
1147
+ assert_bytes "lsr w3, w2, #0", [0x43,0x7c,0x00,0x53]
1148
+ assert_bytes "lsr w9, w10, #0", [0x49,0x7d,0x00,0x53]
1149
+ assert_bytes "lsr w9, w10, #31", [0x49,0x7d,0x1f,0x53]
1150
+ assert_bytes "lsr wzr, wzr, #3", [0xff,0x7f,0x03,0x53]
1151
+ assert_bytes "lsr x19, x20, #0", [0x93,0xfe,0x40,0xd3]
1152
+ assert_bytes "lsr x20, x21, #63", [0xb4,0xfe,0x7f,0xd3]
1153
+ assert_bytes "lsr x5, x6, #12", [0xc5,0xfc,0x4c,0xd3]
1154
+ assert_bytes "lsr w11, w12, #31", [0x8b,0x7d,0x1f,0x53]
1155
+ assert_bytes "lsr w13, w14, #29", [0xcd,0x7d,0x1d,0x53]
1156
+ assert_bytes "lsr w9, w10, #0", [0x49,0x7d,0x00,0x53]
1157
+ assert_bytes "lsr x19, x20, #0", [0x93,0xfe,0x40,0xd3]
1158
+ assert_bytes "lsr x2, x3, #63", [0x62,0xfc,0x7f,0xd3]
1159
+ assert_bytes "lsr x9, x10, #5", [0x49,0xfd,0x45,0xd3]
1160
+ end
1161
+
1162
+ def test_generated_madd
1163
+ assert_bytes "madd w1, w3, w7, w4", [0x61,0x10,0x07,0x1b]
1164
+ assert_bytes "madd w13, wzr, w4, w4", [0xed,0x13,0x04,0x1b]
1165
+ assert_bytes "madd w19, w30, wzr, w29", [0xd3,0x77,0x1f,0x1b]
1166
+ assert_bytes "madd wzr, w0, w9, w11", [0x1f,0x2c,0x09,0x1b]
1167
+ assert_bytes "madd x1, x3, x7, x4", [0x61,0x10,0x07,0x9b]
1168
+ assert_bytes "madd x13, xzr, x4, x4", [0xed,0x13,0x04,0x9b]
1169
+ assert_bytes "madd x19, x30, xzr, x29", [0xd3,0x77,0x1f,0x9b]
1170
+ assert_bytes "madd xzr, x0, x9, x11", [0x1f,0x2c,0x09,0x9b]
1171
+ end
1172
+
1173
+ def test_generated_mneg
1174
+ assert_bytes "mneg w21, w22, w23", [0xd5,0xfe,0x17,0x1b]
1175
+ assert_bytes "mneg w26, wzr, w27", [0xfa,0xff,0x1b,0x1b]
1176
+ assert_bytes "mneg w28, w29, wzr", [0xbc,0xff,0x1f,0x1b]
1177
+ assert_bytes "mneg w4, w5, w6", [0xa4,0xfc,0x06,0x1b]
1178
+ assert_bytes "mneg wzr, w24, w25", [0x1f,0xff,0x19,0x1b]
1179
+ assert_bytes "mneg x4, x5, x6", [0xa4,0xfc,0x06,0x9b]
1180
+ end
1181
+
1182
+ def test_generated_mov
1183
+ assert_bytes "mov sp, x30", [0xdf,0x03,0x00,0x91]
1184
+ assert_bytes "mov w24, wsp", [0xf8,0x03,0x00,0x11]
1185
+ assert_bytes "mov w3, w5", [0xe3,0x03,0x05,0x2a]
1186
+ assert_bytes "mov wsp, w20", [0x9f,0x02,0x00,0x11]
1187
+ assert_bytes "mov wzr, w2", [0xff,0x03,0x02,0x2a]
1188
+ assert_bytes "mov x11, sp", [0xeb,0x03,0x00,0x91]
1189
+ assert_bytes "mov x2, #5299989643264", [0x42,0x9a,0xc0,0xd2]
1190
+ assert_bytes "mov x3, x6", [0xe3,0x03,0x06,0xaa]
1191
+ assert_bytes "mov x3, xzr", [0xe3,0x03,0x1f,0xaa]
1192
+ assert_bytes "mov w1, #65535", [0xe1,0xff,0x9f,0x52]
1193
+ assert_bytes "mov w2, #-1235", [0x42,0x9a,0x80,0x12]
1194
+ assert_bytes "mov w3, #983055", [0xe3,0x8f,0x00,0x32]
1195
+ assert_bytes "mov x10, #-6148914691236517206", [0xea,0xf3,0x01,0xb2]
1196
+ end
1197
+
1198
+ def test_generated_movz
1199
+ assert_bytes "movz w2, #0, lsl #16", [0x02,0x00,0xa0,0x52]
1200
+ end
1201
+
1202
+ def test_generated_msub
1203
+ assert_bytes "msub w1, w3, w7, w4", [0x61,0x90,0x07,0x1b]
1204
+ assert_bytes "msub w13, wzr, w4, w4", [0xed,0x93,0x04,0x1b]
1205
+ assert_bytes "msub w19, w30, wzr, w29", [0xd3,0xf7,0x1f,0x1b]
1206
+ assert_bytes "msub wzr, w0, w9, w11", [0x1f,0xac,0x09,0x1b]
1207
+ assert_bytes "msub x1, x3, x7, x4", [0x61,0x90,0x07,0x9b]
1208
+ assert_bytes "msub x13, xzr, x4, x4", [0xed,0x93,0x04,0x9b]
1209
+ assert_bytes "msub x19, x30, xzr, x29", [0xd3,0xf7,0x1f,0x9b]
1210
+ assert_bytes "msub xzr, x0, x9, x11", [0x1f,0xac,0x09,0x9b]
1211
+ end
1212
+
1213
+ def test_generated_mul
1214
+ assert_bytes "mul w10, w11, wzr", [0x6a,0x7d,0x1f,0x1b]
1215
+ assert_bytes "mul w3, w4, w5", [0x83,0x7c,0x05,0x1b]
1216
+ assert_bytes "mul w4, w5, w6", [0xa4,0x7c,0x06,0x1b]
1217
+ assert_bytes "mul w8, wzr, w9", [0xe8,0x7f,0x09,0x1b]
1218
+ assert_bytes "mul wzr, w6, w7", [0xdf,0x7c,0x07,0x1b]
1219
+ assert_bytes "mul x12, x13, x14", [0xac,0x7d,0x0e,0x9b]
1220
+ assert_bytes "mul x17, xzr, x18", [0xf1,0x7f,0x12,0x9b]
1221
+ assert_bytes "mul x19, x20, xzr", [0x93,0x7e,0x1f,0x9b]
1222
+ assert_bytes "mul x4, x5, x6", [0xa4,0x7c,0x06,0x9b]
1223
+ assert_bytes "mul xzr, x15, x16", [0xff,0x7d,0x10,0x9b]
1224
+ end
1225
+
1226
+ def test_generated_neg
1227
+ assert_bytes "neg w12, w11, asr #31", [0xec,0x7f,0x8b,0x4b]
1228
+ assert_bytes "neg w14, w13, asr #12", [0xee,0x33,0x8d,0x4b]
1229
+ assert_bytes "neg w16, w15, asr #0", [0xf0,0x03,0x8f,0x4b]
1230
+ assert_bytes "neg w18, w17, lsr #31", [0xf2,0x7f,0x51,0x4b]
1231
+ assert_bytes "neg w20, w19, lsr #1", [0xf4,0x07,0x53,0x4b]
1232
+ assert_bytes "neg w20, w4", [0xf4,0x03,0x04,0x4b]
1233
+ assert_bytes "neg w22, w21, lsr #0", [0xf6,0x03,0x55,0x4b]
1234
+ assert_bytes "neg w24, w23, lsl #31", [0xf8,0x7f,0x17,0x4b]
1235
+ assert_bytes "neg w26, w25, lsl #29", [0xfa,0x77,0x19,0x4b]
1236
+ assert_bytes "neg w28, w27", [0xfc,0x03,0x1b,0x4b]
1237
+ assert_bytes "neg w29, w30", [0xfd,0x03,0x1e,0x4b]
1238
+ assert_bytes "neg w30, wzr", [0xfe,0x03,0x1f,0x4b]
1239
+ assert_bytes "neg wzr, w0", [0xff,0x03,0x00,0x4b]
1240
+ assert_bytes "neg x12, x11, asr #31", [0xec,0x7f,0x8b,0xcb]
1241
+ assert_bytes "neg x14, x13, asr #12", [0xee,0x33,0x8d,0xcb]
1242
+ assert_bytes "neg x16, x15, asr #0", [0xf0,0x03,0x8f,0xcb]
1243
+ assert_bytes "neg x18, x17, lsr #31", [0xf2,0x7f,0x51,0xcb]
1244
+ assert_bytes "neg x20, x19, lsr #1", [0xf4,0x07,0x53,0xcb]
1245
+ assert_bytes "neg x20, x4", [0xf4,0x03,0x04,0xcb]
1246
+ assert_bytes "neg x22, x21, lsr #0", [0xf6,0x03,0x55,0xcb]
1247
+ assert_bytes "neg x24, x23, lsl #31", [0xf8,0x7f,0x17,0xcb]
1248
+ assert_bytes "neg x26, x25, lsl #29", [0xfa,0x77,0x19,0xcb]
1249
+ assert_bytes "neg x28, x27", [0xfc,0x03,0x1b,0xcb]
1250
+ assert_bytes "neg x29, x30", [0xfd,0x03,0x1e,0xcb]
1251
+ assert_bytes "neg x30, xzr", [0xfe,0x03,0x1f,0xcb]
1252
+ assert_bytes "neg xzr, x0", [0xff,0x03,0x00,0xcb]
1253
+ end
1254
+
1255
+ def test_generated_negs
1256
+ assert_bytes "negs w12, w11, asr #31", [0xec,0x7f,0x8b,0x6b]
1257
+ assert_bytes "negs w14, w13, asr #12", [0xee,0x33,0x8d,0x6b]
1258
+ assert_bytes "negs w16, w15, asr #0", [0xf0,0x03,0x8f,0x6b]
1259
+ assert_bytes "negs w18, w17, lsr #31", [0xf2,0x7f,0x51,0x6b]
1260
+ assert_bytes "negs w20, w19, lsr #1", [0xf4,0x07,0x53,0x6b]
1261
+ assert_bytes "negs w20, w4", [0xf4,0x03,0x04,0x6b]
1262
+ assert_bytes "negs w22, w21, lsr #0", [0xf6,0x03,0x55,0x6b]
1263
+ assert_bytes "negs w24, w23, lsl #31", [0xf8,0x7f,0x17,0x6b]
1264
+ assert_bytes "negs w26, w25, lsl #29", [0xfa,0x77,0x19,0x6b]
1265
+ assert_bytes "negs w28, w27", [0xfc,0x03,0x1b,0x6b]
1266
+ assert_bytes "negs w29, w30", [0xfd,0x03,0x1e,0x6b]
1267
+ assert_bytes "negs w30, wzr", [0xfe,0x03,0x1f,0x6b]
1268
+ assert_bytes "negs x12, x11, asr #31", [0xec,0x7f,0x8b,0xeb]
1269
+ assert_bytes "negs x14, x13, asr #12", [0xee,0x33,0x8d,0xeb]
1270
+ assert_bytes "negs x16, x15, asr #0", [0xf0,0x03,0x8f,0xeb]
1271
+ assert_bytes "negs x18, x17, lsr #31", [0xf2,0x7f,0x51,0xeb]
1272
+ assert_bytes "negs x20, x19, lsr #1", [0xf4,0x07,0x53,0xeb]
1273
+ assert_bytes "negs x20, x4", [0xf4,0x03,0x04,0xeb]
1274
+ assert_bytes "negs x22, x21, lsr #0", [0xf6,0x03,0x55,0xeb]
1275
+ assert_bytes "negs x24, x23, lsl #31", [0xf8,0x7f,0x17,0xeb]
1276
+ assert_bytes "negs x26, x25, lsl #29", [0xfa,0x77,0x19,0xeb]
1277
+ assert_bytes "negs x28, x27", [0xfc,0x03,0x1b,0xeb]
1278
+ assert_bytes "negs x29, x30", [0xfd,0x03,0x1e,0xeb]
1279
+ assert_bytes "negs x30, xzr", [0xfe,0x03,0x1f,0xeb]
1280
+ end
1281
+
1282
+ def test_generated_ngc
1283
+ assert_bytes "ngc w23, wzr", [0xf7,0x03,0x1f,0x5a]
1284
+ assert_bytes "ngc w3, w12", [0xe3,0x03,0x0c,0x5a]
1285
+ assert_bytes "ngc w9, w10", [0xe9,0x03,0x0a,0x5a]
1286
+ assert_bytes "ngc wzr, w9", [0xff,0x03,0x09,0x5a]
1287
+ assert_bytes "ngc x0, xzr", [0xe0,0x03,0x1f,0xda]
1288
+ assert_bytes "ngc x29, x30", [0xfd,0x03,0x1e,0xda]
1289
+ assert_bytes "ngc x9, x10", [0xe9,0x03,0x0a,0xda]
1290
+ assert_bytes "ngc xzr, x0", [0xff,0x03,0x00,0xda]
1291
+ end
1292
+
1293
+ def test_generated_ngcs
1294
+ assert_bytes "ngcs w23, wzr", [0xf7,0x03,0x1f,0x7a]
1295
+ assert_bytes "ngcs w3, w12", [0xe3,0x03,0x0c,0x7a]
1296
+ assert_bytes "ngcs w9, w10", [0xe9,0x03,0x0a,0x7a]
1297
+ assert_bytes "ngcs wzr, w9", [0xff,0x03,0x09,0x7a]
1298
+ assert_bytes "ngcs x0, xzr", [0xe0,0x03,0x1f,0xfa]
1299
+ assert_bytes "ngcs x29, x30", [0xfd,0x03,0x1e,0xfa]
1300
+ assert_bytes "ngcs x9, x10", [0xe9,0x03,0x0a,0xfa]
1301
+ assert_bytes "ngcs xzr, x0", [0xff,0x03,0x00,0xfa]
1302
+ end
1303
+
1304
+ def test_generated_nop
1305
+ assert_bytes "nop", [0x1f,0x20,0x03,0xd5]
1306
+ end
1307
+
1308
+ def test_generated_orn
1309
+ assert_bytes "orn w2, w5, w29", [0xa2,0x00,0x3d,0x2a]
1310
+ assert_bytes "orn x3, x5, x7, asr #0", [0xa3,0x00,0xa7,0xaa]
1311
+ end
1312
+
1313
+ def test_generated_orr
1314
+ assert_bytes "orr w0, w1, #0xfffffffd", [0x20,0x78,0x1e,0x32]
1315
+ assert_bytes "orr sp, x10, #0xe00000ffe00000ff", [0x5f,0x29,0x03,0xb2]
1316
+ assert_bytes "orr w2, w7, w0, asr #31", [0xe2,0x7c,0x80,0x2a]
1317
+ assert_bytes "orr w3, w9, #0xffff0000", [0x23,0x3d,0x10,0x32]
1318
+ assert_bytes "orr w9, w10, #0x3ff", [0x49,0x25,0x00,0x32]
1319
+ assert_bytes "orr wsp, w10, #0xe00000ff", [0x5f,0x29,0x03,0x32]
1320
+ assert_bytes "orr x11, x12, #0x8000000000000fff", [0x8b,0x31,0x41,0xb2]
1321
+ assert_bytes "orr x3, x9, #0xffff0000ffff0000", [0x23,0x3d,0x10,0xb2]
1322
+ assert_bytes "orr x8, x9, x10, lsl #12", [0x28,0x31,0x0a,0xaa]
1323
+ assert_bytes "orr x9, x10, #0x3ff000003ff", [0x49,0x25,0x00,0xb2]
1324
+ end
1325
+
1326
+ def test_generated_prfm
1327
+ assert_bytes "prfm pldl1keep, [x26, w6, uxtw]", [0x40,0x4b,0xa6,0xf8]
1328
+ assert_bytes "prfm pldl1keep, [sp, #8]", [0xe0,0x07,0x80,0xf9]
1329
+ assert_bytes "prfm pldl2keep, [x5, #16]", [0xa2,0x08,0x80,0xf9]
1330
+ assert_bytes "prfm plil1keep, [sp, #8]", [0xe8,0x07,0x80,0xf9]
1331
+ assert_bytes "prfm plil2keep, [x5, #16]", [0xaa,0x08,0x80,0xf9]
1332
+ assert_bytes "prfm pstl1keep, [sp, #8]", [0xf0,0x07,0x80,0xf9]
1333
+ assert_bytes "prfm pstl2keep, [x5, #16]", [0xb2,0x08,0x80,0xf9]
1334
+ end
1335
+
1336
+ def test_generated_prfum
1337
+ assert_bytes "prfum pldl2keep, [sp, #-256]", [0xe2,0x03,0x90,0xf8]
1338
+ end
1339
+
1340
+ def test_generated_pssbb
1341
+ assert_bytes "pssbb", [0x9f,0x34,0x03,0xd5]
1342
+ end
1343
+
1344
+ def test_generated_rbit
1345
+ assert_bytes "rbit w0, w7", [0xe0,0x00,0xc0,0x5a]
1346
+ assert_bytes "rbit x18, x3", [0x72,0x00,0xc0,0xda]
1347
+ end
1348
+
1349
+ def test_generated_ret
1350
+ assert_bytes "ret", [0xc0,0x03,0x5f,0xd6]
1351
+ assert_bytes "ret x10", [0x40,0x01,0x5f,0xd6]
1352
+ end
1353
+
1354
+ def test_generated_rev
1355
+ assert_bytes "rev w18, w0", [0x12,0x08,0xc0,0x5a]
1356
+ assert_bytes "rev w7, wzr", [0xe7,0x0b,0xc0,0x5a]
1357
+ assert_bytes "rev x13, x12", [0x8d,0x0d,0xc0,0xda]
1358
+ assert_bytes "rev x18, xzr", [0xf2,0x0f,0xc0,0xda]
1359
+ assert_bytes "rev x22, x2", [0x56,0x0c,0xc0,0xda]
1360
+ assert_bytes "rev x22, xzr", [0xf6,0x0f,0xc0,0xda]
1361
+ end
1362
+
1363
+ def test_generated_rev16
1364
+ assert_bytes "rev16 x5, x2", [0x45,0x04,0xc0,0xda]
1365
+ assert_bytes "rev16 w17, w1", [0x31,0x04,0xc0,0x5a]
1366
+ end
1367
+
1368
+ def test_generated_rev32
1369
+ assert_bytes "rev32 x20, x1", [0x34,0x08,0xc0,0xda]
1370
+ assert_bytes "rev32 x20, xzr", [0xf4,0x0b,0xc0,0xda]
1371
+ end
1372
+
1373
+ def test_generated_ror
1374
+ assert_bytes "ror w0, w1, w2", [0x20,0x2c,0xc2,0x1a]
1375
+ assert_bytes "ror w24, w25, w26", [0x38,0x2f,0xda,0x1a]
1376
+ assert_bytes "ror x27, x28, x29", [0x9b,0x2f,0xdd,0x9a]
1377
+ assert_bytes "ror w9, w13, #31", [0xa9,0x7d,0x8d,0x13]
1378
+ assert_bytes "ror x19, x23, #24", [0xf3,0x62,0xd7,0x93]
1379
+ assert_bytes "ror x29, xzr, #63", [0xfd,0xff,0xdf,0x93]
1380
+ assert_bytes "ror x3, x4, x5", [0x83,0x2c,0xc5,0x9a]
1381
+ end
1382
+
1383
+ def test_generated_sbc
1384
+ assert_bytes "sbc w20, w0, wzr", [0x14,0x00,0x1f,0x5a]
1385
+ assert_bytes "sbc w29, w27, w25", [0x7d,0x03,0x19,0x5a]
1386
+ assert_bytes "sbc wzr, w3, w4", [0x7f,0x00,0x04,0x5a]
1387
+ assert_bytes "sbc x20, x0, xzr", [0x14,0x00,0x1f,0xda]
1388
+ assert_bytes "sbc x29, x27, x25", [0x7d,0x03,0x19,0xda]
1389
+ assert_bytes "sbc xzr, x3, x4", [0x7f,0x00,0x04,0xda]
1390
+ end
1391
+
1392
+ def test_generated_sbcs
1393
+ assert_bytes "sbcs w20, w0, wzr", [0x14,0x00,0x1f,0x7a]
1394
+ assert_bytes "sbcs w29, w27, w25", [0x7d,0x03,0x19,0x7a]
1395
+ assert_bytes "sbcs wzr, w3, w4", [0x7f,0x00,0x04,0x7a]
1396
+ assert_bytes "sbcs x20, x0, xzr", [0x14,0x00,0x1f,0xfa]
1397
+ assert_bytes "sbcs x29, x27, x25", [0x7d,0x03,0x19,0xfa]
1398
+ assert_bytes "sbcs xzr, x3, x4", [0x7f,0x00,0x04,0xfa]
1399
+ end
1400
+
1401
+ def test_generated_sbfiz
1402
+ assert_bytes "sbfiz w11, w12, #31, #1", [0x8b,0x01,0x01,0x13]
1403
+ assert_bytes "sbfiz w13, w14, #29, #3", [0xcd,0x09,0x03,0x13]
1404
+ assert_bytes "sbfiz x2, x3, #63, #1", [0x62,0x00,0x41,0x93]
1405
+ assert_bytes "sbfiz x9, x10, #5, #59", [0x49,0xe9,0x7b,0x93]
1406
+ assert_bytes "sbfiz xzr, xzr, #10, #11", [0xff,0x2b,0x76,0x93]
1407
+ end
1408
+
1409
+ def test_generated_sbfx
1410
+ assert_bytes "sbfx w12, w9, #0, #1", [0x2c,0x01,0x00,0x13]
1411
+ assert_bytes "sbfx w9, w10, #0, #1", [0x49,0x01,0x00,0x13]
1412
+ assert_bytes "sbfx x1, x2, #3, #2", [0x41,0x10,0x43,0x93]
1413
+ assert_bytes "sbfx xzr, xzr, #10, #11", [0xff,0x53,0x4a,0x93]
1414
+ end
1415
+
1416
+ def test_generated_sdiv
1417
+ assert_bytes "sdiv w12, w21, w0", [0xac,0x0e,0xc0,0x1a]
1418
+ assert_bytes "sdiv x13, x2, x1", [0x4d,0x0c,0xc1,0x9a]
1419
+ end
1420
+
1421
+ def test_generated_sev
1422
+ assert_bytes "sev", [0x9f,0x20,0x03,0xd5]
1423
+ end
1424
+
1425
+ def test_generated_sevl
1426
+ assert_bytes "sevl", [0xbf,0x20,0x03,0xd5]
1427
+ end
1428
+
1429
+ def test_generated_smaddl
1430
+ assert_bytes "smaddl x13, wzr, w14, x15", [0xed,0x3f,0x2e,0x9b]
1431
+ assert_bytes "smaddl x16, w17, wzr, x18", [0x30,0x4a,0x3f,0x9b]
1432
+ assert_bytes "smaddl x3, w5, w2, x9", [0xa3,0x24,0x22,0x9b]
1433
+ assert_bytes "smaddl xzr, w10, w11, x12", [0x5f,0x31,0x2b,0x9b]
1434
+ end
1435
+
1436
+ def test_generated_smnegl
1437
+ assert_bytes "smnegl x11, w13, w17", [0xab,0xfd,0x31,0x9b]
1438
+ assert_bytes "smnegl x19, w20, w21", [0x93,0xfe,0x35,0x9b]
1439
+ end
1440
+
1441
+ def test_generated_smsubl
1442
+ assert_bytes "smsubl x13, wzr, w14, x15", [0xed,0xbf,0x2e,0x9b]
1443
+ assert_bytes "smsubl x16, w17, wzr, x18", [0x30,0xca,0x3f,0x9b]
1444
+ assert_bytes "smsubl x3, w5, w2, x9", [0xa3,0xa4,0x22,0x9b]
1445
+ assert_bytes "smsubl xzr, w10, w11, x12", [0x5f,0xb1,0x2b,0x9b]
1446
+ end
1447
+
1448
+ def test_generated_smulh
1449
+ assert_bytes "smulh x23, x22, xzr", [0xd7,0x7e,0x5f,0x9b]
1450
+ assert_bytes "smulh x25, xzr, x24", [0xf9,0x7f,0x58,0x9b]
1451
+ assert_bytes "smulh x30, x29, x28", [0xbe,0x7f,0x5c,0x9b]
1452
+ assert_bytes "smulh xzr, x27, x26", [0x7f,0x7f,0x5a,0x9b]
1453
+ end
1454
+
1455
+ def test_generated_smull
1456
+ assert_bytes "smull x11, w13, w17", [0xab,0x7d,0x31,0x9b]
1457
+ assert_bytes "smull x19, w20, w21", [0x93,0x7e,0x35,0x9b]
1458
+ end
1459
+
1460
+ def test_generated_ssbb
1461
+ assert_bytes "ssbb", [0x9f,0x30,0x03,0xd5]
1462
+ end
1463
+
1464
+ def test_generated_stlr
1465
+ assert_bytes "stlr wzr, [x1]", [0x3f,0xfc,0x9f,0x88]
1466
+ assert_bytes "stlr x30, [x2]", [0x5e,0xfc,0x9f,0xc8]
1467
+ end
1468
+
1469
+ def test_generated_stlrb
1470
+ assert_bytes "stlrb w27, [sp]", [0xfb,0xff,0x9f,0x08]
1471
+ end
1472
+
1473
+ def test_generated_stlrh
1474
+ assert_bytes "stlrh w28, [x0]", [0x1c,0xfc,0x9f,0x48]
1475
+ end
1476
+
1477
+ def test_generated_stlxp
1478
+ assert_bytes "stlxp w25, x26, x27, [sp]", [0xfa,0xef,0x39,0xc8]
1479
+ assert_bytes "stlxp wzr, w22, w23, [x24]", [0x16,0xdf,0x3f,0x88]
1480
+ end
1481
+
1482
+ def test_generated_stlxr
1483
+ assert_bytes "stlxr w18, x19, [x20]", [0x93,0xfe,0x12,0xc8]
1484
+ assert_bytes "stlxr wzr, w17, [sp]", [0xf1,0xff,0x1f,0x88]
1485
+ end
1486
+
1487
+ def test_generated_stlxrb
1488
+ assert_bytes "stlxrb w14, w15, [x16]", [0x0f,0xfe,0x0e,0x08]
1489
+ end
1490
+
1491
+ def test_generated_stlxrh
1492
+ assert_bytes "stlxrh w15, w16, [x17]", [0x30,0xfe,0x0f,0x48]
1493
+ end
1494
+
1495
+ def test_generated_stnp
1496
+ assert_bytes "stnp wzr, w9, [sp, #252]", [0xff,0xa7,0x1f,0x28]
1497
+ end
1498
+
1499
+ def test_generated_stp
1500
+ assert_bytes "stp wzr, w9, [sp, #252]", [0xff,0xa7,0x1f,0x29]
1501
+ assert_bytes "stp wzr, w9, [sp, #252]!", [0xff,0xa7,0x9f,0x29]
1502
+ assert_bytes "stp wzr, w9, [sp], #252", [0xff,0xa7,0x9f,0x28]
1503
+ end
1504
+
1505
+ def test_generated_str
1506
+ assert_bytes "str w13, [x27, x5, sxtx #2]", [0x6d,0xfb,0x25,0xb8]
1507
+ assert_bytes "str w14, [x26, w6, uxtw]", [0x4e,0x4b,0x26,0xb8]
1508
+ assert_bytes "str w19, [sp, #255]!", [0xf3,0xff,0x0f,0xb8]
1509
+ assert_bytes "str w19, [sp], #255", [0xf3,0xf7,0x0f,0xb8]
1510
+ assert_bytes "str w20, [x30, #1]!", [0xd4,0x1f,0x00,0xb8]
1511
+ assert_bytes "str w20, [x30], #1", [0xd4,0x17,0x00,0xb8]
1512
+ assert_bytes "str w20, [x4, #16380]", [0x94,0xfc,0x3f,0xb9]
1513
+ assert_bytes "str w21, [x12, #-256]!", [0x95,0x0d,0x10,0xb8]
1514
+ assert_bytes "str w21, [x12], #-256", [0x95,0x05,0x10,0xb8]
1515
+ assert_bytes "str x11, [x29, x3, sxtx]", [0xab,0xeb,0x23,0xf8]
1516
+ assert_bytes "str x19, [x12, #-256]!", [0x93,0x0d,0x10,0xf8]
1517
+ assert_bytes "str x19, [x12], #-256", [0x93,0x05,0x10,0xf8]
1518
+ assert_bytes "str x2, [x3, #1]!", [0x62,0x1c,0x00,0xf8]
1519
+ assert_bytes "str x2, [x3], #1", [0x62,0x14,0x00,0xf8]
1520
+ assert_bytes "str x30, [sp]", [0xfe,0x03,0x00,0xf9]
1521
+ assert_bytes "str x9, [x27, x6]", [0x69,0x6b,0x26,0xf8]
1522
+ assert_bytes "str xzr, [x9, #255]!", [0x3f,0xfd,0x0f,0xf8]
1523
+ assert_bytes "str xzr, [x9], #255", [0x3f,0xf5,0x0f,0xf8]
1524
+ end
1525
+
1526
+ def test_generated_strb
1527
+ assert_bytes "strb w10, [x3, #-256]!", [0x6a,0x0c,0x10,0x38]
1528
+ assert_bytes "strb w10, [x3, #1]!", [0x6a,0x1c,0x00,0x38]
1529
+ assert_bytes "strb w10, [x3], #-256", [0x6a,0x04,0x10,0x38]
1530
+ assert_bytes "strb w10, [x3], #1", [0x6a,0x14,0x00,0x38]
1531
+ assert_bytes "strb w12, [x28, xzr, sxtx #0]", [0x8c,0xfb,0x3f,0x38]
1532
+ assert_bytes "strb w23, [x3, #4095]", [0x77,0xfc,0x3f,0x39]
1533
+ assert_bytes "strb w9, [x2, #255]!", [0x49,0xfc,0x0f,0x38]
1534
+ assert_bytes "strb w9, [x2], #255", [0x49,0xf4,0x0f,0x38]
1535
+ assert_bytes "strb wzr, [x2]", [0x5f,0x00,0x00,0x39]
1536
+ end
1537
+
1538
+ def test_generated_strh
1539
+ assert_bytes "strh w10, [x3, #-256]!", [0x6a,0x0c,0x10,0x78]
1540
+ assert_bytes "strh w10, [x3], #-256", [0x6a,0x04,0x10,0x78]
1541
+ assert_bytes "strh w11, [x29, x3, sxtx]", [0xab,0xeb,0x23,0x78]
1542
+ assert_bytes "strh w17, [sp, #8190]", [0xf1,0xff,0x3f,0x79]
1543
+ assert_bytes "strh w19, [x21, wzr, sxtw #1]", [0xb3,0xda,0x3f,0x78]
1544
+ assert_bytes "strh w20, [x10, #14]", [0x54,0x1d,0x00,0x79]
1545
+ assert_bytes "strh w9, [x2, #1]!", [0x49,0x1c,0x00,0x78]
1546
+ assert_bytes "strh w9, [x2, #255]!", [0x49,0xfc,0x0f,0x78]
1547
+ assert_bytes "strh w9, [x2], #1", [0x49,0x14,0x00,0x78]
1548
+ assert_bytes "strh w9, [x2], #255", [0x49,0xf4,0x0f,0x78]
1549
+ end
1550
+
1551
+ def test_generated_sttr
1552
+ assert_bytes "sttr w16, [x0, #-256]", [0x10,0x08,0x10,0xb8]
1553
+ assert_bytes "sttr x28, [x14, #1]", [0xdc,0x19,0x00,0xf8]
1554
+ end
1555
+
1556
+ def test_generated_sttrb
1557
+ assert_bytes "sttrb w9, [sp]", [0xe9,0x0b,0x00,0x38]
1558
+ end
1559
+
1560
+ def test_generated_sttrh
1561
+ assert_bytes "sttrh wzr, [x12, #255]", [0x9f,0xf9,0x0f,0x78]
1562
+ end
1563
+
1564
+ def test_generated_stur
1565
+ assert_bytes "stur w16, [x0, #-256]", [0x10,0x00,0x10,0xb8]
1566
+ assert_bytes "stur x28, [x14, #1]", [0xdc,0x11,0x00,0xf8]
1567
+ end
1568
+
1569
+ def test_generated_sturb
1570
+ assert_bytes "sturb w9, [sp]", [0xe9,0x03,0x00,0x38]
1571
+ end
1572
+
1573
+ def test_generated_sturh
1574
+ assert_bytes "sturh wzr, [x12, #255]", [0x9f,0xf1,0x0f,0x78]
1575
+ end
1576
+
1577
+ def test_generated_stxp
1578
+ assert_bytes "stxp w11, w12, w13, [x14]", [0xcc,0x35,0x2b,0x88]
1579
+ assert_bytes "stxp wzr, x23, x14, [x15]", [0xf7,0x39,0x3f,0xc8]
1580
+ end
1581
+
1582
+ def test_generated_stxr
1583
+ assert_bytes "stxr w5, x6, [x7]", [0xe6,0x7c,0x05,0xc8]
1584
+ assert_bytes "stxr wzr, w4, [sp]", [0xe4,0x7f,0x1f,0x88]
1585
+ end
1586
+
1587
+ def test_generated_stxrb
1588
+ assert_bytes "stxrb w1, w2, [x3]", [0x62,0x7c,0x01,0x08]
1589
+ end
1590
+
1591
+ def test_generated_stxrh
1592
+ assert_bytes "stxrh w2, w3, [x4]", [0x83,0x7c,0x02,0x48]
1593
+ end
1594
+
1595
+ def test_generated_sub
1596
+ assert_bytes "sub sp, sp, #288", [0xff,0x83,0x04,0xd1]
1597
+ assert_bytes "sub sp, x2, w3, sxtw", [0x5f,0xc0,0x23,0xcb]
1598
+ assert_bytes "sub sp, x3, x7, lsl #4", [0x7f,0x70,0x27,0xcb]
1599
+ assert_bytes "sub w0, wsp, #4077", [0xe0,0xb7,0x3f,0x51]
1600
+ assert_bytes "sub w11, w13, w15", [0xab,0x01,0x0f,0x4b]
1601
+ assert_bytes "sub w17, w29, w20, lsl #31", [0xb1,0x7f,0x14,0x4b]
1602
+ assert_bytes "sub w19, w17, w1, uxtx", [0x33,0x62,0x21,0x4b]
1603
+ assert_bytes "sub w2, w3, w4, asr #0", [0x62,0x00,0x84,0x4b]
1604
+ assert_bytes "sub w2, w3, w5, sxtx", [0x62,0xe0,0x25,0x4b]
1605
+ assert_bytes "sub w2, w5, w1, sxtb", [0xa2,0x80,0x21,0x4b]
1606
+ assert_bytes "sub w2, w5, w7, uxtb", [0xa2,0x00,0x27,0x4b]
1607
+ assert_bytes "sub w21, w15, w17, uxth", [0xf5,0x21,0x31,0x4b]
1608
+ assert_bytes "sub w21, w22, w23, lsr #0", [0xd5,0x02,0x57,0x4b]
1609
+ assert_bytes "sub w24, w25, w26, lsr #18", [0x38,0x4b,0x5a,0x4b]
1610
+ assert_bytes "sub w26, wsp, w19, sxth", [0xfa,0xa3,0x33,0x4b]
1611
+ assert_bytes "sub w27, w28, w29, lsr #31", [0x9b,0x7f,0x5d,0x4b]
1612
+ assert_bytes "sub w3, w5, w7", [0xa3,0x00,0x07,0x4b]
1613
+ assert_bytes "sub w30, w29, wzr, uxtw", [0xbe,0x43,0x3f,0x4b]
1614
+ assert_bytes "sub w4, w20, #546, lsl #12", [0x84,0x8a,0x48,0x51]
1615
+ assert_bytes "sub w4, w6, wzr", [0xc4,0x00,0x1f,0x4b]
1616
+ assert_bytes "sub w5, w6, w7, asr #21", [0xc5,0x54,0x87,0x4b]
1617
+ assert_bytes "sub w8, w9, w10, asr #31", [0x28,0x7d,0x8a,0x4b]
1618
+ assert_bytes "sub w9, w3, wzr, lsl #10", [0x69,0x28,0x1f,0x4b]
1619
+ assert_bytes "sub wsp, w19, #16", [0x7f,0x42,0x00,0x51]
1620
+ assert_bytes "sub wsp, w2, w3, sxtw", [0x5f,0xc0,0x23,0x4b]
1621
+ assert_bytes "sub wzr, w3, w5", [0x7f,0x00,0x05,0x4b]
1622
+ assert_bytes "sub x11, x13, x15", [0xab,0x01,0x0f,0xcb]
1623
+ assert_bytes "sub x12, x1, w20, uxtw", [0x2c,0x40,0x34,0xcb]
1624
+ assert_bytes "sub x17, x25, w20, sxtb", [0x31,0x83,0x34,0xcb]
1625
+ assert_bytes "sub x17, x29, x20, lsl #63", [0xb1,0xff,0x14,0xcb]
1626
+ assert_bytes "sub x18, x13, w19, sxth", [0xb2,0xa1,0x33,0xcb]
1627
+ assert_bytes "sub x2, x3, x4, asr #0", [0x62,0x00,0x84,0xcb]
1628
+ assert_bytes "sub x2, x4, w5, uxtb #2", [0x82,0x08,0x25,0xcb]
1629
+ assert_bytes "sub x20, sp, w19, uxth #4", [0xf4,0x33,0x33,0xcb]
1630
+ assert_bytes "sub x20, x3, x13, uxtx", [0x74,0x60,0x2d,0xcb]
1631
+ assert_bytes "sub x21, x22, x23, lsr #0", [0xd5,0x02,0x57,0xcb]
1632
+ assert_bytes "sub x24, x25, x26, lsr #18", [0x38,0x4b,0x5a,0xcb]
1633
+ assert_bytes "sub x27, x28, x29, lsr #63", [0x9b,0xff,0x5d,0xcb]
1634
+ assert_bytes "sub x3, x5, x7", [0xa3,0x00,0x07,0xcb]
1635
+ assert_bytes "sub x3, x5, x9, sxtx", [0xa3,0xe0,0x29,0xcb]
1636
+ assert_bytes "sub x4, x6, xzr", [0xc4,0x00,0x1f,0xcb]
1637
+ assert_bytes "sub x5, x6, x7, asr #21", [0xc5,0x54,0x87,0xcb]
1638
+ assert_bytes "sub x8, x9, x10, asr #63", [0x28,0xfd,0x8a,0xcb]
1639
+ assert_bytes "sub x9, x3, xzr, lsl #10", [0x69,0x28,0x1f,0xcb]
1640
+ assert_bytes "sub xzr, x3, x5", [0x7f,0x00,0x05,0xcb]
1641
+ end
1642
+
1643
+ def test_generated_subs
1644
+ assert_bytes "subs w11, w13, w15", [0xab,0x01,0x0f,0x6b]
1645
+ assert_bytes "subs w17, w29, w20, lsl #31", [0xb1,0x7f,0x14,0x6b]
1646
+ assert_bytes "subs w19, w17, w1, uxtx", [0x33,0x62,0x21,0x6b]
1647
+ assert_bytes "subs w2, w3, w4, asr #0", [0x62,0x00,0x84,0x6b]
1648
+ assert_bytes "subs w2, w3, w5, sxtx", [0x62,0xe0,0x25,0x6b]
1649
+ assert_bytes "subs w2, w5, w1, sxtb #1", [0xa2,0x84,0x21,0x6b]
1650
+ assert_bytes "subs w2, w5, w7, uxtb", [0xa2,0x00,0x27,0x6b]
1651
+ assert_bytes "subs w21, w15, w17, uxth", [0xf5,0x21,0x31,0x6b]
1652
+ assert_bytes "subs w21, w22, w23, lsr #0", [0xd5,0x02,0x57,0x6b]
1653
+ assert_bytes "subs w24, w25, w26, lsr #18", [0x38,0x4b,0x5a,0x6b]
1654
+ assert_bytes "subs w26, wsp, w19, sxth", [0xfa,0xa3,0x33,0x6b]
1655
+ assert_bytes "subs w27, w28, w29, lsr #31", [0x9b,0x7f,0x5d,0x6b]
1656
+ assert_bytes "subs w3, w5, w7", [0xa3,0x00,0x07,0x6b]
1657
+ assert_bytes "subs w30, w29, wzr, uxtw", [0xbe,0x43,0x3f,0x6b]
1658
+ assert_bytes "subs w4, w6, wzr", [0xc4,0x00,0x1f,0x6b]
1659
+ assert_bytes "subs w5, w6, w7, asr #21", [0xc5,0x54,0x87,0x6b]
1660
+ assert_bytes "subs w8, w9, w10, asr #31", [0x28,0x7d,0x8a,0x6b]
1661
+ assert_bytes "subs w9, w3, wzr, lsl #10", [0x69,0x28,0x1f,0x6b]
1662
+ assert_bytes "subs x11, x13, x15", [0xab,0x01,0x0f,0xeb]
1663
+ assert_bytes "subs x12, x1, w20, uxtw", [0x2c,0x40,0x34,0xeb]
1664
+ assert_bytes "subs x17, x29, x20, lsl #63", [0xb1,0xff,0x14,0xeb]
1665
+ assert_bytes "subs x18, sp, w19, sxth", [0xf2,0xa3,0x33,0xeb]
1666
+ assert_bytes "subs x2, x3, x4, asr #0", [0x62,0x00,0x84,0xeb]
1667
+ assert_bytes "subs x2, x4, w5, uxtb #2", [0x82,0x08,0x25,0xeb]
1668
+ assert_bytes "subs x20, sp, w19, uxth #4", [0xf4,0x33,0x33,0xeb]
1669
+ assert_bytes "subs x20, x3, x13, uxtx", [0x74,0x60,0x2d,0xeb]
1670
+ assert_bytes "subs x21, x22, x23, lsr #0", [0xd5,0x02,0x57,0xeb]
1671
+ assert_bytes "subs x24, x25, x26, lsr #18", [0x38,0x4b,0x5a,0xeb]
1672
+ assert_bytes "subs x27, x28, x29, lsr #63", [0x9b,0xff,0x5d,0xeb]
1673
+ assert_bytes "subs x3, sp, x9, lsl #2", [0xe3,0x6b,0x29,0xeb]
1674
+ assert_bytes "subs x3, x5, x7", [0xa3,0x00,0x07,0xeb]
1675
+ assert_bytes "subs x3, x5, x9, sxtx #2", [0xa3,0xe8,0x29,0xeb]
1676
+ assert_bytes "subs x4, sp, #3822", [0xe4,0xbb,0x3b,0xf1]
1677
+ assert_bytes "subs x4, x6, xzr", [0xc4,0x00,0x1f,0xeb]
1678
+ assert_bytes "subs x5, x6, x7, asr #21", [0xc5,0x54,0x87,0xeb]
1679
+ assert_bytes "subs x8, x9, x10, asr #63", [0x28,0xfd,0x8a,0xeb]
1680
+ assert_bytes "subs x9, x3, xzr, lsl #10", [0x69,0x28,0x1f,0xeb]
1681
+ end
1682
+
1683
+ def test_generated_svc
1684
+ assert_bytes "svc #0", [0x01,0x00,0x00,0xd4]
1685
+ end
1686
+
1687
+ def test_generated_sxtb
1688
+ assert_bytes "sxtb w1, w2", [0x41,0x1c,0x00,0x13]
1689
+ assert_bytes "sxtb xzr, w3", [0x7f,0x1c,0x40,0x93]
1690
+ end
1691
+
1692
+ def test_generated_sxth
1693
+ assert_bytes "sxth w9, w10", [0x49,0x3d,0x00,0x13]
1694
+ assert_bytes "sxth x0, w1", [0x20,0x3c,0x40,0x93]
1695
+ end
1696
+
1697
+ def test_generated_sxtw
1698
+ assert_bytes "sxtw x3, w30", [0xc3,0x7f,0x40,0x93]
1699
+ end
1700
+
1701
+ def test_generated_sys
1702
+ assert_bytes "sys #0, c15, c15, #2", [0x5f,0xff,0x08,0xd5]
1703
+ assert_bytes "sys #7, c5, c9, #7, x5", [0xe5,0x59,0x0f,0xd5]
1704
+ end
1705
+
1706
+ def test_generated_sysl
1707
+ assert_bytes "sysl x1, #0, c15, c15, #2", [0x41,0xff,0x28,0xd5]
1708
+ assert_bytes "sysl x9, #7, c5, c9, #7", [0xe9,0x59,0x2f,0xd5]
1709
+ end
1710
+
1711
+ def test_generated_tlbi
1712
+ assert_bytes "tlbi alle1", [0x9f,0x87,0x0c,0xd5]
1713
+ assert_bytes "tlbi alle1is", [0x9f,0x83,0x0c,0xd5]
1714
+ assert_bytes "tlbi alle2", [0x1f,0x87,0x0c,0xd5]
1715
+ assert_bytes "tlbi alle2is", [0x1f,0x83,0x0c,0xd5]
1716
+ assert_bytes "tlbi alle3", [0x1f,0x87,0x0e,0xd5]
1717
+ assert_bytes "tlbi alle3is", [0x1f,0x83,0x0e,0xd5]
1718
+ assert_bytes "tlbi aside1, x20", [0x54,0x87,0x08,0xd5]
1719
+ assert_bytes "tlbi aside1is, x5", [0x45,0x83,0x08,0xd5]
1720
+ assert_bytes "tlbi ipas2e1, x15", [0x2f,0x84,0x0c,0xd5]
1721
+ assert_bytes "tlbi ipas2e1is, x4", [0x24,0x80,0x0c,0xd5]
1722
+ assert_bytes "tlbi ipas2le1, x16", [0xb0,0x84,0x0c,0xd5]
1723
+ assert_bytes "tlbi ipas2le1is, x9", [0xa9,0x80,0x0c,0xd5]
1724
+ assert_bytes "tlbi vaae1, x21", [0x75,0x87,0x08,0xd5]
1725
+ assert_bytes "tlbi vaae1is, x9", [0x69,0x83,0x08,0xd5]
1726
+ assert_bytes "tlbi vaale1, x25", [0xf9,0x87,0x08,0xd5]
1727
+ assert_bytes "tlbi vaale1is, x14", [0xee,0x83,0x08,0xd5]
1728
+ assert_bytes "tlbi vae1, x17", [0x31,0x87,0x08,0xd5]
1729
+ assert_bytes "tlbi vae1is, x1", [0x21,0x83,0x08,0xd5]
1730
+ assert_bytes "tlbi vae2, x18", [0x32,0x87,0x0c,0xd5]
1731
+ assert_bytes "tlbi vae2is, x2", [0x22,0x83,0x0c,0xd5]
1732
+ assert_bytes "tlbi vae3, x19", [0x33,0x87,0x0e,0xd5]
1733
+ assert_bytes "tlbi vae3is, x3", [0x23,0x83,0x0e,0xd5]
1734
+ assert_bytes "tlbi vale1, x22", [0xb6,0x87,0x08,0xd5]
1735
+ assert_bytes "tlbi vale1is, x10", [0xaa,0x83,0x08,0xd5]
1736
+ assert_bytes "tlbi vale2, x23", [0xb7,0x87,0x0c,0xd5]
1737
+ assert_bytes "tlbi vale2is, x11", [0xab,0x83,0x0c,0xd5]
1738
+ assert_bytes "tlbi vale3, x24", [0xb8,0x87,0x0e,0xd5]
1739
+ assert_bytes "tlbi vale3is, x13", [0xad,0x83,0x0e,0xd5]
1740
+ assert_bytes "tlbi vmalle1", [0x1f,0x87,0x08,0xd5]
1741
+ assert_bytes "tlbi vmalle1is", [0x1f,0x83,0x08,0xd5]
1742
+ assert_bytes "tlbi vmalls12e1", [0xdf,0x87,0x0c,0xd5]
1743
+ assert_bytes "tlbi vmalls12e1is", [0xdf,0x83,0x0c,0xd5]
1744
+ end
1745
+
1746
+ def test_generated_tst
1747
+ assert_bytes "tst w3, w7, lsl #31", [0x7f,0x7c,0x07,0x6a]
1748
+ assert_bytes "tst x2, x20, asr #0", [0x5f,0x00,0x94,0xea]
1749
+ end
1750
+
1751
+ def test_generated_ubfiz
1752
+ assert_bytes "ubfiz x4, x5, #52, #11", [0xa4,0x28,0x4c,0xd3]
1753
+ assert_bytes "ubfiz x4, xzr, #1, #6", [0xe4,0x17,0x7f,0xd3]
1754
+ assert_bytes "ubfiz xzr, xzr, #10, #11", [0xff,0x2b,0x76,0xd3]
1755
+ end
1756
+
1757
+ def test_generated_ubfx
1758
+ assert_bytes "ubfx w9, w10, #0, #1", [0x49,0x01,0x00,0x53]
1759
+ assert_bytes "ubfx xzr, x4, #0, #1", [0x9f,0x00,0x40,0xd3]
1760
+ assert_bytes "ubfx w9, w10, #0, #1", [0x49,0x01,0x00,0x53]
1761
+ assert_bytes "ubfx xzr, xzr, #10, #11", [0xff,0x53,0x4a,0xd3]
1762
+ end
1763
+
1764
+ def test_generated_udiv
1765
+ assert_bytes "udiv w0, w7, w10", [0xe0,0x08,0xca,0x1a]
1766
+ assert_bytes "udiv x9, x22, x4", [0xc9,0x0a,0xc4,0x9a]
1767
+ end
1768
+
1769
+ def test_generated_umaddl
1770
+ assert_bytes "umaddl x13, wzr, w14, x15", [0xed,0x3f,0xae,0x9b]
1771
+ assert_bytes "umaddl x16, w17, wzr, x18", [0x30,0x4a,0xbf,0x9b]
1772
+ assert_bytes "umaddl x3, w5, w2, x9", [0xa3,0x24,0xa2,0x9b]
1773
+ assert_bytes "umaddl xzr, w10, w11, x12", [0x5f,0x31,0xab,0x9b]
1774
+ end
1775
+
1776
+ def test_generated_umnegl
1777
+ assert_bytes "umnegl x11, w13, w17", [0xab,0xfd,0xb1,0x9b]
1778
+ assert_bytes "umnegl x19, w20, w21", [0x93,0xfe,0xb5,0x9b]
1779
+ end
1780
+
1781
+ def test_generated_umsubl
1782
+ assert_bytes "umsubl x13, wzr, w14, x15", [0xed,0xbf,0xae,0x9b]
1783
+ assert_bytes "umsubl x16, w17, wzr, x18", [0x30,0xca,0xbf,0x9b]
1784
+ assert_bytes "umsubl x3, w5, w2, x9", [0xa3,0xa4,0xa2,0x9b]
1785
+ assert_bytes "umsubl xzr, w10, w11, x12", [0x5f,0xb1,0xab,0x9b]
1786
+ end
1787
+
1788
+ def test_generated_umulh
1789
+ assert_bytes "umulh x23, x22, xzr", [0xd7,0x7e,0xdf,0x9b]
1790
+ assert_bytes "umulh x25, xzr, x24", [0xf9,0x7f,0xd8,0x9b]
1791
+ assert_bytes "umulh x30, x29, x28", [0xbe,0x7f,0xdc,0x9b]
1792
+ assert_bytes "umulh xzr, x27, x26", [0x7f,0x7f,0xda,0x9b]
1793
+ end
1794
+
1795
+ def test_generated_umull
1796
+ assert_bytes "umull x11, w13, w17", [0xab,0x7d,0xb1,0x9b]
1797
+ assert_bytes "umull x19, w20, w21", [0x93,0x7e,0xb5,0x9b]
1798
+ end
1799
+
1800
+ def test_generated_uxtb
1801
+ assert_bytes "uxtb w1, w2", [0x41,0x1c,0x00,0x53]
1802
+ end
1803
+
1804
+ def test_generated_uxth
1805
+ assert_bytes "uxth w9, w10", [0x49,0x3d,0x00,0x53]
1806
+ end
1807
+
1808
+ def test_generated_wfe
1809
+ assert_bytes "wfe", [0x5f,0x20,0x03,0xd5]
1810
+ end
1811
+
1812
+ def test_generated_wfi
1813
+ assert_bytes "wfi", [0x7f,0x20,0x03,0xd5]
1814
+ end
1815
+
1816
+ def test_generated_yield
1817
+ assert_bytes "yield", [0x3f,0x20,0x03,0xd5]
1818
+ end
1819
+
1820
+ end