311 lines · plain
1@ RUN: llvm-mc -triple=thumbv7-apple-darwin -mcpu=cortex-a8 -show-encoding < %s | FileCheck %s2 3@------------------------------------------------------------------------------4@ unconditional branches accept narrow suffix and encode to short encodings5@------------------------------------------------------------------------------6 7 b.n #-20488 b.n #20469 10@ CHECK: b #-2048 @ encoding: [0x00,0xe4]11@ CHECK: b #2046 @ encoding: [0xff,0xe3]12 13@------------------------------------------------------------------------------14@ unconditional branches accept wide suffix and encode to wide encodings15@------------------------------------------------------------------------------16 17 b.w #-204818 b.w #204619 b.w #-167721620 b.w #167721421 22@ CHECK: b.w #-2048 @ encoding: [0xff,0xf7,0x00,0xbc]23@ CHECK: b.w #2046 @ encoding: [0x00,0xf0,0xff,0xbb]24@ CHECK: b.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]25@ CHECK: b.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]26 27@------------------------------------------------------------------------------28@ unconditional branches without width suffix encode depending of offset size29@------------------------------------------------------------------------------30 31 b #-204832 b #204633 b #-205034 b #204835 b #-167721636 b #167721437 38@ CHECK: b #-2048 @ encoding: [0x00,0xe4]39@ CHECK: b #2046 @ encoding: [0xff,0xe3]40@ CHECK: b.w #-2050 @ encoding: [0xff,0xf7,0xff,0xbb]41@ CHECK: b.w #2048 @ encoding: [0x00,0xf0,0x00,0xbc]42@ CHECK: b.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]43@ CHECK: b.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]44 45@------------------------------------------------------------------------------46@ unconditional branches with width narrow suffix in IT block 47@------------------------------------------------------------------------------48 49 it eq50 beq.n #-204851 it ne52 bne.n #-204653 54@ CHECK: it eq @ encoding: [0x08,0xbf]55@ CHECK: beq #-2048 @ encoding: [0x00,0xe4] 56@ CHECK: it ne @ encoding: [0x18,0xbf] 57@ CHECK: bne #-2046 @ encoding: [0x01,0xe4]58 59@------------------------------------------------------------------------------60@ unconditional branches with wide suffix in IT block61@------------------------------------------------------------------------------62 63 it gt64 bgt.w #-204865 it le66 ble.w #204667 it ge68 bge.w #-167721669 it lt70 blt.w #167721471 72@ CHECK: it gt @ encoding: [0xc8,0xbf]73@ CHECK: bgt.w #-2048 @ encoding: [0xff,0xf7,0x00,0xbc]74@ CHECK: it le @ encoding: [0xd8,0xbf]75@ CHECK: ble.w #2046 @ encoding: [0x00,0xf0,0xff,0xbb]76@ CHECK: it ge @ encoding: [0xa8,0xbf]77@ CHECK: bge.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]78@ CHECK: it lt @ encoding: [0xb8,0xbf]79@ CHECK: blt.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]80 81@------------------------------------------------------------------------------82@ conditional branches accept narrow suffix and encode to short encodings83@------------------------------------------------------------------------------84 85 beq.n #-25686 bne.n #25487 88@ CHECK: beq #-256 @ encoding: [0x80,0xd0]89@ CHECK: bne #254 @ encoding: [0x7f,0xd1]90 91@------------------------------------------------------------------------------92@ unconditional branches accept wide suffix and encode to wide encodings93@------------------------------------------------------------------------------94 95 bl.w #25696 it ne97 blne.w #25698 bmi.w #-25699 bne.w #254100 blt.w #-1048576101 bge.w #1048574102 103@ CHECK: bl #256 @ encoding: [0x00,0xf0,0x80,0xf8]104@ CHECK: it ne @ encoding: [0x18,0xbf]105@ CHECK: blne #256 @ encoding: [0x00,0xf0,0x80,0xf8]106@ CHECK: bmi.w #-256 @ encoding: [0x3f,0xf5,0x80,0xaf]107@ CHECK: bne.w #254 @ encoding: [0x40,0xf0,0x7f,0x80]108@ CHECK: blt.w #-1048576 @ encoding: [0xc0,0xf6,0x00,0x80]109@ CHECK: bge.w #1048574 @ encoding: [0xbf,0xf2,0xff,0xaf]110 111@------------------------------------------------------------------------------112@ unconditional branches without width suffix encode depending of offset size113@------------------------------------------------------------------------------114 115 bne #-256116 bgt #254117 bne #-258118 bgt #256119 bne #-1048576120 bgt #1048574121 122@ CHECK: bne #-256 @ encoding: [0x80,0xd1]123@ CHECK: bgt #254 @ encoding: [0x7f,0xdc]124@ CHECK: bne.w #-258 @ encoding: [0x7f,0xf4,0x7f,0xaf]125@ CHECK: bgt.w #256 @ encoding: [0x00,0xf3,0x80,0x80]126@ CHECK: bne.w #-1048576 @ encoding: [0x40,0xf4,0x00,0x80]127@ CHECK: bgt.w #1048574 @ encoding: [0x3f,0xf3,0xff,0xaf]128 129@------------------------------------------------------------------------------130@ same branch insturction encoding to conditional or unconditional depending131@ on whether it is in an IT block or not132@------------------------------------------------------------------------------133 134 it eq135 addeq r0, r1136 bne #128137 138@ CHECK: it eq @ encoding: [0x08,0xbf]139@ CHECK: addeq r0, r1 @ encoding: [0x08,0x44]140@ CHECK: bne #128 @ encoding: [0x40,0xd1]141 142 ite eq143 addeq r0, r1144 bne #128145 146@ CHECK: ite eq @ encoding: [0x0c,0xbf]147@ CHECK: addeq r0, r1 @ encoding: [0x08,0x44]148@ CHECK: bne #128 @ encoding: [0x40,0xe0]149 150@ RUN: llvm-mc -triple=thumbv7-apple-darwin -mcpu=cortex-a8 -show-encoding < %s | FileCheck %s151 152@------------------------------------------------------------------------------153@ unconditional branches accept narrow suffix and encode to short encodings154@------------------------------------------------------------------------------155 156 b.n #-2048157 b.n #2046158 159@ CHECK: b #-2048 @ encoding: [0x00,0xe4]160@ CHECK: b #2046 @ encoding: [0xff,0xe3]161 162@------------------------------------------------------------------------------163@ unconditional branches accept wide suffix and encode to wide encodings164@------------------------------------------------------------------------------165 166 b.w #-2048167 b.w #2046168 b.w #-1677216169 b.w #1677214170 171@ CHECK: b.w #-2048 @ encoding: [0xff,0xf7,0x00,0xbc]172@ CHECK: b.w #2046 @ encoding: [0x00,0xf0,0xff,0xbb]173@ CHECK: b.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]174@ CHECK: b.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]175 176@------------------------------------------------------------------------------177@ unconditional branches without width suffix encode depending of offset size178@------------------------------------------------------------------------------179 180 b #-2048181 b #2046182 b #-2050183 b #2048184 b #-1677216185 b #1677214186 187@ CHECK: b #-2048 @ encoding: [0x00,0xe4]188@ CHECK: b #2046 @ encoding: [0xff,0xe3]189@ CHECK: b.w #-2050 @ encoding: [0xff,0xf7,0xff,0xbb]190@ CHECK: b.w #2048 @ encoding: [0x00,0xf0,0x00,0xbc]191@ CHECK: b.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]192@ CHECK: b.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]193 194@------------------------------------------------------------------------------195@ unconditional branches with width narrow suffix in IT block 196@------------------------------------------------------------------------------197 198 it eq199 beq.n #-2048200 it ne201 bne.n #-2046202 203@ CHECK: it eq @ encoding: [0x08,0xbf]204@ CHECK: beq #-2048 @ encoding: [0x00,0xe4] 205@ CHECK: it ne @ encoding: [0x18,0xbf] 206@ CHECK: bne #-2046 @ encoding: [0x01,0xe4]207 208@------------------------------------------------------------------------------209@ unconditional branches with wide suffix in IT block210@------------------------------------------------------------------------------211 212 it gt213 bgt.w #-2048214 it le215 ble.w #2046216 it ge217 bge.w #-1677216218 it lt219 blt.w #1677214220 221@ CHECK: it gt @ encoding: [0xc8,0xbf]222@ CHECK: bgt.w #-2048 @ encoding: [0xff,0xf7,0x00,0xbc]223@ CHECK: it le @ encoding: [0xd8,0xbf]224@ CHECK: ble.w #2046 @ encoding: [0x00,0xf0,0xff,0xbb]225@ CHECK: it ge @ encoding: [0xa8,0xbf]226@ CHECK: bge.w #-1677216 @ encoding: [0x66,0xf6,0x30,0xbc]227@ CHECK: it lt @ encoding: [0xb8,0xbf]228@ CHECK: blt.w #1677214 @ encoding: [0x99,0xf1,0xcf,0xbb]229 230@------------------------------------------------------------------------------231@ conditional branches accept narrow suffix and encode to short encodings232@------------------------------------------------------------------------------233 234 beq.n #-256235 bne.n #254236 237@ CHECK: beq #-256 @ encoding: [0x80,0xd0]238@ CHECK: bne #254 @ encoding: [0x7f,0xd1]239 240@------------------------------------------------------------------------------241@ unconditional branches accept wide suffix and encode to wide encodings242@------------------------------------------------------------------------------243 244 bmi.w #-256245 bne.w #254246 blt.w #-1048576247 bge.w #1048574248 249@ CHECK: bmi.w #-256 @ encoding: [0x3f,0xf5,0x80,0xaf]250@ CHECK: bne.w #254 @ encoding: [0x40,0xf0,0x7f,0x80]251@ CHECK: blt.w #-1048576 @ encoding: [0xc0,0xf6,0x00,0x80]252@ CHECK: bge.w #1048574 @ encoding: [0xbf,0xf2,0xff,0xaf]253 254@------------------------------------------------------------------------------255@ unconditional branches without width suffix encode depending of offset size256@------------------------------------------------------------------------------257 258 bne #-256259 bgt #254260 bne #-258261 bgt #256262 bne #-1048576263 bgt #1048574264 265@ CHECK: bne #-256 @ encoding: [0x80,0xd1]266@ CHECK: bgt #254 @ encoding: [0x7f,0xdc]267@ CHECK: bne.w #-258 @ encoding: [0x7f,0xf4,0x7f,0xaf]268@ CHECK: bgt.w #256 @ encoding: [0x00,0xf3,0x80,0x80]269@ CHECK: bne.w #-1048576 @ encoding: [0x40,0xf4,0x00,0x80]270@ CHECK: bgt.w #1048574 @ encoding: [0x3f,0xf3,0xff,0xaf]271 272@------------------------------------------------------------------------------273@ same branch insturction encoding to conditional or unconditional depending274@ on whether it is in an IT block or not275@------------------------------------------------------------------------------276 277 it eq278 addeq r0, r1279 bne #128280 281@ CHECK: it eq @ encoding: [0x08,0xbf]282@ CHECK: addeq r0, r1 @ encoding: [0x08,0x44]283@ CHECK: bne #128 @ encoding: [0x40,0xd1]284 285 ite eq286 addeq r0, r1287 bne #128288 289@ CHECK: ite eq @ encoding: [0x0c,0xbf]290@ CHECK: addeq r0, r1 @ encoding: [0x08,0x44]291@ CHECK: bne #128 @ encoding: [0x40,0xe0]292 293 294@------------------------------------------------------------------------------295@ Branch targets destined for ARM mode must == 0 (mod 4), otherwise (mod 2).296@------------------------------------------------------------------------------297 298 b #2299 bl #2300 beq #2301 cbz r0, #2302 @ N.b. destination is "align(PC, 4) + imm" so imm is still 4-byte303 @ aligned even though current PC may not and destination must be.304 blx #4305 306@ CHECK: b #2 @ encoding: [0x01,0xe0]307@ CHECK: bl #2 @ encoding: [0x00,0xf0,0x01,0xf8]308@ CHECK: beq #2 @ encoding: [0x01,0xd0]309@ CHECK: cbz r0, #2 @ encoding: [0x08,0xb1]310@ CHECK: blx #4 @ encoding: [0x00,0xf0,0x02,0xe8]311