243 lines · plain
1# REQUIRES: asserts2# RUN: llvm-mc -triple=riscv32 -mattr=+relax,+c -filetype=obj -o %t.rv32 %s3# RUN: llvm-jitlink -num-threads=0 -debug-only=jitlink -noexec \4# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \5# RUN: -check %s %t.rv32 2>&1 \6# RUN: | FileCheck %s7# RUN: llvm-jitlink -num-threads=0 -debug-only=jitlink -noexec \8# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \9# RUN: -check %s -check-name=jitlink-check-rv32 %t.rv32 2>&1 \10# RUN: | FileCheck -check-prefix=CHECK-RV32 %s11 12# RUN: llvm-mc -triple=riscv64 -mattr=+relax,+c -filetype=obj -o %t.rv64 %s13# RUN: llvm-jitlink -num-threads=0 -debug-only=jitlink -noexec \14# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \15# RUN: -check %s %t.rv64 2>&1 \16# RUN: | FileCheck %s17# RUN: llvm-jitlink -num-threads=0 -debug-only=jitlink -noexec \18# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \19# RUN: -check %s -check-name=jitlink-check-rv64 %t.rv64 2>&1 \20# RUN: | FileCheck -check-prefix=CHECK-RV64 %s21 22# RUN: llvm-mc -triple=riscv32 -mattr=+relax,+zca -filetype=obj -o %t.rv32zca %s23# RUN: llvm-jitlink -num-threads=0 -debug-only=jitlink -noexec \24# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \25# RUN: -check %s %t.rv32zca 2>&1 \26# RUN: | FileCheck %s27# RUN: llvm-jitlink -num-threads=0 -debug-only=jitlink -noexec \28# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \29# RUN: -check %s -check-name=jitlink-check-rv32 %t.rv32zca 2>&1 \30# RUN: | FileCheck -check-prefix=CHECK-RV32 %s31 32# RUN: llvm-mc -triple=riscv64 -mattr=+relax,+c -filetype=obj -o %t.rv64 %s33# RUN: llvm-jitlink -num-threads=0 -debug-only=jitlink -noexec \34# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \35# RUN: -check %s %t.rv64 2>&1 \36# RUN: | FileCheck %s37# RUN: llvm-jitlink -num-threads=0 -debug-only=jitlink -noexec \38# RUN: -slab-allocate 100Kb -slab-address 0x1000 -slab-page-size 4096 \39# RUN: -check %s -check-name=jitlink-check-rv64 %t.rv64 2>&1 \40# RUN: | FileCheck -check-prefix=CHECK-RV64 %s41 42 .text43 44## Successful relaxation: call -> jal45 .globl main46 .type main,@function47main:48 call f # rv64+c: jal (size 4)49 .size main, .-main50 51 .skip (1 << 20) - (. - main) - 252 53 .globl f54 .type f,@function55f:56 call main57 .size f, .-f58 59## Failed relaxation: call -> auipc, jalr60 .globl g61g:62 call h63 .size g, .-g64 65 .skip (1 << 20) - (. - g) + 266 67 .globl h68 .type h,@function69h:70 call g71 .size h, .-h72 73## Successful relaxation: jump -> c.j74 .globl i75 .type i,@function76i:77 jump j, t078 .size i, .-i79 80 .skip (1 << 11) - (. - i) - 281 82 .globl j83 .type j,@function84j:85 jump i, t186 .size j, .-j87 88## Successful relaxation: jump -> jal89 .globl k90 .type k,@function91k:92 jump l, t293 .size k, .-k94 95 .skip (1 << 20) - (. - k) - 296 97 .globl l98 .type l,@function99l:100 jump k, t3101 .size l, .-l102 103## Failed relaxation: jump -> auipc, jalr104 .globl m105 .type m,@function106m:107 jump n, t2108 .size m, .-m109 110 .skip (1 << 20) - (. - m) + 2111 112 .globl n113 .type n,@function114n:115 jump m, t3116 .size n, .-n117 118## RV32: Successful relaxation: call -> c.jal119## RV64: Successful relaxation: call -> jal120 .globl o121 .type o,@function122o:123 call p124 .size o, .-o125 126 .skip (1 << 11) - (. - o) - 2127 128 .globl p129 .type p,@function130p:131 call o132 .size p, .-p133 134# CHECK: Link graph before copy-and-fixup:135# CHECK: section .text:136# CHECK: block 0x1000137# CHECK: symbols:138# CHECK: {{.*}} (block + 0x00000000): size: 0x00000004, linkage: strong, scope: default, live - main139# CHECK: {{.*}} (block + 0x000ffffa): size: 0x00000004, linkage: strong, scope: default, live - f140# CHECK: {{.*}} (block + 0x000ffffe): size: 0x00000008, linkage: strong, scope: default, live - g141# CHECK: {{.*}} (block + 0x00200000): size: 0x00000008, linkage: strong, scope: default, live - h142# CHECK: {{.*}} (block + 0x00200008): size: 0x00000002, linkage: strong, scope: default, live - i143# CHECK: {{.*}} (block + 0x00200800): size: 0x00000002, linkage: strong, scope: default, live - j144# CHECK: {{.*}} (block + 0x00200802): size: 0x00000004, linkage: strong, scope: default, live - k145# CHECK: {{.*}} (block + 0x003007fc): size: 0x00000004, linkage: strong, scope: default, live - l146# CHECK: {{.*}} (block + 0x00300800): size: 0x00000008, linkage: strong, scope: default, live - m147# CHECK: {{.*}} (block + 0x00400802): size: 0x00000008, linkage: strong, scope: default, live - n148# CHECK-RV32: {{.*}} (block + 0x0040080a): size: 0x00000002, linkage: strong, scope: default, live - o149# CHECK-RV64: {{.*}} (block + 0x0040080a): size: 0x00000004, linkage: strong, scope: default, live - o150# CHECK-RV32: {{.*}} (block + 0x00401002): size: 0x00000002, linkage: strong, scope: default, live - p151# CHECK-RV64: {{.*}} (block + 0x00401004): size: 0x00000004, linkage: strong, scope: default, live - p152# CHECK: edges:153# CHECK: {{.*}} (block + 0x00000000), addend = +0x00000000, kind = R_RISCV_JAL, target = f154# CHECK: {{.*}} (block + 0x000ffffa), addend = +0x00000000, kind = R_RISCV_JAL, target = main155# CHECK: {{.*}} (block + 0x000ffffe), addend = +0x00000000, kind = R_RISCV_CALL_PLT, target = h156# CHECK: {{.*}} (block + 0x00200000), addend = +0x00000000, kind = R_RISCV_CALL_PLT, target = g157# CHECK: {{.*}} (block + 0x00200008), addend = +0x00000000, kind = R_RISCV_RVC_JUMP, target = j158# CHECK: {{.*}} (block + 0x00200800), addend = +0x00000000, kind = R_RISCV_RVC_JUMP, target = i159# CHECK: {{.*}} (block + 0x00200802), addend = +0x00000000, kind = R_RISCV_JAL, target = l160# CHECK: {{.*}} (block + 0x003007fc), addend = +0x00000000, kind = R_RISCV_JAL, target = k161# CHECK: {{.*}} (block + 0x00300800), addend = +0x00000000, kind = R_RISCV_CALL_PLT, target = n162# CHECK: {{.*}} (block + 0x00400802), addend = +0x00000000, kind = R_RISCV_CALL_PLT, target = m163# CHECK-RV32: {{.*}} (block + 0x0040080a), addend = +0x00000000, kind = R_RISCV_RVC_JUMP, target = p164# CHECK-RV64: {{.*}} (block + 0x0040080a), addend = +0x00000000, kind = R_RISCV_JAL, target = p165# CHECK-RV32: {{.*}} (block + 0x00401002), addend = +0x00000000, kind = R_RISCV_RVC_JUMP, target = o166# CHECK-RV64: {{.*}} (block + 0x00401004), addend = +0x00000000, kind = R_RISCV_JAL, target = o167 168## main: jal f169# jitlink-check: (*{4}(main))[11:0] = 0xef170# jitlink-check: decode_operand(main, 1) = (f - main)171 172## f: jal main173# jitlink-check: (*{4}(f))[11:0] = 0xef174# jitlink-check: decode_operand(f, 1) = (main - f)175 176## g:177## - auipc ra, %pcrel_hi(h)178# jitlink-check: (*{4}(g))[11:0] = 0x97179# jitlink-check: decode_operand(g, 1) = (h - g + 0x800)[31:12]180## - jalr ra, %pcrel_lo(g)181# jitlink-check: (*{4}(g+4))[19:0] = 0x80e7182# jitlink-check: decode_operand(g+4, 2)[11:0] = (h - g)[11:0]183 184## h:185## - auipc ra, %pcrel_hi(g)186# jitlink-check: (*{4}(h))[11:0] = 0x97187# jitlink-check: decode_operand(h, 1) = (g - h + 0x800)[31:12]188## - jalr ra, %pcrel_lo(h)189# jitlink-check: (*{4}(h+4))[19:0] = 0x80e7190# jitlink-check: decode_operand(h+4, 2)[11:0] = (g - h)[11:0]191 192## i: c.j j193# jitlink-check: (*{2}(i))[1:0] = 0x1194# jitlink-check: (*{2}(i))[15:13] = 0x5195# jitlink-check: decode_operand(i, 0)[11:0] = (j - i)[11:0]196 197## j: c.j i198# jitlink-check: (*{2}(j))[1:0] = 0x1199# jitlink-check: (*{2}(j))[15:13] = 0x5200# jitlink-check: decode_operand(j, 0)[11:0] = (i - j)[11:0]201 202## k: jal x0, l203# jitlink-check: (*{4}(k))[11:0] = 0x6f204# jitlink-check: decode_operand(k, 1) = (l - k)205 206## l: jal x0, k207# jitlink-check: (*{4}(l))[11:0] = 0x6f208# jitlink-check: decode_operand(l, 1) = (k - l)209 210## m:211## - auipc t2, %pcrel_hi(n)212# jitlink-check: (*{4}(m))[11:0] = 0x397213# jitlink-check: decode_operand(m, 1) = (n - m + 0x800)[31:12]214## - jalr t2, %pcrel_lo(m)215# jitlink-check: (*{4}(m+4))[19:0] = 0x38067216# jitlink-check: decode_operand(m+4, 2)[11:0] = (n - m)[11:0]217 218## n:219## - auipc t3, %pcrel_hi(m)220# jitlink-check: (*{4}(n))[11:0] = 0xe17221# jitlink-check: decode_operand(n, 1) = (m - n + 0x800)[31:12]222## - jalr t3, %pcrel_lo(n)223# jitlink-check: (*{4}(n+4))[19:0] = 0xe0067224# jitlink-check: decode_operand(n+4, 2)[11:0] = (m - n)[11:0]225 226## RV32: o: c.jal p227# jitlink-check-rv32: (*{2}(o))[1:0] = 0x1228# jitlink-check-rv32: (*{2}(o))[15:13] = 0x1229# jitlink-check-rv32: decode_operand(o, 0) = (p - o)230 231## RV64: o: jal p232# jitlink-check-rv64: (*{4}(o))[11:0] = 0xef233# jitlink-check-rv64: decode_operand(o, 1) = (p - o)234 235## RV32: p: c.jal o236# jitlink-check-rv32: (*{2}(p))[1:0] = 0x1237# jitlink-check-rv32: (*{2}(p))[15:13] = 0x1238# jitlink-check-rv32: decode_operand(p, 0) = (o - p)239 240## RV64: p: jal o241# jitlink-check-rv64: (*{4}(p))[11:0] = 0xef242# jitlink-check-rv64: decode_operand(p, 1) = (o - p)243