263 lines · plain
1# REQUIRES: hexagon2# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o3# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %S/Inputs/hexagon.s -o %t1.o4# RUN: ld.lld %t.o %t1.o -o %t --Ttext=0x200b4 --section-start=b_1000000=0x1000000 \5# RUN: --section-start=b_1000400=0x1000400 --section-start=b_1004000=0x1004000 \6# RUN: --section-start=b_1010000=0x1010000 --section-start=b_1800000=0x18000007# RUN: llvm-objdump --no-print-imm-hex -d %t | FileCheck %s8 9# Note: 131584 == 0x2020010# R_HEX_32_6_X11# R_HEX_12_X12if (p0) r0 = ##_start13# CHECK: immext(#131584)14# CHECK: if (p0) r0 = ##13164415 16# R_HEX_B15_PCREL17if (p0) jump:nt #_start18# CHECK: if (p0) jump:nt 0x2023c19 20# R_HEX_B32_PCREL_X21# R_HEX_B15_PCREL_X22if (p0) jump:nt ##_start23# CHECK: if (p0) jump:nt 0x2023c24 25# R_HEX_B22_PCREL26call #_start27# CHECK: call 0x2023c28 29# R_HEX_B32_PCREL_X30# R_HEX_B22_PCREL_X31call ##_start32# CHECK: immext(#320)33# CHECK: call 0x2023c34 35# R_HEX_6_X tests:36# One test for each mask in the lookup table.37 38#0x3800000039if (!P0) memw(r0+#8)=##_start40# CHECK: 38c0e11c if (!p0) memw(r0+#8) = ##131644 }41 42#0x3900000043{ p0 = p144 if (!P0.new) memw(r0+#0)=##_start }45# CHECK: 39c0e01c if (!p0.new) memw(r0+#0) = ##131644 }46 47#0x3e00000048memw(r0+##_start)+=r149# CHECK: 3e40de01 memw(r0+##131644) += r1 }50 51#0x3f00000052memw(r0+##_start)+=#453# CHECK: 3f40de04 memw(r0+##131644) += #4 }54 55#0x4000000056{ r0 = r157 if (p0) memb(r0+##_start)=r0.new }58# CHECK: 40a0e2e0 if (p0) memb(r0+##131644) = r0.new }59 60#0x4100000061if (p0) r0=memb(r1+##_start)62# CHECK: 4101c780 if (p0) r0 = memb(r1+##131644) }63 64#0x4200000065{ r0 = r166 p0 = p167 if (p0.new) memb(r0+##_start)=r0.new }68# CHECK: 42a0e2e0 if (p0.new) memb(r0+##131644) = r0.new }69 70#0x4300000071{ p0 = p172 if (P0.new) r0=memb(r0+##_start) }73# CHECK: 4300c780 if (p0.new) r0 = memb(r0+##131644) }74 75#0x4400000076if (!p0) memb(r0+##_start)=r177# CHECK: 4400e1e0 if (!p0) memb(r0+##131644) = r1 }78 79#0x4500000080if (!p0) r0=memb(r1+##_start)81# CHECK: 4501c780 if (!p0) r0 = memb(r1+##131644) }82 83#0x4600000084{ p0 = p185 if (!p0.new) memb(r0+##_start)=r1 }86# CHECK: 4600e1e0 if (!p0.new) memb(r0+##131644) = r1 }87 88#0x4700000089{ p0 = p190 if (!p0.new) r0=memb(r1+##_start) }91# CHECK: 4701c780 if (!p0.new) r0 = memb(r1+##131644) }92 93#0x6a000000 -- Note 4294967132 == -0xa4 the distance between94# here and _start, so this will change if95# tests are added between here and _start96r0=add(pc,##_start@pcrel)97# CHECK: 6a49d600 r0 = add(pc,##236) }98 99#0x7c000000100r1:0=combine(#8,##_start)101# CHECK: 7c9ec100 r1:0 = combine(#8,##131644) }102 103#0x9a000000104r1:0=memb_fifo(r2=##_start)105# CHECK: 9a82df00 r1:0 = memb_fifo(r2=##131644) }106 107#0x9b000000108r0=memb(r1=##_start)109# CHECK: 9b01df00 r0 = memb(r1=##131644) }110 111#0x9c000000112r1:0=memb_fifo(r2<<#2+##_start)113# CHECK: 9c82ff00 r1:0 = memb_fifo(r2<<#2+##131644) }114 115#0x9d000000116r0=memb(r1<<#2+##_start)117# CHECK: 9d01ff00 r0 = memb(r1<<#2+##131644) }118 119#0x9f000000120if (!p0) r0=memb(##_start)121# CHECK: 9f1ee880 if (!p0) r0 = memb(##131644) }122 123#0xab000000124memb(r0=##_start)=r1125# CHECK: ab00c1bc memb(r0=##131644) = r1 }126 127#0xad000000128memb(r0<<#2+##_start)=r1129# CHECK: ad00e1bc memb(r0<<#2+##131644) = r1 }130 131#0xaf000000132if (!p0) memb(##_start)=r1133# CHECK: af03c1e4 if (!p0) memb(##131644) = r1 }134 135#0xd7000000136r0=add(##_start,mpyi(r1,r2))137# CHECK: d761e280 r0 = add(##131644,mpyi(r1,r2)) }138 139#0xd8000000140R0=add(##_start,mpyi(r0,#2))141# CHECK: d860e082 r0 = add(##131644,mpyi(r0,#2)) }142 143#0xdb000000144r0=add(r1,add(r2,##_start))145# CHECK: db61e082 r0 = add(r1,add(r2,##131644)) }146 147#0xdf000000148r0=add(r1,mpyi(r2,##_start))149# CHECK: dfe2e081 r0 = add(r1,mpyi(r2,##131644)) }150 151# Duplex form of R_HEX_6_X152# R_HEX_32_6_X153# R_HEX_6_X154{ r0 = ##_start; r2 = r16 }155# CHECK: 2bc03082 r0 = ##131644; r2 = r16 }156 157# R_HEX_HI16158r0.h = #HI(_start)159# CHECK: r0.h = #2160 161# R_HEX_LO16162r0.l = #LO(_start)163# CHECK: r0.l = #572164 165# R_HEX_8_X has 3 relocation mask variations166#0xde000000167r0=sub(##_start, asl(r0, #1))168# CHECK: de20e1c6 r0 = sub(##131644,asl(r0,#1)) }169 170#0x3c000000171memw(r0+#0) = ##_start172# CHECK: 3c40c03c memw(r0+#0) = ##131644 }173 174# The rest:175r1:0=combine(r2,##_start);176# CHECK: 7302e780 r1:0 = combine(r2,##131644) }177 178# R_HEX_32:179r_hex_32:180.word _start181# CHECK: 0002023c182 183# R_HEX_16_X has 4 relocation mask variations184# 0x48000000185memw(##_start) = r0186# CHECK: 4880c03c memw(##131644) = r0 }187 188# 0x49000000189r0 = memw(##_start)190# CHECK: 4980c780 r0 = memw(##131644)191 192# 0x78000000193r0 = ##_start194# CHECK: 7800c780 r0 = ##131644 }195 196# 0xb0000000197r0 = add(r1, ##_start)198# CHECK: b001c780 r0 = add(r1,##131644) }199 200# R_HEX_B9_PCREL:201{r0=#1 ; jump #_start}202# CHECK: jump 0x2023c203 204# R_HEX_B9_PCREL_X:205{r0=#1 ; jump ##_start}206# CHECK: jump 0x2023c207 208# R_HEX_B13_PCREL209if (r0 == #0) jump:t #_start210# CHECK: if (r0==#0) jump:t 0x2023c211 212# R_HEX_9_X213p0 = !cmp.gtu(r0, ##_start)214# CHECK: p0 = !cmp.gtu(r0,##131644)215 216# R_HEX_10_X217p0 = !cmp.gt(r0, ##_start)218# CHECK: p0 = !cmp.gt(r0,##131644)219 220# R_HEX_11_X221r0 = memw(r1+##_start)222# CHECK: r0 = memw(r1+##131644)223 224memw(r0+##_start) = r1225# CHECK: memw(r0+##131644) = r1226 227 228## Tests for maximum branch ranges reachable without trampolines.229 230.section b_1000000, "ax"231## The nop makes sure the first jump is within range.232nop233{ r0 = #0; jump #b_1000400 } // R_HEX_B9_PCREL234if (r0==#0) jump:t #b_1004000 // R_HEX_B13_PCREL235if (p0) jump #b_1010000 // R_HEX_B15_PCREL236jump #b_1800000 // R_HEX_B22_PCREL237 238.section b_1000400, "ax"239nop240 241.section b_1004000, "ax"242nop243 244.section b_1010000, "ax"245nop246 247.section b_1800000, "ax"248nop249 250## Make sure we got the right relocations.251# RUN: llvm-readelf -r %t.o | FileCheck %s --check-prefix=REL252# REL: R_HEX_B9_PCREL 00000000 b_1000400253# REL: R_HEX_B13_PCREL 00000000 b_1004000254# REL: R_HEX_B15_PCREL 00000000 b_1010000255# REL: R_HEX_B22_PCREL 00000000 b_1800000256 257# CHECK: 01000000 <b_1000000>:258# CHECK-NEXT: 1000000: {{.*}} { nop }259# CHECK-NEXT: 1000004: {{.*}} { r0 = #0 ; jump 0x1000400 }260# CHECK-NEXT: 1000008: {{.*}} { if (r0==#0) jump:t 0x1004000 }261# CHECK-NEXT: 100000c: {{.*}} { if (p0) jump:nt 0x1010000 }262# CHECK-NEXT: 1000010: {{.*}} { jump 0x1800000 }263