llvm-project/llvm/test/MC/AMDGPU/elf-lds.s

83 lines
2.1 KiB
ArmAsm
Raw Normal View History

AMDGPU/MC: Add .amdgpu_lds directive Summary: The directive defines a symbol as an group/local memory (LDS) symbol. LDS symbols behave similar to common symbols for the purposes of ELF, using the processor-specific SHN_AMDGPU_LDS as section index. It is the linker and/or runtime loader's job to "instantiate" LDS symbols and resolve relocations that reference them. It is not possible to initialize LDS memory (not even zero-initialize as for .bss). We want to be able to link together objects -- starting with relocatable objects, but possible expanding to shared objects in the future -- that access LDS memory in a flexible way. LDS memory is in an address space that is entirely separate from the address space that contains the program image (code and normal data), so having program segments for it doesn't really make sense. Furthermore, we want to be able to compile multiple kernels in a compilation unit which have disjoint use of LDS memory. In that case, we may want to place LDS symbols differently for different kernels to save memory (LDS memory is very limited and physically private to each kernel invocation), so we can't simply place LDS symbols in a .lds section. Hence this solution where LDS symbols always stay undefined. Change-Id: I08cbc37a7c0c32f53f7b6123aa0afc91dbc1748f Reviewers: arsenm, rampitec, t-tye, b-sumner, jsjodin Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, rupprecht, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61493 llvm-svn: 364296
2019-06-25 19:51:35 +08:00
// RUN: llvm-mc -filetype=obj -triple amdgcn-- -mcpu gfx900 %s -o - | llvm-readobj -t -r | FileCheck %s
.text
.globl test_kernel
.p2align 8
.type test_kernel,@function
test_kernel:
s_mov_b32 s0, lds0@abs32@lo
v_lshl_add_u32 v3, v0, 2, s0
ds_read2_b32 v[1:2], v3 offset1:1
s_mov_b32 s0, lds4@abs32@lo
v_lshl_add_u32 v3, v0, 2, s0
ds_write_b32 v3, v1
s_endpgm
.Lfunc_end:
.size test_kernel, .Lfunc_end-test_kernel
.globl lds0
.amdgpu_lds lds0, 192, 16
.globl lds1
.amdgpu_lds lds1,387,8
; Weird whitespace cases
.globl lds2
.amdgpu_lds lds2, 12
; No alignment or .globl directive, not mentioned anywhere
.amdgpu_lds lds3, 16
; No alignment or .globl directive, size 0, but mentioned in .text
.amdgpu_lds lds4, 0
// CHECK: Relocations [
// CHECK: Section (3) .rel.text {
// CHECK-NEXT: 0x4 R_AMDGPU_ABS32 lds0 0x0
// CHECK-NEXT: 0x1C R_AMDGPU_ABS32 lds4 0x0
// CHECK-NEXT: }
// CHECK: ]
// CHECK: Symbol {
// CHECK: Name: lds0 (54)
// CHECK-NEXT: Value: 0x10
// CHECK-NEXT: Size: 192
// CHECK-NEXT: Binding: Global (0x1)
// CHECK-NEXT: Type: Object (0x1)
// CHECK-NEXT: Other: 0
// CHECK-NEXT: Section: Processor Specific (0xFF00)
// CHECK-NEXT: }
// CHECK: Symbol {
// CHECK: Name: lds1 (49)
// CHECK-NEXT: Value: 0x8
// CHECK-NEXT: Size: 387
// CHECK-NEXT: Binding: Global (0x1)
// CHECK-NEXT: Type: Object (0x1)
// CHECK-NEXT: Other: 0
// CHECK-NEXT: Section: Processor Specific (0xFF00)
// CHECK-NEXT: }
// CHECK: Symbol {
// CHECK: Name: lds2 (44)
// CHECK-NEXT: Value: 0x4
// CHECK-NEXT: Size: 12
// CHECK-NEXT: Binding: Global (0x1)
// CHECK-NEXT: Type: Object (0x1)
// CHECK-NEXT: Other: 0
// CHECK-NEXT: Section: Processor Specific (0xFF00)
// CHECK-NEXT: }
// CHECK-NOT: Name: lds3
// CHECK: Symbol {
// CHECK: Name: lds4 (39)
// CHECK-NEXT: Value: 0x4
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Global (0x1)
// CHECK-NEXT: Type: Object (0x1)
// CHECK-NEXT: Other: 0
// CHECK-NEXT: Section: Processor Specific (0xFF00)
// CHECK-NEXT: }