[llvm] [RISCV] Vendor Relocations for Xqci extension (PR #135400)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed May 28 08:57:17 PDT 2025


================
@@ -1,46 +1,92 @@
-# RUN: llvm-mc -triple riscv32 -mattr=+experimental-xqcilb %s -show-encoding \
-# RUN:     | FileCheck -check-prefix=INSTR %s
-# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcilb %s -o %t.o
-# RUN: llvm-readobj -r %t.o | FileCheck -check-prefix=RELOC %s
+# RUN: llvm-mc -triple riscv32 -mattr=+experimental-xqcilb %s \
+# RUN:     | FileCheck -check-prefix=ASM %s
+# RUN: llvm-mc -triple riscv32 -mattr=+experimental-xqcilb %s \
+# RUN:     -filetype=obj -o - \
+# RUN:     | llvm-objdump -dr --mattr=+experimental-xqcilb - \
+# RUN:     | FileCheck -check-prefix=OBJ %s
 
-# Check prefixes:
-# RELOC - Check the relocation in the object.
-# INSTR - Check the instruction is handled properly by the ASMPrinter.
-
-.text
+## This test checks that we emit the right relocations for Xqcilb
+## relative jumps. These can be resolved within the same section
+## (when relaxations are disabled) but otherwise require a
+## vendor-specific relocation pair.
 
+# This is required so that the conditional jumps are not compressed
+# by the assembler
 .option exact
 
-qc.e.j foo
-# RELOC: R_RISCV_CUSTOM195 foo 0x0
-# INSTR: qc.e.j foo
+# ASM-LABEL: this_section:
+# OBJ-LABEL: <this_section>:
+this_section:
+
+# ASM: qc.e.j undef
+# OBJ: qc.e.j 0x0
+# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
+# OBJ-NEXT: R_RISCV_CUSTOM195 undef{{$}}
+# OBJ-NOT: R_RISCV
+qc.e.j undef
+
+# ASM: qc.e.jal undef
+# OBJ: qc.e.jal 0x6
+# OBJ-NEXT: R_RISCV_VENDOR QUALCOMM{{$}}
+# OBJ-NEXT: R_RISCV_CUSTOM195 undef{{$}}
+# OBJ-NOT: R_RISCV
+qc.e.jal undef
+
+
+# ASM: qc.e.j same_section
+# OBJ: qc.e.j 0x30
+# OBJ-NOT: R_RISCV
+qc.e.j same_section
+
+# ASM: qc.e.jal same_section
+# OBJ: qc.e.jal 0x30
----------------
MaskRay wrote:

If we use OBJ-NEXT:, OBJ-NOT: R_RISCV will not be needed

https://github.com/llvm/llvm-project/pull/135400


More information about the llvm-commits mailing list