daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
Nicolas Capens | 16004fc | 2014-06-11 11:29:11 -0400 | [diff] [blame] | 2 | // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved. |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 7 | #ifndef COMPILER_TRANSLATOR_INTERMEDIATE_H_ |
| 8 | #define COMPILER_TRANSLATOR_INTERMEDIATE_H_ |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 9 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 10 | #include "compiler/translator/IntermNode.h" |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 11 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 12 | struct TVectorFields |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 13 | { |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 14 | int offsets[4]; |
| 15 | int num; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 16 | }; |
| 17 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 18 | // |
Olli Etuaho | f119a26 | 2016-08-19 15:54:22 +0300 | [diff] [blame] | 19 | // Set of helper functions to help build the tree. |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 20 | // |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 21 | class TIntermediate |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 22 | { |
| 23 | public: |
Alok Priyadarshi | 8156b6b | 2013-09-23 14:56:58 -0400 | [diff] [blame] | 24 | POOL_ALLOCATOR_NEW_DELETE(); |
Olli Etuaho | f119a26 | 2016-08-19 15:54:22 +0300 | [diff] [blame] | 25 | TIntermediate() {} |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 26 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 27 | TIntermSymbol *addSymbol( |
| 28 | int id, const TString &, const TType &, const TSourceLoc &); |
Olli Etuaho | 3272a6d | 2016-08-29 17:54:50 +0300 | [diff] [blame] | 29 | TIntermTyped *addIndex(TOperator op, |
| 30 | TIntermTyped *base, |
| 31 | TIntermTyped *index, |
| 32 | const TSourceLoc &line, |
| 33 | TDiagnostics *diagnostics); |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 34 | TIntermTyped *addUnaryMath( |
Olli Etuaho | f6c694b | 2015-03-26 14:50:53 +0200 | [diff] [blame] | 35 | TOperator op, TIntermTyped *child, const TSourceLoc &line, const TType *funcReturnType); |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 36 | TIntermAggregate *growAggregate( |
| 37 | TIntermNode *left, TIntermNode *right, const TSourceLoc &); |
| 38 | TIntermAggregate *makeAggregate(TIntermNode *node, const TSourceLoc &); |
Olli Etuaho | 7d7f8c4 | 2015-05-19 18:38:49 +0300 | [diff] [blame] | 39 | TIntermAggregate *ensureSequence(TIntermNode *node); |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 40 | TIntermAggregate *setAggregateOperator(TIntermNode *, TOperator, const TSourceLoc &); |
Olli Etuaho | d0bad2c | 2016-09-09 18:01:16 +0300 | [diff] [blame^] | 41 | TIntermNode *addSelection(TIntermTyped *cond, TIntermNodePair code, const TSourceLoc &line); |
| 42 | static TIntermTyped *AddTernarySelection(TIntermTyped *cond, |
| 43 | TIntermTyped *trueExpression, |
| 44 | TIntermTyped *falseExpression, |
| 45 | const TSourceLoc &line); |
Olli Etuaho | a3a3666 | 2015-02-17 13:46:51 +0200 | [diff] [blame] | 46 | TIntermSwitch *addSwitch( |
| 47 | TIntermTyped *init, TIntermAggregate *statementList, const TSourceLoc &line); |
| 48 | TIntermCase *addCase( |
| 49 | TIntermTyped *condition, const TSourceLoc &line); |
Olli Etuaho | 1520004 | 2015-11-04 16:56:31 +0200 | [diff] [blame] | 50 | TIntermTyped *addComma(TIntermTyped *left, |
| 51 | TIntermTyped *right, |
| 52 | const TSourceLoc &line, |
| 53 | int shaderVersion); |
Olli Etuaho | 5c0e023 | 2015-11-11 15:55:59 +0200 | [diff] [blame] | 54 | TIntermConstantUnion *addConstantUnion(const TConstantUnion *constantUnion, |
| 55 | const TType &type, |
| 56 | const TSourceLoc &line); |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 57 | TIntermNode *addLoop(TLoopType, TIntermNode *, TIntermTyped *, TIntermTyped *, |
| 58 | TIntermNode *, const TSourceLoc &); |
| 59 | TIntermBranch *addBranch(TOperator, const TSourceLoc &); |
| 60 | TIntermBranch *addBranch(TOperator, TIntermTyped *, const TSourceLoc &); |
| 61 | TIntermTyped *addSwizzle(TVectorFields &, const TSourceLoc &); |
Olli Etuaho | f119a26 | 2016-08-19 15:54:22 +0300 | [diff] [blame] | 62 | static TIntermAggregate *PostProcess(TIntermNode *root); |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 63 | |
| 64 | static void outputTree(TIntermNode *, TInfoSinkBase &); |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 65 | |
Olli Etuaho | f119a26 | 2016-08-19 15:54:22 +0300 | [diff] [blame] | 66 | TIntermTyped *foldAggregateBuiltIn(TIntermAggregate *aggregate, TDiagnostics *diagnostics); |
Arun Patole | 274f070 | 2015-05-05 13:33:30 +0530 | [diff] [blame] | 67 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 68 | private: |
| 69 | void operator=(TIntermediate &); // prevent assignments |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 72 | #endif // COMPILER_TRANSLATOR_INTERMEDIATE_H_ |