[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)
Farzon Lotfi via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 29 06:40:57 PDT 2025
================
@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = {
static_assert(std::size(BuiltinInfos) == NumBuiltins);
llvm::SmallVector<Builtin::InfosShard>
-SPIRVTargetInfo::getTargetBuiltins() const {
- return {{&BuiltinStrings, BuiltinInfos}};
+BaseSPIRTargetInfo::getTargetBuiltins() const {
+ if (getTriple().isSPIRV())
+ return {{&BuiltinStrings, BuiltinInfos}};
----------------
farzonl wrote:
I don't understand why this change (in SPIR.cpp and SPIR.h) is necessesary. The existing code accomplished the same thing with method overriding. The original code also had some defensive programming safety to me. We went from a compile time enforcement of SPIRVTargetInfo== BuiltinsSPIRV.td to now a runtime enforcement. The problem with that is the next guy that comes along and makes a change might assume the builtins so far are SPIRV and thats why you are checking the triple, then add a new SPIR flavor builtin that would not be valid for SPIRV.
https://github.com/llvm/llvm-project/pull/137805
More information about the cfe-commits
mailing list