Skip to content

Commit af5f054

Browse files
aratajewsys_zuul
authored andcommitted
Introduce support for OpConstFunctionPointerINTEL in SPIRVReader
Change-Id: I61b2e4ae69748d28cff17c3dab96d7c804cedff5
1 parent bb0c926 commit af5f054

File tree

6 files changed

+34
-41
lines changed

6 files changed

+34
-41
lines changed

IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,14 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
24412441
return mapValue(BV, transValue(BI, nullptr, nullptr, false));
24422442
}
24432443

2444+
case OpConstFunctionPointerINTEL: {
2445+
SPIRVConstFunctionPointerINTEL* BC =
2446+
static_cast<SPIRVConstFunctionPointerINTEL*>(BV);
2447+
SPIRVFunction* F = BC->getFunction();
2448+
BV->setName(F->getName());
2449+
return mapValue(BV, transFunction(F));
2450+
}
2451+
24442452
case OpConstantPipeStorage:
24452453
{
24462454
auto CPS = static_cast<SPIRVConstantPipeStorage*>(BV);
@@ -2969,13 +2977,6 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
29692977
// function exactly we are calling.
29702978
return mapValue(BV, Call);
29712979
}
2972-
case OpFunctionPointerINTEL: {
2973-
SPIRVFunctionPointerINTEL *BC =
2974-
static_cast<SPIRVFunctionPointerINTEL *>(BV);
2975-
SPIRVFunction* F = BC->getFunction();
2976-
BV->setName(F->getName());
2977-
return mapValue(BV, transFunction(F));
2978-
}
29792980

29802981
case OpExtInst:
29812982
return mapValue(BV, transOCLBuiltinFromExtInst(

IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVFunction.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,30 @@ class SPIRVFunction: public SPIRVValue, public SPIRVComponentExecutionModes {
191191

192192
typedef SPIRVEntryOpCodeOnly<OpFunctionEnd> SPIRVFunctionEnd;
193193

194+
class SPIRVConstFunctionPointerINTEL : public SPIRVValue {
195+
const static Op OC = OpConstFunctionPointerINTEL;
196+
const static SPIRVWord FixedWordCount = 4;
197+
198+
public:
199+
SPIRVConstFunctionPointerINTEL(SPIRVId TheId, SPIRVType* TheType,
200+
SPIRVFunction* TheFunction, SPIRVModule* M)
201+
: SPIRVValue(M, FixedWordCount, OC, TheType, TheId),
202+
TheFunction(TheFunction->getId()) {
203+
validate();
204+
}
205+
SPIRVConstFunctionPointerINTEL()
206+
: SPIRVValue(OC), TheFunction(SPIRVID_INVALID) {}
207+
SPIRVFunction* getFunction() const { return get<SPIRVFunction>(TheFunction); }
208+
_SPIRV_DEF_DEC3_OVERRIDE(Type, Id, TheFunction)
209+
void validate() const override { SPIRVValue::validate(); }
210+
CapVec getRequiredCapability() const override {
211+
return getVec(CapabilityFunctionPointersINTEL);
212+
}
213+
214+
protected:
215+
SPIRVId TheFunction;
216+
};
217+
194218
}
195219

196220
#endif /* SPIRVFUNCTION_HPP_ */

IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVInstruction.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,6 @@ void SPIRVFunctionPointerCallINTEL::validate() const {
136136
SPIRVFunctionCallGeneric::validate();
137137
}
138138

139-
SPIRVFunctionPointerINTEL::SPIRVFunctionPointerINTEL(SPIRVId TheId,
140-
SPIRVType * TheType,
141-
SPIRVFunction * TheFunction,
142-
SPIRVBasicBlock * BB)
143-
: SPIRVInstruction(FixedWordCount, OC, TheType, TheId, BB),
144-
TheFunction(TheFunction->getId()) {
145-
validate();
146-
}
147-
148-
void SPIRVFunctionPointerINTEL::validate() const {
149-
SPIRVInstruction::validate();
150-
}
151-
152139
//Each instruction should implement this function
153140
std::vector<SPIRVValue*>
154141
SPIRVInstruction::getOperands() {

IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVInstruction.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,25 +1165,6 @@ class SPIRVFunctionPointerCallINTEL
11651165
SPIRVId CalledValueId;
11661166
};
11671167

1168-
class SPIRVFunctionPointerINTEL : public SPIRVInstruction {
1169-
const static Op OC = OpFunctionPointerINTEL;
1170-
const static SPIRVWord FixedWordCount = 4;
1171-
public:
1172-
SPIRVFunctionPointerINTEL(SPIRVId TheId, SPIRVType* TheType,
1173-
SPIRVFunction* TheFunction, SPIRVBasicBlock* BB);
1174-
SPIRVFunctionPointerINTEL() : SPIRVInstruction(OC), TheFunction(SPIRVID_INVALID) {}
1175-
SPIRVFunction* getFunction() const { return SPIRVEntry::get<SPIRVFunction>(TheFunction); }
1176-
_SPIRV_DEF_DEC3_OVERRIDE(Type, Id, TheFunction)
1177-
void validate() const override;
1178-
bool isOperandLiteral(unsigned Index) const override { return false; }
1179-
CapVec getRequiredCapability() const override {
1180-
return getVec(CapabilityFunctionPointersINTEL);
1181-
}
1182-
1183-
protected:
1184-
SPIRVId TheFunction;
1185-
};
1186-
11871168
class SPIRVExtInst: public SPIRVFunctionCallGeneric<OpExtInst, 5> {
11881169
public:
11891170
SPIRVExtInst(SPIRVExtInstSetKind SetKind = SPIRVEIS_Count,

IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVOpCode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ inline bool isConstantOpCode(Op OpCode) {
217217
unsigned OC = OpCode;
218218
return (OpConstantTrue <= OC
219219
&& OC <= OpSpecConstantOp)
220-
|| OC == OpUndef;
220+
|| OC == OpUndef || OC == OpConstFunctionPointerINTEL;
221221
}
222222

223223
inline bool isModuleScopeAllowedOpCode(Op OpCode) {

IGC/AdaptorOCL/SPIRV/libSPIRV/SPIRVOpCodeEnum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ _SPIRV_OP(AsmCallINTEL, 5611)
383383
_SPIRV_OP(AssumeTrueINTEL, 5630)
384384
_SPIRV_OP(ExpectINTEL, 5631)
385385
// Function pointers
386-
_SPIRV_OP(FunctionPointerINTEL, 5600)
386+
_SPIRV_OP(ConstFunctionPointerINTEL, 5600)
387387
_SPIRV_OP(FunctionPointerCallINTEL, 5601)
388388
// device_side_avc_motion_estimation extension
389389
_SPIRV_OP(VmeImageINTEL, 5699)

0 commit comments

Comments
 (0)