Ver Fonte

auto option rank: initial commit. possible top-down implementation startup point.

Signed-off-by: Vivien Oddou <[email protected]>
Vivien Oddou há 2 anos atrás
pai
commit
f45fa443b1

+ 25 - 0
src/AzslcIntermediateRepresentation.cpp

@@ -951,4 +951,29 @@ namespace AZ::ShaderCompiler
         return memberList[memberList.size() - 1];
     }
 
+    void IntermediateRepresentation::AnalyzeOptionRanks()
+    {
+        // loop over variables
+        for (auto& [uid, varInfo, kindInfo] : m_symbols.GetOrderedSymbolsOfSubType_3<VarInfo>())
+        {
+            // only options
+            if (varInfo->CheckHasStorageFlag(StorageFlag::Option))
+            {
+                int impactScore = 0;
+                // loop over appearances over the program
+                for (Seenat& ref : kindInfo->GetSeenats())
+                {
+                    // determine an impact score
+                    impactScore += AnalyzeImpact(ref.m_where);
+                }
+            }
+        }
+    }
+
+    int IntermediateRepresentation::AnalyzeImpact(TokensLocation const& location)
+    {
+        // find the node at location:
+        return 0;
+    }
+
 }  // end of namespace AZ::ShaderCompiler

+ 6 - 0
src/AzslcIntermediateRepresentation.h

@@ -305,6 +305,12 @@ namespace AZ::ShaderCompiler
         // If @structUid is not struct or class, then it returns nullptr.
         IdentifierUID GetLastMemberVariable(const IdentifierUID& structUid);
 
+        //! Determine a heurisitcal global order between options in the program, using "impacted code size" static analysis.
+        void AnalyzeOptionRanks();
+
+        //! Estimate a score proportional to how much code is "child" to the AST node at `location`
+        int AnalyzeImpact(TokensLocation const& location);
+
         // the maps of all variables, functions, etc, from the source code (things with declarations and a name).
         SymbolAggregator      m_symbols;
         // stateful helper during parsing