llvm-project/clang/lib/Frontend
Yaxun Liu 0bc4b2d337 [OpenCL] Generate opaque type for sampler_t and function call for the initializer
Currently Clang use int32 to represent sampler_t, which have been a source of issue for some backends, because in some backends sampler_t cannot be represented by int32. They have to depend on kernel argument metadata and use IPA to find the sampler arguments and global variables and transform them to target specific sampler type.

This patch uses opaque pointer type opencl.sampler_t* for sampler_t. For each use of file-scope sampler variable, it generates a function call of __translate_sampler_initializer. For each initialization of function-scope sampler variable, it generates a function call of __translate_sampler_initializer.

Each builtin library can implement its own __translate_sampler_initializer(). Since the real sampler type tends to be architecture dependent, allowing it to be initialized by a library function simplifies backend design. A typical implementation of __translate_sampler_initializer could be a table lookup of real sampler literal values. Since its argument is always a literal, the returned pointer is known at compile time and easily optimized to finally become some literal values directly put into image read instructions.

This patch is partially based on Alexey Sotkin's work in Khronos Clang (3d4eec6162).

Differential Revision: https://reviews.llvm.org/D21567

llvm-svn: 277024
2016-07-28 19:26:30 +00:00
..
Rewrite [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
ASTConsumers.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
ASTMerge.cpp [Frontend] Make the memory management of FrontendAction pointers explicit by using unique_ptr. 2016-02-07 19:28:36 +00:00
ASTUnit.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
CMakeLists.txt clangFrontend: Make intrinsics_gen optional for standalone build. 2016-06-02 20:24:07 +00:00
CacheTokens.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
ChainedDiagnosticConsumer.cpp
ChainedIncludesSource.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
CodeGenOptions.cpp revert SVN r265702, r265640 2016-04-08 16:52:00 +00:00
CompilerInstance.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
CompilerInvocation.cpp [OpenCL] Generate opaque type for sampler_t and function call for the initializer 2016-07-28 19:26:30 +00:00
CreateInvocationFromCommandLine.cpp [CUDA][OpenMP] Create generic offload action 2016-07-15 23:13:27 +00:00
DependencyFile.cpp Turn copies into references as suggested by clang-tidy's performance-unnecessary-copy-initialization. 2016-05-27 13:36:58 +00:00
DependencyGraph.cpp Revert r240270 ("Fixed/added namespace ending comments using clang-tidy"). 2015-06-22 23:07:51 +00:00
DiagnosticRenderer.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
FrontendAction.cpp Revert r276973 "Adjust Registry interface to not require plugins to export a registry" 2016-07-28 17:17:22 +00:00
FrontendActions.cpp Modules: add command line option fmodules-disable-diagnostic-validation 2016-07-26 17:12:17 +00:00
FrontendOptions.cpp Ensure that we still parse preprocessed CUDA files as CUDA when we use 2015-03-19 17:32:06 +00:00
HeaderIncludeGen.cpp [Frontend] StringRefize and fix bad indentation. 2016-05-27 12:52:19 +00:00
InitHeaderSearch.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
InitPreprocessor.cpp Provide __GLIBCXX_TYPE_INT_N_0 and __GLIBCXX_BITSIZE_INT_N_0 when in C++ gnu language extensions. 2016-07-21 07:44:41 +00:00
LangStandards.cpp [C++11] Use 'nullptr'. Frontend edition. 2014-05-22 04:46:25 +00:00
LayoutOverrideSource.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 19:38:18 +00:00
LogDiagnosticPrinter.cpp Replace double negation of !FileID.isInvalid() with FileID.isValid(). 2015-10-03 10:46:20 +00:00
ModuleDependencyCollector.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
MultiplexConsumer.cpp [OpenMP] Parse+Sema for '#pragma omp declare target' syntax version 4.5 2016-05-09 14:59:13 +00:00
PCHContainerOperations.cpp Frontend: Simplify ownership model for clang's output streams. 2016-07-15 00:55:40 +00:00
PrintPreprocessedOutput.cpp [modules] Add a comment to explain why -E leaves some #includes in the preprocessed output. 2016-04-08 01:23:59 +00:00
SerializedDiagnosticPrinter.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
SerializedDiagnosticReader.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
TestModuleFileExtension.cpp Use arrays or initializer lists to feed ArrayRefs instead of SmallVector where possible. 2016-07-02 11:41:41 +00:00
TestModuleFileExtension.h Module file extensions: pass a Sema through to the extension writer. 2015-12-08 22:43:32 +00:00
TextDiagnostic.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
TextDiagnosticBuffer.cpp Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types 2015-05-29 19:42:19 +00:00
TextDiagnosticPrinter.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
VerifyDiagnosticConsumer.cpp Refactor: Simplify boolean conditional return statements in lib/Frontend 2015-12-28 15:15:16 +00:00