Add support for -cl-std option (#484)
Match what Clang does except that:
- lowercase aliases of the language names are not supported
(they are not described in the OpenCL specification)
- the default standard is OpenCL C 1.2
Remove -c++ (replaced by -cl-std=CLC++).
Turn on address space inferencing when compiling as OpenCL C 2.0.
Signed-off-by: Kévin Petit <kpet@free.fr>
diff --git a/lib/SPIRVProducerPass.cpp b/lib/SPIRVProducerPass.cpp
index 5429366..e80795c 100644
--- a/lib/SPIRVProducerPass.cpp
+++ b/lib/SPIRVProducerPass.cpp
@@ -3546,10 +3546,25 @@
// Ops[1] = Version (LiteralNum)
//
Ops.clear();
- if (clspv::Option::CPlusPlus()) {
- Ops << MkNum(spv::SourceLanguageOpenCL_CPP) << MkNum(100);
- } else {
+ switch (clspv::Option::Language()) {
+ case clspv::Option::SourceLanguage::OpenCL_C_10:
+ Ops << MkNum(spv::SourceLanguageOpenCL_C) << MkNum(100);
+ break;
+ case clspv::Option::SourceLanguage::OpenCL_C_11:
+ Ops << MkNum(spv::SourceLanguageOpenCL_C) << MkNum(110);
+ break;
+ case clspv::Option::SourceLanguage::OpenCL_C_12:
Ops << MkNum(spv::SourceLanguageOpenCL_C) << MkNum(120);
+ break;
+ case clspv::Option::SourceLanguage::OpenCL_C_20:
+ Ops << MkNum(spv::SourceLanguageOpenCL_C) << MkNum(200);
+ break;
+ case clspv::Option::SourceLanguage::OpenCL_CPP:
+ Ops << MkNum(spv::SourceLanguageOpenCL_CPP) << MkNum(100);
+ break;
+ default:
+ Ops << MkNum(spv::SourceLanguageUnknown) << MkNum(0);
+ break;
}
auto *OpenSourceInst = new SPIRVInstruction(spv::OpSource, Ops);