diff --git a/third_party/intel/cmake/3388.patch b/third_party/intel/cmake/3388.patch index ce5109ccd5..5db1b211ff 100644 --- a/third_party/intel/cmake/3388.patch +++ b/third_party/intel/cmake/3388.patch @@ -1,8 +1,8 @@ diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp -index d363f060a..28f83d661 100644 +index ec4ec41f5..4f6d80dd1 100644 --- a/lib/SPIRV/SPIRVWriter.cpp +++ b/lib/SPIRV/SPIRVWriter.cpp -@@ -4211,20 +4211,6 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II, +@@ -4276,20 +4276,6 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II, // -spirv-allow-unknown-intrinsics work correctly. auto IID = II->getIntrinsicID(); switch (IID) { @@ -23,7 +23,7 @@ index d363f060a..28f83d661 100644 case Intrinsic::assume: { // llvm.assume translation is currently supported only within // SPV_KHR_expect_assume extension, ignore it otherwise, since it's -@@ -5508,11 +5494,6 @@ SPIRVValue *LLVMToSPIRVBase::transDirectCallInst(CallInst *CI, +@@ -5721,11 +5707,6 @@ SPIRVValue *LLVMToSPIRVBase::transDirectCallInst(CallInst *CI, SmallVector Dec; if (isBuiltinTransToExtInst(CI->getCalledFunction(), &ExtSetKind, &ExtOp, &Dec)) { @@ -36,10 +36,10 @@ index d363f060a..28f83d661 100644 auto *FormatStrPtr = cast(CI->getArgOperand(0)->getType()); if (FormatStrPtr->getAddressSpace() != diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/lib/SPIRV/libSPIRV/SPIRVModule.cpp -index a680574ec..2ff1df097 100644 +index b76987e93..8d06ee792 100644 --- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp +++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp -@@ -1732,8 +1732,6 @@ SPIRVInstruction *SPIRVModuleImpl::addBinaryInst(Op TheOpCode, SPIRVType *Type, +@@ -1739,8 +1739,6 @@ SPIRVInstruction *SPIRVModuleImpl::addBinaryInst(Op TheOpCode, SPIRVType *Type, SPIRVValue *Op1, SPIRVValue *Op2, SPIRVBasicBlock *BB) { @@ -48,10 +48,10 @@ index a680574ec..2ff1df097 100644 return addInstruction(SPIRVInstTemplateBase::create( TheOpCode, Type, getId(), getVec(Op1->getId(), Op2->getId()), BB, this), -@@ -1757,8 +1755,6 @@ SPIRVInstruction *SPIRVModuleImpl::addUnaryInst(Op TheOpCode, - SPIRVType *TheType, - SPIRVValue *Op, - SPIRVBasicBlock *BB) { +@@ -1764,8 +1762,6 @@ SPIRVInstruction * + SPIRVModuleImpl::addUnaryInst(Op TheOpCode, SPIRVType *TheType, SPIRVValue *Op, + SPIRVBasicBlock *BB, + SPIRVInstruction *InsertBefore) { - if (TheType->isTypeFloat(16, FPEncodingBFloat16KHR) && TheOpCode != OpDot) - addCapability(internal::CapabilityBFloat16ArithmeticINTEL); return addInstruction( diff --git a/third_party/intel/cmake/3462.patch b/third_party/intel/cmake/3462.patch new file mode 100644 index 0000000000..5f3b25de75 --- /dev/null +++ b/third_party/intel/cmake/3462.patch @@ -0,0 +1,13 @@ +diff --git a/lib/SPIRV/SPIRVReader.cpp b/lib/SPIRV/SPIRVReader.cpp +index a3d9a1da..c4c88cbe 100644 +--- a/lib/SPIRV/SPIRVReader.cpp ++++ b/lib/SPIRV/SPIRVReader.cpp +@@ -1124,7 +1124,7 @@ Value *SPIRVToLLVM::transConvertInst(SPIRVValue *BV, Function *F, + FPEncodingWrap DstEnc = GetEncodingAndUpdateType(SPVDstTy); + if (IsFP4OrFP8Encoding(SrcEnc) || IsFP4OrFP8Encoding(DstEnc) || + SPVSrcTy->isTypeInt(4) || SPVDstTy->isTypeInt(4)) { +- FPConversionDesc FPDesc = {SrcEnc, DstEnc, BC->getOpCode()}; ++ FPConversionDesc FPDesc = {SrcEnc, DstEnc, static_cast(BC->getOpCode())}; + auto Conv = SPIRV::FPConvertToEncodingMap::rmap(FPDesc); + std::vector Ops = {Src}; + std::vector OpsTys = {Src->getType()}; diff --git a/third_party/intel/cmake/FindSPIRVToLLVMTranslator.cmake b/third_party/intel/cmake/FindSPIRVToLLVMTranslator.cmake index d3c5333913..bac4121d60 100644 --- a/third_party/intel/cmake/FindSPIRVToLLVMTranslator.cmake +++ b/third_party/intel/cmake/FindSPIRVToLLVMTranslator.cmake @@ -123,6 +123,51 @@ if (NOT SPIRVToLLVMTranslator_FOUND) if(NOT PATCH_RESULT EQUAL 0) message(FATAL_ERROR "Failed to apply revert_3406.patch to SPIRV-LLVM-Translator") endif() + execute_process( + COMMAND git apply --check ${CMAKE_CURRENT_LIST_DIR}/revert_3407.patch + WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR} + ERROR_QUIET + RESULT_VARIABLE PATCH_RESULT + ) + if(PATCH_RESULT EQUAL 0) + execute_process( + COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/revert_3407.patch + WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR} + RESULT_VARIABLE PATCH_RESULT + ) + else() + execute_process( # Check if the patch is already applied + COMMAND git apply --reverse --check ${CMAKE_CURRENT_LIST_DIR}/revert_3407.patch + WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR} + RESULT_VARIABLE PATCH_RESULT + ) + endif() + if(NOT PATCH_RESULT EQUAL 0) + message(FATAL_ERROR "Failed to apply revert_3407.patch to SPIRV-LLVM-Translator") + endif() + + execute_process( + COMMAND git apply --check ${CMAKE_CURRENT_LIST_DIR}/3462.patch + WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR} + ERROR_QUIET + RESULT_VARIABLE PATCH_RESULT + ) + if(PATCH_RESULT EQUAL 0) + execute_process( + COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/3462.patch + WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR} + RESULT_VARIABLE PATCH_RESULT + ) + else() + execute_process( # Check if the patch is already applied + COMMAND git apply --reverse --check ${CMAKE_CURRENT_LIST_DIR}/3462.patch + WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR} + RESULT_VARIABLE PATCH_RESULT + ) + endif() + if(NOT PATCH_RESULT EQUAL 0) + message(FATAL_ERROR "Failed to apply 3462.patch to SPIRV-LLVM-Translator") + endif() endif() set(SPIRVToLLVMTranslator_INCLUDE_DIR "${SPIRVToLLVMTranslator_SOURCE_DIR}/include" diff --git a/third_party/intel/cmake/revert_3407.patch b/third_party/intel/cmake/revert_3407.patch new file mode 100644 index 0000000000..a3e4e94306 --- /dev/null +++ b/third_party/intel/cmake/revert_3407.patch @@ -0,0 +1,66 @@ +diff --git a/lib/SPIRV/OCLToSPIRV.cpp b/lib/SPIRV/OCLToSPIRV.cpp +index 05a60ec4..2866141c 100644 +--- a/lib/SPIRV/OCLToSPIRV.cpp ++++ b/lib/SPIRV/OCLToSPIRV.cpp +@@ -152,8 +152,8 @@ getAtomicPointerMemorySemanticsMemoryMask(const Value *Ptr, + + static size_t getOCLCpp11AtomicMaxNumOps(StringRef Name) { + return StringSwitch(Name) +- .Cases({"load", "flag_test_and_set", "flag_clear"}, 3) +- .Cases({"store", "exchange"}, 4) ++ .Cases("load", "flag_test_and_set", "flag_clear", 3) ++ .Cases("store", "exchange", 4) + .StartsWith("compare_exchange", 6) + .StartsWith("fetch", 4) + .Default(0); +diff --git a/lib/SPIRV/SPIRVUtil.cpp b/lib/SPIRV/SPIRVUtil.cpp +index b747e423..14fc6d05 100644 +--- a/lib/SPIRV/SPIRVUtil.cpp ++++ b/lib/SPIRV/SPIRVUtil.cpp +@@ -620,11 +620,11 @@ static std::string demangleBuiltinOpenCLTypeName(StringRef MangledStructName) { + /// floating point type. + static Type *parsePrimitiveType(LLVMContext &Ctx, StringRef Name) { + return StringSwitch(Name) +- .Cases({"char", "signed char", "unsigned char"}, Type::getInt8Ty(Ctx)) +- .Cases({"short", "unsigned short"}, Type::getInt16Ty(Ctx)) +- .Cases({"int", "unsigned int"}, Type::getInt32Ty(Ctx)) +- .Cases({"long", "unsigned long"}, Type::getInt64Ty(Ctx)) +- .Cases({"long long", "unsigned long long"}, Type::getInt64Ty(Ctx)) ++ .Cases("char", "signed char", "unsigned char", Type::getInt8Ty(Ctx)) ++ .Cases("short", "unsigned short", Type::getInt16Ty(Ctx)) ++ .Cases("int", "unsigned int", Type::getInt32Ty(Ctx)) ++ .Cases("long", "unsigned long", Type::getInt64Ty(Ctx)) ++ .Cases("long long", "unsigned long long", Type::getInt64Ty(Ctx)) + .Case("half", Type::getHalfTy(Ctx)) + .Case("float", Type::getFloatTy(Ctx)) + .Case("double", Type::getDoubleTy(Ctx)) +diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp +index b017e663..3fd8f21b 100644 +--- a/lib/SPIRV/SPIRVWriter.cpp ++++ b/lib/SPIRV/SPIRVWriter.cpp +@@ -5397,16 +5397,16 @@ LLVMToSPIRVBase::getFPBuiltinType(IntrinsicInst *II, StringRef &OpName) { + OpName = Name.split('.').first; + FPBuiltinType Type = + StringSwitch(OpName) +- .Cases({"fadd", "fsub", "fmul", "fdiv", "frem"}, ++ .Cases("fadd", "fsub", "fmul", "fdiv", "frem", + FPBuiltinType::REGULAR_MATH) +- .Cases({"sin", "cos", "tan"}, FPBuiltinType::EXT_1OPS) +- .Cases({"sinh", "cosh", "tanh"}, FPBuiltinType::EXT_1OPS) +- .Cases({"asin", "acos", "atan"}, FPBuiltinType::EXT_1OPS) +- .Cases({"asinh", "acosh", "atanh"}, FPBuiltinType::EXT_1OPS) +- .Cases({"exp", "exp2", "exp10", "expm1"}, FPBuiltinType::EXT_1OPS) +- .Cases({"log", "log2", "log10", "log1p"}, FPBuiltinType::EXT_1OPS) +- .Cases({"sqrt", "rsqrt", "erf", "erfc"}, FPBuiltinType::EXT_1OPS) +- .Cases({"atan2", "pow", "hypot", "ldexp"}, FPBuiltinType::EXT_2OPS) ++ .Cases("sin", "cos", "tan", FPBuiltinType::EXT_1OPS) ++ .Cases("sinh", "cosh", "tanh", FPBuiltinType::EXT_1OPS) ++ .Cases("asin", "acos", "atan", FPBuiltinType::EXT_1OPS) ++ .Cases("asinh", "acosh", "atanh", FPBuiltinType::EXT_1OPS) ++ .Cases("exp", "exp2", "exp10", "expm1", FPBuiltinType::EXT_1OPS) ++ .Cases("log", "log2", "log10", "log1p", FPBuiltinType::EXT_1OPS) ++ .Cases("sqrt", "rsqrt", "erf", "erfc", FPBuiltinType::EXT_1OPS) ++ .Cases("atan2", "pow", "hypot", "ldexp", FPBuiltinType::EXT_2OPS) + .Case("sincos", FPBuiltinType::EXT_3OPS) + .Default(FPBuiltinType::UNKNOWN); + return Type; diff --git a/third_party/intel/lib/Target/SPIRV/spirv-llvm-translator.conf b/third_party/intel/lib/Target/SPIRV/spirv-llvm-translator.conf index 4f19afceae..a53efa42e0 100644 --- a/third_party/intel/lib/Target/SPIRV/spirv-llvm-translator.conf +++ b/third_party/intel/lib/Target/SPIRV/spirv-llvm-translator.conf @@ -1 +1 @@ -daba8b217bc266806ac00095262d1af0ba2ee610 +af594c0b45250fefa2093dfc31cb14d1eb6a32f2