File: xqcibi-linker-relaxation.s

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (84 lines) | stat: -rw-r--r-- 2,481 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# RUN: llvm-mc --triple=riscv32 -mattr=+relax,+experimental-xqcilb,+experimental-xqcibi \
# RUN:    %s -filetype=obj -o - -riscv-add-build-attributes \
# RUN:    | llvm-objdump -dr -M no-aliases - \
# RUN:    | FileCheck %s

## This tests that we correctly emit relocations for linker relaxation when
## relaxing `JAL` to `QC.E.JAL`.

## PR150071

.global foo

# CHECK-LABEL: <branch_over_relaxable>:
branch_over_relaxable:
  jal x1, foo
# CHECK: qc.e.jal 0x0 <branch_over_relaxable>
# CHECK-NEXT: R_RISCV_VENDOR QUALCOMM
# CHECK-NEXT: R_RISCV_CUSTOM195 foo
# CHECK-NEXT: R_RISCV_RELAX *ABS*
  bne a0, a1, branch_over_relaxable
# CHECK-NEXT: bne a0, a1, 0x6 <branch_over_relaxable+0x6>
# CHECK-NEXT: R_RISCV_BRANCH branch_over_relaxable
# CHECK-NOT: R_RISCV_RELAX
  qc.e.bnei a0, 0x21, branch_over_relaxable
# CHECK-NEXT: qc.e.bnei a0, 0x21, 0xa <branch_over_relaxable+0xa>
# CHECK-NEXT: R_RISCV_VENDOR QUALCOMM
# CHECK-NEXT: R_RISCV_CUSTOM193 branch_over_relaxable
# CHECK-NOT: R_RISCV_RELAX
  ret
# CHECK-NEXT: c.jr ra

# CHECK-LABEL: <short_jump_over_fixed>:
short_jump_over_fixed:
  nop
# CHECK: c.nop
  j short_jump_over_fixed
# CHECK-NEXT: c.j 0x14 <short_jump_over_fixed+0x2>
# CHECK-NEXT: R_RISCV_RVC_JUMP short_jump_over_fixed
# CHECK-NOT: R_RISCV_RELAX
  ret
# CHECK-NEXT: c.jr ra

# CHECK-LABEL: <short_jump_over_relaxable>:
short_jump_over_relaxable:
  call foo
# CHECK: auipc ra, 0x0
# CHECK-NEXT: R_RISCV_CALL_PLT foo
# CHECK-NEXT: R_RISCV_RELAX *ABS*
# CHECK-NEXT: jalr ra, 0x0(ra) <short_jump_over_relaxable>
  j short_jump_over_relaxable
# CHECK-NEXT: c.j 0x20 <short_jump_over_relaxable+0x8>
# CHECK-NEXT: R_RISCV_RVC_JUMP short_jump_over_relaxable
# CHECK-NOT: R_RISCV_RELAX
  ret
# CHECK-NEXT: c.jr ra

# CHECK-LABEL: <mid_jump_over_fixed>:
mid_jump_over_fixed:
  nop
# CHECK: c.nop
  .space 0x1000
# CHECK-NEXT: ...
  j mid_jump_over_fixed
# CHECK-NEXT: jal zero, 0x1026 <mid_jump_over_fixed+0x1002>
# CHECK-NEXT: R_RISCV_JAL mid_jump_over_fixed
# CHECK-NOT: R_RISCV_RELAX
  ret
# CHECK-NEXT: c.jr ra

# CHECK-LABEL: <mid_jump_over_relaxable>:
mid_jump_over_relaxable:
  call foo
# CHECK: auipc ra, 0x0
# CHECK-NEXT: R_RISCV_CALL_PLT foo
# CHECK-NEXT: R_RISCV_RELAX *ABS*
# CHECK-NEXT: jalr ra, 0x0(ra) <mid_jump_over_relaxable>
  .space 0x1000
# CHECK-NEXT: ...
  j mid_jump_over_relaxable
# CHECK-NEXT: jal zero, 0x2034 <mid_jump_over_relaxable+0x1008>
# CHECK-NEXT: R_RISCV_JAL mid_jump_over_relaxable
# CHECK-NOT: R_RISCV_RELAX
  ret
# CHECK-NEXT: c.jr ra