This fixes three issues related to Thumb literal loads:
[oota-llvm.git] / test / MC / ARM / thumb-diagnostics.s
1 @ RUN: not llvm-mc -triple=thumbv6-apple-darwin < %s 2> %t
2 @ RUN: FileCheck --check-prefix=CHECK-ERRORS < %t %s
3 @ RUN: not llvm-mc -triple=thumbv5-apple-darwin < %s 2> %t
4 @ RUN: FileCheck --check-prefix=CHECK-ERRORS-V5 < %t %s
5
6 @ Check for various assembly diagnostic messages on invalid input.
7
8 @ ADD instruction w/o 'S' suffix.
9         add r1, r2, r3
10 @ CHECK-ERRORS: error: invalid instruction
11 @ CHECK-ERRORS:         add r1, r2, r3
12 @ CHECK-ERRORS:         ^
13
14 @ Instructions which require v6+ for both registers to be low regs.
15         add r2, r3
16         mov r2, r3
17 @ CHECK-ERRORS: error: instruction variant requires Thumb2
18 @ CHECK-ERRORS:         add r2, r3
19 @ CHECK-ERRORS:         ^
20 @ CHECK-ERRORS-V5: error: instruction variant requires ARMv6 or later
21 @ CHECK-ERRORS-V5:         mov r2, r3
22 @ CHECK-ERRORS-V5:         ^
23
24
25 @ Out of range immediates for ASR instruction.
26         asrs r2, r3, #33
27 @ CHECK-ERRORS: error: invalid operand for instruction
28 @ CHECK-ERRORS:         asrs r2, r3, #33
29 @ CHECK-ERRORS:                      ^
30
31 @ Out of range immediates for BKPT instruction.
32         bkpt #256
33         bkpt #-1
34 error: invalid operand for instruction
35         bkpt #256
36              ^
37 error: invalid operand for instruction
38         bkpt #-1
39              ^
40
41 @ Invalid writeback and register lists for LDM
42         ldm r2!, {r5, r8}
43         ldm r2, {r5, r7}
44         ldm r2!, {r2, r3, r4}
45 @ CHECK-ERRORS: error: registers must be in range r0-r7
46 @ CHECK-ERRORS:         ldm r2!, {r5, r8}
47 @ CHECK-ERRORS:                  ^
48 @ CHECK-ERRORS: error: writeback operator '!' expected
49 @ CHECK-ERRORS:         ldm r2, {r5, r7}
50 @ CHECK-ERRORS:             ^
51 @ CHECK-ERRORS: error: writeback operator '!' not allowed when base register in register list
52 @ CHECK-ERRORS:         ldm r2!, {r2, r3, r4}
53 @ CHECK-ERRORS:               ^
54
55 @ Invalid writeback and register lists for PUSH/POP
56         pop {r1, r2, r10}
57         push {r8, r9}
58 @ CHECK-ERRORS: error: registers must be in range r0-r7 or pc
59 @ CHECK-ERRORS:         pop {r1, r2, r10}
60 @ CHECK-ERRORS:             ^
61 @ CHECK-ERRORS: error: registers must be in range r0-r7 or lr
62 @ CHECK-ERRORS:         push {r8, r9}
63 @ CHECK-ERRORS:              ^
64
65
66 @ Invalid writeback and register lists for STM
67         stm r1, {r2, r6}
68         stm r1!, {r2, r9}
69 @ CHECK-ERRORS: error: instruction requires: thumb2
70 @ CHECK-ERRORS:         stm r1, {r2, r6}
71 @ CHECK-ERRORS:         ^
72 @ CHECK-ERRORS: error: registers must be in range r0-r7
73 @ CHECK-ERRORS:         stm r1!, {r2, r9}
74 @ CHECK-ERRORS:                  ^
75
76 @ Out of range immediates for LSL instruction.
77         lsls r4, r5, #-1
78         lsls r4, r5, #32
79 @ CHECK-ERRORS: error: invalid operand for instruction
80 @ CHECK-ERRORS:         lsls r4, r5, #-1
81 @ CHECK-ERRORS:                      ^
82 @ CHECK-ERRORS: error: invalid operand for instruction
83 @ CHECK-ERRORS:         lsls r4, r5, #32
84 @ CHECK-ERRORS:                      ^
85
86 @ Mismatched source/destination operands for MUL instruction.
87         muls r1, r2, r3
88 @ CHECK-ERRORS: error: destination register must match source register
89 @ CHECK-ERRORS:         muls r1, r2, r3
90 @ CHECK-ERRORS:              ^
91
92
93 @ Out of range immediates for STR instruction.
94         str r2, [r7, #-1]
95         str r5, [r1, #3]
96         str r3, [r7, #128]
97 @ CHECK-ERRORS: error: instruction requires: thumb2
98 @ CHECK-ERRORS:         str r2, [r7, #-1]
99 @ CHECK-ERRORS:         ^
100 @ CHECK-ERRORS: error: instruction requires: thumb2
101 @ CHECK-ERRORS:         str r5, [r1, #3]
102 @ CHECK-ERRORS:         ^
103 @ CHECK-ERRORS: error: instruction requires: thumb2
104 @ CHECK-ERRORS:         str r3, [r7, #128]
105 @ CHECK-ERRORS:         ^
106
107 @ Out of range immediate for SVC instruction.
108         svc #-1
109         svc #256
110 @ CHECK-ERRORS: error: invalid operand for instruction
111 @ CHECK-ERRORS:         svc #-1
112 @ CHECK-ERRORS:             ^
113 @ CHECK-ERRORS: error: instruction requires: arm-mode
114 @ CHECK-ERRORS:         svc #256
115 @ CHECK-ERRORS:         ^
116
117
118 @ Out of range immediate for ADD SP instructions
119         add sp, #-1
120         add sp, #3
121         add sp, sp, #512
122         add r2, sp, #1024
123 @ CHECK-ERRORS: error: instruction requires: thumb2
124 @ CHECK-ERRORS:         add sp, #-1
125 @ CHECK-ERRORS:                 ^
126 @ CHECK-ERRORS: error: instruction requires: thumb2
127 @ CHECK-ERRORS:         add sp, #3
128 @ CHECK-ERRORS:                 ^
129 @ CHECK-ERRORS: error: instruction requires: thumb2
130 @ CHECK-ERRORS:         add sp, sp, #512
131 @ CHECK-ERRORS:                     ^
132 @ CHECK-ERRORS: error: instruction requires: arm-mode
133 @ CHECK-ERRORS:         add r2, sp, #1024
134 @ CHECK-ERRORS:         ^
135
136         add r2, sp, ip
137 @ CHECK-ERRORS: error: source register must be the same as destination
138 @ CHECK-ERRORS:         add r2, sp, ip
139 @ CHECK-ERRORS:                     ^
140
141
142 @------------------------------------------------------------------------------
143 @ B/Bcc - out of range immediates for Thumb1 branches
144 @------------------------------------------------------------------------------
145
146         beq    #-258
147         bne    #256
148         bgt    #13
149         b      #-1048578
150         b      #1048576
151         b      #10323
152
153 @ CHECK-ERRORS: error: Branch target out of range
154 @ CHECK-ERRORS: error: Branch target out of range
155 @ CHECK-ERRORS: error: Branch target out of range
156 @ CHECK-ERRORS: error: Branch target out of range
157 @ CHECK-ERRORS: error: Branch target out of range
158 @ CHECK-ERRORS: error: Branch target out of range
159
160 @------------------------------------------------------------------------------
161 @ WFE/WFI/YIELD - are not supported pre v6T2
162 @------------------------------------------------------------------------------
163         wfe
164         wfi
165         yield
166
167 @ CHECK-ERRORS: error: instruction requires: thumb2
168 @ CHECK-ERRORS: wfe
169 @ CHECK-ERRORS: ^
170 @ CHECK-ERRORS: error: instruction requires: thumb2
171 @ CHECK-ERRORS: wfi
172 @ CHECK-ERRORS: ^
173 @ CHECK-ERRORS: error: instruction requires: thumb2
174 @ CHECK-ERRORS: yield
175 @ CHECK-ERRORS: ^
176
177 @------------------------------------------------------------------------------
178 @ PLDW required mp-extensions
179 @------------------------------------------------------------------------------
180         pldw [r0, #4]
181 @ CHECK-ERRORS: error: instruction requires: mp-extensions
182
183 @------------------------------------------------------------------------------
184 @ LDR(lit) - invalid offsets
185 @------------------------------------------------------------------------------
186
187         ldr r4, [pc, #-12]
188 @ CHECK-ERRORS: error: instruction requires: thumb2
189