blob: eb1d1d0e562f0fb5b05d5c83fef23fc92c8ed028 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Nicolas Capens16004fc2014-06-11 11:29:11 -04002// Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
Geoff Lang0a73dd82014-11-19 16:18:08 -05007#ifndef COMPILER_TRANSLATOR_INTERMEDIATE_H_
8#define COMPILER_TRANSLATOR_INTERMEDIATE_H_
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00009
Jamie Madillb1a85f42014-08-19 15:23:24 -040010#include "compiler/translator/IntermNode.h"
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011
Jamie Madill45bcc782016-11-07 13:58:48 -050012namespace sh
13{
14
Jamie Madillb1a85f42014-08-19 15:23:24 -040015struct TVectorFields
Zhenyao Moe40d1e92014-07-16 17:40:36 -070016{
Jamie Madillb1a85f42014-08-19 15:23:24 -040017 int offsets[4];
18 int num;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000019};
20
Jamie Madillb1a85f42014-08-19 15:23:24 -040021//
Olli Etuahof119a262016-08-19 15:54:22 +030022// Set of helper functions to help build the tree.
Jamie Madillb1a85f42014-08-19 15:23:24 -040023//
Jamie Madillb1a85f42014-08-19 15:23:24 -040024class TIntermediate
Zhenyao Moe40d1e92014-07-16 17:40:36 -070025{
26 public:
Alok Priyadarshi8156b6b2013-09-23 14:56:58 -040027 POOL_ALLOCATOR_NEW_DELETE();
Olli Etuahof119a262016-08-19 15:54:22 +030028 TIntermediate() {}
alokp@chromium.org58e54292010-08-24 21:40:03 +000029
Jamie Madilld7b1ab52016-12-12 14:42:19 -050030 TIntermSymbol *addSymbol(int id, const TString &, const TType &, const TSourceLoc &);
Olli Etuaho3272a6d2016-08-29 17:54:50 +030031 TIntermTyped *addIndex(TOperator op,
32 TIntermTyped *base,
33 TIntermTyped *index,
34 const TSourceLoc &line,
35 TDiagnostics *diagnostics);
Olli Etuaho6d40bbd2016-09-30 13:49:38 +010036 static TIntermBlock *EnsureBlock(TIntermNode *node);
Olli Etuaho57961272016-09-14 13:57:46 +030037 TIntermNode *addIfElse(TIntermTyped *cond, TIntermNodePair code, const TSourceLoc &line);
Olli Etuahod0bad2c2016-09-09 18:01:16 +030038 static TIntermTyped *AddTernarySelection(TIntermTyped *cond,
39 TIntermTyped *trueExpression,
40 TIntermTyped *falseExpression,
41 const TSourceLoc &line);
Olli Etuaho6d40bbd2016-09-30 13:49:38 +010042 TIntermSwitch *addSwitch(TIntermTyped *init,
43 TIntermBlock *statementList,
44 const TSourceLoc &line);
Jamie Madilld7b1ab52016-12-12 14:42:19 -050045 TIntermCase *addCase(TIntermTyped *condition, const TSourceLoc &line);
Olli Etuaho4db7ded2016-10-13 12:23:11 +010046 static TIntermTyped *AddComma(TIntermTyped *left,
47 TIntermTyped *right,
48 const TSourceLoc &line,
49 int shaderVersion);
Olli Etuaho5c0e0232015-11-11 15:55:59 +020050 TIntermConstantUnion *addConstantUnion(const TConstantUnion *constantUnion,
51 const TType &type,
52 const TSourceLoc &line);
Jamie Madilld7b1ab52016-12-12 14:42:19 -050053 TIntermNode *addLoop(TLoopType,
54 TIntermNode *,
55 TIntermTyped *,
56 TIntermTyped *,
57 TIntermNode *,
58 const TSourceLoc &);
Jamie Madillb1a85f42014-08-19 15:23:24 -040059 TIntermBranch *addBranch(TOperator, const TSourceLoc &);
60 TIntermBranch *addBranch(TOperator, TIntermTyped *, const TSourceLoc &);
Olli Etuahob6fa0432016-09-28 16:28:05 +010061 static TIntermTyped *AddSwizzle(TIntermTyped *baseExpression,
62 const TVectorFields &fields,
63 const TSourceLoc &dotLocation);
Olli Etuahoa3a5cc62015-02-13 13:12:22 +020064
65 static void outputTree(TIntermNode *, TInfoSinkBase &);
alokp@chromium.org58e54292010-08-24 21:40:03 +000066
Olli Etuahof119a262016-08-19 15:54:22 +030067 TIntermTyped *foldAggregateBuiltIn(TIntermAggregate *aggregate, TDiagnostics *diagnostics);
Arun Patole274f0702015-05-05 13:33:30 +053068
Jamie Madillb1a85f42014-08-19 15:23:24 -040069 private:
Jamie Madilld7b1ab52016-12-12 14:42:19 -050070 void operator=(TIntermediate &); // prevent assignments
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000071};
72
Jamie Madill45bcc782016-11-07 13:58:48 -050073} // namespace sh
74
Geoff Lang0a73dd82014-11-19 16:18:08 -050075#endif // COMPILER_TRANSLATOR_INTERMEDIATE_H_