1*0a6a1f1dSLionel Sambuc@ RUN: not llvm-mc -triple=thumbv6-apple-darwin -o /dev/null < %s 2>&1 \ 2*0a6a1f1dSLionel Sambuc@ RUN: | FileCheck --check-prefix=CHECK-ERRORS %s 3*0a6a1f1dSLionel Sambuc@ RUN: not llvm-mc -triple=thumbv5-apple-darwin -o /dev/null < %s 2>&1 \ 4*0a6a1f1dSLionel Sambuc@ RUN: | FileCheck --check-prefix=CHECK-ERRORS-V5 %s 5*0a6a1f1dSLionel Sambuc@ RUN: not llvm-mc -triple=thumbv7m -o /dev/null < %s 2>&1 \ 6*0a6a1f1dSLionel Sambuc@ RUN: | FileCheck --check-prefix=CHECK-ERRORS-V7M %s 7*0a6a1f1dSLionel Sambuc@ RUN: not llvm-mc -triple=thumbv8 -o /dev/null < %s 2>&1 \ 8*0a6a1f1dSLionel Sambuc@ RUN: | FileCheck --check-prefix=CHECK-ERRORS-V8 %s 9f4a2713aSLionel Sambuc 10f4a2713aSLionel Sambuc@ Check for various assembly diagnostic messages on invalid input. 11f4a2713aSLionel Sambuc 12f4a2713aSLionel Sambuc@ ADD instruction w/o 'S' suffix. 13f4a2713aSLionel Sambuc add r1, r2, r3 14f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: invalid instruction 15f4a2713aSLionel Sambuc@ CHECK-ERRORS: add r1, r2, r3 16f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 17f4a2713aSLionel Sambuc 18f4a2713aSLionel Sambuc@ Instructions which require v6+ for both registers to be low regs. 19f4a2713aSLionel Sambuc add r2, r3 20f4a2713aSLionel Sambuc mov r2, r3 21f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction variant requires Thumb2 22f4a2713aSLionel Sambuc@ CHECK-ERRORS: add r2, r3 23f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 24f4a2713aSLionel Sambuc@ CHECK-ERRORS-V5: error: instruction variant requires ARMv6 or later 25f4a2713aSLionel Sambuc@ CHECK-ERRORS-V5: mov r2, r3 26f4a2713aSLionel Sambuc@ CHECK-ERRORS-V5: ^ 27f4a2713aSLionel Sambuc 28f4a2713aSLionel Sambuc 29f4a2713aSLionel Sambuc@ Out of range immediates for ASR instruction. 30f4a2713aSLionel Sambuc asrs r2, r3, #33 31f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: invalid operand for instruction 32f4a2713aSLionel Sambuc@ CHECK-ERRORS: asrs r2, r3, #33 33f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 34f4a2713aSLionel Sambuc 35f4a2713aSLionel Sambuc@ Out of range immediates for BKPT instruction. 36f4a2713aSLionel Sambuc bkpt #256 37f4a2713aSLionel Sambuc bkpt #-1 38f4a2713aSLionel Sambucerror: invalid operand for instruction 39f4a2713aSLionel Sambuc bkpt #256 40f4a2713aSLionel Sambuc ^ 41f4a2713aSLionel Sambucerror: invalid operand for instruction 42f4a2713aSLionel Sambuc bkpt #-1 43f4a2713aSLionel Sambuc ^ 44f4a2713aSLionel Sambuc 45f4a2713aSLionel Sambuc@ Out of range immediates for v8 HLT instruction. 46f4a2713aSLionel Sambuc hlt #64 47f4a2713aSLionel Sambuc hlt #-1 48f4a2713aSLionel Sambuc@CHECK-ERRORS: error: instruction requires: armv8 arm-mode 49f4a2713aSLionel Sambuc@CHECK-ERRORS: hlt #64 50f4a2713aSLionel Sambuc@CHECK-ERRORS: ^ 51f4a2713aSLionel Sambuc@CHECK-ERRORS-V8: error: instruction requires: arm-mode 52f4a2713aSLionel Sambuc@CHECK-ERRORS-V8: hlt #64 53f4a2713aSLionel Sambuc@CHECK-ERRORS-V8: ^ 54f4a2713aSLionel Sambuc@CHECK-ERRORS: error: invalid operand for instruction 55f4a2713aSLionel Sambuc@CHECK-ERRORS: hlt #-1 56f4a2713aSLionel Sambuc@CHECK-ERRORS: ^ 57f4a2713aSLionel Sambuc 58f4a2713aSLionel Sambuc@ Invalid writeback and register lists for LDM 59f4a2713aSLionel Sambuc ldm r2!, {r5, r8} 60f4a2713aSLionel Sambuc ldm r2, {r5, r7} 61f4a2713aSLionel Sambuc ldm r2!, {r2, r3, r4} 62f4a2713aSLionel Sambuc ldm r2!, {r2, r3, r4, r10} 63f4a2713aSLionel Sambuc ldmdb r2!, {r2, r3, r4} 64*0a6a1f1dSLionel Sambuc ldm r0, {r2, sp} 65*0a6a1f1dSLionel Sambuc ldmia r0, {r2-r3, sp} 66*0a6a1f1dSLionel Sambuc ldmia r0!, {r2-r3, sp} 67*0a6a1f1dSLionel Sambuc ldmfd r2, {r1, r3-r6, sp} 68*0a6a1f1dSLionel Sambuc ldmfd r2!, {r1, r3-r6, sp} 69*0a6a1f1dSLionel Sambuc ldmdb r1, {r2, r3, sp} 70*0a6a1f1dSLionel Sambuc ldmdb r1!, {r2, r3, sp} 71f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: registers must be in range r0-r7 72f4a2713aSLionel Sambuc@ CHECK-ERRORS: ldm r2!, {r5, r8} 73f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 74f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: writeback operator '!' expected 75f4a2713aSLionel Sambuc@ CHECK-ERRORS: ldm r2, {r5, r7} 76f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 77f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: writeback operator '!' not allowed when base register in register list 78f4a2713aSLionel Sambuc@ CHECK-ERRORS: ldm r2!, {r2, r3, r4} 79f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 80f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: error: writeback operator '!' not allowed when base register in register list 81f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: ldm r2!, {r2, r3, r4, r10} 82f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: ^ 83f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: error: writeback register not allowed in register list 84f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: ldmdb r2!, {r2, r3, r4} 85f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: ^ 86*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 87*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ldm r0, {r2, sp} 88*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 89*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 90*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ldmia r0, {r2-r3, sp} 91*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 92*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 93*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ldmia r0!, {r2-r3, sp} 94*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 95*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 96*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ldmfd r2, {r1, r3-r6, sp} 97*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 98*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 99*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ldmfd r2!, {r1, r3-r6, sp} 100*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 101*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 102*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ldmdb r1, {r2, r3, sp} 103*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 104*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 105*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ldmdb r1!, {r2, r3, sp} 106*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 107f4a2713aSLionel Sambuc 108f4a2713aSLionel Sambuc@ Invalid writeback and register lists for PUSH/POP 109f4a2713aSLionel Sambuc pop {r1, r2, r10} 110f4a2713aSLionel Sambuc push {r8, r9} 111f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: registers must be in range r0-r7 or pc 112f4a2713aSLionel Sambuc@ CHECK-ERRORS: pop {r1, r2, r10} 113f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 114f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: registers must be in range r0-r7 or lr 115f4a2713aSLionel Sambuc@ CHECK-ERRORS: push {r8, r9} 116f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 117f4a2713aSLionel Sambuc 118f4a2713aSLionel Sambuc 119f4a2713aSLionel Sambuc@ Invalid writeback and register lists for STM 120f4a2713aSLionel Sambuc stm r1, {r2, r6} 121f4a2713aSLionel Sambuc stm r1!, {r2, r9} 122f4a2713aSLionel Sambuc stm r2!, {r2, r9} 123f4a2713aSLionel Sambuc stmdb r2!, {r0, r2} 124*0a6a1f1dSLionel Sambuc stm r1!, {r2, sp} 125*0a6a1f1dSLionel Sambuc stmia r4!, {r0-r3, sp} 126*0a6a1f1dSLionel Sambuc stmdb r1, {r2, r3, sp} 127*0a6a1f1dSLionel Sambuc stmdb r1!, {r2, r3, sp} 128f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: thumb2 129f4a2713aSLionel Sambuc@ CHECK-ERRORS: stm r1, {r2, r6} 130f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 131f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: registers must be in range r0-r7 132f4a2713aSLionel Sambuc@ CHECK-ERRORS: stm r1!, {r2, r9} 133f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 134f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: error: writeback operator '!' not allowed when base register in register list 135f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: stm r2!, {r2, r9} 136f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: ^ 137f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: error: writeback register not allowed in register list 138f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: stmdb r2!, {r0, r2} 139f4a2713aSLionel Sambuc@ CHECK-ERRORS-V8: ^ 140*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 141*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: stm r1!, {r2, sp} 142*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 143*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 144*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: stmia r4!, {r0-r3, sp} 145*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 146*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 147*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: stmdb r1, {r2, r3, sp} 148*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 149*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: error: SP may not be in the register list 150*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: stmdb r1!, {r2, r3, sp} 151*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS-V7M: ^ 152f4a2713aSLionel Sambuc 153f4a2713aSLionel Sambuc@ Out of range immediates for LSL instruction. 154f4a2713aSLionel Sambuc lsls r4, r5, #-1 155f4a2713aSLionel Sambuc lsls r4, r5, #32 156f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: invalid operand for instruction 157f4a2713aSLionel Sambuc@ CHECK-ERRORS: lsls r4, r5, #-1 158f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 159f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: invalid operand for instruction 160f4a2713aSLionel Sambuc@ CHECK-ERRORS: lsls r4, r5, #32 161f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 162f4a2713aSLionel Sambuc 163f4a2713aSLionel Sambuc@ Mismatched source/destination operands for MUL instruction. 164f4a2713aSLionel Sambuc muls r1, r2, r3 165f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: destination register must match source register 166f4a2713aSLionel Sambuc@ CHECK-ERRORS: muls r1, r2, r3 167f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 168f4a2713aSLionel Sambuc 169f4a2713aSLionel Sambuc 170f4a2713aSLionel Sambuc@ Out of range immediates for STR instruction. 171f4a2713aSLionel Sambuc str r2, [r7, #-1] 172f4a2713aSLionel Sambuc str r5, [r1, #3] 173f4a2713aSLionel Sambuc str r3, [r7, #128] 174f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: thumb2 175f4a2713aSLionel Sambuc@ CHECK-ERRORS: str r2, [r7, #-1] 176f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 177f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: thumb2 178f4a2713aSLionel Sambuc@ CHECK-ERRORS: str r5, [r1, #3] 179f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 180f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: thumb2 181f4a2713aSLionel Sambuc@ CHECK-ERRORS: str r3, [r7, #128] 182f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 183f4a2713aSLionel Sambuc 184f4a2713aSLionel Sambuc@ Out of range immediate for SVC instruction. 185f4a2713aSLionel Sambuc svc #-1 186f4a2713aSLionel Sambuc svc #256 187f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: invalid operand for instruction 188f4a2713aSLionel Sambuc@ CHECK-ERRORS: svc #-1 189f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 190f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: arm-mode 191f4a2713aSLionel Sambuc@ CHECK-ERRORS: svc #256 192f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 193f4a2713aSLionel Sambuc 194f4a2713aSLionel Sambuc 195f4a2713aSLionel Sambuc@ Out of range immediate for ADD SP instructions 196f4a2713aSLionel Sambuc add sp, #-1 197f4a2713aSLionel Sambuc add sp, #3 198f4a2713aSLionel Sambuc add sp, sp, #512 199f4a2713aSLionel Sambuc add r2, sp, #1024 200f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: thumb2 201f4a2713aSLionel Sambuc@ CHECK-ERRORS: add sp, #-1 202f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 203f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: thumb2 204f4a2713aSLionel Sambuc@ CHECK-ERRORS: add sp, #3 205f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 206f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: thumb2 207f4a2713aSLionel Sambuc@ CHECK-ERRORS: add sp, sp, #512 208f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 209*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: thumb2 210f4a2713aSLionel Sambuc@ CHECK-ERRORS: add r2, sp, #1024 211f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 212f4a2713aSLionel Sambuc 213f4a2713aSLionel Sambuc add r2, sp, ip 214f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: source register must be the same as destination 215f4a2713aSLionel Sambuc@ CHECK-ERRORS: add r2, sp, ip 216f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 217f4a2713aSLionel Sambuc 218f4a2713aSLionel Sambuc 219f4a2713aSLionel Sambuc@------------------------------------------------------------------------------ 220f4a2713aSLionel Sambuc@ B/Bcc - out of range immediates for Thumb1 branches 221f4a2713aSLionel Sambuc@------------------------------------------------------------------------------ 222f4a2713aSLionel Sambuc 223f4a2713aSLionel Sambuc beq #-258 224f4a2713aSLionel Sambuc bne #256 225f4a2713aSLionel Sambuc bgt #13 226f4a2713aSLionel Sambuc b #-1048578 227f4a2713aSLionel Sambuc b #1048576 228f4a2713aSLionel Sambuc b #10323 229f4a2713aSLionel Sambuc 230f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: branch target out of range 231f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: branch target out of range 232f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: branch target out of range 233f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: branch target out of range 234f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: branch target out of range 235f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: branch target out of range 236f4a2713aSLionel Sambuc 237f4a2713aSLionel Sambuc@------------------------------------------------------------------------------ 238f4a2713aSLionel Sambuc@ WFE/WFI/YIELD - are not supported pre v6T2 239f4a2713aSLionel Sambuc@------------------------------------------------------------------------------ 240f4a2713aSLionel Sambuc wfe 241f4a2713aSLionel Sambuc wfi 242f4a2713aSLionel Sambuc yield 243f4a2713aSLionel Sambuc 244f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: armv6m or armv6t2 245f4a2713aSLionel Sambuc@ CHECK-ERRORS: wfe 246f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 247f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: armv6m or armv6t2 248f4a2713aSLionel Sambuc@ CHECK-ERRORS: wfi 249f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 250f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: armv6m or armv6t2 251f4a2713aSLionel Sambuc@ CHECK-ERRORS: yield 252f4a2713aSLionel Sambuc@ CHECK-ERRORS: ^ 253f4a2713aSLionel Sambuc 254f4a2713aSLionel Sambuc@------------------------------------------------------------------------------ 255f4a2713aSLionel Sambuc@ PLDW required mp-extensions 256f4a2713aSLionel Sambuc@------------------------------------------------------------------------------ 257f4a2713aSLionel Sambuc pldw [r0, #4] 258f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: mp-extensions 259f4a2713aSLionel Sambuc 260f4a2713aSLionel Sambuc@------------------------------------------------------------------------------ 261f4a2713aSLionel Sambuc@ LDR(lit) - invalid offsets 262f4a2713aSLionel Sambuc@------------------------------------------------------------------------------ 263f4a2713aSLionel Sambuc 264f4a2713aSLionel Sambuc ldr r4, [pc, #-12] 265f4a2713aSLionel Sambuc@ CHECK-ERRORS: error: instruction requires: thumb2 266f4a2713aSLionel Sambuc 267*0a6a1f1dSLionel Sambuc@------------------------------------------------------------------------------ 268*0a6a1f1dSLionel Sambuc@ STC2{L}/LDC2{L} - requires thumb2 269*0a6a1f1dSLionel Sambuc@------------------------------------------------------------------------------ 270*0a6a1f1dSLionel Sambuc stc2 p0, c8, [r1, #4] 271*0a6a1f1dSLionel Sambuc stc2l p6, c2, [r7, #4] 272*0a6a1f1dSLionel Sambuc ldc2 p0, c8, [r1, #4] 273*0a6a1f1dSLionel Sambuc ldc2l p6, c2, [r7, #4] 274*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS: error: invalid operand for instruction 275*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS: error: invalid operand for instruction 276*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS: error: invalid operand for instruction 277*0a6a1f1dSLionel Sambuc@ CHECK-ERRORS: error: invalid operand for instruction 278