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 | 45bcc78 | 2016-11-07 13:58:48 -0500 | [diff] [blame] | 12 | namespace sh |
| 13 | { |
| 14 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 15 | struct TVectorFields |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 16 | { |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 17 | int offsets[4]; |
| 18 | int num; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 19 | }; |
| 20 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 21 | // |
Olli Etuaho | f119a26 | 2016-08-19 15:54:22 +0300 | [diff] [blame] | 22 | // Set of helper functions to help build the tree. |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 23 | // |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 24 | class TIntermediate |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 25 | { |
| 26 | public: |
Alok Priyadarshi | 8156b6b | 2013-09-23 14:56:58 -0400 | [diff] [blame] | 27 | POOL_ALLOCATOR_NEW_DELETE(); |
Olli Etuaho | f119a26 | 2016-08-19 15:54:22 +0300 | [diff] [blame] | 28 | TIntermediate() {} |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 29 | |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 30 | TIntermSymbol *addSymbol(int id, const TString &, const TType &, const TSourceLoc &); |
Olli Etuaho | 3272a6d | 2016-08-29 17:54:50 +0300 | [diff] [blame] | 31 | TIntermTyped *addIndex(TOperator op, |
| 32 | TIntermTyped *base, |
| 33 | TIntermTyped *index, |
| 34 | const TSourceLoc &line, |
| 35 | TDiagnostics *diagnostics); |
Olli Etuaho | 6d40bbd | 2016-09-30 13:49:38 +0100 | [diff] [blame] | 36 | static TIntermBlock *EnsureBlock(TIntermNode *node); |
Olli Etuaho | 5796127 | 2016-09-14 13:57:46 +0300 | [diff] [blame] | 37 | TIntermNode *addIfElse(TIntermTyped *cond, TIntermNodePair code, const TSourceLoc &line); |
Olli Etuaho | d0bad2c | 2016-09-09 18:01:16 +0300 | [diff] [blame] | 38 | static TIntermTyped *AddTernarySelection(TIntermTyped *cond, |
| 39 | TIntermTyped *trueExpression, |
| 40 | TIntermTyped *falseExpression, |
| 41 | const TSourceLoc &line); |
Olli Etuaho | 6d40bbd | 2016-09-30 13:49:38 +0100 | [diff] [blame] | 42 | TIntermSwitch *addSwitch(TIntermTyped *init, |
| 43 | TIntermBlock *statementList, |
| 44 | const TSourceLoc &line); |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 45 | TIntermCase *addCase(TIntermTyped *condition, const TSourceLoc &line); |
Olli Etuaho | 4db7ded | 2016-10-13 12:23:11 +0100 | [diff] [blame] | 46 | static TIntermTyped *AddComma(TIntermTyped *left, |
| 47 | TIntermTyped *right, |
| 48 | const TSourceLoc &line, |
| 49 | int shaderVersion); |
Olli Etuaho | 5c0e023 | 2015-11-11 15:55:59 +0200 | [diff] [blame] | 50 | TIntermConstantUnion *addConstantUnion(const TConstantUnion *constantUnion, |
| 51 | const TType &type, |
| 52 | const TSourceLoc &line); |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 53 | TIntermNode *addLoop(TLoopType, |
| 54 | TIntermNode *, |
| 55 | TIntermTyped *, |
| 56 | TIntermTyped *, |
| 57 | TIntermNode *, |
| 58 | const TSourceLoc &); |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 59 | TIntermBranch *addBranch(TOperator, const TSourceLoc &); |
| 60 | TIntermBranch *addBranch(TOperator, TIntermTyped *, const TSourceLoc &); |
Olli Etuaho | b6fa043 | 2016-09-28 16:28:05 +0100 | [diff] [blame] | 61 | static TIntermTyped *AddSwizzle(TIntermTyped *baseExpression, |
| 62 | const TVectorFields &fields, |
| 63 | const TSourceLoc &dotLocation); |
Olli Etuaho | a3a5cc6 | 2015-02-13 13:12:22 +0200 | [diff] [blame] | 64 | |
| 65 | static void outputTree(TIntermNode *, TInfoSinkBase &); |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 66 | |
Olli Etuaho | f119a26 | 2016-08-19 15:54:22 +0300 | [diff] [blame] | 67 | TIntermTyped *foldAggregateBuiltIn(TIntermAggregate *aggregate, TDiagnostics *diagnostics); |
Arun Patole | 274f070 | 2015-05-05 13:33:30 +0530 | [diff] [blame] | 68 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 69 | private: |
Jamie Madill | d7b1ab5 | 2016-12-12 14:42:19 -0500 | [diff] [blame] | 70 | void operator=(TIntermediate &); // prevent assignments |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 71 | }; |
| 72 | |
Jamie Madill | 45bcc78 | 2016-11-07 13:58:48 -0500 | [diff] [blame] | 73 | } // namespace sh |
| 74 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame] | 75 | #endif // COMPILER_TRANSLATOR_INTERMEDIATE_H_ |