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 | // |
| 19 | // Set of helper functions to help parse and build the tree. |
| 20 | // |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 21 | class TInfoSink; |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 22 | class TIntermediate |
Zhenyao Mo | e40d1e9 | 2014-07-16 17:40:36 -0700 | [diff] [blame] | 23 | { |
| 24 | public: |
Alok Priyadarshi | 8156b6b | 2013-09-23 14:56:58 -0400 | [diff] [blame] | 25 | POOL_ALLOCATOR_NEW_DELETE(); |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 26 | TIntermediate(TInfoSink &i) |
| 27 | : mInfoSink(i) { } |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 28 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 29 | TIntermSymbol *addSymbol( |
| 30 | int id, const TString &, const TType &, const TSourceLoc &); |
| 31 | TIntermTyped *addBinaryMath( |
| 32 | TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &); |
| 33 | TIntermTyped *addAssign( |
| 34 | TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &); |
| 35 | TIntermTyped *addIndex( |
| 36 | TOperator op, TIntermTyped *base, TIntermTyped *index, const TSourceLoc &); |
| 37 | TIntermTyped *addUnaryMath( |
| 38 | TOperator op, TIntermNode *child, const TSourceLoc &); |
| 39 | TIntermAggregate *growAggregate( |
| 40 | TIntermNode *left, TIntermNode *right, const TSourceLoc &); |
| 41 | TIntermAggregate *makeAggregate(TIntermNode *node, const TSourceLoc &); |
| 42 | TIntermAggregate *setAggregateOperator(TIntermNode *, TOperator, const TSourceLoc &); |
| 43 | TIntermNode *addSelection(TIntermTyped *cond, TIntermNodePair code, const TSourceLoc &); |
| 44 | TIntermTyped *addSelection( |
| 45 | TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock, const TSourceLoc &); |
| 46 | TIntermTyped *addComma( |
| 47 | TIntermTyped *left, TIntermTyped *right, const TSourceLoc &); |
| 48 | TIntermConstantUnion *addConstantUnion(ConstantUnion *, const TType &, const TSourceLoc &); |
| 49 | // TODO(zmo): Get rid of default value. |
| 50 | bool parseConstTree(const TSourceLoc &, TIntermNode *, ConstantUnion *, |
| 51 | TOperator, TType, bool singleConstantParam = false); |
| 52 | TIntermNode *addLoop(TLoopType, TIntermNode *, TIntermTyped *, TIntermTyped *, |
| 53 | TIntermNode *, const TSourceLoc &); |
| 54 | TIntermBranch *addBranch(TOperator, const TSourceLoc &); |
| 55 | TIntermBranch *addBranch(TOperator, TIntermTyped *, const TSourceLoc &); |
| 56 | TIntermTyped *addSwizzle(TVectorFields &, const TSourceLoc &); |
| 57 | bool postProcess(TIntermNode *); |
| 58 | void remove(TIntermNode *); |
| 59 | void outputTree(TIntermNode *); |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 60 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 61 | private: |
| 62 | void operator=(TIntermediate &); // prevent assignments |
alokp@chromium.org | 58e5429 | 2010-08-24 21:40:03 +0000 | [diff] [blame] | 63 | |
Jamie Madill | b1a85f4 | 2014-08-19 15:23:24 -0400 | [diff] [blame] | 64 | TInfoSink & mInfoSink; |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 65 | }; |
| 66 | |
Geoff Lang | 0a73dd8 | 2014-11-19 16:18:08 -0500 | [diff] [blame^] | 67 | #endif // COMPILER_TRANSLATOR_INTERMEDIATE_H_ |