Skip to content

Commit

Permalink
Support for new SPV_INTEL_fpga_memory_attributes
Browse files Browse the repository at this point in the history
This commit adds StridesizeINTEL, WordsizeINTEL and TrueDualPortINTEL
support to translator.
  • Loading branch information
bwlodarcz committed Oct 31, 2023
1 parent a76f24e commit 5ec56f1
Show file tree
Hide file tree
Showing 9 changed files with 460 additions and 1,451 deletions.
14 changes: 14 additions & 0 deletions lib/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3513,6 +3513,12 @@ void generateIntelFPGAAnnotation(
}
if (E->hasDecorate(DecorationForcePow2DepthINTEL, 0, &Result))
Out << "{force_pow2_depth:" << Result << '}';
if (E->hasDecorate(DecorationStridesizeINTEL, 0, &Result))
Out << "{stride_size:" << Result << "}";
if (E->hasDecorate(DecorationWordsizeINTEL, 0, &Result))
Out << "{word_size:" << Result << "}";
if (E->hasDecorate(DecorationTrueDualPortINTEL))
Out << "{true_dual_port:1}";
if (E->hasDecorate(DecorationBufferLocationINTEL, 0, &Result))
Out << "{sycl-buffer-location:" << Result << '}';
if (E->hasDecorate(DecorationLatencyControlLabelINTEL, 0, &Result))
Expand Down Expand Up @@ -3610,6 +3616,14 @@ void generateIntelFPGAAnnotationForStructMember(
if (E->hasMemberDecorate(DecorationForcePow2DepthINTEL, 0, MemberNumber,
&Result))
Out << "{force_pow2_depth:" << Result << '}';
if (E->hasMemberDecorate(DecorationStridesizeINTEL, 0, MemberNumber,
&Result))
Out << "{stride_size:"<< Result << "}";
if (E->hasMemberDecorate(DecorationWordsizeINTEL, 0, MemberNumber,
&Result))
Out << "{word_size:"<< Result << "}";
if (E->hasMemberDecorate(DecorationTrueDualPortINTEL, 0, MemberNumber))
Out << "{true_dual_port:1}";
if (!AnnotStr.empty())
AnnotStrVec.emplace_back(AnnotStr);

Expand Down
13 changes: 11 additions & 2 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3179,6 +3179,9 @@ AnnotationDecorations tryParseAnnotationString(SPIRVModule *BM,
.Case("bank_bits", DecorationBankBitsINTEL)
.Case("merge", DecorationMergeINTEL)
.Case("force_pow2_depth", DecorationForcePow2DepthINTEL)
.Case("stride_size", DecorationStridesizeINTEL)
.Case("word_size", DecorationWordsizeINTEL)
.Case("true_dual_port", DecorationTrueDualPortINTEL)
.Default(DecorationUserSemantic);
if (Dec == DecorationUserSemantic)
// Restore the braces to translate the whole input string
Expand Down Expand Up @@ -3277,7 +3280,8 @@ void addAnnotationDecorations(SPIRVEntry *E, DecorationsInfoVec &Decorations) {
case DecorationRegisterINTEL:
case DecorationSinglepumpINTEL:
case DecorationDoublepumpINTEL:
case DecorationSimpleDualPortINTEL: {
case DecorationSimpleDualPortINTEL:
case DecorationTrueDualPortINTEL: {
if (M->isAllowedToUseExtension(
ExtensionID::SPV_INTEL_fpga_memory_attributes)) {
M->getErrorLog().checkError(I.second.empty(), SPIRVEC_InvalidLlvmModule,
Expand All @@ -3298,7 +3302,9 @@ void addAnnotationDecorations(SPIRVEntry *E, DecorationsInfoVec &Decorations) {
case DecorationBankwidthINTEL:
case DecorationMaxPrivateCopiesINTEL:
case DecorationMaxReplicatesINTEL:
case DecorationForcePow2DepthINTEL: {
case DecorationForcePow2DepthINTEL:
case DecorationStridesizeINTEL:
case DecorationWordsizeINTEL: {
if (M->isAllowedToUseExtension(
ExtensionID::SPV_INTEL_fpga_memory_attributes)) {
M->getErrorLog().checkError(I.second.size() == 1,
Expand Down Expand Up @@ -3427,6 +3433,7 @@ void addAnnotationDecorationsForStructMember(SPIRVEntry *E,
case DecorationSinglepumpINTEL:
case DecorationDoublepumpINTEL:
case DecorationSimpleDualPortINTEL:
case DecorationTrueDualPortINTEL:
M->getErrorLog().checkError(I.second.empty(), SPIRVEC_InvalidLlvmModule,
"Member decoration takes no arguments.");
E->addMemberDecorate(MemberNumber, I.first);
Expand All @@ -3437,6 +3444,8 @@ void addAnnotationDecorationsForStructMember(SPIRVEntry *E,
// DecorationMaxPrivateCopiesINTEL
// DecorationMaxReplicatesINTEL
// DecorationForcePow2DepthINTEL
// DecorarionStridesizeINTEL
// DecorationWordsizeINTEL
default:
M->getErrorLog().checkError(
I.second.size() == 1, SPIRVEC_InvalidLlvmModule,
Expand Down
6 changes: 6 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVDecorate.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class SPIRVDecorate : public SPIRVDecorateGeneric {
case DecorationMergeINTEL:
case DecorationBankBitsINTEL:
case DecorationForcePow2DepthINTEL:
case DecorationStridesizeINTEL:
case DecorationWordsizeINTEL:
case DecorationTrueDualPortINTEL:
return ExtensionID::SPV_INTEL_fpga_memory_attributes;
case DecorationBurstCoalesceINTEL:
case DecorationCacheSizeINTEL:
Expand Down Expand Up @@ -336,6 +339,9 @@ class SPIRVMemberDecorate : public SPIRVDecorateGeneric {
case DecorationMergeINTEL:
case DecorationBankBitsINTEL:
case DecorationForcePow2DepthINTEL:
case DecorationStridesizeINTEL:
case DecorationWordsizeINTEL:
case DecorationTrueDualPortINTEL:
return ExtensionID::SPV_INTEL_fpga_memory_attributes;
case DecorationBurstCoalesceINTEL:
case DecorationCacheSizeINTEL:
Expand Down
6 changes: 6 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@ template <> inline void SPIRVMap<Decoration, SPIRVCapVec>::init() {
ADD_VEC_INIT(DecorationBankBitsINTEL, {CapabilityFPGAMemoryAttributesINTEL});
ADD_VEC_INIT(DecorationForcePow2DepthINTEL,
{CapabilityFPGAMemoryAttributesINTEL});
ADD_VEC_INIT(DecorationStridesizeINTEL,
{CapabilityFPGAMemoryAttributesINTEL});
ADD_VEC_INIT(DecorationWordsizeINTEL,
{CapabilityFPGAMemoryAttributesINTEL});
ADD_VEC_INIT(DecorationTrueDualPortINTEL,
{CapabilityFPGAMemoryAttributesINTEL});
ADD_VEC_INIT(DecorationReferencedIndirectlyINTEL,
{CapabilityIndirectReferencesINTEL});
ADD_VEC_INIT(DecorationIOPipeStorageINTEL, {CapabilityIOPipesINTEL});
Expand Down
3 changes: 3 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ template <> inline void SPIRVMap<Decoration, std::string>::init() {
add(DecorationMergeINTEL, "MergeINTEL");
add(DecorationBankBitsINTEL, "BankBitsINTEL");
add(DecorationForcePow2DepthINTEL, "ForcePow2DepthINTEL");
add(DecorationStridesizeINTEL, "StridesizeINTEL");
add(DecorationWordsizeINTEL, "WordsizeINTEL");
add(DecorationTrueDualPortINTEL, "TrueDualPortINTEL");
add(DecorationBurstCoalesceINTEL, "BurstCoalesceINTEL");
add(DecorationCacheSizeINTEL, "CacheSizeINTEL");
add(DecorationDontStaticallyCoalesceINTEL, "DontStaticallyCoalesceINTEL");
Expand Down
2 changes: 1 addition & 1 deletion spirv-headers-tag.conf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b8b9eb8640c8c0107ba580fbcb10f969022ca32c
88bc5e321c2839707df8b1ab534e243e00744177
Loading

0 comments on commit 5ec56f1

Please sign in to comment.