basic-thumb2-instructions.s revision 7413f41d3b45d9fe851943d110a5ef5a54a5e076
1@ RUN: llvm-mc -triple=thumbv7-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 complex constructs like shifter operands, check more thoroughly for them 7@ once then spot check that following instructions accept the form generally. 8@ This gives us good coverage while keeping the overall size of the test 9@ more reasonable. 10 11 12@ FIXME: Some 3-operand instructions have a 2-operand assembly syntax. 13 14_func: 15@ CHECK: _func 16 17@------------------------------------------------------------------------------ 18@ ADC (immediate) 19@------------------------------------------------------------------------------ 20 adc r0, r1, #4 21 adcs r0, r1, #0 22 adc r1, r2, #255 23 adc r3, r7, #0x00550055 24 adc r8, r12, #0xaa00aa00 25 adc r9, r7, #0xa5a5a5a5 26 adc r5, r3, #0x87000000 27 adc r4, r2, #0x7f800000 28 adc r4, r2, #0x00000680 29 30@ CHECK: adc r0, r1, #4 @ encoding: [0x41,0xf1,0x04,0x00] 31@ CHECK: adcs r0, r1, #0 @ encoding: [0x51,0xf1,0x00,0x00] 32@ CHECK: adc r1, r2, #255 @ encoding: [0x42,0xf1,0xff,0x01] 33@ CHECK: adc r3, r7, #5570645 @ encoding: [0x47,0xf1,0x55,0x13] 34@ CHECK: adc r8, r12, #2852170240 @ encoding: [0x4c,0xf1,0xaa,0x28] 35@ CHECK: adc r9, r7, #2779096485 @ encoding: [0x47,0xf1,0xa5,0x39] 36@ CHECK: adc r5, r3, #2264924160 @ encoding: [0x43,0xf1,0x07,0x45] 37@ CHECK: adc r4, r2, #2139095040 @ encoding: [0x42,0xf1,0xff,0x44] 38@ CHECK: adc r4, r2, #1664 @ encoding: [0x42,0xf5,0xd0,0x64] 39 40@------------------------------------------------------------------------------ 41@ ADC (register) 42@------------------------------------------------------------------------------ 43 adc r4, r5, r6 44 adcs r4, r5, r6 45 adc.w r9, r1, r3 46 adcs.w r9, r1, r3 47 adc r0, r1, r3, ror #4 48 adcs r0, r1, r3, lsl #7 49 adc.w r0, r1, r3, lsr #31 50 adcs.w r0, r1, r3, asr #32 51 52@ CHECK: adc.w r4, r5, r6 @ encoding: [0x45,0xeb,0x06,0x04] 53@ CHECK: adcs.w r4, r5, r6 @ encoding: [0x55,0xeb,0x06,0x04] 54@ CHECK: adc.w r9, r1, r3 @ encoding: [0x41,0xeb,0x03,0x09] 55@ CHECK: adcs.w r9, r1, r3 @ encoding: [0x51,0xeb,0x03,0x09] 56@ CHECK: adc.w r0, r1, r3, ror #4 @ encoding: [0x41,0xeb,0x33,0x10] 57@ CHECK: adcs.w r0, r1, r3, lsl #7 @ encoding: [0x51,0xeb,0xc3,0x10] 58@ CHECK: adc.w r0, r1, r3, lsr #31 @ encoding: [0x41,0xeb,0xd3,0x70] 59@ CHECK: adcs.w r0, r1, r3, asr #32 @ encoding: [0x51,0xeb,0x23,0x00] 60 61 62@------------------------------------------------------------------------------ 63@ ADD (immediate) 64@------------------------------------------------------------------------------ 65 itet eq 66 addeq r1, r2, #4 67 addwne r5, r3, #1023 68 addeq r4, r5, #293 69 add r2, sp, #1024 70 add r2, r8, #0xff00 71 add r2, r3, #257 72 addw r2, r3, #257 73 add r12, r6, #0x100 74 addw r12, r6, #0x100 75 adds r1, r2, #0x1f0 76 77@ CHECK: itet eq @ encoding: [0x0a,0xbf] 78@ CHECK: addeq r1, r2, #4 @ encoding: [0x11,0x1d] 79@ CHECK: addwne r5, r3, #1023 @ encoding: [0x03,0xf2,0xff,0x35] 80@ CHECK: addweq r4, r5, #293 @ encoding: [0x05,0xf2,0x25,0x14] 81@ CHECK: add.w r2, sp, #1024 @ encoding: [0x0d,0xf5,0x80,0x62] 82@ CHECK: add.w r2, r8, #65280 @ encoding: [0x08,0xf5,0x7f,0x42] 83@ CHECK: addw r2, r3, #257 @ encoding: [0x03,0xf2,0x01,0x12] 84@ CHECK: addw r2, r3, #257 @ encoding: [0x03,0xf2,0x01,0x12] 85@ CHECK: add.w r12, r6, #256 @ encoding: [0x06,0xf5,0x80,0x7c] 86@ CHECK: addw r12, r6, #256 @ encoding: [0x06,0xf2,0x00,0x1c] 87@ CHECK: adds.w r1, r2, #496 @ encoding: [0x12,0xf5,0xf8,0x71] 88 89 90@------------------------------------------------------------------------------ 91@ ADD (register) 92@------------------------------------------------------------------------------ 93 add r1, r2, r8 94 add r5, r9, r2, asr #32 95 adds r7, r3, r1, lsl #31 96 adds.w r0, r3, r6, lsr #25 97 add.w r4, r8, r1, ror #12 98 99@ CHECK: add.w r1, r2, r8 @ encoding: [0x02,0xeb,0x08,0x01] 100@ CHECK: add.w r5, r9, r2, asr #32 @ encoding: [0x09,0xeb,0x22,0x05] 101@ CHECK: adds.w r7, r3, r1, lsl #31 @ encoding: [0x13,0xeb,0xc1,0x77] 102@ CHECK: adds.w r0, r3, r6, lsr #25 @ encoding: [0x13,0xeb,0x56,0x60] 103@ CHECK: add.w r4, r8, r1, ror #12 @ encoding: [0x08,0xeb,0x31,0x34] 104 105 106@------------------------------------------------------------------------------ 107@ FIXME: ADR 108@------------------------------------------------------------------------------ 109 110@------------------------------------------------------------------------------ 111@ AND (immediate) 112@------------------------------------------------------------------------------ 113 and r2, r5, #0xff000 114 ands r3, r12, #0xf 115 and r1, #0xff 116 and r1, r1, #0xff 117 118@ CHECK: and r2, r5, #1044480 @ encoding: [0x05,0xf4,0x7f,0x22] 119@ CHECK: ands r3, r12, #15 @ encoding: [0x1c,0xf0,0x0f,0x03] 120@ CHECK: and r1, r1, #255 @ encoding: [0x01,0xf0,0xff,0x01] 121@ CHECK: and r1, r1, #255 @ encoding: [0x01,0xf0,0xff,0x01] 122 123 124@------------------------------------------------------------------------------ 125@ AND (register) 126@------------------------------------------------------------------------------ 127 and r4, r9, r8 128 and r1, r4, r8, asr #3 129 ands r2, r1, r7, lsl #1 130 ands.w r4, r5, r2, lsr #20 131 and.w r9, r12, r1, ror #17 132 133@ CHECK: and.w r4, r9, r8 @ encoding: [0x09,0xea,0x08,0x04] 134@ CHECK: and.w r1, r4, r8, asr #3 @ encoding: [0x04,0xea,0xe8,0x01] 135@ CHECK: ands.w r2, r1, r7, lsl #1 @ encoding: [0x11,0xea,0x47,0x02] 136@ CHECK: ands.w r4, r5, r2, lsr #20 @ encoding: [0x15,0xea,0x12,0x54] 137@ CHECK: and.w r9, r12, r1, ror #17 @ encoding: [0x0c,0xea,0x71,0x49] 138 139@------------------------------------------------------------------------------ 140@ ASR (immediate) 141@------------------------------------------------------------------------------ 142 asr r2, r3, #12 143 asrs r8, r3, #32 144 asrs.w r2, r3, #1 145 asr r2, r3, #4 146 asrs r2, r12, #15 147 148 asr r3, #19 149 asrs r8, #2 150 asrs.w r7, #5 151 asr.w r12, #21 152 153@ CHECK: asr.w r2, r3, #12 @ encoding: [0x4f,0xea,0x23,0x32] 154@ CHECK: asrs.w r8, r3, #32 @ encoding: [0x5f,0xea,0x23,0x08] 155@ CHECK: asrs.w r2, r3, #1 @ encoding: [0x5f,0xea,0x63,0x02] 156@ CHECK: asr.w r2, r3, #4 @ encoding: [0x4f,0xea,0x23,0x12] 157@ CHECK: asrs.w r2, r12, #15 @ encoding: [0x5f,0xea,0xec,0x32] 158 159@ CHECK: asr.w r3, r3, #19 @ encoding: [0x4f,0xea,0xe3,0x43] 160@ CHECK: asrs.w r8, r8, #2 @ encoding: [0x5f,0xea,0xa8,0x08] 161@ CHECK: asrs.w r7, r7, #5 @ encoding: [0x5f,0xea,0x67,0x17] 162@ CHECK: asr.w r12, r12, #21 @ encoding: [0x4f,0xea,0x6c,0x5c] 163 164 165@------------------------------------------------------------------------------ 166@ ASR (register) 167@------------------------------------------------------------------------------ 168 asr r3, r4, r2 169 asr.w r1, r2 170 asrs r3, r4, r8 171 172@ CHECK: asr.w r3, r4, r2 @ encoding: [0x44,0xfa,0x02,0xf3] 173@ CHECK: asr.w r1, r1, r2 @ encoding: [0x41,0xfa,0x02,0xf1] 174@ CHECK: asrs.w r3, r4, r8 @ encoding: [0x54,0xfa,0x08,0xf3] 175 176 177@------------------------------------------------------------------------------ 178@ B 179@------------------------------------------------------------------------------ 180 b.w _bar 181 beq.w _bar 182 it eq 183 beq.w _bar 184 bmi.w #-183396 185 186@ CHECK: b.w _bar @ encoding: [A,0xf0'A',A,0x90'A'] 187 @ fixup A - offset: 0, value: _bar, kind: fixup_t2_uncondbranch 188@ CHECK: beq.w _bar @ encoding: [A,0xf0'A',A,0x80'A'] 189 @ fixup A - offset: 0, value: _bar, kind: fixup_t2_condbranch 190@ CHECK: it eq @ encoding: [0x08,0xbf] 191@ CHECK: b.w _bar @ encoding: [A,0xf0'A',A,0x90'A'] 192 @ fixup A - offset: 0, value: _bar, kind: fixup_t2_uncondbranch 193@ CHECK: bmi.w #-183396 @ encoding: [0x13,0xf5,0xce,0xa9] 194 195 196@------------------------------------------------------------------------------ 197@ BFC 198@------------------------------------------------------------------------------ 199 bfc r5, #3, #17 200 it lo 201 bfccc r5, #3, #17 202 203@ CHECK: bfc r5, #3, #17 @ encoding: [0x6f,0xf3,0xd3,0x05] 204@ CHECK: it lo @ encoding: [0x38,0xbf] 205@ CHECK: bfclo r5, #3, #17 @ encoding: [0x6f,0xf3,0xd3,0x05] 206 207 208@------------------------------------------------------------------------------ 209@ CBZ/CBNZ 210@------------------------------------------------------------------------------ 211 cbnz r7, #6 212 cbnz r7, #12 213 214@ CHECK: cbnz r7, #6 @ encoding: [0x1f,0xb9] 215@ CHECK: cbnz r7, #12 @ encoding: [0x37,0xb9] 216 217@------------------------------------------------------------------------------ 218@ IT 219@------------------------------------------------------------------------------ 220@ Test encodings of a few full IT blocks, not just the IT instruction 221 222 iteet eq 223 addeq r0, r1, r2 224 nopne 225 subne r5, r6, r7 226 addeq r1, r2, #4 227 228@ CHECK: iteet eq @ encoding: [0x0d,0xbf] 229@ CHECK: addeq r0, r1, r2 @ encoding: [0x88,0x18] 230@ CHECK: nopne @ encoding: [0x00,0xbf] 231@ CHECK: subne r5, r6, r7 @ encoding: [0xf5,0x1b] 232@ CHECK: addeq r1, r2, #4 @ encoding: [0x11,0x1d] 233