xref: /llvm-project/llvm/test/MC/ARM/arm-branches.s (revision 0ba553d153e65b283c7934c3f061ad0487f03ba6)
13e036171STim Northover@ RUN: llvm-mc -triple=armv7-apple-darwin -show-encoding < %s | FileCheck %s
23e036171STim Northover
33e036171STim Northover@------------------------------------------------------------------------------
43e036171STim Northover@ Branch targets destined for ARM mode must == 0 (mod 4), otherwise (mod 2).
53e036171STim Northover@------------------------------------------------------------------------------
63e036171STim Northover
73e036171STim Northover        b #4
83e036171STim Northover        bl #4
93e036171STim Northover        beq #4
103e036171STim Northover        blx #2
113e036171STim Northover
123e036171STim Northover@ CHECK: b	#4                      @ encoding: [0x01,0x00,0x00,0xea]
133e036171STim Northover@ CHECK: bl	#4                      @ encoding: [0x01,0x00,0x00,0xeb]
143e036171STim Northover@ CHECK: beq	#4                      @ encoding: [0x01,0x00,0x00,0x0a]
153e036171STim Northover@ CHECK: blx	#2                      @ encoding: [0x00,0x00,0x00,0xfb]
16af1c2e56SLucas Prates
17af1c2e56SLucas Prates@------------------------------------------------------------------------------
18af1c2e56SLucas Prates@ Leading '$' on branch targets must not be dropped if part of symbol names
19af1c2e56SLucas Prates@------------------------------------------------------------------------------
20af1c2e56SLucas Prates
21af1c2e56SLucas Prates        .global $foo
22*0ba553d1SLucas Prates        .global $4
23af1c2e56SLucas Prates        b $foo
24af1c2e56SLucas Prates        bl $foo
25af1c2e56SLucas Prates        beq $foo
26af1c2e56SLucas Prates        blx $foo
27af1c2e56SLucas Prates        b $foo + 4
28*0ba553d1SLucas Prates        bl $4
29*0ba553d1SLucas Prates        beq $4 + 4
30af1c2e56SLucas Prates
31af1c2e56SLucas Prates@ CHECK: b      ($foo)                      @ encoding: [A,A,A,0xea]
32af1c2e56SLucas Prates@ CHECK: bl     ($foo)                      @ encoding: [A,A,A,0xeb]
33af1c2e56SLucas Prates@ CHECK: beq    ($foo)                      @ encoding: [A,A,A,0x0a]
34af1c2e56SLucas Prates@ CHECK: blx    ($foo)                      @ encoding: [A,A,A,0xfa]
35af1c2e56SLucas Prates@ CHECK: b      #($foo)+4                   @ encoding: [A,A,A,0xea]
36*0ba553d1SLucas Prates@ CHECK: bl     ($4)                        @ encoding: [A,A,A,0xeb]
37*0ba553d1SLucas Prates@ CHECK: beq    #($4)+4                     @ encoding: [A,A,A,0x0a]
38af1c2e56SLucas Prates
39af1c2e56SLucas Prates@------------------------------------------------------------------------------
40af1c2e56SLucas Prates@ Leading '$' should be allowed to introduce an expression
41af1c2e56SLucas Prates@------------------------------------------------------------------------------
42af1c2e56SLucas Prates
43af1c2e56SLucas Prates        .global bar
44af1c2e56SLucas Prates        b $ 4
45af1c2e56SLucas Prates        bl $ bar + 4
46af1c2e56SLucas Prates        blx $ bar
47af1c2e56SLucas Prates@ CHECK: b	    #4                        @ encoding: [0x01,0x00,0x00,0xea]
48af1c2e56SLucas Prates@ CHECK: bl     #bar+4                    @ encoding: [A,A,A,0xeb]
49af1c2e56SLucas Prates@ CHECK: blx    bar                       @ encoding: [A,A,A,0xfa]
50