Skip to content

Commit 3bf6cbd

Browse files
[JITLink][AArch32] Add tests for BLX interworking calls
Exercise transformation of BL into BLX instructions, if instruction set mode differs between origin and target.
1 parent 17a1104 commit 3bf6cbd

File tree

2 files changed

+65
-42
lines changed

2 files changed

+65
-42
lines changed

llvm/test/ExecutionEngine/JITLink/AArch32/ELF_static_arm_reloc.s

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,46 @@
88
.text
99
.syntax unified
1010

11-
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_CALL call_target
11+
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_CALL call_target_arm
1212
# CHECK-INSTR: 00000000 <call_site>:
13-
# CHECK-INSTR: 0: ebfffffe bl 0x0 <call_site>
14-
# CHECK-INSTR: 00000004 <call_target>:
15-
# CHECK-INSTR: 4: e12fff1e bx lr
13+
# CHECK-INSTR: 0: ebfffffe bl
14+
# CHECK-INSTR: 4: ebfffffe bl
15+
# CHECK-INSTR: 0000000c <call_target_arm>
16+
# CHECK-INSTR: 00000010 <call_target_thumb>
1617
# ARM branch offset is 8, because it accounts for an additional prefetch
1718
# instruction that increments PC even though it is implicit
18-
# jitlink-check: decode_operand(call_site, 0) = call_target - (call_site + 8)
19+
# jitlink-check: decode_operand(call_site + 0, 0) = call_target_arm - (call_site + 8)
20+
# jitlink-check: decode_operand(call_site + 4, 0) = call_target_thumb - (call_site + 12)
1921
.globl call_site
2022
.type call_site,%function
2123
.p2align 2
2224
call_site:
23-
bl call_target
24-
.size call_site, .-call_site
25+
bl call_target_arm
26+
bl call_target_thumb
27+
bx lr
28+
.size call_site, .-call_site
2529

26-
.globl call_target
27-
.type call_target,%function
30+
.globl call_target_arm
31+
.type call_target_arm,%function
2832
.p2align 2
29-
call_target:
33+
call_target_arm:
34+
bx lr
35+
.size call_target_arm, .-call_target_arm
36+
37+
.code 16
38+
.globl call_target_thumb
39+
.type call_target_thumb,%function
40+
.p2align 1
41+
.thumb_func
42+
call_target_thumb:
3043
bx lr
31-
.size call_target, .-call_target
44+
.size call_target_thumb, .-call_target_thumb
45+
.code 32
3246

3347
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_JUMP24 jump24_target
34-
# CHECK-INSTR: 00000008 <jump24_site>:
35-
# CHECK-INSTR: 8: eafffffe b 0x8 <jump24_site>
36-
# CHECK-INSTR: 0000000c <jump24_target>:
37-
# CHECK-INSTR: c: e12fff1e bx lr
48+
# CHECK-INSTR: 00000014 <jump24_site>:
49+
# CHECK-INSTR: 14: eafffffe b
50+
# CHECK-INSTR: 00000018 <jump24_target>
3851
# jitlink-check: decode_operand(jump24_site, 0) = jump24_target - (jump24_site + 8)
3952
.globl jump24_site
4053
.type jump24_site,%function
@@ -52,8 +65,8 @@ jump24_target:
5265

5366

5467
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_MOVW_ABS_NC data_symbol
55-
# CHECK-INSTR: 00000010 <movw>:
56-
# CHECK-INSTR: 10: e3000000 movw r0, #0x0
68+
# CHECK-INSTR: 0000001c <movw>:
69+
# CHECK-INSTR: 1c: e3000000 movw r0, #0x0
5770
# jitlink-check: decode_operand(movw, 1) = (data_symbol&0x0000ffff)
5871
.globl movw
5972
.type movw,%function
@@ -63,8 +76,8 @@ movw:
6376
.size movw, .-movw
6477

6578
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_MOVT_ABS data_symbol
66-
# CHECK-INSTR: 00000014 <movt>:
67-
# CHECK-INSTR: 14: e3400000 movt r0, #0x0
79+
# CHECK-INSTR: 00000020 <movt>:
80+
# CHECK-INSTR: 20: e3400000 movt r0, #0x0
6881
# We decode the operand with index 2, because movt generates one leading implicit
6982
# predicate operand that we have to skip in order to decode the data_symbol operand
7083
# jitlink-check: decode_operand(movt, 2) = (data_symbol&0xffff0000>>16)

llvm/test/ExecutionEngine/JITLink/AArch32/ELF_static_thumb_reloc.s

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,47 @@
99
.text
1010
.syntax unified
1111

12-
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_THM_CALL call_target
12+
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_THM_CALL call_target_thumb
1313
# CHECK-INSTR: 00000000 <call_site>:
14-
# CHECK-INSTR: 0: f7ff fffe bl 0x0 <call_site>
15-
# CHECK-INSTR: 00000004 <call_target>:
16-
# CHECK-INSTR: 4: 4770 bx lr
14+
# CHECK-INSTR: 0: f7ff fffe bl
15+
# CHECK-INSTR: 4: f7ff fffe bl
16+
# CHECK-INSTR: 00000008 <call_target_thumb>
17+
# CHECK-INSTR: 0000000c <call_target_arm>
1718
# We decode the operand with index 2, because bl generates two leading implicit
1819
# predicate operands that we have to skip in order to decode the call_target operand
19-
# jitlink-check: decode_operand(call_site, 2) = call_target - next_pc(call_site)
20+
# jitlink-check: decode_operand(call_site + 0, 2) = call_target_thumb - (call_site + 4)
21+
# jitlink-check: decode_operand(call_site + 4, 2) = call_target_arm - (call_site + 8)
2022
.globl call_site
2123
.type call_site,%function
2224
.p2align 1
2325
.code 16
2426
.thumb_func
2527
call_site:
26-
bl call_target
27-
.size call_site, .-call_site
28+
bl call_target_thumb
29+
bl call_target_arm
30+
.size call_site, .-call_site
2831

29-
.globl call_target
30-
.type call_target,%function
32+
.globl call_target_thumb
33+
.type call_target_thumb,%function
3134
.p2align 1
3235
.code 16
3336
.thumb_func
34-
call_target:
37+
call_target_thumb:
3538
bx lr
36-
.size call_target, .-call_target
39+
.size call_target_thumb, .-call_target_thumb
40+
41+
.globl call_target_arm
42+
.type call_target_arm,%function
43+
.p2align 2
44+
.code 32
45+
call_target_arm:
46+
bx lr
47+
.size call_target_arm, .-call_target_arm
3748

3849
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_THM_JUMP24 jump24_target
39-
# CHECK-INSTR: 00000006 <jump24_site>:
40-
# CHECK-INSTR: 6: f7ff bffe b.w 0x6 <jump24_site>
41-
# CHECK-INSTR: 0000000a <jump24_target>:
42-
# CHECK-INSTR: a: 4770 bx lr
50+
# CHECK-INSTR: 00000010 <jump24_site>:
51+
# CHECK-INSTR: 10: f7ff bffe b.w
52+
# CHECK-INSTR: 00000014 <jump24_target>
4353
# b.w generates two implicit predicate operands as well, but they are trailing
4454
# operands, so there is no need to adjust the operand index.
4555
# jitlink-check: decode_operand(jump24_site, 0) = jump24_target - next_pc(jump24_site)
@@ -62,8 +72,8 @@ jump24_target:
6272
.size jump24_target, .-jump24_target
6373

6474
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_THM_MOVW_ABS_NC data_symbol
65-
# CHECK-INSTR: 0000000c <movw>:
66-
# CHECK-INSTR: c: f240 0000 movw r0, #0x0
75+
# CHECK-INSTR: 00000016 <movw>:
76+
# CHECK-INSTR: 16: f240 0000 movw r0, #0x0
6777
# jitlink-check: decode_operand(movw, 1) = (data_symbol&0x0000ffff)
6878
.globl movw
6979
.type movw,%function
@@ -75,8 +85,8 @@ movw:
7585
.size movw, .-movw
7686

7787
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_THM_MOVT_ABS data_symbol
78-
# CHECK-INSTR: 00000010 <movt>:
79-
# CHECK-INSTR: 10: f2c0 0000 movt r0, #0x0
88+
# CHECK-INSTR: 0000001a <movt>:
89+
# CHECK-INSTR: 1a: f2c0 0000 movt r0, #0x0
8090
# We decode the operand with index 2, because movt generates one leading implicit
8191
# predicate operand that we have to skip in order to decode the data_symbol operand
8292
# jitlink-check: decode_operand(movt, 2) = (data_symbol&0xffff0000>>16)
@@ -97,8 +107,8 @@ data_symbol:
97107
.text
98108

99109
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_THM_MOVW_PREL_NC external_func
100-
# CHECK-INSTR: 00000014 <movw_prel>:
101-
# CHECK-INSTR: 14: f240 0000 movw r0, #0x0
110+
# CHECK-INSTR: 0000001e <movw_prel>:
111+
# CHECK-INSTR: 1e: f240 0000 movw r0, #0x0
102112
# jitlink-check: decode_operand(movw_prel, 1) = \
103113
# jitlink-check: ((external_func - movw_prel)&0x0000ffff)
104114
.globl movw_prel
@@ -111,8 +121,8 @@ movw_prel:
111121
.size movw_prel, .-movw_prel
112122

113123
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_THM_MOVT_PREL external_func
114-
# CHECK-INSTR: 00000018 <movt_prel>:
115-
# CHECK-INSTR: 18: f2c0 0000 movt r0, #0x0
124+
# CHECK-INSTR: 00000022 <movt_prel>:
125+
# CHECK-INSTR: 22: f2c0 0000 movt r0, #0x0
116126
# jitlink-check: decode_operand(movt_prel, 2) = \
117127
# jitlink-check: ((external_func - movt_prel)&0xffff0000>>16)
118128
.globl movt_prel

0 commit comments

Comments
 (0)