forked from KhronosGroup/SPIRV-LLVM-Translator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport to 9] Implement SPV_INTEL_global_variable_decorations exten…
…sion (KhronosGroup#1389) * Implement SPV_INTEL_global_variable_decorations extension This change adds support of decorations applied to global variables through `spirv.Decorations` metadata in LLVM IR. These decorations are mostly intended to help code generation for FPGA devices: * HostAccessINTEL * InitModeINTEL * ImplementInCSRINTEL Spec: https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/DeviceGlobal/SPV_INTEL_global_variable_decorations.asciidoc
- Loading branch information
1 parent
fb7b3f3
commit a11ee80
Showing
9 changed files
with
246 additions
and
3 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
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
75 changes: 75 additions & 0 deletions
75
test/transcoding/SPV_INTEL_global_variable_decorations/global_var_decorations.ll
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
; RUN: llvm-as %s -o %t.bc | ||
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_global_variable_decorations -o %t.spv | ||
; RUN: llvm-spirv %t.spv -to-text -o %t.spt | ||
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV | ||
|
||
; RUN: llvm-spirv -r %t.spv --spirv-target-env=SPV-IR -o %t.rev.bc | ||
; RUN: llvm-dis %t.rev.bc | ||
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-SPV-IR | ||
|
||
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc | ||
; RUN: llvm-dis %t.rev.bc | ||
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM | ||
|
||
; Expected to fail - the decorations require enabled extension to be translated. | ||
; RUN: not llvm-spirv %t.bc -o %t.spv | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64-unknown-unknown" | ||
|
||
@int_var = addrspace(1) global i32 42, !spirv.Decorations !1 | ||
@float_var = addrspace(1) global float 1.0, !spirv.Decorations !6 | ||
@bool_var = addrspace(1) global i1 0, !spirv.Decorations !9 | ||
|
||
; CHECK-SPIRV: Capability GlobalVariableDecorationsINTEL | ||
; CHECK-SPIRV: Extension "SPV_INTEL_global_variable_decorations" | ||
|
||
; CHECK-SPIRV: Decorate [[#GROUP0:]] InitModeINTEL 0 | ||
; CHECK-SPIRV: DecorationGroup [[#GROUP0]] | ||
; CHECK-SPIRV: Decorate [[#GROUP1:]] ImplementInCSRINTEL 1 | ||
; CHECK-SPIRV: DecorationGroup [[#GROUP1]] | ||
|
||
; CHECK-SPIRV: Decorate [[#INT_VAR_ID:]] HostAccessINTEL 1 "IntVarName" | ||
; CHECK-SPIRV: Decorate [[#BOOL_VAR_ID:]] HostAccessINTEL 3 "BoolVarName" | ||
; CHECK-SPIRV: Decorate [[#FLOAT_VAR_ID:]] InitModeINTEL 1 | ||
; CHECK-SPIRV: Decorate [[#BOOL_VAR_ID]] ImplementInCSRINTEL 0 | ||
; CHECK-SPIRV: GroupDecorate [[#GROUP0]] [[#INT_VAR_ID]] [[#BOOL_VAR_ID]] | ||
; CHECK-SPIRV: GroupDecorate [[#GROUP1]] [[#INT_VAR_ID]] [[#FLOAT_VAR_ID]] | ||
|
||
; 5 is a global storage | ||
; CHECK-SPIRV: Variable [[#IGNORE0:]] [[#INT_VAR_ID]] 5 | ||
; CHECK-SPIRV: Variable [[#IGNORE1:]] [[#FLOAT_VAR_ID]] 5 | ||
; CHECK-SPIRV: Variable [[#IGNORE2:]] [[#BOOL_VAR_ID]] 5 | ||
|
||
!1 = !{!2, !3, !4} | ||
!2 = !{i32 6147, i32 1, !"IntVarName"} ; HostAccessINTEL 1 "IntVarName" | ||
!3 = !{i32 6149, i1 true} ; ImplementInCSRINTEL = true | ||
!4 = !{i32 6148, i32 0} ; InitModeINTEL = 0 | ||
!5 = !{i32 6148, i32 1} ; InitModeINTEL = 1 | ||
!6 = !{!3, !5} | ||
!7 = !{i32 6147, i32 3, !"BoolVarName"} ; HostAccessINTEL 3 "BoolVarName" | ||
!8 = !{i32 6149, i1 false} ; ImplementInCSRINTEL = false | ||
!9 = !{!7, !8, !4} | ||
|
||
; CHECK-SPV-IR: @int_var = addrspace(1) global i32 42, !spirv.Decorations ![[#INT_VAR_DEC:]] | ||
; CHECK-SPV-IR: @float_var = addrspace(1) global float 1.000000e+00, !spirv.Decorations ![[#FLOAT_VAR_DEC:]] | ||
; CHECK-SPV-IR: @bool_var = addrspace(1) global i1 false, !spirv.Decorations ![[#BOOL_VAR_DEC:]] | ||
|
||
; CHECK-SPV-IR: ![[#INT_VAR_DEC]] = !{![[#IGNORE3:]], ![[#MD_HOST_ACCESS_INTVAR:]], ![[#MD_INIT_0:]], ![[#MD_CSR_1:]]} | ||
; CHECK-SPV-IR: ![[#MD_HOST_ACCESS_INTVAR]] = !{i32 6147, i32 1, !"IntVarName"} | ||
; CHECK-SPV-IR: ![[#MD_INIT_0]] = !{i32 6148, i32 0} | ||
; CHECK-SPV-IR: ![[#MD_CSR_1]] = !{i32 6149, i32 1} | ||
; CHECK-SPV-IR: ![[#FLOAT_VAR_DEC]] = !{![[#IGNORE4:]], ![[#MD_INIT_1:]], ![[#MD_CSR_1]]} | ||
; CHECK-SPV-IR: ![[#MD_INIT_1]] = !{i32 6148, i32 1} | ||
; CHECK-SPV-IR: ![[#BOOL_VAR_DEC]] = !{![[#IGNORE5:]], ![[#MD_HOST_ACCESS_BOOLVAR:]], ![[#MD_INIT_0]], ![[#MD_CSR_0:]]} | ||
; CHECK-SPV-IR: ![[#MD_HOST_ACCESS_BOOLVAR]] = !{i32 6147, i32 3, !"BoolVarName"} | ||
; CHECK-SPV-IR: ![[#MD_CSR_0]] = !{i32 6149, i32 0} | ||
|
||
|
||
; CHECK-LLVM-NOT: @int_var = {{.*}}, !spirv.Decorations ![[#IGNORE6:]] | ||
; CHECK-LLVM-NOT: @float_var = {{.*}}, !spirv.Decorations ![[#IGNORE7:]] | ||
; CHECK-LLVM-NOT: @bool_var = {{.*}}, !spirv.Decorations ![[#IGNORE8:]] | ||
|
||
; CHECK-LLVM: @int_var = addrspace(1) global i32 42 | ||
; CHECK-LLVM: @float_var = addrspace(1) global float 1.000000e+00 | ||
; CHECK-LLVM: @bool_var = addrspace(1) global i1 false |