[PATCH] D108034: [SPIR-V] Add SPIR-V builtin functions and types

Alexey Bader via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 13 06:57:54 PDT 2021


bader created this revision.
bader added a reviewer: Naghasan.
Herald added subscribers: dexonsmith, wenlei, ThomasRaoux, dang, ebevhan, jfb, arphaman, martong, Anastasia, mgorny.
Herald added a reviewer: shafik.
bader requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Make the OpenCL Builtin lookup agnostic to programming models

  Rename the OpenCL Builtin lookup system to make it agnostic. The Builtin emitter is now outputting the builtin information into a class so that different programming models can be produced and used.

- Add SPIR-V variants of TypeSampledImage as clang builtin type.

  This patch adds SPIR-V sampled image types as derivative of the builtin OpenCL Image types. For each OpenCL image type, clang defines a Sampled<image type> variant and lowered as a "spirv.SampledImage.<image>" llvm opaque type.

- Enable SPIR-V builtin lookup

  Add flag -fdeclare-spirv-builtins to enable lookup of SPIR-V builtins.

  If -fdeclare-spirv-builtins is passed to clang, the compiler will try to lookup for the builtin described in SPIRVBuiltins.td for any match. If a match is found, overloads are build for the match.

  This will enforce a stable way to express SPIR-V builtins and make them closer to how the translator mangles them. This will help ensuring builtin for CUDA does not break easily. This will also support any changes suggested by the SPIRV-LLVM people on how to represent builtins.

  Define __SPIRV_BUILTIN_DECLARATIONS__ when passing -fdeclare-spirv-builtins to clang.

  Added OpenCL SPIR-V extended set builtins bindings and part of the core SPIR-V (mostly missing Images and Pipes)

TODO: Known vendor extensions are not implemented yet.

Signed-off-by: Victor Lomuller <victor at codeplay.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108034

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGOpenCLRuntime.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/OpenCLBuiltins.td
  clang/lib/Sema/SPIRVBuiltins.td
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGenOpenCL/sampled_image.cl
  clang/test/CodeGenSPIRV/spirv-builtin-lookup-win.cpp
  clang/test/CodeGenSPIRV/spirv-builtin-lookup.cpp
  clang/test/Preprocessor/spirv-macro.cpp
  clang/test/SemaOpenCL/sampled_image_overload.cl
  clang/test/SemaSYCL/spirv-builtin-lookup-invalid.cpp
  clang/test/SemaSYCL/spirv-builtin-lookup.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXType.cpp
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
  clang/utils/TableGen/ClangProgModelBuiltinEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108034.366270.patch
Type: text/x-patch
Size: 115030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210813/58ec4d50/attachment-0001.bin>


More information about the cfe-commits mailing list