@@ -62,23 +62,30 @@ void SPIRVSupportDocsEmitter::emit(raw_ostream &OS) {
6262 OS << " This document lists all SPIR-V extensions supported by IGC and their platform requirements.\n\n " ;
6363 for (const auto &Ext : Extensions) {
6464 OS << " ## " << Ext.Name << " \n\n " ;
65- if (Ext.IsExperimental ) {
66- OS << " > **Note**: The support for this extension is experimental. It has been implemented but has not been "
67- " thoroughly tested "
68- " and should not be used in production environments.\n\n " ;
65+ bool HasProd = (Ext.ProductionSupport != nullptr );
66+ bool HasExp = (Ext.ExperimentalSupport != nullptr );
67+ OS << " **Specification**: " << Ext.SpecURL << " \n\n " ;
68+ // Print explicit extension platform support when not inheriting from capabilities
69+ if (HasProd && Ext.ProductionSupport ->getName () != " InheritFromCapabilities" ) {
70+ OS << " > **Supported on**: " << formatPlatformSupport (Ext.ProductionSupport ) << " \n\n " ;
6971 }
70- OS << " **Specification:** " << Ext.SpecURL << " \n\n " ;
71- if (!Ext.IsInheritFromCapabilitiesMode ) {
72- OS << " **Extension Platform Support:** " << formatPlatformSupport (Ext.Platforms ) << " \n\n " ;
72+ if (HasExp && Ext.ExperimentalSupport ->getName () != " InheritFromCapabilities" ) {
73+ OS << " > **Experimentally supported on**: " << formatPlatformSupport (Ext.ExperimentalSupport ) << " \n\n " ;
7374 }
74- OS << " **Capabilities:** \n\n " ;
75+ OS << " **Capabilities**: \n\n " ;
7576 if (Ext.Capabilities .empty ()) {
7677 OS << " - No capabilities defined\n " ;
7778 } else {
7879 for (const auto &Cap : Ext.Capabilities ) {
7980 OS << " - **" << Cap.Name << " **" ;
80- if (shouldShowCapabilityPlatformSupport (Ext, Cap))
81- OS << " \n - Platform Support: " << formatPlatformSupport (Cap.EffectivePlatform );
81+ if (shouldShowCapabilityPlatformSupport (Ext, Cap)) {
82+ if (Cap.ProductionSupport ) {
83+ OS << " \n > **Supported On**: " << formatPlatformSupport (Cap.ProductionSupport );
84+ }
85+ if (Cap.ExperimentalSupport ) {
86+ OS << " \n > **Experimentally supported on**: " << formatPlatformSupport (Cap.ExperimentalSupport );
87+ }
88+ }
8289 OS << " \n " ;
8390 }
8491 }
@@ -88,7 +95,11 @@ void SPIRVSupportDocsEmitter::emit(raw_ostream &OS) {
8895
8996bool SPIRVSupportDocsEmitter::shouldShowCapabilityPlatformSupport (const ExtensionEntry &Ext,
9097 const CapabilityEntry &Cap) const {
91- if (Ext.IsInheritFromCapabilitiesMode )
98+ // Show capability platform support if extension inherits from capabilities in any variant,
99+ // or if the capability specified explicit support (not InheritFromExtension).
100+ bool ExtInherit = (Ext.ProductionSupport && Ext.ProductionSupport ->getName () == " InheritFromCapabilities" ) ||
101+ (Ext.ExperimentalSupport && Ext.ExperimentalSupport ->getName () == " InheritFromCapabilities" );
102+ if (ExtInherit)
92103 return true ;
93104 const Record *OriginalCapSupport = Cap.Root ->getValueAsDef (" Support" );
94105 return OriginalCapSupport->getName () != " InheritFromExtension" ;
@@ -281,7 +292,7 @@ class SPIRVSupportQueriesEmitter {
281292 void emitGetSupportedInfoFn (raw_ostream &OS);
282293 std::string buildPredicate (const Record *Support, StringRef platformVar);
283294 void emitSingleExtensionSupportIf (raw_ostream &OS, const ExtensionEntry &Ext);
284- void emitSingleCapabilitySupportIf (raw_ostream &OS, StringRef CapName, const Record *Support );
295+ void emitSingleCapabilitySupportIf (raw_ostream &OS, const CapabilityEntry &Cap );
285296 std::string buildAutoExtensionPredicate (const ExtensionEntry &Ext);
286297
287298public:
@@ -321,14 +332,15 @@ void SPIRVSupportQueriesEmitter::emitSPIRVExtensionStructures(raw_ostream &OS) {
321332 OS << " std::string Name;\n " ;
322333 OS << " std::string SpecURL;\n " ;
323334 OS << " std::vector<SPIRVCapability> Capabilities;\n " ;
324- OS << " bool IsExperimental;\n " ;
325335 OS << " };\n\n " ;
326336}
327337
328338void SPIRVSupportQueriesEmitter::emitForwardDecls (raw_ostream &OS) {
329339 OS << " // Forward declarations\n " ;
330- OS << " inline bool isExtensionSupported(const std::string& ExtensionName, PLATFORM Platform);\n " ;
331- OS << " inline bool isCapabilitySupported(const std::string& CapabilityName, PLATFORM Platform);\n\n " ;
340+ OS << " inline bool isExtensionSupported(const std::string& ExtensionName, PLATFORM Platform, bool "
341+ " includeExperimental);\n " ;
342+ OS << " inline bool isCapabilitySupported(const std::string& CapabilityName, PLATFORM Platform, bool "
343+ " includeExperimental);\n\n " ;
332344}
333345
334346void SPIRVSupportQueriesEmitter::emitExtensionsVector (raw_ostream &OS) {
@@ -346,8 +358,7 @@ void SPIRVSupportQueriesEmitter::emitExtensionsVector(raw_ostream &OS) {
346358 OS << " ," ;
347359 OS << " \n " ;
348360 }
349- OS << " },\n " ;
350- OS << " " << (Ext.IsExperimental ? " true" : " false" ) << " \n " ;
361+ OS << " }\n " ;
351362 OS << " }" << (std::next (It) != Extensions.end () ? " ," : " " ) << " \n " ;
352363 }
353364 OS << " };\n\n " ;
@@ -361,49 +372,64 @@ std::string SPIRVSupportQueriesEmitter::buildAutoExtensionPredicate(const Extens
361372 for (const auto &Cap : Ext.Capabilities ) {
362373 if (!First)
363374 Expr += " || " ;
364- Expr += " isCapabilitySupported(\" " + Cap.Name .str () + " \" , Platform)" ;
375+ Expr += " isCapabilitySupported(\" " + Cap.Name .str () + " \" , Platform, includeExperimental )" ;
365376 First = false ;
366377 }
367378 return Expr;
368379}
369380
370381void SPIRVSupportQueriesEmitter::emitSingleExtensionSupportIf (raw_ostream &OS, const ExtensionEntry &Ext) {
371382 OS << " if (ExtensionName == \" " << Ext.Name << " \" ) {\n " ;
372- if (Ext.IsInheritFromCapabilitiesMode ) {
373- OS << " return " << buildAutoExtensionPredicate (Ext) << " ;\n " ;
374- } else {
375- OS << " return " << buildPredicate (Ext.Platforms , " Platform" ) << " ;\n " ;
383+ // Experimental variant (gated by includeExperimental)
384+ if (Ext.ExperimentalSupport ) {
385+ OS << " if (includeExperimental) {\n " ;
386+ if (Ext.ExperimentalSupport ->getName () == " InheritFromCapabilities" ) {
387+ OS << " if (" << buildAutoExtensionPredicate (Ext) << " ) return true;\n " ;
388+ } else {
389+ OS << " if (" << buildPredicate (Ext.ExperimentalSupport , " Platform" ) << " ) return true;\n " ;
390+ }
391+ OS << " }\n " ;
392+ }
393+ // Production variant
394+ if (Ext.ProductionSupport ) {
395+ if (Ext.ProductionSupport ->getName () == " InheritFromCapabilities" ) {
396+ OS << " if (" << buildAutoExtensionPredicate (Ext) << " ) return true;\n " ;
397+ } else {
398+ OS << " if (" << buildPredicate (Ext.ProductionSupport , " Platform" ) << " ) return true;\n " ;
399+ }
376400 }
377401 OS << " }\n " ;
378402}
379403
380- void SPIRVSupportQueriesEmitter::emitSingleCapabilitySupportIf (raw_ostream &OS, StringRef CapName,
381- const Record *Support) {
382- OS << " if (CapabilityName == \" " << CapName << " \" ) {\n " ;
383- OS << " return " << buildPredicate (Support, " Platform" ) << " ;\n " ;
404+ void SPIRVSupportQueriesEmitter::emitSingleCapabilitySupportIf (raw_ostream &OS, const CapabilityEntry &Cap) {
405+ OS << " if (CapabilityName == \" " << Cap.Name << " \" ) {\n " ;
406+ if (Cap.ExperimentalSupport ) {
407+ OS << " if (includeExperimental) {\n " ;
408+ OS << " if (" << buildPredicate (Cap.ExperimentalSupport , " Platform" ) << " ) return true;\n " ;
409+ OS << " }\n " ;
410+ }
411+ if (Cap.ProductionSupport ) {
412+ OS << " if (" << buildPredicate (Cap.ProductionSupport , " Platform" ) << " ) return true;\n " ;
413+ }
384414 OS << " }\n " ;
385415}
386416
387417void SPIRVSupportQueriesEmitter::emitExtensionSupportFn (raw_ostream &OS) {
388418 OS << " // Individual extension/capability query functions\n " ;
389- OS << " inline bool isExtensionSupported(const std::string& ExtensionName, PLATFORM Platform) {\n " ;
419+ OS << " inline bool isExtensionSupported(const std::string& ExtensionName, PLATFORM Platform, bool "
420+ " includeExperimental) {\n " ;
390421 for (const auto &Ext : Extensions)
391422 emitSingleExtensionSupportIf (OS, Ext);
392423 OS << " return false;\n " ;
393424 OS << " }\n\n " ;
394425}
395426
396427void SPIRVSupportQueriesEmitter::emitCapabilitySupportFn (raw_ostream &OS) {
397- OS << " inline bool isCapabilitySupported(const std::string& CapabilityName, PLATFORM Platform) { \n " ;
398- SmallSet<StringRef, 32 > Seen ;
428+ OS << " inline bool isCapabilitySupported(const std::string& CapabilityName, PLATFORM Platform, bool "
429+ " includeExperimental) { \n " ;
399430 for (const auto &Ext : Extensions) {
400431 for (const auto &Cap : Ext.Capabilities ) {
401- if (!Seen.insert (Cap.Name ).second ) {
402- PrintFatalError (Cap.Root ->getLoc (), " Duplicate capability name '" + Cap.Name .str () +
403- " ' encountered in extension '" + Ext.Name .str () +
404- " '. Capability names must be unique." );
405- }
406- emitSingleCapabilitySupportIf (OS, Cap.Name , Cap.EffectivePlatform );
432+ emitSingleCapabilitySupportIf (OS, Cap);
407433 }
408434 }
409435 OS << " return false;\n " ;
@@ -416,16 +442,12 @@ void SPIRVSupportQueriesEmitter::emitGetSupportedInfoFn(raw_ostream &OS) {
416442 " false) {\n " ;
417443 OS << " std::vector<SPIRVExtension> SupportedExtensions;\n " ;
418444 OS << " for (const auto& Ext : AllExtensions) {\n " ;
419- OS << " if (!includeExperimental && Ext.IsExperimental) {\n " ;
420- OS << " continue;\n " ;
421- OS << " }\n " ;
422- OS << " if (isExtensionSupported(Ext.Name, Platform)) {\n " ;
445+ OS << " if (isExtensionSupported(Ext.Name, Platform, includeExperimental)) {\n " ;
423446 OS << " SPIRVExtension SupportedExt;\n " ;
424447 OS << " SupportedExt.Name = Ext.Name;\n " ;
425448 OS << " SupportedExt.SpecURL = Ext.SpecURL;\n " ;
426- OS << " SupportedExt.IsExperimental = Ext.IsExperimental;\n " ;
427449 OS << " for (const auto& Cap : Ext.Capabilities) {\n " ;
428- OS << " if (isCapabilitySupported(Cap.Name, Platform)) {\n " ;
450+ OS << " if (isCapabilitySupported(Cap.Name, Platform, includeExperimental )) {\n " ;
429451 OS << " SupportedExt.Capabilities.push_back(Cap);\n " ;
430452 OS << " }\n " ;
431453 OS << " }\n " ;
0 commit comments