Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AMDGPU] Emit constant address space data in .rodata section and use …
…relocations instead of fixups (amdhsa only) Differential Revision: https://reviews.llvm.org/D25693 llvm-svn: 284759
- Loading branch information
Showing
8 changed files
with
94 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,54 @@ | ||
; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=NOHSA %s | ||
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=kaveri -verify-machineinstrs < %s | FileCheck -check-prefix=GCN -check-prefix=HSA %s | ||
|
||
@readonly = private unnamed_addr addrspace(2) constant [4 x float] [float 0.0, float 1.0, float 2.0, float 3.0] | ||
@readonly2 = private unnamed_addr addrspace(2) constant [4 x float] [float 4.0, float 5.0, float 6.0, float 7.0] | ||
@private1 = private unnamed_addr addrspace(2) constant [4 x float] [float 0.0, float 1.0, float 2.0, float 3.0] | ||
@private2 = private unnamed_addr addrspace(2) constant [4 x float] [float 4.0, float 5.0, float 6.0, float 7.0] | ||
@available_externally = available_externally addrspace(2) global [256 x i32] zeroinitializer | ||
|
||
; GCN-LABEL: {{^}}main: | ||
; GCN-LABEL: {{^}}private_test: | ||
; GCN: s_getpc_b64 s{{\[}}[[PC0_LO:[0-9]+]]:[[PC0_HI:[0-9]+]]{{\]}} | ||
; GCN-NEXT: s_add_u32 s{{[0-9]+}}, s[[PC0_LO]], readonly | ||
; GCN: s_addc_u32 s{{[0-9]+}}, s[[PC0_HI]], 0 | ||
|
||
; Non-HSA OSes use fixup into .text section. | ||
; NOHSA: s_add_u32 s{{[0-9]+}}, s[[PC0_LO]], private1 | ||
; NOHSA: s_addc_u32 s{{[0-9]+}}, s[[PC0_HI]], 0 | ||
|
||
; HSA OSes use relocations. | ||
; HSA: s_add_u32 s{{[0-9]+}}, s[[PC0_LO]], private1@rel32@lo+4 | ||
; HSA: s_addc_u32 s{{[0-9]+}}, s[[PC0_HI]], private1@rel32@hi+4 | ||
|
||
; GCN: s_getpc_b64 s{{\[}}[[PC1_LO:[0-9]+]]:[[PC1_HI:[0-9]+]]{{\]}} | ||
; GCN-NEXT: s_add_u32 s{{[0-9]+}}, s[[PC1_LO]], readonly | ||
; GCN: s_addc_u32 s{{[0-9]+}}, s[[PC1_HI]], 0 | ||
; NOHSA: .text | ||
; HSA: .text | ||
; GCN: readonly: | ||
; GCN: readonly2: | ||
define void @main(i32 %index, float addrspace(1)* %out) { | ||
%ptr = getelementptr [4 x float], [4 x float] addrspace(2) * @readonly, i32 0, i32 %index | ||
|
||
; Non-HSA OSes use fixup into .text section. | ||
; NOHSA: s_add_u32 s{{[0-9]+}}, s[[PC1_LO]], private2 | ||
; NOHSA: s_addc_u32 s{{[0-9]+}}, s[[PC1_HI]], 0 | ||
|
||
; HSA OSes use relocations. | ||
; HSA: s_add_u32 s{{[0-9]+}}, s[[PC1_LO]], private2@rel32@lo+4 | ||
; HSA: s_addc_u32 s{{[0-9]+}}, s[[PC1_HI]], private2@rel32@hi+4 | ||
|
||
define void @private_test(i32 %index, float addrspace(1)* %out) { | ||
%ptr = getelementptr [4 x float], [4 x float] addrspace(2) * @private1, i32 0, i32 %index | ||
%val = load float, float addrspace(2)* %ptr | ||
store float %val, float addrspace(1)* %out | ||
%ptr2 = getelementptr [4 x float], [4 x float] addrspace(2) * @readonly2, i32 0, i32 %index | ||
%ptr2 = getelementptr [4 x float], [4 x float] addrspace(2) * @private2, i32 0, i32 %index | ||
%val2 = load float, float addrspace(2)* %ptr2 | ||
store float %val2, float addrspace(1)* %out | ||
ret void | ||
} | ||
|
||
; HSA-LABEL: {{^}}available_externally_test: | ||
; HSA: s_getpc_b64 s{{\[}}[[PC0_LO:[0-9]+]]:[[PC0_HI:[0-9]+]]{{\]}} | ||
; HSA: s_add_u32 s{{[0-9]+}}, s[[PC0_LO]], available_externally@gotpcrel32@lo+4 | ||
; HSA: s_addc_u32 s{{[0-9]+}}, s[[PC0_HI]], available_externally@gotpcrel32@hi+4 | ||
define void @available_externally_test(i32 addrspace(1)* %out) { | ||
%ptr = getelementptr [256 x i32], [256 x i32] addrspace(2)* @available_externally, i32 0, i32 1 | ||
%val = load i32, i32 addrspace(2)* %ptr | ||
store i32 %val, i32 addrspace(1)* %out | ||
ret void | ||
} | ||
|
||
; NOHSA: .text | ||
; HSA: .section .rodata | ||
|
||
; GCN: private1: | ||
; GCN: private2: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters