@@ -2317,11 +2317,13 @@ AnnotationDecorations tryParseAnnotationString(SPIRVModule *BM,
2317
2317
RegexIterT DecorationsIt (AnnotatedCode.begin (), AnnotatedCode.end (),
2318
2318
DecorationRegex);
2319
2319
RegexIterT DecorationsEnd;
2320
- // If we didn't find any FPGA specific annotations then add a UserSemantic
2321
- // decoration
2320
+ // If we didn't find any FPGA specific annotations that are seprated as
2321
+ // described above, then add a UserSemantic decoration
2322
2322
if (DecorationsIt == DecorationsEnd)
2323
2323
Decorates.MemoryAttributesVec .emplace_back (DecorationUserSemantic,
2324
2324
AnnotatedCode.str ());
2325
+ bool IntelFPGADecorationFound = false ;
2326
+ DecorationsInfoVec IntelFPGADecorationsVec;
2325
2327
for (; DecorationsIt != DecorationsEnd; ++DecorationsIt) {
2326
2328
// Drop the braces surrounding the actual decoration
2327
2329
const StringRef AnnotatedDecoration = AnnotatedCode.substr (
@@ -2331,12 +2333,14 @@ AnnotationDecorations tryParseAnnotationString(SPIRVModule *BM,
2331
2333
StringRef Name = Split.first , ValueStr = Split.second ;
2332
2334
if (AllowFPGAMemAccesses) {
2333
2335
if (Name == " params" ) {
2336
+ IntelFPGADecorationFound = true ;
2334
2337
unsigned ParamsBitMask = 0 ;
2335
2338
bool Failure = ValueStr.getAsInteger (10 , ParamsBitMask);
2336
2339
assert (!Failure && " Non-integer LSU controls value" );
2337
2340
(void )Failure;
2338
2341
LSUControls.setWithBitMask (ParamsBitMask);
2339
2342
} else if (Name == " cache-size" ) {
2343
+ IntelFPGADecorationFound = true ;
2340
2344
if (!LSUControls.CacheSizeInfo .hasValue ())
2341
2345
continue ;
2342
2346
unsigned CacheSizeValue = 0 ;
@@ -2350,12 +2354,15 @@ AnnotationDecorations tryParseAnnotationString(SPIRVModule *BM,
2350
2354
StringRef Annotation;
2351
2355
Decoration Dec;
2352
2356
if (Name == " pump" ) {
2357
+ IntelFPGADecorationFound = true ;
2353
2358
Dec = llvm::StringSwitch<Decoration>(ValueStr)
2354
2359
.Case (" 1" , DecorationSinglepumpINTEL)
2355
2360
.Case (" 2" , DecorationDoublepumpINTEL);
2356
2361
} else if (Name == " register" ) {
2362
+ IntelFPGADecorationFound = true ;
2357
2363
Dec = DecorationRegisterINTEL;
2358
2364
} else if (Name == " simple_dual_port" ) {
2365
+ IntelFPGADecorationFound = true ;
2359
2366
Dec = DecorationSimpleDualPortINTEL;
2360
2367
} else {
2361
2368
Dec = llvm::StringSwitch<Decoration>(Name)
@@ -2369,14 +2376,25 @@ AnnotationDecorations tryParseAnnotationString(SPIRVModule *BM,
2369
2376
.Case (" force_pow2_depth" , DecorationForcePow2DepthINTEL)
2370
2377
.Default (DecorationUserSemantic);
2371
2378
if (Dec == DecorationUserSemantic)
2372
- Annotation = AnnotatedCode;
2373
- else
2379
+ Annotation = AnnotatedDecoration;
2380
+ else {
2381
+ IntelFPGADecorationFound = true ;
2374
2382
Annotation = ValueStr;
2383
+ }
2375
2384
}
2376
- Decorates. MemoryAttributesVec .emplace_back (Dec, Annotation.str ());
2385
+ IntelFPGADecorationsVec .emplace_back (Dec, Annotation.str ());
2377
2386
}
2378
2387
}
2388
+ // Even if there is an annotation string that is split in blocks like Intel
2389
+ // FPGA annotation, it's not necessarily an FPGA annotation. Translate the
2390
+ // whole string as UserSemantic decoration in this case.
2391
+ if (IntelFPGADecorationFound)
2392
+ Decorates.MemoryAttributesVec = IntelFPGADecorationsVec;
2393
+ else
2394
+ Decorates.MemoryAttributesVec .emplace_back (DecorationUserSemantic,
2395
+ AnnotatedCode.str ());
2379
2396
Decorates.MemoryAccessesVec = LSUControls.getDecorationsFromCurrentState ();
2397
+
2380
2398
return Decorates;
2381
2399
}
2382
2400
0 commit comments