[llvm] b975487 - Sparc: Reorganize relocation and ELF tests
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun May 4 21:07:58 PDT 2025
Author: Fangrui Song
Date: 2025-05-04T21:07:53-07:00
New Revision: b975487ce98ff68989dc626feba21b95bfffe8db
URL: https://github.com/llvm/llvm-project/commit/b975487ce98ff68989dc626feba21b95bfffe8db
DIFF: https://github.com/llvm/llvm-project/commit/b975487ce98ff68989dc626feba21b95bfffe8db.diff
LOG: Sparc: Reorganize relocation and ELF tests
Following the subdirectory schemes of newer ports (LoongArch, M68k).
Added:
llvm/test/MC/Sparc/Directives/data.s
llvm/test/MC/Sparc/Misc/elf-feature.s
llvm/test/MC/Sparc/Misc/elf-machine-type.s
llvm/test/MC/Sparc/Misc/little-endian.s
llvm/test/MC/Sparc/Relocations/expr.s
llvm/test/MC/Sparc/Relocations/reloc-directive.s
llvm/test/MC/Sparc/Relocations/relocation-specifier-pic.s
llvm/test/MC/Sparc/Relocations/relocation-specifier.s
llvm/test/MC/Sparc/Relocations/relocation.s
Modified:
Removed:
llvm/test/MC/Sparc/elf-sparc-feature.s
llvm/test/MC/Sparc/elf-sparc-machine-type.s
llvm/test/MC/Sparc/reloc-directive.s
llvm/test/MC/Sparc/relocation-specifier.s
llvm/test/MC/Sparc/sparc-assembly-exprs.s
llvm/test/MC/Sparc/sparc-directives.s
llvm/test/MC/Sparc/sparc-fixups.s
llvm/test/MC/Sparc/sparc-little-endian.s
llvm/test/MC/Sparc/sparc-pic.s
llvm/test/MC/Sparc/sparc-relocations.s
################################################################################
diff --git a/llvm/test/MC/Sparc/sparc-directives.s b/llvm/test/MC/Sparc/Directives/data.s
similarity index 100%
rename from llvm/test/MC/Sparc/sparc-directives.s
rename to llvm/test/MC/Sparc/Directives/data.s
diff --git a/llvm/test/MC/Sparc/elf-sparc-feature.s b/llvm/test/MC/Sparc/Misc/elf-feature.s
similarity index 100%
rename from llvm/test/MC/Sparc/elf-sparc-feature.s
rename to llvm/test/MC/Sparc/Misc/elf-feature.s
diff --git a/llvm/test/MC/Sparc/elf-sparc-machine-type.s b/llvm/test/MC/Sparc/Misc/elf-machine-type.s
similarity index 100%
rename from llvm/test/MC/Sparc/elf-sparc-machine-type.s
rename to llvm/test/MC/Sparc/Misc/elf-machine-type.s
diff --git a/llvm/test/MC/Sparc/sparc-little-endian.s b/llvm/test/MC/Sparc/Misc/little-endian.s
similarity index 100%
rename from llvm/test/MC/Sparc/sparc-little-endian.s
rename to llvm/test/MC/Sparc/Misc/little-endian.s
diff --git a/llvm/test/MC/Sparc/sparc-assembly-exprs.s b/llvm/test/MC/Sparc/Relocations/expr.s
similarity index 100%
rename from llvm/test/MC/Sparc/sparc-assembly-exprs.s
rename to llvm/test/MC/Sparc/Relocations/expr.s
diff --git a/llvm/test/MC/Sparc/reloc-directive.s b/llvm/test/MC/Sparc/Relocations/reloc-directive.s
similarity index 100%
rename from llvm/test/MC/Sparc/reloc-directive.s
rename to llvm/test/MC/Sparc/Relocations/reloc-directive.s
diff --git a/llvm/test/MC/Sparc/sparc-pic.s b/llvm/test/MC/Sparc/Relocations/relocation-specifier-pic.s
similarity index 97%
rename from llvm/test/MC/Sparc/sparc-pic.s
rename to llvm/test/MC/Sparc/Relocations/relocation-specifier-pic.s
index 49aadd0a764d4..1118dc1fea83c 100644
--- a/llvm/test/MC/Sparc/sparc-pic.s
+++ b/llvm/test/MC/Sparc/Relocations/relocation-specifier-pic.s
@@ -1,7 +1,7 @@
+## Test relocation specifiers with
diff erent behaviors with non-PIC and PIC.
! RUN: llvm-mc %s -triple=sparcv9 --position-independent -filetype=obj | llvm-readobj -r - | FileCheck --check-prefix=PIC %s
! RUN: llvm-mc %s -triple=sparcv9 -filetype=obj | llvm-readobj -r - | FileCheck --check-prefix=NOPIC %s
-
! PIC: .rela.text {
! PIC-NEXT: 0x{{[0-9,A-F]+}} R_SPARC_PC22 _GLOBAL_OFFSET_TABLE_ 0x4
! PIC-NEXT: 0x{{[0-9,A-F]+}} R_SPARC_PC10 _GLOBAL_OFFSET_TABLE_ 0x8
diff --git a/llvm/test/MC/Sparc/relocation-specifier.s b/llvm/test/MC/Sparc/Relocations/relocation-specifier.s
similarity index 87%
rename from llvm/test/MC/Sparc/relocation-specifier.s
rename to llvm/test/MC/Sparc/Relocations/relocation-specifier.s
index 8f74b5c4cf10c..b5da46904c650 100644
--- a/llvm/test/MC/Sparc/relocation-specifier.s
+++ b/llvm/test/MC/Sparc/Relocations/relocation-specifier.s
@@ -88,6 +88,41 @@ sethi %gdop_hix22(sym), %l1
or %l1, %gdop_lox10(sym), %l1
ldx [%l7 + %l1], %l2, %gdop(sym)
+.set abs, 0xfedcba98
+
+## FIXME: Don't emit GOT relocations when -position-independent is specified.
+# NOPIC: sethi 0x3fb72e, %o0
+# NOPIC-NEXT: xor %o0, 0x298, %o0
+# NOPIC-NEXT: sethi 0x3b72ea, %o1
+# NOPIC-NEXT: xor %o0, 0x188, %o1
+sethi %hi(abs), %o0
+xor %o0, %lo(abs), %o0
+sethi %hi(-0x12345678), %o1
+xor %o0, %lo(-0x12345678), %o1
+
+# OBJDUMP: ld [%o0+0x7], %o0
+ld [%o0 + seven], %o0
+seven = 7
+
+# OBJDUMP: sethi 0x3fb, %o0
+# OBJDUMP-NEXT: or %o0, 0x1cb, %o0
+# OBJDUMP-NEXT: ld [%o0+0xa98], %o0
+sethi %h44(abs), %o0
+or %o0, %m44(abs), %o0
+ld [%o0 + %l44(abs)], %o0
+
+# OBJDUMP-NEXT: sethi 0x0, %o0
+# OBJDUMP-NEXT: sethi 0x3fb72e, %o0
+# OBJDUMP-NEXT: or %o0, 0x0, %o0
+sethi %hh(abs), %o0
+sethi %lm(abs), %o0
+or %o0, %hm(abs), %o0
+
+# OBJDUMP-NEXT: sethi 0x48d1, %o0
+# OBJDUMP-NEXT: xor %o0, -0x168, %o0
+sethi %hix(abs), %o0
+xor %o0, %lox(abs), %o0
+
# OBJDUMP-LABEL: <.tls>:
.section .tls,"ax"
## Local Executable model:
diff --git a/llvm/test/MC/Sparc/Relocations/relocation.s b/llvm/test/MC/Sparc/Relocations/relocation.s
new file mode 100644
index 0000000000000..aa24198f2cf5b
--- /dev/null
+++ b/llvm/test/MC/Sparc/Relocations/relocation.s
@@ -0,0 +1,38 @@
+## Test relocations without specifiers. See also relocation-specifier.s for relocations with specifiers.
+# RUN: llvm-mc %s -triple=sparcv9 | FileCheck %s --check-prefix=ASM
+# RUN: llvm-mc %s -triple=sparcv9 -filetype=obj -o %t
+# RUN: llvm-objdump -dr %t | FileCheck %s --check-prefix=OBJDUMP
+
+# ASM: call local
+# ASM: call local1
+# ASM-NEXT: call undef
+# OBJDUMP: call 0x14
+# OBJDUMP-NEXT: call 0x0
+# OBJDUMP-NEXT: R_SPARC_WDISP30 .text1+0x4
+# OBJDUMP-NEXT: call 0x0
+# OBJDUMP-NEXT: R_SPARC_WDISP30 undef{{$}}
+call local
+call local1
+call undef
+
+# ASM: or %g1, sym, %g3
+# ASM-NEXT: or %g1, sym+4, %g3
+# OBJDUMP: or %g1, 0x0, %g3
+# OBJDUMP-NEXT: 0000000c: R_SPARC_13 sym{{$}}
+# OBJDUMP-NEXT: or %g1, 0x0, %g3
+# OBJDUMP-NEXT: 00000010: R_SPARC_13 sym+0x4
+or %g1, sym, %g3
+or %g1, (sym+4), %g3
+
+local:
+
+.section .text1,"ax"
+nop
+local1:
+
+.data
+# This test needs to placed last in the file
+# ASM: .half a-.Ltmp0
+.half a - .
+.byte a - .
+a:
diff --git a/llvm/test/MC/Sparc/sparc-fixups.s b/llvm/test/MC/Sparc/sparc-fixups.s
deleted file mode 100644
index e77f56e24cad3..0000000000000
--- a/llvm/test/MC/Sparc/sparc-fixups.s
+++ /dev/null
@@ -1,40 +0,0 @@
-# RUN: llvm-mc %s -triple=sparcv9 -filetype=obj | llvm-objdump -dr - | FileCheck %s --check-prefixes=NOPIC,CHECK
-# RUN: llvm-mc %s -triple=sparcv9 -filetype=obj -position-independent | llvm-objdump -dr - | FileCheck %s
-.text
-
-# Check that fixups are correctly applied.
-
-.set sym, 0xfedcba98
-
-## FIXME: Don't emit GOT relocations when -position-independent is specified.
-# NOPIC: sethi 0x3fb72e, %o0
-# NOPIC-NEXT: xor %o0, 0x298, %o0
-# NOPIC-NEXT: sethi 0x3b72ea, %o1
-# NOPIC-NEXT: xor %o0, 0x188, %o1
-sethi %hi(sym), %o0
-xor %o0, %lo(sym), %o0
-sethi %hi(-0x12345678), %o1
-xor %o0, %lo(-0x12345678), %o1
-
-# CHECK: ld [%i0+0x7], %o0
-ld [%i0 + abs], %o0
-abs = 7
-
-# CHECK-NEXT: sethi 0x3fb, %o0
-# CHECK-NEXT: or %o0, 0x1cb, %o0
-# CHECK-NEXT: ld [%o0+0xa98], %o0
-sethi %h44(sym), %o0
-or %o0, %m44(sym), %o0
-ld [%o0 + %l44(sym)], %o0
-
-# CHECK-NEXT: sethi 0x0, %o0
-# CHECK-NEXT: sethi 0x3fb72e, %o0
-# CHECK-NEXT: or %o0, 0x0, %o0
-sethi %hh(sym), %o0
-sethi %lm(sym), %o0
-or %o0, %hm(sym), %o0
-
-# CHECK-NEXT: sethi 0x48d1, %o0
-# CHECK-NEXT: xor %o0, -0x168, %o0
-sethi %hix(sym), %o0
-xor %o0, %lox(sym), %o0
diff --git a/llvm/test/MC/Sparc/sparc-relocations.s b/llvm/test/MC/Sparc/sparc-relocations.s
deleted file mode 100644
index 3510eaabc0250..0000000000000
--- a/llvm/test/MC/Sparc/sparc-relocations.s
+++ /dev/null
@@ -1,25 +0,0 @@
-! RUN: llvm-mc %s -triple=sparcv9 | FileCheck %s
-! RUN: llvm-mc %s -triple=sparcv9 -filetype=obj | llvm-readobj -r - | FileCheck %s --check-prefix=CHECK-OBJ
-
- ! CHECK-OBJ: Format: elf64-sparc
- ! CHECK-OBJ: .rela.text {
- ! CHECK-OBJ-NEXT: 0x{{[0-9,A-F]+}} R_SPARC_WDISP30 foo
- ! CHECK-OBJ-NEXT: 0x{{[0-9,A-F]+}} R_SPARC_13 sym
- ! CHECK-OBJ-NEXT: 0x{{[0-9,A-F]+}} R_SPARC_13 sym
- ! CHECK-OBJ-NEXT: }
-
- call a
- ! CHECK: call foo
- call foo
-
- ! CHECK: or %g1, sym, %g3
- or %g1, sym, %g3
-
- ! CHECK: or %g1, sym+4, %g3
- or %g1, (sym+4), %g3
-
- ! This test needs to placed last in the file
- ! CHECK: .half a-.Ltmp0
- .half a - .
- .byte a - .
-a:
More information about the llvm-commits
mailing list