Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriPlyakhin committed Oct 10, 2024
1 parent 38db490 commit 1b4c844
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/LLVMSPIRVExtensions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,4 @@ EXT(SPV_INTEL_subgroup_requirements)
EXT(SPV_INTEL_task_sequence)
EXT(SPV_INTEL_maximum_registers)
EXT(SPV_INTEL_bindless_images)
EXT(SPV_INTEL_2d_block_io)
24 changes: 24 additions & 0 deletions lib/SPIRV/SPIRVUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,30 @@ class SPIRVFriendlyIRMangleInfo : public BuiltinFuncMangleInfo {
case internal::OpConvertHandleToSampledImageINTEL:
addUnsignedArg(0);
break;
case internal::OpSubgroup2DBlockLoadINTEL:
case internal::OpSubgroup2DBlockLoadTransposeINTEL:
case internal::OpSubgroup2DBlockLoadTransformINTEL:
addUnsignedArgs(0, 3);
setArgAttr(4, SPIR::ATTR_GLOBAL);
addVoidPtrArg(4);
addUnsignedArgs(5, 8);
setArgAttr(9, SPIR::ATTR_PRIVATE);
addVoidPtrArg(9);
break;
case internal::OpSubgroup2DBlockPrefetchINTEL:
addUnsignedArgs(0, 3);
setArgAttr(4, SPIR::ATTR_GLOBAL);
addVoidPtrArg(4);
addUnsignedArgs(5, 8);
break;
case internal::OpSubgroup2DBlockStoreINTEL:
addUnsignedArgs(0, 3);
setArgAttr(4, SPIR::ATTR_PRIVATE);
addVoidPtrArg(4);
setArgAttr(5, SPIR::ATTR_GLOBAL);
addVoidPtrArg(5);
addUnsignedArgs(6, 9);
break;
default:;
// No special handling is needed
}
Expand Down
39 changes: 39 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -4195,5 +4195,44 @@ _SPIRV_OP(ConvertHandleToSamplerINTEL)
_SPIRV_OP(ConvertHandleToSampledImageINTEL)
#undef _SPIRV_OP

class SPIRVSubgroup2DBlockIOINTELInstBase : public SPIRVInstTemplateBase {
public:
std::optional<ExtensionID> getRequiredExtension() const override {
return ExtensionID::SPV_INTEL_2d_block_io;
}
SPIRVCapVec getRequiredCapability() const override {
return getVec(internal::Subgroup2DBlockIOINTEL);
}
};

class SPIRVSubgroup2DBlockLoadINTELInst : public SPIRVSubgroup2DBlockIOINTELInstBase {
protected:
void validate() const override {
SPIRVInstruction::validate();
std::string InstName = "Subgroup2DBlockLoadINTEL";
SPIRVErrorLog &SPVErrLog = this->getModule()->getErrorLog();

SPVErrLog.checkError(
this->isOperandLiteral(0), SPIRVEC_InvalidInstruction,
InstName + "\nElement Size must be a constant instructions with scalar 32-bit integer type\n");
SPVErrLog.checkError(
this->isOperandLiteral(1), SPIRVEC_InvalidInstruction,
InstName + "\nBlock Width must be a constant instructions with scalar 32-bit integer type\n");
SPVErrLog.checkError(
this->isOperandLiteral(2), SPIRVEC_InvalidInstruction,
InstName + "\nBlock Height must be a constant instructions with scalar 32-bit integer type\n");
SPVErrLog.checkError(
this->isOperandLiteral(3), SPIRVEC_InvalidInstruction,
InstName + "\nElement Size must be a constant instructions with scalar 32-bit integer type\n");
}
};

#define _SPIRV_OP(x, ...) \
typedef SPIRVInstTemplate<SPIRVSubgroup2DBlockLoadINTELInst, \
internal::Op##x##INTEL, __VA_ARGS__> \
SPIRV##x##INTEL;
_SPIRV_OP(Subgroup2DBlockLoad, true, 11)
#undef _SPIRV_OP

} // namespace SPIRV
#endif // SPIRV_LIBSPIRV_SPIRVINSTRUCTION_H

0 comments on commit 1b4c844

Please sign in to comment.