1 # RUN: llvm-mc -triple arm64-apple-darwin --disassemble < %s | FileCheck %s 2 3 #==---------------------------------------------------------------------------== 4 # Add/Subtract with carry/borrow 5 #==---------------------------------------------------------------------------== 6 7 0x41 0x00 0x03 0x1a 8 0x41 0x00 0x03 0x9a 9 0x85 0x00 0x03 0x3a 10 0x85 0x00 0x03 0xba 11 12 # CHECK: adc w1, w2, w3 13 # CHECK: adc x1, x2, x3 14 # CHECK: adcs w5, w4, w3 15 # CHECK: adcs x5, x4, x3 16 17 0x41 0x00 0x03 0x5a 18 0x41 0x00 0x03 0xda 19 0x41 0x00 0x03 0x7a 20 0x41 0x00 0x03 0xfa 21 22 # CHECK: sbc w1, w2, w3 23 # CHECK: sbc x1, x2, x3 24 # CHECK: sbcs w1, w2, w3 25 # CHECK: sbcs x1, x2, x3 26 27 #==---------------------------------------------------------------------------== 28 # Add/Subtract with (optionally shifted) immediate 29 #==---------------------------------------------------------------------------== 30 31 0x83 0x00 0x10 0x11 32 0x83 0x00 0x10 0x91 33 34 # CHECK: add w3, w4, #1024 35 # CHECK: add x3, x4, #1024 36 37 0x83 0x00 0x50 0x11 38 0x83 0x00 0x40 0x11 39 0x83 0x00 0x50 0x91 40 0x83 0x00 0x40 0x91 41 0xff 0x83 0x00 0x91 42 43 # CHECK: add w3, w4, #1024, lsl #12 44 # CHECK: add x3, x4, #1024, lsl #12 45 # CHECK: add x3, x4, #0, lsl #12 46 # CHECK: add sp, sp, #32 47 48 0x83 0x00 0x10 0x31 49 0x83 0x00 0x50 0x31 50 0x83 0x00 0x10 0xb1 51 0x83 0x00 0x50 0xb1 52 0xff 0x83 0x00 0xb1 53 54 # CHECK: adds w3, w4, #1024 55 # CHECK: adds w3, w4, #1024, lsl #12 56 # CHECK: adds x3, x4, #1024 57 # CHECK: adds x3, x4, #1024, lsl #12 58 # CHECK: cmn sp, #32 59 60 0x83 0x00 0x10 0x51 61 0x83 0x00 0x50 0x51 62 0x83 0x00 0x10 0xd1 63 0x83 0x00 0x50 0xd1 64 0xff 0x83 0x00 0xd1 65 66 # CHECK: sub w3, w4, #1024 67 # CHECK: sub w3, w4, #1024, lsl #12 68 # CHECK: sub x3, x4, #1024 69 # CHECK: sub x3, x4, #1024, lsl #12 70 # CHECK: sub sp, sp, #32 71 72 0x83 0x00 0x10 0x71 73 0x83 0x00 0x50 0x71 74 0x83 0x00 0x10 0xf1 75 0x83 0x00 0x50 0xf1 76 0xff 0x83 0x00 0xf1 77 78 # CHECK: subs w3, w4, #1024 79 # CHECK: subs w3, w4, #1024, lsl #12 80 # CHECK: subs x3, x4, #1024 81 # CHECK: subs x3, x4, #1024, lsl #12 82 # CHECK: cmp sp, #32 83 84 #==---------------------------------------------------------------------------== 85 # Add/Subtract register with (optional) shift 86 #==---------------------------------------------------------------------------== 87 88 0xac 0x01 0x0e 0x0b 89 0xac 0x01 0x0e 0x8b 90 0xac 0x31 0x0e 0x0b 91 0xac 0x31 0x0e 0x8b 92 0xac 0x29 0x4e 0x0b 93 0xac 0x29 0x4e 0x8b 94 0xac 0x1d 0x8e 0x0b 95 0xac 0x9d 0x8e 0x8b 96 97 # CHECK: add w12, w13, w14 98 # CHECK: add x12, x13, x14 99 # CHECK: add w12, w13, w14, lsl #12 100 # CHECK: add x12, x13, x14, lsl #12 101 # CHECK: add w12, w13, w14, lsr #10 102 # CHECK: add x12, x13, x14, lsr #10 103 # CHECK: add w12, w13, w14, asr #7 104 # CHECK: add x12, x13, x14, asr #39 105 106 0xac 0x01 0x0e 0x4b 107 0xac 0x01 0x0e 0xcb 108 0xac 0x31 0x0e 0x4b 109 0xac 0x31 0x0e 0xcb 110 0xac 0x29 0x4e 0x4b 111 0xac 0x29 0x4e 0xcb 112 0xac 0x1d 0x8e 0x4b 113 0xac 0x9d 0x8e 0xcb 114 115 # CHECK: sub w12, w13, w14 116 # CHECK: sub x12, x13, x14 117 # CHECK: sub w12, w13, w14, lsl #12 118 # CHECK: sub x12, x13, x14, lsl #12 119 # CHECK: sub w12, w13, w14, lsr #10 120 # CHECK: sub x12, x13, x14, lsr #10 121 # CHECK: sub w12, w13, w14, asr #7 122 # CHECK: sub x12, x13, x14, asr #39 123 124 0xac 0x01 0x0e 0x2b 125 0xac 0x01 0x0e 0xab 126 0xac 0x31 0x0e 0x2b 127 0xac 0x31 0x0e 0xab 128 0xac 0x29 0x4e 0x2b 129 0xac 0x29 0x4e 0xab 130 0xac 0x1d 0x8e 0x2b 131 0xac 0x9d 0x8e 0xab 132 133 # CHECK: adds w12, w13, w14 134 # CHECK: adds x12, x13, x14 135 # CHECK: adds w12, w13, w14, lsl #12 136 # CHECK: adds x12, x13, x14, lsl #12 137 # CHECK: adds w12, w13, w14, lsr #10 138 # CHECK: adds x12, x13, x14, lsr #10 139 # CHECK: adds w12, w13, w14, asr #7 140 # CHECK: adds x12, x13, x14, asr #39 141 142 0xac 0x01 0x0e 0x6b 143 0xac 0x01 0x0e 0xeb 144 0xac 0x31 0x0e 0x6b 145 0xac 0x31 0x0e 0xeb 146 0xac 0x29 0x4e 0x6b 147 0xac 0x29 0x4e 0xeb 148 0xac 0x1d 0x8e 0x6b 149 0xac 0x9d 0x8e 0xeb 150 151 # CHECK: subs w12, w13, w14 152 # CHECK: subs x12, x13, x14 153 # CHECK: subs w12, w13, w14, lsl #12 154 # CHECK: subs x12, x13, x14, lsl #12 155 # CHECK: subs w12, w13, w14, lsr #10 156 # CHECK: subs x12, x13, x14, lsr #10 157 # CHECK: subs w12, w13, w14, asr #7 158 # CHECK: subs x12, x13, x14, asr #39 159 160 #==---------------------------------------------------------------------------== 161 # Add/Subtract with (optional) extend 162 #==---------------------------------------------------------------------------== 163 164 0x41 0x00 0x23 0x0b 165 0x41 0x20 0x23 0x0b 166 0x41 0x40 0x23 0x0b 167 0x41 0x60 0x23 0x0b 168 0x41 0x80 0x23 0x0b 169 0x41 0xa0 0x23 0x0b 170 0x41 0xc0 0x23 0x0b 171 0x41 0xe0 0x23 0x0b 172 173 # CHECK: add w1, w2, w3, uxtb 174 # CHECK: add w1, w2, w3, uxth 175 # CHECK: add w1, w2, w3 176 # CHECK: add w1, w2, w3, uxtx 177 # CHECK: add w1, w2, w3, sxtb 178 # CHECK: add w1, w2, w3, sxth 179 # CHECK: add w1, w2, w3, sxtw 180 # CHECK: add w1, w2, w3, sxtx 181 182 0x41 0x00 0x23 0x8b 183 0x41 0x20 0x23 0x8b 184 0x41 0x40 0x23 0x8b 185 0x41 0x80 0x23 0x8b 186 0x41 0xa0 0x23 0x8b 187 0x41 0xc0 0x23 0x8b 188 189 # CHECK: add x1, x2, w3, uxtb 190 # CHECK: add x1, x2, w3, uxth 191 # CHECK: add x1, x2, w3, uxtw 192 # CHECK: add x1, x2, w3, sxtb 193 # CHECK: add x1, x2, w3, sxth 194 # CHECK: add x1, x2, w3, sxtw 195 196 0xe1 0x43 0x23 0x0b 197 0xe1 0x43 0x23 0x0b 198 0x5f 0x60 0x23 0x8b 199 0x5f 0x60 0x23 0x8b 200 201 # CHECK: add w1, wsp, w3 202 # CHECK: add w1, wsp, w3 203 # CHECK: add sp, x2, x3 204 # CHECK: add sp, x2, x3 205 206 0x41 0x00 0x23 0x4b 207 0x41 0x20 0x23 0x4b 208 0x41 0x40 0x23 0x4b 209 0x41 0x60 0x23 0x4b 210 0x41 0x80 0x23 0x4b 211 0x41 0xa0 0x23 0x4b 212 0x41 0xc0 0x23 0x4b 213 0x41 0xe0 0x23 0x4b 214 215 # CHECK: sub w1, w2, w3, uxtb 216 # CHECK: sub w1, w2, w3, uxth 217 # CHECK: sub w1, w2, w3 218 # CHECK: sub w1, w2, w3, uxtx 219 # CHECK: sub w1, w2, w3, sxtb 220 # CHECK: sub w1, w2, w3, sxth 221 # CHECK: sub w1, w2, w3, sxtw 222 # CHECK: sub w1, w2, w3, sxtx 223 224 0x41 0x00 0x23 0xcb 225 0x41 0x20 0x23 0xcb 226 0x41 0x40 0x23 0xcb 227 0x41 0x80 0x23 0xcb 228 0x41 0xa0 0x23 0xcb 229 0x41 0xc0 0x23 0xcb 230 231 # CHECK: sub x1, x2, w3, uxtb 232 # CHECK: sub x1, x2, w3, uxth 233 # CHECK: sub x1, x2, w3, uxtw 234 # CHECK: sub x1, x2, w3, sxtb 235 # CHECK: sub x1, x2, w3, sxth 236 # CHECK: sub x1, x2, w3, sxtw 237 238 0xe1 0x43 0x23 0x4b 239 0xe1 0x43 0x23 0x4b 240 0x5f 0x60 0x23 0xcb 241 0x5f 0x60 0x23 0xcb 242 243 # CHECK: sub w1, wsp, w3 244 # CHECK: sub w1, wsp, w3 245 # CHECK: sub sp, x2, x3 246 # CHECK: sub sp, x2, x3 247 248 0x41 0x00 0x23 0x2b 249 0x41 0x20 0x23 0x2b 250 0x41 0x40 0x23 0x2b 251 0x41 0x60 0x23 0x2b 252 0x41 0x80 0x23 0x2b 253 0x41 0xa0 0x23 0x2b 254 0x41 0xc0 0x23 0x2b 255 0x41 0xe0 0x23 0x2b 256 257 # CHECK: adds w1, w2, w3, uxtb 258 # CHECK: adds w1, w2, w3, uxth 259 # CHECK: adds w1, w2, w3 260 # CHECK: adds w1, w2, w3, uxtx 261 # CHECK: adds w1, w2, w3, sxtb 262 # CHECK: adds w1, w2, w3, sxth 263 # CHECK: adds w1, w2, w3, sxtw 264 # CHECK: adds w1, w2, w3, sxtx 265 266 0x41 0x00 0x23 0xab 267 0x41 0x20 0x23 0xab 268 0x41 0x40 0x23 0xab 269 0x41 0x80 0x23 0xab 270 0x41 0xa0 0x23 0xab 271 0x41 0xc0 0x23 0xab 272 273 # CHECK: adds x1, x2, w3, uxtb 274 # CHECK: adds x1, x2, w3, uxth 275 # CHECK: adds x1, x2, w3, uxtw 276 # CHECK: adds x1, x2, w3, sxtb 277 # CHECK: adds x1, x2, w3, sxth 278 # CHECK: adds x1, x2, w3, sxtw 279 280 0xe1 0x43 0x23 0x2b 281 0xe1 0x43 0x23 0x2b 282 283 # CHECK: adds w1, wsp, w3 284 # CHECK: adds w1, wsp, w3 285 286 0x41 0x00 0x23 0x6b 287 0x41 0x20 0x23 0x6b 288 0x41 0x40 0x23 0x6b 289 0x41 0x60 0x23 0x6b 290 0x41 0x80 0x23 0x6b 291 0x41 0xa0 0x23 0x6b 292 0x41 0xc0 0x23 0x6b 293 0x41 0xe0 0x23 0x6b 294 295 # CHECK: subs w1, w2, w3, uxtb 296 # CHECK: subs w1, w2, w3, uxth 297 # CHECK: subs w1, w2, w3 298 # CHECK: subs w1, w2, w3, uxtx 299 # CHECK: subs w1, w2, w3, sxtb 300 # CHECK: subs w1, w2, w3, sxth 301 # CHECK: subs w1, w2, w3, sxtw 302 # CHECK: subs w1, w2, w3, sxtx 303 304 0x41 0x00 0x23 0xeb 305 0x41 0x20 0x23 0xeb 306 0x41 0x40 0x23 0xeb 307 0x41 0x80 0x23 0xeb 308 0x41 0xa0 0x23 0xeb 309 0x41 0xc0 0x23 0xeb 310 311 # CHECK: subs x1, x2, w3, uxtb 312 # CHECK: subs x1, x2, w3, uxth 313 # CHECK: subs x1, x2, w3, uxtw 314 # CHECK: subs x1, x2, w3, sxtb 315 # CHECK: subs x1, x2, w3, sxth 316 # CHECK: subs x1, x2, w3, sxtw 317 318 0xe1 0x43 0x23 0x6b 319 0xe1 0x43 0x23 0x6b 320 321 # CHECK: subs w1, wsp, w3 322 # CHECK: subs w1, wsp, w3 323 324 0x1f 0x41 0x28 0xeb 325 0x3f 0x41 0x28 0x6b 326 0xff 0x43 0x28 0x6b 327 0xff 0x43 0x28 0xeb 328 329 # CHECK: cmp x8, w8, uxtw 330 # CHECK: cmp w9, w8, uxtw 331 # CHECK: cmp wsp, w8 332 # CHECK: cmp sp, w8 333 334 0x3f 0x41 0x28 0x4b 335 0xe1 0x43 0x28 0x4b 336 0xff 0x43 0x28 0x4b 337 0x3f 0x41 0x28 0xcb 338 0xe1 0x43 0x28 0xcb 339 0xff 0x43 0x28 0xcb 340 0xe1 0x43 0x28 0x6b 341 0xe1 0x43 0x28 0xeb 342 343 # CHECK: sub wsp, w9, w8 344 # CHECK: sub w1, wsp, w8 345 # CHECK: sub wsp, wsp, w8 346 # CHECK: sub sp, x9, w8 347 # CHECK: sub x1, sp, w8 348 # CHECK: sub sp, sp, w8 349 # CHECK: subs w1, wsp, w8 350 # CHECK: subs x1, sp, w8 351 352 #==---------------------------------------------------------------------------== 353 # Signed/Unsigned divide 354 #==---------------------------------------------------------------------------== 355 356 0x41 0x0c 0xc3 0x1a 357 0x41 0x0c 0xc3 0x9a 358 0x41 0x08 0xc3 0x1a 359 0x41 0x08 0xc3 0x9a 360 361 # CHECK: sdiv w1, w2, w3 362 # CHECK: sdiv x1, x2, x3 363 # CHECK: udiv w1, w2, w3 364 # CHECK: udiv x1, x2, x3 365 366 #==---------------------------------------------------------------------------== 367 # Variable shifts 368 #==---------------------------------------------------------------------------== 369 370 0x41 0x28 0xc3 0x1a 371 # CHECK: asr w1, w2, w3 372 0x41 0x28 0xc3 0x9a 373 # CHECK: asr x1, x2, x3 374 0x41 0x20 0xc3 0x1a 375 # CHECK: lsl w1, w2, w3 376 0x41 0x20 0xc3 0x9a 377 # CHECK: lsl x1, x2, x3 378 0x41 0x24 0xc3 0x1a 379 # CHECK: lsr w1, w2, w3 380 0x41 0x24 0xc3 0x9a 381 # CHECK: lsr x1, x2, x3 382 0x41 0x2c 0xc3 0x1a 383 # CHECK: ror w1, w2, w3 384 0x41 0x2c 0xc3 0x9a 385 # CHECK: ror x1, x2, x3 386 387 #==---------------------------------------------------------------------------== 388 # One operand instructions 389 #==---------------------------------------------------------------------------== 390 391 0x41 0x14 0xc0 0x5a 392 # CHECK: cls w1, w2 393 0x41 0x14 0xc0 0xda 394 # CHECK: cls x1, x2 395 0x41 0x10 0xc0 0x5a 396 # CHECK: clz w1, w2 397 0x41 0x10 0xc0 0xda 398 # CHECK: clz x1, x2 399 0x41 0x00 0xc0 0x5a 400 # CHECK: rbit w1, w2 401 0x41 0x00 0xc0 0xda 402 # CHECK: rbit x1, x2 403 0x41 0x08 0xc0 0x5a 404 # CHECK: rev w1, w2 405 0x41 0x0c 0xc0 0xda 406 # CHECK: rev x1, x2 407 0x41 0x04 0xc0 0x5a 408 # CHECK: rev16 w1, w2 409 0x41 0x04 0xc0 0xda 410 # CHECK: rev16 x1, x2 411 0x41 0x08 0xc0 0xda 412 # CHECK: rev32 x1, x2 413 414 #==---------------------------------------------------------------------------== 415 # 6.6.1 Multiply-add instructions 416 #==---------------------------------------------------------------------------== 417 418 0x41 0x10 0x03 0x1b 419 0x41 0x10 0x03 0x9b 420 0x41 0x90 0x03 0x1b 421 0x41 0x90 0x03 0x9b 422 0x41 0x10 0x23 0x9b 423 0x41 0x90 0x23 0x9b 424 0x41 0x10 0xa3 0x9b 425 0x41 0x90 0xa3 0x9b 426 427 # CHECK: madd w1, w2, w3, w4 428 # CHECK: madd x1, x2, x3, x4 429 # CHECK: msub w1, w2, w3, w4 430 # CHECK: msub x1, x2, x3, x4 431 # CHECK: smaddl x1, w2, w3, x4 432 # CHECK: smsubl x1, w2, w3, x4 433 # CHECK: umaddl x1, w2, w3, x4 434 # CHECK: umsubl x1, w2, w3, x4 435 436 #==---------------------------------------------------------------------------== 437 # Multiply-high instructions 438 #==---------------------------------------------------------------------------== 439 440 0x41 0x7c 0x43 0x9b 441 0x41 0x7c 0xc3 0x9b 442 443 # CHECK: smulh x1, x2, x3 444 # CHECK: umulh x1, x2, x3 445 446 #==---------------------------------------------------------------------------== 447 # Move immediate instructions 448 #==---------------------------------------------------------------------------== 449 450 0x20 0x00 0x80 0x52 451 0x20 0x00 0x80 0xd2 452 0x20 0x00 0xa0 0x52 453 0x20 0x00 0xa0 0xd2 454 455 # CHECK: movz w0, #0x1 456 # CHECK: movz x0, #0x1 457 # CHECK: movz w0, #0x1, lsl #16 458 # CHECK: movz x0, #0x1, lsl #16 459 460 0x40 0x00 0x80 0x12 461 0x40 0x00 0x80 0x92 462 0x40 0x00 0xa0 0x12 463 0x40 0x00 0xa0 0x92 464 465 # CHECK: movn w0, #0x2 466 # CHECK: movn x0, #0x2 467 # CHECK: movn w0, #0x2, lsl #16 468 # CHECK: movn x0, #0x2, lsl #16 469 470 0x20 0x00 0x80 0x72 471 0x20 0x00 0x80 0xf2 472 0x20 0x00 0xa0 0x72 473 0x20 0x00 0xa0 0xf2 474 475 # CHECK: movk w0, #0x1 476 # CHECK: movk x0, #0x1 477 # CHECK: movk w0, #0x1, lsl #16 478 # CHECK: movk x0, #0x1, lsl #16 479 480 #==---------------------------------------------------------------------------== 481 # Conditionally set flags instructions 482 #==---------------------------------------------------------------------------== 483 484 0x1f 0x00 0x00 0x31 485 # CHECK: cmn w0, #0 486 0x1f 0xfc 0x03 0xb1 487 # CHECK: x0, #255 488 489 0x23 0x08 0x42 0x3a 490 # CHECK: ccmn w1, #2, #3, eq 491 0x23 0x08 0x42 0xba 492 # CHECK: ccmn x1, #2, #3, eq 493 0x23 0x08 0x42 0x7a 494 # CHECK: ccmp w1, #2, #3, eq 495 0x23 0x08 0x42 0xfa 496 # CHECK: ccmp x1, #2, #3, eq 497 498 0x23 0x00 0x42 0x3a 499 # CHECK: ccmn w1, w2, #3, eq 500 0x23 0x00 0x42 0xba 501 # CHECK: ccmn x1, x2, #3, eq 502 0x23 0x00 0x42 0x7a 503 # CHECK: ccmp w1, w2, #3, eq 504 0x23 0x00 0x42 0xfa 505 # CHECK: ccmp x1, x2, #3, eq 506 507 #==---------------------------------------------------------------------------== 508 # Conditional select instructions 509 #==---------------------------------------------------------------------------== 510 511 0x41 0x00 0x83 0x1a 512 # CHECK: csel w1, w2, w3, eq 513 0x41 0x00 0x83 0x9a 514 # CHECK: csel x1, x2, x3, eq 515 0x41 0x04 0x83 0x1a 516 # CHECK: csinc w1, w2, w3, eq 517 0x41 0x04 0x83 0x9a 518 # CHECK: csinc x1, x2, x3, eq 519 0x41 0x00 0x83 0x5a 520 # CHECK: csinv w1, w2, w3, eq 521 0x41 0x00 0x83 0xda 522 # CHECK: csinv x1, x2, x3, eq 523 0x41 0x04 0x83 0x5a 524 # CHECK: csneg w1, w2, w3, eq 525 0x41 0x04 0x83 0xda 526 # CHECK: csneg x1, x2, x3, eq 527