Skip to content

Commit

Permalink
Merge (conflict) bafc886 [SPV-IR] Fix SPIRV builtin variable/call tra…
Browse files Browse the repository at this point in the history
…nslation (KhronosGroup#1133) 'master' -> 'xmain-web' (KhronosGroup#3)

  CONFLICT (content): Merge conflict in lib/SPIRV/SPIRVInternal.h

  commit bafc886
  Author: Yilong Guo <[email protected]>
  Date:   Tue Aug 3 15:25:57 2021 +0800

      [SPV-IR] Fix SPIRV builtin variable/call translation (KhronosGroup#1133)

      This PR fixes the translation of SPIRV builtin variables/calls. The translator
      now is able to recognize builtin-call-based SPV-IR input.
      e.g. `call spir_func i64 @_Z33__spirv_BuiltinGlobalInvocationIdi(i32 1)`

      ### LLVM --> SPIRV translation:

      We first translate OCL work item builtins to SPV-IR builtin calls in
      `OCLToSPIRV`. For example:
      `@_Z13get_global_idj(i) -> @_Z33__spirv_BuiltinGlobalInvocationIdi(i)`

      SPV-IR builtin calls are transformed to variables in `LLVMToSPIRV`. This
      step is shared by all source inputs (SPV-IR, OCL-IR). For example:
      `@_Z33__spirv_BuiltinGlobalInvocationIdi(i) ->
      x = load GlobalInvocationId; extract x, i`

      ### SPIRV --> LLVM translation:

      We lower SPIRV builtin variables into calls in `SPIRVToLLVM` so that SPV-IR
      has builtin function calls (instead of variables) by default.

      Builtin calls in SPV-IR can be then translated into OpenCL builtin calls,
      in `SPIRVToOCL`.
      e.g. `@_Z33__spirv_BuiltinGlobalInvocationIdi(i) -> @_Z13get_global_idj(i)`

      `SPIRVToOCL` is also capable of lower SPIRV builtin variables into calls as
      preprocessing, so that this pass can be used by users independently to
      translate SPV-IR into OCL-IR.

      Signed-off-by: Yilong Guo [email protected]

Change-Id: Ie361b71607ba37677d7634f33f55e7286cee673f
  • Loading branch information
iclsrc authored and speryt committed Aug 3, 2021
2 parents 8409a14 + bafc886 commit fcfa3d8
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/SPIRV/SPIRVInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,6 @@ bool lowerBuiltinVariablesToCalls(Module *M);
template<typename T>
MetadataAsValue *map2MDString(LLVMContext &C, SPIRVValue *V);
#endif // INTEL_CUSTOMIZATION

} // namespace SPIRV

#endif // SPIRV_SPIRVINTERNAL_H

0 comments on commit fcfa3d8

Please sign in to comment.