Skip to content

Commit 5c98bcc

Browse files
Update spirv-llvm-translator.conf (#5524)
Signed-off-by: Whitney Tsang <[email protected]>
1 parent a12938d commit 5c98bcc

File tree

5 files changed

+134
-10
lines changed

5 files changed

+134
-10
lines changed

third_party/intel/cmake/3388.patch

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp
2-
index d363f060a..28f83d661 100644
2+
index ec4ec41f5..4f6d80dd1 100644
33
--- a/lib/SPIRV/SPIRVWriter.cpp
44
+++ b/lib/SPIRV/SPIRVWriter.cpp
5-
@@ -4211,20 +4211,6 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
5+
@@ -4276,20 +4276,6 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
66
// -spirv-allow-unknown-intrinsics work correctly.
77
auto IID = II->getIntrinsicID();
88
switch (IID) {
@@ -23,7 +23,7 @@ index d363f060a..28f83d661 100644
2323
case Intrinsic::assume: {
2424
// llvm.assume translation is currently supported only within
2525
// SPV_KHR_expect_assume extension, ignore it otherwise, since it's
26-
@@ -5508,11 +5494,6 @@ SPIRVValue *LLVMToSPIRVBase::transDirectCallInst(CallInst *CI,
26+
@@ -5721,11 +5707,6 @@ SPIRVValue *LLVMToSPIRVBase::transDirectCallInst(CallInst *CI,
2727
SmallVector<std::string, 2> Dec;
2828
if (isBuiltinTransToExtInst(CI->getCalledFunction(), &ExtSetKind, &ExtOp,
2929
&Dec)) {
@@ -36,10 +36,10 @@ index d363f060a..28f83d661 100644
3636
auto *FormatStrPtr = cast<PointerType>(CI->getArgOperand(0)->getType());
3737
if (FormatStrPtr->getAddressSpace() !=
3838
diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
39-
index a680574ec..2ff1df097 100644
39+
index b76987e93..8d06ee792 100644
4040
--- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp
4141
+++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
42-
@@ -1732,8 +1732,6 @@ SPIRVInstruction *SPIRVModuleImpl::addBinaryInst(Op TheOpCode, SPIRVType *Type,
42+
@@ -1739,8 +1739,6 @@ SPIRVInstruction *SPIRVModuleImpl::addBinaryInst(Op TheOpCode, SPIRVType *Type,
4343
SPIRVValue *Op1,
4444
SPIRVValue *Op2,
4545
SPIRVBasicBlock *BB) {
@@ -48,10 +48,10 @@ index a680574ec..2ff1df097 100644
4848
return addInstruction(SPIRVInstTemplateBase::create(
4949
TheOpCode, Type, getId(),
5050
getVec(Op1->getId(), Op2->getId()), BB, this),
51-
@@ -1757,8 +1755,6 @@ SPIRVInstruction *SPIRVModuleImpl::addUnaryInst(Op TheOpCode,
52-
SPIRVType *TheType,
53-
SPIRVValue *Op,
54-
SPIRVBasicBlock *BB) {
51+
@@ -1764,8 +1762,6 @@ SPIRVInstruction *
52+
SPIRVModuleImpl::addUnaryInst(Op TheOpCode, SPIRVType *TheType, SPIRVValue *Op,
53+
SPIRVBasicBlock *BB,
54+
SPIRVInstruction *InsertBefore) {
5555
- if (TheType->isTypeFloat(16, FPEncodingBFloat16KHR) && TheOpCode != OpDot)
5656
- addCapability(internal::CapabilityBFloat16ArithmeticINTEL);
5757
return addInstruction(

third_party/intel/cmake/3462.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/lib/SPIRV/SPIRVReader.cpp b/lib/SPIRV/SPIRVReader.cpp
2+
index a3d9a1da..c4c88cbe 100644
3+
--- a/lib/SPIRV/SPIRVReader.cpp
4+
+++ b/lib/SPIRV/SPIRVReader.cpp
5+
@@ -1124,7 +1124,7 @@ Value *SPIRVToLLVM::transConvertInst(SPIRVValue *BV, Function *F,
6+
FPEncodingWrap DstEnc = GetEncodingAndUpdateType(SPVDstTy);
7+
if (IsFP4OrFP8Encoding(SrcEnc) || IsFP4OrFP8Encoding(DstEnc) ||
8+
SPVSrcTy->isTypeInt(4) || SPVDstTy->isTypeInt(4)) {
9+
- FPConversionDesc FPDesc = {SrcEnc, DstEnc, BC->getOpCode()};
10+
+ FPConversionDesc FPDesc = {SrcEnc, DstEnc, static_cast<SPIRV::SPIRVWord>(BC->getOpCode())};
11+
auto Conv = SPIRV::FPConvertToEncodingMap::rmap(FPDesc);
12+
std::vector<Value *> Ops = {Src};
13+
std::vector<Type *> OpsTys = {Src->getType()};

third_party/intel/cmake/FindSPIRVToLLVMTranslator.cmake

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,51 @@ if (NOT SPIRVToLLVMTranslator_FOUND)
123123
if(NOT PATCH_RESULT EQUAL 0)
124124
message(FATAL_ERROR "Failed to apply revert_3406.patch to SPIRV-LLVM-Translator")
125125
endif()
126+
execute_process(
127+
COMMAND git apply --check ${CMAKE_CURRENT_LIST_DIR}/revert_3407.patch
128+
WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR}
129+
ERROR_QUIET
130+
RESULT_VARIABLE PATCH_RESULT
131+
)
132+
if(PATCH_RESULT EQUAL 0)
133+
execute_process(
134+
COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/revert_3407.patch
135+
WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR}
136+
RESULT_VARIABLE PATCH_RESULT
137+
)
138+
else()
139+
execute_process( # Check if the patch is already applied
140+
COMMAND git apply --reverse --check ${CMAKE_CURRENT_LIST_DIR}/revert_3407.patch
141+
WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR}
142+
RESULT_VARIABLE PATCH_RESULT
143+
)
144+
endif()
145+
if(NOT PATCH_RESULT EQUAL 0)
146+
message(FATAL_ERROR "Failed to apply revert_3407.patch to SPIRV-LLVM-Translator")
147+
endif()
148+
149+
execute_process(
150+
COMMAND git apply --check ${CMAKE_CURRENT_LIST_DIR}/3462.patch
151+
WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR}
152+
ERROR_QUIET
153+
RESULT_VARIABLE PATCH_RESULT
154+
)
155+
if(PATCH_RESULT EQUAL 0)
156+
execute_process(
157+
COMMAND git apply ${CMAKE_CURRENT_LIST_DIR}/3462.patch
158+
WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR}
159+
RESULT_VARIABLE PATCH_RESULT
160+
)
161+
else()
162+
execute_process( # Check if the patch is already applied
163+
COMMAND git apply --reverse --check ${CMAKE_CURRENT_LIST_DIR}/3462.patch
164+
WORKING_DIRECTORY ${spirv-llvm-translator_SOURCE_DIR}
165+
RESULT_VARIABLE PATCH_RESULT
166+
)
167+
endif()
168+
if(NOT PATCH_RESULT EQUAL 0)
169+
message(FATAL_ERROR "Failed to apply 3462.patch to SPIRV-LLVM-Translator")
170+
endif()
126171
endif()
127172

128173
set(SPIRVToLLVMTranslator_INCLUDE_DIR "${SPIRVToLLVMTranslator_SOURCE_DIR}/include"
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
diff --git a/lib/SPIRV/OCLToSPIRV.cpp b/lib/SPIRV/OCLToSPIRV.cpp
2+
index 05a60ec4..2866141c 100644
3+
--- a/lib/SPIRV/OCLToSPIRV.cpp
4+
+++ b/lib/SPIRV/OCLToSPIRV.cpp
5+
@@ -152,8 +152,8 @@ getAtomicPointerMemorySemanticsMemoryMask(const Value *Ptr,
6+
7+
static size_t getOCLCpp11AtomicMaxNumOps(StringRef Name) {
8+
return StringSwitch<size_t>(Name)
9+
- .Cases({"load", "flag_test_and_set", "flag_clear"}, 3)
10+
- .Cases({"store", "exchange"}, 4)
11+
+ .Cases("load", "flag_test_and_set", "flag_clear", 3)
12+
+ .Cases("store", "exchange", 4)
13+
.StartsWith("compare_exchange", 6)
14+
.StartsWith("fetch", 4)
15+
.Default(0);
16+
diff --git a/lib/SPIRV/SPIRVUtil.cpp b/lib/SPIRV/SPIRVUtil.cpp
17+
index b747e423..14fc6d05 100644
18+
--- a/lib/SPIRV/SPIRVUtil.cpp
19+
+++ b/lib/SPIRV/SPIRVUtil.cpp
20+
@@ -620,11 +620,11 @@ static std::string demangleBuiltinOpenCLTypeName(StringRef MangledStructName) {
21+
/// floating point type.
22+
static Type *parsePrimitiveType(LLVMContext &Ctx, StringRef Name) {
23+
return StringSwitch<Type *>(Name)
24+
- .Cases({"char", "signed char", "unsigned char"}, Type::getInt8Ty(Ctx))
25+
- .Cases({"short", "unsigned short"}, Type::getInt16Ty(Ctx))
26+
- .Cases({"int", "unsigned int"}, Type::getInt32Ty(Ctx))
27+
- .Cases({"long", "unsigned long"}, Type::getInt64Ty(Ctx))
28+
- .Cases({"long long", "unsigned long long"}, Type::getInt64Ty(Ctx))
29+
+ .Cases("char", "signed char", "unsigned char", Type::getInt8Ty(Ctx))
30+
+ .Cases("short", "unsigned short", Type::getInt16Ty(Ctx))
31+
+ .Cases("int", "unsigned int", Type::getInt32Ty(Ctx))
32+
+ .Cases("long", "unsigned long", Type::getInt64Ty(Ctx))
33+
+ .Cases("long long", "unsigned long long", Type::getInt64Ty(Ctx))
34+
.Case("half", Type::getHalfTy(Ctx))
35+
.Case("float", Type::getFloatTy(Ctx))
36+
.Case("double", Type::getDoubleTy(Ctx))
37+
diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp
38+
index b017e663..3fd8f21b 100644
39+
--- a/lib/SPIRV/SPIRVWriter.cpp
40+
+++ b/lib/SPIRV/SPIRVWriter.cpp
41+
@@ -5397,16 +5397,16 @@ LLVMToSPIRVBase::getFPBuiltinType(IntrinsicInst *II, StringRef &OpName) {
42+
OpName = Name.split('.').first;
43+
FPBuiltinType Type =
44+
StringSwitch<FPBuiltinType>(OpName)
45+
- .Cases({"fadd", "fsub", "fmul", "fdiv", "frem"},
46+
+ .Cases("fadd", "fsub", "fmul", "fdiv", "frem",
47+
FPBuiltinType::REGULAR_MATH)
48+
- .Cases({"sin", "cos", "tan"}, FPBuiltinType::EXT_1OPS)
49+
- .Cases({"sinh", "cosh", "tanh"}, FPBuiltinType::EXT_1OPS)
50+
- .Cases({"asin", "acos", "atan"}, FPBuiltinType::EXT_1OPS)
51+
- .Cases({"asinh", "acosh", "atanh"}, FPBuiltinType::EXT_1OPS)
52+
- .Cases({"exp", "exp2", "exp10", "expm1"}, FPBuiltinType::EXT_1OPS)
53+
- .Cases({"log", "log2", "log10", "log1p"}, FPBuiltinType::EXT_1OPS)
54+
- .Cases({"sqrt", "rsqrt", "erf", "erfc"}, FPBuiltinType::EXT_1OPS)
55+
- .Cases({"atan2", "pow", "hypot", "ldexp"}, FPBuiltinType::EXT_2OPS)
56+
+ .Cases("sin", "cos", "tan", FPBuiltinType::EXT_1OPS)
57+
+ .Cases("sinh", "cosh", "tanh", FPBuiltinType::EXT_1OPS)
58+
+ .Cases("asin", "acos", "atan", FPBuiltinType::EXT_1OPS)
59+
+ .Cases("asinh", "acosh", "atanh", FPBuiltinType::EXT_1OPS)
60+
+ .Cases("exp", "exp2", "exp10", "expm1", FPBuiltinType::EXT_1OPS)
61+
+ .Cases("log", "log2", "log10", "log1p", FPBuiltinType::EXT_1OPS)
62+
+ .Cases("sqrt", "rsqrt", "erf", "erfc", FPBuiltinType::EXT_1OPS)
63+
+ .Cases("atan2", "pow", "hypot", "ldexp", FPBuiltinType::EXT_2OPS)
64+
.Case("sincos", FPBuiltinType::EXT_3OPS)
65+
.Default(FPBuiltinType::UNKNOWN);
66+
return Type;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
daba8b217bc266806ac00095262d1af0ba2ee610
1+
af594c0b45250fefa2093dfc31cb14d1eb6a32f2

0 commit comments

Comments
 (0)