ARM tests for LDRHT assembly parsing and encoding.
[oota-llvm.git] / test / MC / ARM / arm-memory-instructions.s
1 @ RUN: llvm-mc -triple=armv7-apple-darwin -show-encoding < %s | FileCheck %s
2   .syntax unified
3   .globl _func
4
5 @ Check that the assembler can handle the documented syntax from the ARM ARM
6 @ for loads and stores.
7
8 _func:
9 @ CHECK: _func
10
11 @------------------------------------------------------------------------------
12 @ LDR (immediate)
13 @------------------------------------------------------------------------------
14         ldr r5, [r7]
15         ldr r6, [r3, #63]
16         ldr r2, [r4, #4095]!
17         ldr r1, [r2], #30
18         ldr r3, [r1], #-30
19
20 @ CHECK: ldr    r5, [r7]                @ encoding: [0x00,0x50,0x97,0xe5]
21 @ CHECK: ldr    r6, [r3, #63]           @ encoding: [0x3f,0x60,0x93,0xe5]
22 @ CHECK: ldr    r2, [r4, #4095]!        @ encoding: [0xff,0x2f,0xb4,0xe5]
23 @ CHECK: ldr    r1, [r2], #30           @ encoding: [0x1e,0x10,0x92,0xe4]
24 @ CHECK: ldr    r3, [r1], #-30          @ encoding: [0x1e,0x30,0x11,0xe4]
25
26 @------------------------------------------------------------------------------
27 @ FIXME: LDR (literal)
28 @------------------------------------------------------------------------------
29 @ label operands currently assert the show-encoding asm comment helper due
30 @ to the use of non-contiguous bit ranges for fixups in ARM. Once that's
31 @ cleaned up, we can write useful assembly testcases for these sorts of
32 @ instructions.
33
34 @------------------------------------------------------------------------------
35 @ LDR (register)
36 @------------------------------------------------------------------------------
37         ldr r3, [r8, r1]
38         ldr r2, [r5, -r3]
39         ldr r1, [r5, r9]!
40         ldr r6, [r7, -r8]!
41         ldr r5, [r9], r2
42         ldr r4, [r3], -r6
43         ldr r3, [r8, -r2, lsl #15]
44         ldr r1, [r5], r3, asr #15
45
46 @ CHECK: ldr    r3, [r8, r1]            @ encoding: [0x01,0x30,0x98,0xe7]
47 @ CHECK: ldr    r2, [r5, -r3]           @ encoding: [0x03,0x20,0x15,0xe7]
48 @ CHECK: ldr    r1, [r5, r9]!           @ encoding: [0x09,0x10,0xb5,0xe7]
49 @ CHECK: ldr    r6, [r7, -r8]!          @ encoding: [0x08,0x60,0x37,0xe7]
50 @ CHECK: ldr    r5, [r9], r2            @ encoding: [0x02,0x50,0x99,0xe6]
51 @ CHECK: ldr    r4, [r3], -r6           @ encoding: [0x06,0x40,0x13,0xe6]
52 @ CHECK: ldr    r3, [r8, -r2, lsl #15]  @ encoding: [0x82,0x37,0x18,0xe7]
53 @ CHECK: ldr    r1, [r5], r3, asr #15   @ encoding: [0xc3,0x17,0x95,0xe6]
54
55
56 @------------------------------------------------------------------------------
57 @ LDRB (immediate)
58 @------------------------------------------------------------------------------
59         ldrb r3, [r8]
60         ldrb r1, [sp, #63]
61         ldrb r9, [r3, #4095]!
62         ldrb r8, [r1], #22
63         ldrb r2, [r7], #-19
64
65 @ CHECK: ldrb   r3, [r8]                @ encoding: [0x00,0x30,0xd8,0xe5]
66 @ CHECK: ldrb   r1, [sp, #63]           @ encoding: [0x3f,0x10,0xdd,0xe5]
67 @ CHECK: ldrb   r9, [r3, #4095]!        @ encoding: [0xff,0x9f,0xf3,0xe5]
68 @ CHECK: ldrb   r8, [r1], #22           @ encoding: [0x16,0x80,0xd1,0xe4]
69 @ CHECK: ldrb   r2, [r7], #-19          @ encoding: [0x13,0x20,0x57,0xe4]
70
71
72 @------------------------------------------------------------------------------
73 @ LDRB (register)
74 @------------------------------------------------------------------------------
75         ldr r9, [r8, r5]
76         ldr r1, [r5, -r1]
77         ldr r3, [r5, r2]!
78         ldr r6, [r9, -r3]!
79         ldr r2, [r1], r4
80         ldr r8, [r4], -r5
81         ldr r7, [r12, -r1, lsl #15]
82         ldr r5, [r2], r9, asr #15
83
84 @ CHECK: ldr    r9, [r8, r5]            @ encoding: [0x05,0x90,0x98,0xe7]
85 @ CHECK: ldr    r1, [r5, -r1]           @ encoding: [0x01,0x10,0x15,0xe7]
86 @ CHECK: ldr    r3, [r5, r2]!           @ encoding: [0x02,0x30,0xb5,0xe7]
87 @ CHECK: ldr    r6, [r9, -r3]!          @ encoding: [0x03,0x60,0x39,0xe7]
88 @ CHECK: ldr    r2, [r1], r4            @ encoding: [0x04,0x20,0x91,0xe6]
89 @ CHECK: ldr    r8, [r4], -r5           @ encoding: [0x05,0x80,0x14,0xe6]
90 @ CHECK: ldr    r7, [r12, -r1, lsl #15] @ encoding: [0x81,0x77,0x1c,0xe7]
91 @ CHECK: ldr    r5, [r2], r9, asr #15   @ encoding: [0xc9,0x57,0x92,0xe6]
92
93
94 @------------------------------------------------------------------------------
95 @ LDRBT
96 @------------------------------------------------------------------------------
97 @ FIXME: Optional offset operand.
98         ldrbt r3, [r1], #4
99         ldrbt r2, [r8], #-8
100         ldrbt r8, [r7], r6
101         ldrbt r1, [r2], -r6, lsl #12
102
103
104 @ CHECK: ldrbt  r3, [r1], #4            @ encoding: [0x04,0x30,0xf1,0xe4]
105 @ CHECK: ldrbt  r2, [r8], #-8           @ encoding: [0x08,0x20,0x78,0xe4]
106 @ CHECK: ldrbt  r8, [r7], r6            @ encoding: [0x06,0x80,0xf7,0xe6]
107 @ CHECK: ldrbt  r1, [r2], -r6, lsl #12  @ encoding: [0x06,0x16,0x72,0xe6]
108
109
110 @------------------------------------------------------------------------------
111 @ LDRD (immediate)
112 @------------------------------------------------------------------------------
113         ldrd r3, r4, [r5]
114         ldrd r7, r8, [r2, #15]
115         ldrd r1, r2, [r9, #32]!
116         ldrd r6, r7, [r1], #8
117         ldrd r1, r2, [r8], #0
118         ldrd r1, r2, [r8], #+0
119         ldrd r1, r2, [r8], #-0
120
121 @ CHECK: ldrd   r3, r4, [r5]            @ encoding: [0xd0,0x30,0xc5,0xe1]
122 @ CHECK: ldrd   r7, r8, [r2, #15]       @ encoding: [0xdf,0x70,0xc2,0xe1]
123 @ CHECK: ldrd   r1, r2, [r9, #32]!      @ encoding: [0xd0,0x12,0xe9,0xe1]
124 @ CHECK: ldrd   r6, r7, [r1], #8        @ encoding: [0xd8,0x60,0xc1,0xe0]
125 @ CHECK: ldrd   r1, r2, [r8], #0        @ encoding: [0xd0,0x10,0xc8,0xe0]
126 @ CHECK: ldrd   r1, r2, [r8], #0        @ encoding: [0xd0,0x10,0xc8,0xe0]
127 @ CHECK: ldrd   r1, r2, [r8], #-0       @ encoding: [0xd0,0x10,0x48,0xe0]
128
129
130 @------------------------------------------------------------------------------
131 @ FIXME: LDRD (label)
132 @------------------------------------------------------------------------------
133
134 @------------------------------------------------------------------------------
135 @ LDRD (register)
136 @------------------------------------------------------------------------------
137         ldrd r3, r4, [r1, r3]
138         ldrd r4, r5, [r7, r2]!
139         ldrd r1, r2, [r8], r12
140         ldrd r1, r2, [r8], -r12
141
142 @ CHECK: ldrd   r3, r4, [r1, r3]        @ encoding: [0xd3,0x30,0x81,0xe1]
143 @ CHECK: ldrd   r4, r5, [r7, r2]!       @ encoding: [0xd2,0x40,0xa7,0xe1]
144 @ CHECK: ldrd   r1, r2, [r8], r12       @ encoding: [0xdc,0x10,0x88,0xe0]
145 @ CHECK: ldrd   r1, r2, [r8], -r12      @ encoding: [0xdc,0x10,0x08,0xe0]
146
147
148 @------------------------------------------------------------------------------
149 @ LDRH (immediate)
150 @------------------------------------------------------------------------------
151         ldrh r3, [r4]
152         ldrh r2, [r7, #4]
153         ldrh r1, [r8, #64]!
154         ldrh r12, [sp], #4
155
156 @ CHECK: ldrh   r3, [r4]                @ encoding: [0xb0,0x30,0xd4,0xe1]
157 @ CHECK: ldrh   r2, [r7, #4]            @ encoding: [0xb4,0x20,0xd7,0xe1]
158 @ CHECK: ldrh   r1, [r8, #64]!          @ encoding: [0xb0,0x14,0xf8,0xe1]
159 @ CHECK: ldrh   r12, [sp], #4           @ encoding: [0xb4,0xc0,0xdd,0xe0]
160
161
162 @------------------------------------------------------------------------------
163 @ LDRH (register)
164 @------------------------------------------------------------------------------
165         ldrh r6, [r5, r4]
166         ldrh r3, [r8, r11]!
167         ldrh r1, [r2, -r1]!
168         ldrh r9, [r7], r2
169         ldrh r4, [r3], -r2
170
171 @ CHECK: ldrh   r6, [r5, r4]            @ encoding: [0xb4,0x60,0x95,0xe1]
172 @ CHECK: ldrh   r3, [r8, r11]!          @ encoding: [0xbb,0x30,0xb8,0xe1]
173 @ CHECK: ldrh   r1, [r2, -r1]!          @ encoding: [0xb1,0x10,0x32,0xe1]
174 @ CHECK: ldrh   r9, [r7], r2            @ encoding: [0xb2,0x90,0x97,0xe0]
175 @ CHECK: ldrh   r4, [r3], -r2           @ encoding: [0xb2,0x40,0x13,0xe0]
176
177
178 @------------------------------------------------------------------------------
179 @ LDRHT
180 @------------------------------------------------------------------------------
181         ldrht r9, [r7], #128
182         ldrht r4, [r3], #-75
183         ldrht r9, [r7], r2
184         ldrht r4, [r3], -r2
185
186 @ CHECK: ldrht  r9, [r7], #128          @ encoding: [0xb0,0x98,0xf7,0xe0]
187 @ CHECK: ldrht  r4, [r3], #-75          @ encoding: [0xbb,0x44,0x73,0xe0]
188 @ CHECK: ldrht  r9, [r7], r2            @ encoding: [0xb2,0x90,0xb7,0xe0]
189 @ CHECK: ldrht  r4, [r3], -r2           @ encoding: [0xb2,0x40,0x33,0xe0]
190
191