|
1 | | -# RUN: llvm-mc -triple riscv32 -mattr=+experimental-xqcibi %s -show-encoding \ |
2 | | -# RUN: | FileCheck -check-prefix=INSTR %s |
3 | | -# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcibi %s -o %t.o |
4 | | -# RUN: llvm-readobj -r %t.o | FileCheck -check-prefix=RELOC %s |
| 1 | +# RUN: llvm-mc -triple riscv32 -mattr=+experimental-xqcibi %s \ |
| 2 | +# RUN: | FileCheck -check-prefix=ASM %s |
| 3 | +# RUN: llvm-mc -triple riscv32 -mattr=+experimental-xqcibi %s \ |
| 4 | +# RUN: -filetype=obj -o - \ |
| 5 | +# RUN: | llvm-objdump -dr --mattr=+experimental-xqcibi - \ |
| 6 | +# RUN: | FileCheck -check-prefix=OBJ %s |
5 | 7 |
|
6 | | -# Check prefixes: |
7 | | -# RELOC - Check the relocation in the object. |
8 | | -# INSTR - Check the instruction is handled properly by the ASMPrinter. |
| 8 | +## This test checks that we emit the right relocations for Xqcibi |
| 9 | +## relative branches. These can be resolved within the same section |
| 10 | +## (when relaxations are disabled) but otherwise require a relocation. |
| 11 | +## The QC.E.B<op>I instructions also require a vendor relocation. |
9 | 12 |
|
10 | | -.text |
| 13 | +# This is required so that the conditional branches requiring relocations |
| 14 | +# are not converted into inverted branches with long jumps by the assembler. |
| 15 | +.option exact |
11 | 16 |
|
12 | | -# Since foo is undefined, this will be relaxed to (qc.beqi + jal) |
13 | | -qc.bnei x6, 10, foo |
14 | | -# RELOC: R_RISCV_JAL foo 0x0 |
15 | | -# INSTR: qc.bnei t1, 10, foo |
| 17 | +# ASM-LABEL: this_section: |
| 18 | +# OBJ-LABEL: <this_section>: |
| 19 | +this_section: |
16 | 20 |
|
17 | | -# Since foo is undefined, this will be relaxed to (qc.e.bltui + jal) |
18 | | -qc.e.bgeui x8, 12, foo |
19 | | -# RELOC: R_RISCV_JAL foo 0x0 |
20 | | -# INSTR: qc.e.bgeui s0, 12, foo |
| 21 | +# ASM: qc.bnei t1, 10, undef |
| 22 | +# OBJ: qc.bnei t1, 0xa, 0x0 <this_section> |
| 23 | +# OBJ-NEXT: R_RISCV_BRANCH undef{{$}} |
| 24 | +qc.bnei t1, 10, undef |
21 | 25 |
|
22 | | -# Check that a label in a different section is handled similar to an undefined |
23 | | -# symbol and gets relaxed to (qc.e.bgeui + jal) |
24 | | -qc.e.bltui x4, 9, .bar |
25 | | -# RELOC: R_RISCV_JAL .bar 0x0 |
26 | | -# INSTR: qc.e.bltui tp, 9, .bar |
| 26 | +# ASM: qc.e.bgeui s0, 20, undef |
| 27 | +# OBJ-NEXT: qc.e.bgeui s0, 0x14, 0x4 <this_section+0x4> |
| 28 | +# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}} |
| 29 | +# OBJ-NEXT: R_RISCV_CUSTOM193 undef{{$}} |
| 30 | +qc.e.bgeui s0, 20, undef |
27 | 31 |
|
28 | | -# Check that branches to a defined symbol are handled correctly |
29 | | -qc.e.beqi x7, 8, .L1 |
30 | | -# INSTR: qc.e.beqi t2, 8, .L1 |
31 | 32 |
|
32 | | -.L1: |
33 | | - ret |
| 33 | +# ASM: qc.bnei t2, 11, same_section |
| 34 | +# OBJ-NEXT: qc.bnei t2, 0xb, 0x28 <same_section> |
| 35 | +qc.bnei t2, 11, same_section |
34 | 36 |
|
35 | | -.section .t2 |
| 37 | +# ASM: qc.e.bgeui s1, 21, same_section |
| 38 | +# OBJ-NEXT: qc.e.bgeui s1, 0x15, 0x28 <same_section> |
| 39 | +qc.e.bgeui s1, 21, same_section |
36 | 40 |
|
37 | | -.bar: |
38 | | - ret |
| 41 | + |
| 42 | +# ASM: qc.bnei t2, 12, same_section_extern |
| 43 | +# OBJ-NEXT: qc.bnei t2, 0xc, 0x14 <this_section+0x14> |
| 44 | +# OBJ-NEXT: R_RISCV_BRANCH same_section_extern{{$}} |
| 45 | +qc.bnei t2, 12, same_section_extern |
| 46 | + |
| 47 | +# ASM: qc.e.bgeui s1, 22, same_section_extern |
| 48 | +# OBJ-NEXT: qc.e.bgeui s1, 0x16, 0x18 <this_section+0x18> |
| 49 | +# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}} |
| 50 | +# OBJ-NEXT: R_RISCV_CUSTOM193 same_section_extern{{$}} |
| 51 | +qc.e.bgeui s1, 22, same_section_extern |
| 52 | + |
| 53 | + |
| 54 | +# ASM: qc.bnei t3, 13, other_section |
| 55 | +# OBJ-NEXT: qc.bnei t3, 0xd, 0x1e <this_section+0x1e> |
| 56 | +# OBJ-NEXT: R_RISCV_BRANCH other_section{{$}} |
| 57 | +qc.bnei t3, 13, other_section |
| 58 | + |
| 59 | +# ASM: qc.e.bgeui s2, 23, other_section |
| 60 | +# OBJ-NEXT: qc.e.bgeui s2, 0x17, 0x22 <this_section+0x22> |
| 61 | +# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}} |
| 62 | +# OBJ-NEXT: R_RISCV_CUSTOM193 other_section{{$}} |
| 63 | +qc.e.bgeui s2, 23, other_section |
| 64 | + |
| 65 | + |
| 66 | +# ASM-LABEL: same_section: |
| 67 | +# OBJ-LABEL: <same_section>: |
| 68 | +same_section: |
| 69 | + nop |
| 70 | + |
| 71 | +# ASM-LABEL: same_section_extern: |
| 72 | +# OBJ-LABEL: <same_section_extern>: |
| 73 | + .global same_section_extern |
| 74 | +same_section_extern: |
| 75 | + nop |
| 76 | + |
| 77 | + |
| 78 | +.section .text.second, "ax", @progbits |
| 79 | + |
| 80 | +# ASM-LABEL: other_section: |
| 81 | +# OBJ-LABEL: <other_section>: |
| 82 | +other_section: |
| 83 | + nop |
0 commit comments