blob: 911a8f2fd4ef3a78af3f200df4a9096d26136a57 [file] [log] [blame]
alokp@chromium.org07620a52010-09-23 17:53:56 +00001//
Jamie Madill88f6e942014-02-19 10:27:53 -05002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
alokp@chromium.org07620a52010-09-23 17:53:56 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
Jamie Madilld4a3a312014-06-25 16:04:56 -04007#include "compiler/translator/Compiler.h"
Corentin Wallez71d147f2015-02-11 11:15:24 -08008#include "compiler/translator/CallDAG.h"
Geoff Lang17732822013-08-29 13:46:49 -04009#include "compiler/translator/ForLoopUnroll.h"
10#include "compiler/translator/Initialize.h"
Geoff Lang17732822013-08-29 13:46:49 -040011#include "compiler/translator/InitializeParseContext.h"
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080012#include "compiler/translator/InitializeVariables.h"
Jamie Madill6b9cb252013-10-17 10:45:47 -040013#include "compiler/translator/ParseContext.h"
Olli Etuahoc6833112015-04-22 15:15:54 +030014#include "compiler/translator/PruneEmptyDeclarations.h"
Zhenyao Moe740add2014-07-18 17:01:01 -070015#include "compiler/translator/RegenerateStructNames.h"
Olli Etuaho5c407bb2015-06-01 12:20:39 +030016#include "compiler/translator/RemovePow.h"
Geoff Lang17732822013-08-29 13:46:49 -040017#include "compiler/translator/RenameFunction.h"
Zhenyao Mocd68fe72014-07-11 10:45:44 -070018#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
Zhenyao Mo7cab38b2013-10-15 12:59:30 -070019#include "compiler/translator/UnfoldShortCircuitAST.h"
Geoff Lang17732822013-08-29 13:46:49 -040020#include "compiler/translator/ValidateLimitations.h"
21#include "compiler/translator/ValidateOutputs.h"
22#include "compiler/translator/VariablePacker.h"
23#include "compiler/translator/depgraph/DependencyGraph.h"
24#include "compiler/translator/depgraph/DependencyGraphOutput.h"
25#include "compiler/translator/timing/RestrictFragmentShaderTiming.h"
26#include "compiler/translator/timing/RestrictVertexShaderTiming.h"
shannon.woods@transgaming.comda1ed362013-01-25 21:54:57 +000027#include "third_party/compiler/ArrayBoundsClamper.h"
Jamie Madill183bde52014-07-02 15:31:19 -040028#include "angle_gl.h"
Jamie Madillaa72d782014-07-02 15:31:19 -040029#include "common/utilities.h"
alokp@chromium.org07620a52010-09-23 17:53:56 +000030
Jamie Madill5508f392014-02-20 13:31:36 -050031bool IsWebGLBasedSpec(ShShaderSpec spec)
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +000032{
Zhenyao Modb9b40b2014-10-29 15:00:04 -070033 return (spec == SH_WEBGL_SPEC ||
34 spec == SH_CSS_SHADERS_SPEC ||
35 spec == SH_WEBGL2_SPEC);
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +000036}
37
Qingqing Dengad0d0792015-04-08 14:25:06 -070038bool IsGLSL130OrNewer(ShShaderOutput output)
39{
40 return (output == SH_GLSL_130_OUTPUT ||
41 output == SH_GLSL_410_CORE_OUTPUT ||
42 output == SH_GLSL_420_CORE_OUTPUT);
43}
44
Zhenyao Mo7faf1a12014-04-25 18:03:56 -070045size_t GetGlobalMaxTokenSize(ShShaderSpec spec)
Jamie Madill88f6e942014-02-19 10:27:53 -050046{
Jamie Madill88f6e942014-02-19 10:27:53 -050047 // WebGL defines a max token legnth of 256, while ES2 leaves max token
48 // size undefined. ES3 defines a max size of 1024 characters.
Zhenyao Modb9b40b2014-10-29 15:00:04 -070049 switch (spec)
Jamie Madill88f6e942014-02-19 10:27:53 -050050 {
Zhenyao Modb9b40b2014-10-29 15:00:04 -070051 case SH_WEBGL_SPEC:
52 case SH_CSS_SHADERS_SPEC:
Jamie Madill88f6e942014-02-19 10:27:53 -050053 return 256;
Zhenyao Modb9b40b2014-10-29 15:00:04 -070054 default:
Jamie Madill88f6e942014-02-19 10:27:53 -050055 return 1024;
56 }
57}
58
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +000059namespace {
Zhenyao Modb9b40b2014-10-29 15:00:04 -070060
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080061class TScopedPoolAllocator
62{
63 public:
64 TScopedPoolAllocator(TPoolAllocator* allocator) : mAllocator(allocator)
65 {
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -040066 mAllocator->push();
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +000067 SetGlobalPoolAllocator(mAllocator);
68 }
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080069 ~TScopedPoolAllocator()
70 {
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +000071 SetGlobalPoolAllocator(NULL);
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -040072 mAllocator->pop();
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +000073 }
74
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080075 private:
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +000076 TPoolAllocator* mAllocator;
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -040077};
78
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080079class TScopedSymbolTableLevel
80{
81 public:
82 TScopedSymbolTableLevel(TSymbolTable* table) : mTable(table)
83 {
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -040084 ASSERT(mTable->atBuiltInLevel());
85 mTable->push();
86 }
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080087 ~TScopedSymbolTableLevel()
88 {
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -040089 while (!mTable->atBuiltInLevel())
90 mTable->pop();
91 }
92
Zhenyao Mo4a667fe2014-02-11 12:35:01 -080093 private:
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -040094 TSymbolTable* mTable;
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +000095};
Zhenyao Modb9b40b2014-10-29 15:00:04 -070096
97int MapSpecToShaderVersion(ShShaderSpec spec)
98{
99 switch (spec)
100 {
101 case SH_GLES2_SPEC:
102 case SH_WEBGL_SPEC:
103 case SH_CSS_SHADERS_SPEC:
104 return 100;
105 case SH_GLES3_SPEC:
106 case SH_WEBGL2_SPEC:
107 return 300;
108 default:
109 UNREACHABLE();
110 return 0;
111 }
112}
113
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000114} // namespace
115
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800116TShHandleBase::TShHandleBase()
117{
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000118 allocator.push();
119 SetGlobalPoolAllocator(&allocator);
120}
121
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800122TShHandleBase::~TShHandleBase()
123{
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000124 SetGlobalPoolAllocator(NULL);
125 allocator.popAll();
126}
127
Jamie Madill183bde52014-07-02 15:31:19 -0400128TCompiler::TCompiler(sh::GLenum type, ShShaderSpec spec, ShShaderOutput output)
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000129 : shaderType(type),
zmo@google.comf420c422011-09-12 18:27:59 +0000130 shaderSpec(spec),
Jamie Madill68fe74a2014-05-27 12:56:01 -0400131 outputType(output),
Jamie Madilleb1a0102013-07-08 13:31:38 -0400132 maxUniformVectors(0),
133 maxExpressionComplexity(0),
134 maxCallStackDepth(0),
shannon.woods%transgaming.com@gtempaccount.comcbb6b6a2013-04-13 03:27:47 +0000135 fragmentPrecisionHigh(false),
shannon.woods@transgaming.com1d432bb2013-01-25 21:57:28 +0000136 clampingStrategy(SH_CLAMP_WITH_CLAMP_INTRINSIC),
Olli Etuaho8efc5ad2015-03-03 17:21:10 +0200137 builtInFunctionEmulator(),
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200138 mSourcePath(NULL)
alokp@chromium.org4888ceb2010-10-01 21:13:12 +0000139{
140}
141
142TCompiler::~TCompiler()
143{
144}
145
146bool TCompiler::Init(const ShBuiltInResources& resources)
alokp@chromium.org07620a52010-09-23 17:53:56 +0000147{
shannon.woods%transgaming.com@gtempaccount.com0bbed382013-04-13 03:38:07 +0000148 shaderVersion = 100;
Jamie Madill183bde52014-07-02 15:31:19 -0400149 maxUniformVectors = (shaderType == GL_VERTEX_SHADER) ?
gman@chromium.org8d804792012-10-17 21:33:48 +0000150 resources.MaxVertexUniformVectors :
151 resources.MaxFragmentUniformVectors;
Jamie Madilleb1a0102013-07-08 13:31:38 -0400152 maxExpressionComplexity = resources.MaxExpressionComplexity;
153 maxCallStackDepth = resources.MaxCallStackDepth;
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -0400154
155 SetGlobalPoolAllocator(&allocator);
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000156
alokp@chromium.org07620a52010-09-23 17:53:56 +0000157 // Generate built-in symbol table.
158 if (!InitBuiltInSymbolTable(resources))
159 return false;
alokp@chromium.org07620a52010-09-23 17:53:56 +0000160 InitExtensionBehavior(resources, extensionBehavior);
shannon.woods%transgaming.com@gtempaccount.comcbb6b6a2013-04-13 03:27:47 +0000161 fragmentPrecisionHigh = resources.FragmentPrecisionHigh == 1;
alokp@chromium.orgbafcbaa2010-11-23 19:07:43 +0000162
shannon.woods@transgaming.com1d432bb2013-01-25 21:57:28 +0000163 arrayBoundsClamper.SetClampingStrategy(resources.ArrayIndexClampingStrategy);
164 clampingStrategy = resources.ArrayIndexClampingStrategy;
165
daniel@transgaming.comc23f4612012-11-28 19:42:57 +0000166 hashFunction = resources.HashFunction;
167
alokp@chromium.org07620a52010-09-23 17:53:56 +0000168 return true;
169}
170
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200171TIntermNode *TCompiler::compileTreeForTesting(const char* const shaderStrings[],
172 size_t numStrings, int compileOptions)
alokp@chromium.org07620a52010-09-23 17:53:56 +0000173{
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200174 return compileTreeImpl(shaderStrings, numStrings, compileOptions);
175}
176
177TIntermNode *TCompiler::compileTreeImpl(const char* const shaderStrings[],
178 size_t numStrings, int compileOptions)
179{
alokp@chromium.org07620a52010-09-23 17:53:56 +0000180 clearResults();
181
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200182 ASSERT(numStrings > 0);
183 ASSERT(GetGlobalPoolAllocator());
alokp@chromium.org07620a52010-09-23 17:53:56 +0000184
David Yen0fbd1282015-02-02 14:46:09 -0800185 // Reset the extension behavior for each compilation unit.
186 ResetExtensionBehavior(extensionBehavior);
187
alokp@chromium.orgb59a7782010-11-24 18:38:33 +0000188 // If compiling for WebGL, validate loop and indexing as well.
Jamie Madill5508f392014-02-20 13:31:36 -0500189 if (IsWebGLBasedSpec(shaderSpec))
alokp@chromium.orgb59a7782010-11-24 18:38:33 +0000190 compileOptions |= SH_VALIDATE_LOOP_INDEXING;
alokp@chromium.org1f299542010-11-12 15:50:23 +0000191
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000192 // First string is path of source file if flag is set. The actual source follows.
shannon.woods@transgaming.comd64b3da2013-02-28 23:19:26 +0000193 size_t firstSource = 0;
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000194 if (compileOptions & SH_SOURCE_PATH)
195 {
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200196 mSourcePath = shaderStrings[0];
apatrick@chromium.org0f4cefe2011-01-26 19:30:57 +0000197 ++firstSource;
198 }
199
Olli Etuaho853dc1a2014-11-06 17:25:48 +0200200 bool debugShaderPrecision = getResources().WEBGL_debug_shader_precision == 1;
alokp@chromium.org07620a52010-09-23 17:53:56 +0000201 TIntermediate intermediate(infoSink);
202 TParseContext parseContext(symbolTable, extensionBehavior, intermediate,
zmo@google.comdc4b4f82011-06-17 00:42:53 +0000203 shaderType, shaderSpec, compileOptions, true,
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200204 infoSink, debugShaderPrecision);
Olli Etuaho853dc1a2014-11-06 17:25:48 +0200205
Jamie Madill6e06b1f2015-05-14 10:01:17 -0400206 parseContext.setFragmentPrecisionHigh(fragmentPrecisionHigh);
Alok Priyadarshi8156b6b2013-09-23 14:56:58 -0400207 SetGlobalParseContext(&parseContext);
alokp@chromium.org07620a52010-09-23 17:53:56 +0000208
209 // We preserve symbols at the built-in level from compile-to-compile.
210 // Start pushing the user-defined symbols at global level.
Alok Priyadarshibc3f1ac2013-09-23 14:57:02 -0400211 TScopedSymbolTableLevel scopedSymbolLevel(&symbolTable);
alokp@chromium.org07620a52010-09-23 17:53:56 +0000212
213 // Parse shader.
214 bool success =
Jamie Madill6e06b1f2015-05-14 10:01:17 -0400215 (PaParseStrings(numStrings - firstSource, &shaderStrings[firstSource], nullptr, &parseContext) == 0) &&
216 (parseContext.getTreeRoot() != nullptr);
shannon.woods%transgaming.com@gtempaccount.com0bbed382013-04-13 03:38:07 +0000217
shannon.woods%transgaming.com@gtempaccount.com5524db02013-04-13 03:38:16 +0000218 shaderVersion = parseContext.getShaderVersion();
Zhenyao Modb9b40b2014-10-29 15:00:04 -0700219 if (success && MapSpecToShaderVersion(shaderSpec) < shaderVersion)
220 {
221 infoSink.info.prefix(EPrefixError);
222 infoSink.info << "unsupported shader version";
223 success = false;
224 }
shannon.woods%transgaming.com@gtempaccount.com0bbed382013-04-13 03:38:07 +0000225
Jamie Madill6e06b1f2015-05-14 10:01:17 -0400226 TIntermNode *root = nullptr;
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200227
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800228 if (success)
229 {
Zhenyao Mo94ac7b72014-10-15 18:22:08 -0700230 mPragma = parseContext.pragma();
231 if (mPragma.stdgl.invariantAll)
232 {
233 symbolTable.setGlobalInvariant();
234 }
235
Jamie Madill6e06b1f2015-05-14 10:01:17 -0400236 root = parseContext.getTreeRoot();
alokp@chromium.orgb59a7782010-11-24 18:38:33 +0000237 success = intermediate.postProcess(root);
238
Jamie Madill6654bc92014-03-26 14:01:57 -0400239 // Disallow expressions deemed too complex.
240 if (success && (compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY))
241 success = limitExpressionComplexity(root);
242
Corentin Wallez71d147f2015-02-11 11:15:24 -0800243 // Create the function DAG and check there is no recursion
zmo@google.comb1762df2011-07-30 02:04:23 +0000244 if (success)
Corentin Wallez71d147f2015-02-11 11:15:24 -0800245 success = initCallDag(root);
246
247 if (success && (compileOptions & SH_LIMIT_CALL_STACK_DEPTH))
248 success = checkCallDepth();
249
250 // Checks which functions are used and if "main" exists
251 if (success)
252 {
253 functionMetadata.clear();
254 functionMetadata.resize(mCallDag.size());
255 success = tagUsedFunctions();
256 }
zmo@google.comb1762df2011-07-30 02:04:23 +0000257
Corentin Walleza094a8a2015-04-07 11:53:06 -0700258 if (success && !(compileOptions & SH_DONT_PRUNE_UNUSED_FUNCTIONS))
259 success = pruneUnusedFunctions(root);
260
Olli Etuahoc6833112015-04-22 15:15:54 +0300261 // Prune empty declarations to work around driver bugs and to keep declaration output simple.
262 if (success)
263 PruneEmptyDeclarations(root);
264
Jamie Madill183bde52014-07-02 15:31:19 -0400265 if (success && shaderVersion == 300 && shaderType == GL_FRAGMENT_SHADER)
Jamie Madill05a80ce2013-06-20 11:55:49 -0400266 success = validateOutputs(root);
267
alokp@chromium.orgb59a7782010-11-24 18:38:33 +0000268 if (success && (compileOptions & SH_VALIDATE_LOOP_INDEXING))
269 success = validateLimitations(root);
alokp@chromium.org07620a52010-09-23 17:53:56 +0000270
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000271 if (success && (compileOptions & SH_TIMING_RESTRICTIONS))
maxvujovic@gmail.com77222c92012-06-04 21:06:05 +0000272 success = enforceTimingRestrictions(root, (compileOptions & SH_DEPENDENCY_GRAPH) != 0);
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000273
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000274 if (success && shaderSpec == SH_CSS_SHADERS_SPEC)
275 rewriteCSSShader(root);
276
zmo@google.com0c6bb7a2011-08-17 19:39:58 +0000277 // Unroll for-loop markup needs to happen after validateLimitations pass.
278 if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX))
Zhenyao Mo3cdfcce2014-03-07 13:00:08 -0800279 {
280 ForLoopUnrollMarker marker(ForLoopUnrollMarker::kIntegerIndex);
Zhenyao Mo550c6002014-02-26 15:40:48 -0800281 root->traverse(&marker);
282 }
283 if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX))
Zhenyao Mo3cdfcce2014-03-07 13:00:08 -0800284 {
285 ForLoopUnrollMarker marker(ForLoopUnrollMarker::kSamplerArrayIndex);
Zhenyao Mo550c6002014-02-26 15:40:48 -0800286 root->traverse(&marker);
287 if (marker.samplerArrayIndexIsFloatLoopIndex())
288 {
289 infoSink.info.prefix(EPrefixError);
290 infoSink.info << "sampler array index is float loop index";
291 success = false;
292 }
293 }
zmo@google.com0c6bb7a2011-08-17 19:39:58 +0000294
zmo@google.com32e97312011-08-24 01:03:11 +0000295 // Built-in function emulation needs to happen after validateLimitations pass.
Olli Etuaho8efc5ad2015-03-03 17:21:10 +0200296 if (success)
297 {
298 initBuiltInFunctionEmulator(&builtInFunctionEmulator, compileOptions);
zmo@google.com32e97312011-08-24 01:03:11 +0000299 builtInFunctionEmulator.MarkBuiltInFunctionsForEmulation(root);
Olli Etuaho8efc5ad2015-03-03 17:21:10 +0200300 }
zmo@google.com32e97312011-08-24 01:03:11 +0000301
daniel@transgaming.com4167cc92013-01-11 04:11:53 +0000302 // Clamping uniform array bounds needs to happen after validateLimitations pass.
303 if (success && (compileOptions & SH_CLAMP_INDIRECT_ARRAY_BOUNDS))
304 arrayBoundsClamper.MarkIndirectArrayBoundsForClamping(root);
305
Jamie Madill183bde52014-07-02 15:31:19 -0400306 if (success && shaderType == GL_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION))
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800307 initializeGLPosition(root);
Zhenyao Moac44cd22013-09-23 14:57:09 -0400308
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800309 if (success && (compileOptions & SH_UNFOLD_SHORT_CIRCUIT))
310 {
Zhenyao Mo7cab38b2013-10-15 12:59:30 -0700311 UnfoldShortCircuitAST unfoldShortCircuit;
312 root->traverse(&unfoldShortCircuit);
313 unfoldShortCircuit.updateTree();
314 }
315
Olli Etuaho5c407bb2015-06-01 12:20:39 +0300316 if (success && (compileOptions & SH_REMOVE_POW_WITH_CONSTANT_EXPONENT))
317 {
318 RemovePow(root);
319 }
320
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800321 if (success && (compileOptions & SH_VARIABLES))
322 {
Zhenyao Mo74da9f22013-09-23 14:57:01 -0400323 collectVariables(root);
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800324 if (compileOptions & SH_ENFORCE_PACKING_RESTRICTIONS)
325 {
gman@chromium.org8d804792012-10-17 21:33:48 +0000326 success = enforcePackingRestrictions();
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800327 if (!success)
328 {
Jamie Madill075edd82013-07-08 13:30:19 -0400329 infoSink.info.prefix(EPrefixError);
330 infoSink.info << "too many uniforms";
gman@chromium.org8d804792012-10-17 21:33:48 +0000331 }
332 }
Jamie Madill183bde52014-07-02 15:31:19 -0400333 if (success && shaderType == GL_VERTEX_SHADER &&
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800334 (compileOptions & SH_INIT_VARYINGS_WITHOUT_STATIC_USE))
335 initializeVaryingsWithoutStaticUse(root);
gman@chromium.org8d804792012-10-17 21:33:48 +0000336 }
zmo@google.comfd747b82011-04-23 01:30:07 +0000337
Zhenyao Mocd68fe72014-07-11 10:45:44 -0700338 if (success && (compileOptions & SH_SCALARIZE_VEC_AND_MAT_CONSTRUCTOR_ARGS))
339 {
Zhenyao Modaf56572014-08-06 16:18:30 -0700340 ScalarizeVecAndMatConstructorArgs scalarizer(
341 shaderType, fragmentPrecisionHigh);
Zhenyao Mocd68fe72014-07-11 10:45:44 -0700342 root->traverse(&scalarizer);
343 }
344
Zhenyao Moe740add2014-07-18 17:01:01 -0700345 if (success && (compileOptions & SH_REGENERATE_STRUCT_NAMES))
346 {
347 RegenerateStructNames gen(symbolTable, shaderVersion);
348 root->traverse(&gen);
349 }
alokp@chromium.org07620a52010-09-23 17:53:56 +0000350 }
351
Zhenyao Mo7faf1a12014-04-25 18:03:56 -0700352 SetGlobalParseContext(NULL);
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200353 if (success)
354 return root;
355
356 return NULL;
357}
358
359bool TCompiler::compile(const char* const shaderStrings[],
360 size_t numStrings, int compileOptions)
361{
362 if (numStrings == 0)
363 return true;
364
365 TScopedPoolAllocator scopedAlloc(&allocator);
366 TIntermNode *root = compileTreeImpl(shaderStrings, numStrings, compileOptions);
367
368 if (root)
369 {
370 if (compileOptions & SH_INTERMEDIATE_TREE)
371 TIntermediate::outputTree(root, infoSink.info);
372
373 if (compileOptions & SH_OBJECT_CODE)
374 translate(root, compileOptions);
375
376 // The IntermNode tree doesn't need to be deleted here, since the
377 // memory will be freed in a big chunk by the PoolAllocator.
378 return true;
379 }
380 return false;
alokp@chromium.org07620a52010-09-23 17:53:56 +0000381}
382
Nicolas Capens49a88872013-06-20 09:54:03 -0400383bool TCompiler::InitBuiltInSymbolTable(const ShBuiltInResources &resources)
alokp@chromium.org07620a52010-09-23 17:53:56 +0000384{
shannon.woods%transgaming.com@gtempaccount.com18b4c4b2013-04-13 03:31:40 +0000385 compileResources = resources;
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400386 setResourceString();
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000387
Nicolas Capens49a88872013-06-20 09:54:03 -0400388 assert(symbolTable.isEmpty());
389 symbolTable.push(); // COMMON_BUILTINS
390 symbolTable.push(); // ESSL1_BUILTINS
391 symbolTable.push(); // ESSL3_BUILTINS
shannonwoods@chromium.org2ac0be92013-05-30 00:02:27 +0000392
Nicolas Capens49a88872013-06-20 09:54:03 -0400393 TPublicType integer;
394 integer.type = EbtInt;
395 integer.primarySize = 1;
396 integer.secondarySize = 1;
397 integer.array = false;
398
399 TPublicType floatingPoint;
400 floatingPoint.type = EbtFloat;
401 floatingPoint.primarySize = 1;
402 floatingPoint.secondarySize = 1;
403 floatingPoint.array = false;
404
Zhenyao Moa5a1dfc2013-09-23 14:57:03 -0400405 TPublicType sampler;
406 sampler.primarySize = 1;
407 sampler.secondarySize = 1;
408 sampler.array = false;
409
Nicolas Capens49a88872013-06-20 09:54:03 -0400410 switch(shaderType)
411 {
Jamie Madill183bde52014-07-02 15:31:19 -0400412 case GL_FRAGMENT_SHADER:
Nicolas Capens49a88872013-06-20 09:54:03 -0400413 symbolTable.setDefaultPrecision(integer, EbpMedium);
414 break;
Jamie Madill183bde52014-07-02 15:31:19 -0400415 case GL_VERTEX_SHADER:
Nicolas Capens49a88872013-06-20 09:54:03 -0400416 symbolTable.setDefaultPrecision(integer, EbpHigh);
417 symbolTable.setDefaultPrecision(floatingPoint, EbpHigh);
418 break;
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800419 default:
420 assert(false && "Language not supported");
Nicolas Capens49a88872013-06-20 09:54:03 -0400421 }
Zhenyao Moa5a1dfc2013-09-23 14:57:03 -0400422 // We set defaults for all the sampler types, even those that are
423 // only available if an extension exists.
424 for (int samplerType = EbtGuardSamplerBegin + 1;
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800425 samplerType < EbtGuardSamplerEnd; ++samplerType)
426 {
Zhenyao Moa5a1dfc2013-09-23 14:57:03 -0400427 sampler.type = static_cast<TBasicType>(samplerType);
428 symbolTable.setDefaultPrecision(sampler, EbpLow);
429 }
Nicolas Capens49a88872013-06-20 09:54:03 -0400430
Jamie Madill1b452142013-07-12 14:51:11 -0400431 InsertBuiltInFunctions(shaderType, shaderSpec, resources, symbolTable);
Nicolas Capens49a88872013-06-20 09:54:03 -0400432
433 IdentifyBuiltIns(shaderType, shaderSpec, resources, symbolTable);
434
435 return true;
alokp@chromium.org07620a52010-09-23 17:53:56 +0000436}
437
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400438void TCompiler::setResourceString()
439{
440 std::ostringstream strstream;
441 strstream << ":MaxVertexAttribs:" << compileResources.MaxVertexAttribs
442 << ":MaxVertexUniformVectors:" << compileResources.MaxVertexUniformVectors
443 << ":MaxVaryingVectors:" << compileResources.MaxVaryingVectors
444 << ":MaxVertexTextureImageUnits:" << compileResources.MaxVertexTextureImageUnits
445 << ":MaxCombinedTextureImageUnits:" << compileResources.MaxCombinedTextureImageUnits
446 << ":MaxTextureImageUnits:" << compileResources.MaxTextureImageUnits
447 << ":MaxFragmentUniformVectors:" << compileResources.MaxFragmentUniformVectors
448 << ":MaxDrawBuffers:" << compileResources.MaxDrawBuffers
449 << ":OES_standard_derivatives:" << compileResources.OES_standard_derivatives
450 << ":OES_EGL_image_external:" << compileResources.OES_EGL_image_external
451 << ":ARB_texture_rectangle:" << compileResources.ARB_texture_rectangle
452 << ":EXT_draw_buffers:" << compileResources.EXT_draw_buffers
453 << ":FragmentPrecisionHigh:" << compileResources.FragmentPrecisionHigh
454 << ":MaxExpressionComplexity:" << compileResources.MaxExpressionComplexity
455 << ":MaxCallStackDepth:" << compileResources.MaxCallStackDepth
456 << ":EXT_frag_depth:" << compileResources.EXT_frag_depth
457 << ":EXT_shader_texture_lod:" << compileResources.EXT_shader_texture_lod
Erik Dahlströmea7a2122014-11-17 16:15:57 +0100458 << ":EXT_shader_framebuffer_fetch:" << compileResources.EXT_shader_framebuffer_fetch
459 << ":NV_shader_framebuffer_fetch:" << compileResources.NV_shader_framebuffer_fetch
460 << ":ARM_shader_framebuffer_fetch:" << compileResources.ARM_shader_framebuffer_fetch
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400461 << ":MaxVertexOutputVectors:" << compileResources.MaxVertexOutputVectors
462 << ":MaxFragmentInputVectors:" << compileResources.MaxFragmentInputVectors
463 << ":MinProgramTexelOffset:" << compileResources.MinProgramTexelOffset
Olli Etuahoe61209a2014-09-26 12:01:17 +0300464 << ":MaxProgramTexelOffset:" << compileResources.MaxProgramTexelOffset
Olli Etuaho853dc1a2014-11-06 17:25:48 +0200465 << ":NV_draw_buffers:" << compileResources.NV_draw_buffers
466 << ":WEBGL_debug_shader_precision:" << compileResources.WEBGL_debug_shader_precision;
Shannon Woods2d76e5f2014-05-16 17:46:41 -0400467
468 builtInResourcesString = strstream.str();
469}
470
alokp@chromium.org07620a52010-09-23 17:53:56 +0000471void TCompiler::clearResults()
472{
daniel@transgaming.com4167cc92013-01-11 04:11:53 +0000473 arrayBoundsClamper.Cleanup();
alokp@chromium.org07620a52010-09-23 17:53:56 +0000474 infoSink.info.erase();
475 infoSink.obj.erase();
476 infoSink.debug.erase();
477
Jamie Madilled27c722014-07-02 15:31:23 -0400478 attributes.clear();
479 outputVariables.clear();
alokp@chromium.org07620a52010-09-23 17:53:56 +0000480 uniforms.clear();
Jamie Madill23a8a432014-07-09 13:27:42 -0400481 expandedUniforms.clear();
Zhenyao Mod2d340b2013-09-23 14:57:05 -0400482 varyings.clear();
Jamie Madilled27c722014-07-02 15:31:23 -0400483 interfaceBlocks.clear();
zmo@google.coma3b4ab42011-09-16 00:53:26 +0000484
485 builtInFunctionEmulator.Cleanup();
daniel@transgaming.com0aa3b5a2012-11-28 19:43:24 +0000486
487 nameMap.clear();
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200488
489 mSourcePath = NULL;
alokp@chromium.org07620a52010-09-23 17:53:56 +0000490}
491
Corentin Wallez71d147f2015-02-11 11:15:24 -0800492bool TCompiler::initCallDag(TIntermNode *root)
zmo@google.comb1762df2011-07-30 02:04:23 +0000493{
Corentin Wallez71d147f2015-02-11 11:15:24 -0800494 mCallDag.clear();
495
496 switch (mCallDag.init(root, &infoSink.info))
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800497 {
Corentin Wallez71d147f2015-02-11 11:15:24 -0800498 case CallDAG::INITDAG_SUCCESS:
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800499 return true;
Corentin Wallez71d147f2015-02-11 11:15:24 -0800500 case CallDAG::INITDAG_RECURSION:
501 infoSink.info.prefix(EPrefixError);
502 infoSink.info << "Function recursion detected";
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800503 return false;
Corentin Wallez71d147f2015-02-11 11:15:24 -0800504 case CallDAG::INITDAG_UNDEFINED:
505 infoSink.info.prefix(EPrefixError);
506 infoSink.info << "Unimplemented function detected";
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800507 return false;
Corentin Wallez71d147f2015-02-11 11:15:24 -0800508 }
509
510 UNREACHABLE();
511 return true;
512}
513
514bool TCompiler::checkCallDepth()
515{
516 std::vector<int> depths(mCallDag.size());
517
518 for (size_t i = 0; i < mCallDag.size(); i++)
519 {
520 int depth = 0;
521 auto &record = mCallDag.getRecordFromIndex(i);
522
523 for (auto &calleeIndex : record.callees)
524 {
525 depth = std::max(depth, depths[calleeIndex] + 1);
526 }
527
528 depths[i] = depth;
529
530 if (depth >= maxCallStackDepth)
531 {
532 // Trace back the function chain to have a meaningful info log.
533 infoSink.info.prefix(EPrefixError);
534 infoSink.info << "Call stack too deep (larger than " << maxCallStackDepth
535 << ") with the following call chain: " << record.name;
536
537 int currentFunction = i;
538 int currentDepth = depth;
539
540 while (currentFunction != -1)
541 {
542 infoSink.info << " -> " << mCallDag.getRecordFromIndex(currentFunction).name;
543
544 int nextFunction = -1;
545 for (auto& calleeIndex : mCallDag.getRecordFromIndex(currentFunction).callees)
546 {
547 if (depths[calleeIndex] == currentDepth - 1)
548 {
549 currentDepth--;
550 nextFunction = calleeIndex;
551 }
552 }
553
554 currentFunction = nextFunction;
555 }
556
557 return false;
558 }
559 }
560
561 return true;
562}
563
564bool TCompiler::tagUsedFunctions()
565{
566 // Search from main, starting from the end of the DAG as it usually is the root.
567 for (int i = mCallDag.size(); i-- > 0;)
568 {
569 if (mCallDag.getRecordFromIndex(i).name == "main(")
570 {
571 internalTagUsedFunction(i);
572 return true;
573 }
574 }
575
576 infoSink.info.prefix(EPrefixError);
577 infoSink.info << "Missing main()";
578 return false;
579}
580
581void TCompiler::internalTagUsedFunction(size_t index)
582{
583 if (functionMetadata[index].used)
584 {
585 return;
586 }
587
588 functionMetadata[index].used = true;
589
590 for (int calleeIndex : mCallDag.getRecordFromIndex(index).callees)
591 {
592 internalTagUsedFunction(calleeIndex);
zmo@google.comb1762df2011-07-30 02:04:23 +0000593 }
594}
595
Corentin Walleza094a8a2015-04-07 11:53:06 -0700596// A predicate for the stl that returns if a top-level node is unused
597class TCompiler::UnusedPredicate
598{
599 public:
600 UnusedPredicate(const CallDAG *callDag, const std::vector<FunctionMetadata> *metadatas)
601 : mCallDag(callDag),
602 mMetadatas(metadatas)
603 {
604 }
605
606 bool operator ()(TIntermNode *node)
607 {
608 const TIntermAggregate *asAggregate = node->getAsAggregate();
609
610 if (asAggregate == nullptr)
611 {
612 return false;
613 }
614
615 if (!(asAggregate->getOp() == EOpFunction || asAggregate->getOp() == EOpPrototype))
616 {
617 return false;
618 }
619
620 size_t callDagIndex = mCallDag->findIndex(asAggregate);
621 if (callDagIndex == CallDAG::InvalidIndex)
622 {
623 // This happens only for unimplemented prototypes which are thus unused
624 ASSERT(asAggregate->getOp() == EOpPrototype);
625 return true;
626 }
627
628 ASSERT(callDagIndex < mMetadatas->size());
629 return !(*mMetadatas)[callDagIndex].used;
630 }
631
632 private:
633 const CallDAG *mCallDag;
634 const std::vector<FunctionMetadata> *mMetadatas;
635};
636
637bool TCompiler::pruneUnusedFunctions(TIntermNode *root)
638{
639 TIntermAggregate *rootNode = root->getAsAggregate();
640 ASSERT(rootNode != nullptr);
641
642 UnusedPredicate isUnused(&mCallDag, &functionMetadata);
643 TIntermSequence *sequence = rootNode->getSequence();
644 sequence->erase(std::remove_if(sequence->begin(), sequence->end(), isUnused), sequence->end());
645
646 return true;
647}
648
Jamie Madill05a80ce2013-06-20 11:55:49 -0400649bool TCompiler::validateOutputs(TIntermNode* root)
650{
651 ValidateOutputs validateOutputs(infoSink.info, compileResources.MaxDrawBuffers);
652 root->traverse(&validateOutputs);
653 return (validateOutputs.numErrors() == 0);
654}
655
maxvujovic@gmail.com430f5e02012-06-08 17:47:59 +0000656void TCompiler::rewriteCSSShader(TIntermNode* root)
657{
658 RenameFunction renamer("main(", "css_main(");
659 root->traverse(&renamer);
660}
661
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800662bool TCompiler::validateLimitations(TIntermNode* root)
663{
alokp@chromium.orgb59a7782010-11-24 18:38:33 +0000664 ValidateLimitations validate(shaderType, infoSink.info);
665 root->traverse(&validate);
666 return validate.numErrors() == 0;
667}
668
maxvujovic@gmail.com77222c92012-06-04 21:06:05 +0000669bool TCompiler::enforceTimingRestrictions(TIntermNode* root, bool outputGraph)
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000670{
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800671 if (shaderSpec != SH_WEBGL_SPEC)
672 {
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000673 infoSink.info << "Timing restrictions must be enforced under the WebGL spec.";
674 return false;
675 }
676
Jamie Madill183bde52014-07-02 15:31:19 -0400677 if (shaderType == GL_FRAGMENT_SHADER)
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800678 {
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000679 TDependencyGraph graph(root);
680
681 // Output any errors first.
maxvujovic@gmail.com77222c92012-06-04 21:06:05 +0000682 bool success = enforceFragmentShaderTimingRestrictions(graph);
Jamie Madill5508f392014-02-20 13:31:36 -0500683
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000684 // Then, output the dependency graph.
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800685 if (outputGraph)
686 {
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000687 TDependencyGraphOutput output(infoSink.info);
688 output.outputAllSpanningTrees(graph);
689 }
Jamie Madill5508f392014-02-20 13:31:36 -0500690
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000691 return success;
692 }
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800693 else
694 {
maxvujovic@gmail.com77222c92012-06-04 21:06:05 +0000695 return enforceVertexShaderTimingRestrictions(root);
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000696 }
697}
698
Jamie Madilleb1a0102013-07-08 13:31:38 -0400699bool TCompiler::limitExpressionComplexity(TIntermNode* root)
700{
Jamie Madill6654bc92014-03-26 14:01:57 -0400701 TMaxDepthTraverser traverser(maxExpressionComplexity+1);
Jamie Madilleb1a0102013-07-08 13:31:38 -0400702 root->traverse(&traverser);
Jamie Madill6654bc92014-03-26 14:01:57 -0400703
704 if (traverser.getMaxDepth() > maxExpressionComplexity)
705 {
706 infoSink.info << "Expression too complex.";
707 return false;
708 }
709
Jamie Madilleb1a0102013-07-08 13:31:38 -0400710 TDependencyGraph graph(root);
711
712 for (TFunctionCallVector::const_iterator iter = graph.beginUserDefinedFunctionCalls();
713 iter != graph.endUserDefinedFunctionCalls();
714 ++iter)
715 {
716 TGraphFunctionCall* samplerSymbol = *iter;
717 TDependencyGraphTraverser graphTraverser;
718 samplerSymbol->traverse(&graphTraverser);
719 }
720
Jamie Madilleb1a0102013-07-08 13:31:38 -0400721 return true;
722}
723
maxvujovic@gmail.com77222c92012-06-04 21:06:05 +0000724bool TCompiler::enforceFragmentShaderTimingRestrictions(const TDependencyGraph& graph)
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000725{
maxvujovic@gmail.com77222c92012-06-04 21:06:05 +0000726 RestrictFragmentShaderTiming restrictor(infoSink.info);
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000727 restrictor.enforceRestrictions(graph);
728 return restrictor.numErrors() == 0;
729}
730
maxvujovic@gmail.com77222c92012-06-04 21:06:05 +0000731bool TCompiler::enforceVertexShaderTimingRestrictions(TIntermNode* root)
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000732{
maxvujovic@gmail.com77222c92012-06-04 21:06:05 +0000733 RestrictVertexShaderTiming restrictor(infoSink.info);
maxvujovic@gmail.com66ebd012012-05-30 22:18:11 +0000734 restrictor.enforceRestrictions(root);
735 return restrictor.numErrors() == 0;
736}
737
Zhenyao Mo74da9f22013-09-23 14:57:01 -0400738void TCompiler::collectVariables(TIntermNode* root)
alokp@chromium.org07620a52010-09-23 17:53:56 +0000739{
Jamie Madilla2fbb842014-09-03 09:40:47 -0400740 sh::CollectVariables collect(&attributes,
741 &outputVariables,
742 &uniforms,
743 &varyings,
744 &interfaceBlocks,
Zhenyao Mo94ac7b72014-10-15 18:22:08 -0700745 hashFunction,
746 symbolTable);
alokp@chromium.org07620a52010-09-23 17:53:56 +0000747 root->traverse(&collect);
Jamie Madill23a8a432014-07-09 13:27:42 -0400748
Zhenyao Mo409078f2014-10-28 13:23:18 -0700749 // This is for enforcePackingRestriction().
750 sh::ExpandUniforms(uniforms, &expandedUniforms);
alokp@chromium.org07620a52010-09-23 17:53:56 +0000751}
zmo@google.comfd747b82011-04-23 01:30:07 +0000752
gman@chromium.org8d804792012-10-17 21:33:48 +0000753bool TCompiler::enforcePackingRestrictions()
754{
755 VariablePacker packer;
Jamie Madill23a8a432014-07-09 13:27:42 -0400756 return packer.CheckVariablesWithinPackingLimits(maxUniformVectors, expandedUniforms);
gman@chromium.org8d804792012-10-17 21:33:48 +0000757}
758
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800759void TCompiler::initializeGLPosition(TIntermNode* root)
760{
761 InitializeVariables::InitVariableInfoList variables;
762 InitializeVariables::InitVariableInfo var(
763 "gl_Position", TType(EbtFloat, EbpUndefined, EvqPosition, 4));
764 variables.push_back(var);
765 InitializeVariables initializer(variables);
766 root->traverse(&initializer);
767}
768
769void TCompiler::initializeVaryingsWithoutStaticUse(TIntermNode* root)
770{
771 InitializeVariables::InitVariableInfoList variables;
772 for (size_t ii = 0; ii < varyings.size(); ++ii)
773 {
Jamie Madilla718c1e2014-07-02 15:31:22 -0400774 const sh::Varying& varying = varyings[ii];
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800775 if (varying.staticUse)
776 continue;
Jamie Madillaa72d782014-07-02 15:31:19 -0400777 unsigned char primarySize = static_cast<unsigned char>(gl::VariableColumnCount(varying.type));
778 unsigned char secondarySize = static_cast<unsigned char>(gl::VariableRowCount(varying.type));
Jamie Madilla718c1e2014-07-02 15:31:22 -0400779 TType type(EbtFloat, EbpUndefined, EvqVaryingOut, primarySize, secondarySize, varying.isArray());
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800780 TString name = varying.name.c_str();
Jamie Madilla718c1e2014-07-02 15:31:22 -0400781 if (varying.isArray())
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800782 {
Jamie Madilla718c1e2014-07-02 15:31:22 -0400783 type.setArraySize(varying.arraySize);
Zhenyao Mo4a667fe2014-02-11 12:35:01 -0800784 name = name.substr(0, name.find_first_of('['));
785 }
786
787 InitializeVariables::InitVariableInfo var(name, type);
788 variables.push_back(var);
789 }
790 InitializeVariables initializer(variables);
791 root->traverse(&initializer);
792}
793
zmo@google.com5601ea02011-06-10 18:23:25 +0000794const TExtensionBehavior& TCompiler::getExtensionBehavior() const
795{
796 return extensionBehavior;
797}
zmo@google.com32e97312011-08-24 01:03:11 +0000798
Olli Etuahoa3a5cc62015-02-13 13:12:22 +0200799const char *TCompiler::getSourcePath() const
800{
801 return mSourcePath;
802}
803
shannon.woods%transgaming.com@gtempaccount.com18b4c4b2013-04-13 03:31:40 +0000804const ShBuiltInResources& TCompiler::getResources() const
805{
806 return compileResources;
807}
808
daniel@transgaming.com4167cc92013-01-11 04:11:53 +0000809const ArrayBoundsClamper& TCompiler::getArrayBoundsClamper() const
810{
811 return arrayBoundsClamper;
812}
813
shannon.woods@transgaming.com1d432bb2013-01-25 21:57:28 +0000814ShArrayIndexClampingStrategy TCompiler::getArrayIndexClampingStrategy() const
815{
816 return clampingStrategy;
817}
818
Olli Etuaho8efc5ad2015-03-03 17:21:10 +0200819const BuiltInFunctionEmulator& TCompiler::getBuiltInFunctionEmulator() const
shannon.woods@transgaming.com1d432bb2013-01-25 21:57:28 +0000820{
821 return builtInFunctionEmulator;
822}
Zhenyao Mo94ac7b72014-10-15 18:22:08 -0700823
824void TCompiler::writePragma()
825{
826 TInfoSinkBase &sink = infoSink.obj;
827 if (mPragma.stdgl.invariantAll)
828 sink << "#pragma STDGL invariant(all)\n";
829}