KhronosGroup / SPIRV-LLVM-Translator

A tool and a library for bi-directional translation between SPIR-V and LLVM IR
Other
464 stars 208 forks source link

spt file containing GlobalVariableHostAccessINTEL changes after -to-binary and then -to-text #2558

Open wenju-he opened 2 months ago

wenju-he commented 2 months ago

Content of global_var_host_access.spt:

119734787 65536 393230 10 0
2 Capability Addresses
2 Capability Linkage
2 Capability Kernel
2 Capability GlobalVariableHostAccessINTEL
11 Extension "SPV_INTEL_global_variable_host_access"
5 ExtInstImport 1 "OpenCL.std"
3 MemoryModel 2 2
3 Source 0 0
4 Name 5 "int_var"
5 Name 9 "bool_var"

6 Decorate 5 LinkageAttributes "int_var" Export
7 Decorate 5 HostAccessINTEL ReadINTEL "IntVarName"
7 Decorate 9 LinkageAttributes "bool_var" Export
7 Decorate 9 HostAccessINTEL ReadWriteINTEL "BoolVarName"
4 TypeInt 2 32 0
4 Constant 2 4 42
4 TypePointer 3 5 2
2 TypeBool 6
4 TypePointer 7 5 6
5 Variable 3 5 5 4
3 ConstantFalse 6 8
5 Variable 7 9 5 8

Apply commands llvm-spirv -to-binary global_var_host_access.spt and then llvm-spirv -to-text global_var_host_access.spv -o global_var_host_access.spv.spt. Output global_var_host_access.spv.spt is

119734787 65536 393230 10 0
2 Capability Addresses
2 Capability Linkage
2 Capability Kernel
2 Capability GlobalVariableDecorationsINTEL
2 Capability GlobalVariableHostAccessINTEL
11 Extension "SPV_INTEL_global_variable_host_access"
5 ExtInstImport 1 "OpenCL.std"
3 MemoryModel 2 2
3 Source 0 0
4 Name 5 "int_var"
5 Name 9 "bool_var"

6 Decorate 5 LinkageAttributes "int_var" Export
7 Decorate 5 HostAccessINTEL 0 ""

Differences in the new global_var_host_access.spv.spt:

  1. GlobalVariableDecorationsINTEL is added
  2. In Decorate 5, ReadINTEL "IntVarName" are missing
  3. Decorate 9 is missing
  4. two global variables are missing

Please check if there is expected.