Non-functional: Sweep through the stack for consistent with "main" and entry point.
authorJohn Kessenich <cepheus@frii.com>
Mon, 19 Sep 2016 22:01:41 +0000 (16:01 -0600)
committerJohn Kessenich <cepheus@frii.com>
Mon, 19 Sep 2016 22:01:41 +0000 (16:01 -0600)
Partially addresses issue #513.

26 files changed:
SPIRV/GlslangToSpv.cpp
SPIRV/SpvBuilder.cpp
SPIRV/SpvBuilder.h
Test/baseResults/120.frag.out
Test/baseResults/420.geom.out
Test/baseResults/420_size_gl_in.geom.out
Test/baseResults/430.vert.out
Test/baseResults/440.frag.out
Test/baseResults/440.vert.out
Test/baseResults/450.comp.out
Test/baseResults/badChars.frag.out
Test/baseResults/cppBad.vert.out
Test/baseResults/dce.frag.out
Test/baseResults/errors.frag.out
Test/baseResults/mains1.frag.out
Test/baseResults/noMain.vert.out
Test/baseResults/nonVulkan.frag.out
glslang/Include/revision.h
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/SymbolTable.cpp
glslang/MachineIndependent/linkValidate.cpp
glslang/MachineIndependent/localintermediate.h
glslang/MachineIndependent/preprocessor/PpScanner.cpp
glslang/MachineIndependent/reflection.cpp
hlsl/hlslParseHelper.cpp
hlsl/hlslParseHelper.h

index 4513df8..eab7cec 100755 (executable)
@@ -137,7 +137,7 @@ protected:
     void updateMemberOffset(const glslang::TType& structType, const glslang::TType& memberType, int& currentOffset, int& nextOffset, glslang::TLayoutPacking, glslang::TLayoutMatrix);
     void declareUseOfStructMember(const glslang::TTypeList& members, int glslangMember);
 
-    bool isShaderEntrypoint(const glslang::TIntermAggregate* node);
+    bool isShaderEntryPoint(const glslang::TIntermAggregate* node);
     void makeFunctions(const glslang::TIntermSequence&);
     void makeGlobalInitializers(const glslang::TIntermSequence&);
     void visitFunctions(const glslang::TIntermSequence&);
@@ -713,7 +713,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(const glslang::TIntermediate* gls
     builder.setSource(TranslateSourceLanguage(glslangIntermediate->getSource(), glslangIntermediate->getProfile()), glslangIntermediate->getVersion());
     stdBuiltins = builder.import("GLSL.std.450");
     builder.setMemoryModel(spv::AddressingModelLogical, spv::MemoryModelGLSL450);
-    shaderEntry = builder.makeEntrypoint(glslangIntermediate->getEntryPoint().c_str());
+    shaderEntry = builder.makeEntryPoint(glslangIntermediate->getEntryPoint().c_str());
     entryPoint = builder.addEntryPoint(executionModel, shaderEntry, glslangIntermediate->getEntryPoint().c_str());
 
     // Add the source extensions
@@ -1279,7 +1279,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
             // In all cases, still let the traverser visit the children for us.
             makeFunctions(node->getAsAggregate()->getSequence());
 
-            // Also, we want all globals initializers to go into the entry of main(), before
+            // Also, we want all globals initializers to go into the beginning of the entry point, before
             // anything else gets there, so visit out of order, doing them all now.
             makeGlobalInitializers(node->getAsAggregate()->getSequence());
 
@@ -1313,7 +1313,7 @@ bool TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TInt
     }
     case glslang::EOpFunction:
         if (visit == glslang::EvPreVisit) {
-            if (isShaderEntrypoint(node)) {
+            if (isShaderEntryPoint(node)) {
                 inMain = true;
                 builder.setBuildPoint(shaderEntry->getLastBlock());
             } else {
@@ -2451,7 +2451,7 @@ void TGlslangToSpvTraverser::declareUseOfStructMember(const glslang::TTypeList&
     }
 }
 
-bool TGlslangToSpvTraverser::isShaderEntrypoint(const glslang::TIntermAggregate* node)
+bool TGlslangToSpvTraverser::isShaderEntryPoint(const glslang::TIntermAggregate* node)
 {
     // have to ignore mangling and just look at the base name
     size_t firstOpen = node->getName().find('(');
@@ -2463,7 +2463,7 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
 {
     for (int f = 0; f < (int)glslFunctions.size(); ++f) {
         glslang::TIntermAggregate* glslFunction = glslFunctions[f]->getAsAggregate();
-        if (! glslFunction || glslFunction->getOp() != glslang::EOpFunction || isShaderEntrypoint(glslFunction))
+        if (! glslFunction || glslFunction->getOp() != glslang::EOpFunction || isShaderEntryPoint(glslFunction))
             continue;
 
         // We're on a user function.  Set up the basic interface for the function now,
@@ -2523,7 +2523,7 @@ void TGlslangToSpvTraverser::makeGlobalInitializers(const glslang::TIntermSequen
         if (initializer && initializer->getOp() != glslang::EOpFunction && initializer->getOp() != glslang::EOpLinkerObjects) {
 
             // We're on a top-level node that's not a function.  Treat as an initializer, whose
-            // code goes into the beginning of main.
+            // code goes into the beginning of the entry point.
             initializer->traverse(this);
         }
     }
index 708871e..a881d1b 100644 (file)
@@ -931,7 +931,7 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
 }
 
 // Comments in header
-Function* Builder::makeEntrypoint(const char* entryPoint)
+Function* Builder::makeEntryPoint(const char* entryPoint)
 {
     assert(! mainFunction);
 
index 787d98e..38dc1fa 100755 (executable)
@@ -210,7 +210,7 @@ public:
 
     // Make the entry-point function. The returned pointer is only valid
     // for the lifetime of this builder.
-    Function* makeEntrypoint(const char*);
+    Function* makeEntryPoint(const char*);
 
     // Make a shader-style function, and create its entry block if entry is non-zero.
     // Return the function, pass back the entry.
index 0d10b0e..4fa7600 100644 (file)
@@ -23,7 +23,7 @@ ERROR: 0:84: 'z' : vector field selection out of range
 ERROR: 0:85: 'assign' :  l-value required 
 ERROR: 0:91: 'int' : overloaded functions must have the same return type 
 ERROR: 0:91: 'main' : function already has a body 
-ERROR: 0:91: 'int' :  main function cannot return a value
+ERROR: 0:91: 'int' :  entry point cannot return a value
 ERROR: 0:92: 'main' : function cannot take any parameter(s) 
 ERROR: 0:94: 'a' : variables with qualifier 'const' must be initialized 
 ERROR: 0:97: 'out' : overloaded functions must have the same parameter storage qualifiers for argument 1
index 416df13..625feea 100644 (file)
@@ -132,7 +132,7 @@ ERROR: node is still EOpNull!
 
 Linked geometry stage:
 
-ERROR: Linking geometry stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking geometry stage: Missing entry point: Each stage requires one entry point
 ERROR: Linking geometry stage: At least one shader must specify an output layout primitive
 ERROR: Linking geometry stage: At least one shader must specify a layout(max_vertices = value)
 
index 21d1944..28d09a6 100644 (file)
@@ -39,7 +39,7 @@ ERROR: node is still EOpNull!
 
 Linked geometry stage:
 
-ERROR: Linking geometry stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking geometry stage: Missing entry point: Each stage requires one entry point
 ERROR: Linking geometry stage: At least one shader must specify an output layout primitive
 ERROR: Linking geometry stage: At least one shader must specify a layout(max_vertices = value)
 
index 4b7825b..676fcd3 100644 (file)
@@ -266,7 +266,7 @@ ERROR: node is still EOpNull!
 
 Linked vertex stage:
 
-ERROR: Linking vertex stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
 ERROR: Linking vertex stage: xfb_stride is too small to hold all buffer entries:
 ERROR:     xfb_buffer 3, xfb_stride 64, minimum stride needed: 80
 
index cafd85a..064fe19 100644 (file)
@@ -122,7 +122,7 @@ ERROR: node is still EOpNull!
 
 Linked fragment stage:
 
-ERROR: Linking fragment stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
 
 Shader version: 440
 ERROR: node is still EOpNull!
index 2e1f5fe..022ddec 100644 (file)
@@ -160,7 +160,7 @@ ERROR: node is still EOpNull!
 
 Linked vertex stage:
 
-ERROR: Linking vertex stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
 ERROR: Linking vertex stage: xfb_stride is too small to hold all buffer entries:
 ERROR:     xfb_buffer 0, xfb_stride 92, minimum stride needed: 96
 ERROR: Linking vertex stage: xfb_stride must be multiple of 8 for buffer holding a double:
index d5d1eca..203c4b2 100644 (file)
@@ -9,7 +9,7 @@ local_size = (1, 1, 1)
 
 Linked compute stage:
 
-ERROR: Linking compute stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking compute stage: Missing entry point: Each stage requires one entry point
 
 Shader version: 450
 local_size = (1, 1, 1)
index 37af287..a29b22f 100644 (file)
@@ -17,7 +17,7 @@ ERROR: node is still EOpNull!
 
 Linked fragment stage:
 
-ERROR: Linking fragment stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
 
 Shader version: 100
 ERROR: node is still EOpNull!
index 6938af6..1fb18ec 100755 (executable)
@@ -14,7 +14,7 @@ ERROR: node is still EOpNull!
 
 Linked vertex stage:
 
-ERROR: Linking vertex stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
 
 Shader version: 100
 ERROR: node is still EOpNull!
index a19fe4e..2846abd 100644 (file)
@@ -138,7 +138,7 @@ Shader version: 400
 
 Linked fragment stage:
 
-ERROR: Linking fragment stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
 
 Shader version: 400
 0:? Sequence
index f1e06d2..23f6631 100644 (file)
@@ -1,6 +1,6 @@
 errors.frag
 ERROR: 0:1: 'main' : function cannot take any parameter(s) 
-ERROR: 0:1: 'int' :  main function cannot return a value
+ERROR: 0:1: 'int' :  entry point cannot return a value
 ERROR: 2 compilation errors.  No code generated.
 
 
index 8ba02bf..0b5c2b7 100644 (file)
@@ -42,7 +42,7 @@ output primitive = line_strip
 Linked geometry stage:
 
 ERROR: Linking geometry stage: Contradictory output layout primitives
-ERROR: Linking geometry stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking geometry stage: Missing entry point: Each stage requires one entry point
 ERROR: Linking geometry stage: At least one shader must specify an input layout primitive
 ERROR: Linking geometry stage: At least one shader must specify a layout(max_vertices = value)
 
index 630af95..80a3225 100644 (file)
@@ -23,7 +23,7 @@ ERROR: node is still EOpNull!
 
 Linked vertex stage:
 
-ERROR: Linking vertex stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point
 
 Linked fragment stage:
 
index 10c693c..8e03610 100644 (file)
@@ -18,7 +18,7 @@ ERROR: node is still EOpNull!
 
 Linked fragment stage:
 
-ERROR: Linking fragment stage: Missing entry point: Each stage requires one "void main()" entry point
+ERROR: Linking fragment stage: Missing entry point: Each stage requires one entry point
 
 Shader version: 450
 ERROR: node is still EOpNull!
index 1fc0ca7..2058a25 100644 (file)
@@ -2,5 +2,5 @@
 // For the version, it uses the latest git tag followed by the number of commits.
 // For the date, it uses the current date (when then script is run).
 
-#define GLSLANG_REVISION "Overload400-PrecQual.1495"
+#define GLSLANG_REVISION "Overload400-PrecQual.1496"
 #define GLSLANG_DATE "19-Sep-2016"
index 297ae15..c15d721 100644 (file)
@@ -1058,8 +1058,8 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(const TSourceLoc& loc,
         if (function.getParamCount() > 0)
             error(loc, "function cannot take any parameter(s)", function.getName().c_str(), "");
         if (function.getType().getBasicType() != EbtVoid)
-            error(loc, "", function.getType().getBasicTypeString().c_str(), "main function cannot return a value");
-        intermediate.addMainCount();
+            error(loc, "", function.getType().getBasicTypeString().c_str(), "entry point cannot return a value");
+        intermediate.incrementEntryPointCount();
         inMain = true;
     } else
         inMain = false;
index 630053a..2068f26 100644 (file)
@@ -35,7 +35,7 @@
 //
 
 //
-// Symbol table for parsing.  Most functionaliy and main ideas
+// Symbol table for parsing.  Most functionality and main ideas
 // are documented in the header file.
 //
 
index dbd2f92..9fd93a7 100644 (file)
@@ -81,7 +81,7 @@ void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
         else
             entryPoint = unit.entryPoint;
     }
-    numMains += unit.numMains;
+    numEntryPoints += unit.numEntryPoints;
     numErrors += unit.numErrors;
     numPushConstants += unit.numPushConstants;
     callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
@@ -370,8 +370,8 @@ void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& sy
 //
 void TIntermediate::finalCheck(TInfoSink& infoSink)
 {
-    if (source == EShSourceGlsl && numMains < 1)
-        error(infoSink, "Missing entry point: Each stage requires one \"void main()\" entry point");
+    if (source == EShSourceGlsl && numEntryPoints < 1)
+        error(infoSink, "Missing entry point: Each stage requires one entry point");
 
     if (numPushConstants > 1)
         error(infoSink, "Only one push_constant block is allowed per stage");
index 80deabe..0491bdd 100644 (file)
@@ -137,7 +137,7 @@ class TIntermediate {
 public:
     explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) :
         source(EShSourceNone), language(l), profile(p), version(v), treeRoot(0),
-        numMains(0), numErrors(0), numPushConstants(0), recursive(false),
+        numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
         invocations(TQualifier::layoutNotSet), vertices(TQualifier::layoutNotSet), inputPrimitive(ElgNone), outputPrimitive(ElgNone),
         pixelCenterInteger(false), originUpperLeft(false),
         vertexSpacing(EvsNone), vertexOrder(EvoNone), pointMode(false), earlyFragmentTests(false), depthLayout(EldNone), depthReplacing(false), blendEquations(0),
@@ -173,8 +173,8 @@ public:
 
     void setTreeRoot(TIntermNode* r) { treeRoot = r; }
     TIntermNode* getTreeRoot() const { return treeRoot; }
-    void addMainCount() { ++numMains; }
-    int getNumMains() const { return numMains; }
+    void incrementEntryPointCount() { ++numEntryPoints; }
+    int getNumEntryPoints() const { return numEntryPoints; }
     int getNumErrors() const { return numErrors; }
     void addPushConstantCount() { ++numPushConstants; }
     bool isRecursive() const { return recursive; }
@@ -370,7 +370,7 @@ protected:
     TIntermNode* treeRoot;
     std::set<std::string> requestedExtensions;  // cumulation of all enabled or required extensions; not connected to what subset of the shader used them
     TBuiltInResource resources;
-    int numMains;
+    int numEntryPoints;
     int numErrors;
     int numPushConstants;
     bool recursive;
index d6b76c5..7daebb3 100644 (file)
@@ -696,7 +696,7 @@ int TPpContext::tStringInput::scan(TPpToken* ppToken)
 }
 
 //
-// The main functional entry-point into the preprocessor, which will
+// The main functional entry point into the preprocessor, which will
 // scan the source strings to figure out and return the next processing token.
 //
 // Return string pointer to next token.
index d3e04af..3082647 100644 (file)
@@ -48,7 +48,7 @@
 //
 // High-level algorithm for one stage:
 //
-// 1. Put main() on list of live functions.
+// 1. Put the entry point on the list of live functions.
 //
 // 2. Traverse any live function, while skipping if-tests with a compile-time constant
 //    condition of false, and while adding any encountered function calls to the live
@@ -59,7 +59,7 @@
 // 3. Add any encountered uniform variables and blocks to the reflection database.
 //
 // Can be attempted with a failed link, but will return false if recursion had been detected, or
-// there wasn't exactly one main.
+// there wasn't exactly one entry point.
 //
 
 namespace glslang {
@@ -83,7 +83,7 @@ public:
     virtual void visitSymbol(TIntermSymbol* base);
     virtual bool visitSelection(TVisit, TIntermSelection* node);
 
-    // Track live funtions as well as uniforms, so that we don't visit dead functions
+    // Track live functions as well as uniforms, so that we don't visit dead functions
     // and only visit each function once.
     void addFunctionCall(TIntermAggregate* call)
     {
@@ -717,12 +717,12 @@ bool TLiveTraverser::visitSelection(TVisit /* visit */,  TIntermSelection* node)
 // Returns false if the input is too malformed to do this.
 bool TReflection::addStage(EShLanguage, const TIntermediate& intermediate)
 {
-    if (intermediate.getNumMains() != 1 || intermediate.isRecursive())
+    if (intermediate.getNumEntryPoints() != 1 || intermediate.isRecursive())
         return false;
 
     TLiveTraverser it(intermediate, *this);
 
-    // put main() on functions to process
+    // put the entry point on functions to process
     it.pushFunction("main(");
 
     // process all the functions
index 5504d1f..edbb706 100755 (executable)
@@ -704,7 +704,7 @@ TIntermTyped* HlslParseContext::handleDotDereference(const TSourceLoc& loc, TInt
 // E.g., pipeline inputs to the vertex stage and outputs from the fragment stage.
 bool HlslParseContext::shouldFlatten(const TType& type) const
 {
-    if (! inEntrypoint)
+    if (! inEntryPoint)
         return false;
 
     const TStorageQualifier qualifier = type.getQualifier().storage;
@@ -850,16 +850,16 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
         currentFunctionType = new TType(EbtVoid);
     functionReturnsValue = false;
 
-    inEntrypoint = (function.getName() == intermediate.getEntryPoint().c_str());
-    if (inEntrypoint) {
-        remapEntrypointIO(function);
+    inEntryPoint = (function.getName() == intermediate.getEntryPoint().c_str());
+    if (inEntryPoint) {
+        remapEntryPointIO(function);
         if (entryPointOutput) {
             if (shouldFlatten(entryPointOutput->getType()))
                 flatten(*entryPointOutput);
             assignLocations(*entryPointOutput);
         }
     } else
-        remapNonEntrypointIO(function);
+        remapNonEntryPointIO(function);
 
     //
     // New symbol table scope for body of function plus its arguments
@@ -885,7 +885,7 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
                 error(loc, "redefinition", variable->getName().c_str(), "");
             else {
                 // get IO straightened out
-                if (inEntrypoint) {
+                if (inEntryPoint) {
                     if (shouldFlatten(*param.type))
                         flatten(*variable);
                     assignLocations(*variable);
@@ -925,7 +925,7 @@ void HlslParseContext::handleFunctionBody(const TSourceLoc& loc, TFunction& func
 // AST I/O is done through shader globals declared in the 'in' or 'out'
 // storage class.  An HLSL entry point has a return value, input parameters
 // and output parameters.  These need to get remapped to the AST I/O.
-void HlslParseContext::remapEntrypointIO(TFunction& function)
+void HlslParseContext::remapEntryPointIO(TFunction& function)
 {
     // Will auto-assign locations here to the inputs/outputs defined by the entry point
 
@@ -969,7 +969,7 @@ void HlslParseContext::remapEntrypointIO(TFunction& function)
 
 // An HLSL function that looks like an entry point, but is not,
 // declares entry point IO built-ins, but these have to be undone.
-void HlslParseContext::remapNonEntrypointIO(TFunction& function)
+void HlslParseContext::remapNonEntryPointIO(TFunction& function)
 {
     const auto remapBuiltInType = [&](TType& type) { type.getQualifier().builtIn = EbvNone; };
 
@@ -1007,7 +1007,7 @@ TIntermNode* HlslParseContext::handleReturnValue(const TSourceLoc& loc, TIntermT
     // assignment subtree, and the second part being a return with no value.
     //
     // Otherwise, for a non entry point, just return a return statement.
-    if (inEntrypoint) {
+    if (inEntryPoint) {
         assert(entryPointOutput != nullptr); // should have been error tested at the beginning
         TIntermSymbol* left = new TIntermSymbol(entryPointOutput->getUniqueId(), entryPointOutput->getName(),
                                                 entryPointOutput->getType());
index d963584..ea76341 100755 (executable)
@@ -90,8 +90,8 @@ public:
     TFunction& handleFunctionDeclarator(const TSourceLoc&, TFunction& function, bool prototype);
     TIntermAggregate* handleFunctionDefinition(const TSourceLoc&, TFunction&);
     void handleFunctionBody(const TSourceLoc&, TFunction&, TIntermNode* functionBody, TIntermNode*& node);
-    void remapEntrypointIO(TFunction& function);
-    void remapNonEntrypointIO(TFunction& function);
+    void remapEntryPointIO(TFunction& function);
+    void remapNonEntryPointIO(TFunction& function);
     TIntermNode* handleReturnValue(const TSourceLoc&, TIntermTyped*);
     void handleFunctionArgument(TFunction*, TIntermTyped*& arguments, TIntermTyped* newArg);
     TIntermTyped* handleAssign(const TSourceLoc&, TOperator, TIntermTyped* left, TIntermTyped* right) const;
@@ -185,7 +185,7 @@ protected:
     int structNestingLevel;      // 0 if outside blocks and structures
     int controlFlowNestingLevel; // 0 if outside all flow control
     TList<TIntermSequence*> switchSequenceStack;  // case, node, case, case, node, ...; ensure only one node between cases;   stack of them for nesting
-    bool inEntrypoint;           // if inside a function, true if the function is the entry point
+    bool inEntryPoint;           // if inside a function, true if the function is the entry point
     bool postMainReturn;         // if inside a function, true if the function is the entry point and this is after a return statement
     const TType* currentFunctionType;  // the return type of the function that's currently being parsed
     bool functionReturnsValue;   // true if a non-void function has a return