blob: 8e6519dd68744cbcc4d6e6ff5c4738857394e00a [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
Nicolas Capens6ed8d8a2014-06-11 11:25:20 -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
7//
8// Build the intermediate representation.
9//
10
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000011#include <float.h>
alokp@chromium.org1bcc3fd2010-05-19 17:08:44 +000012#include <limits.h>
alokp@chromium.org32cfaf42010-08-23 21:01:13 +000013#include <algorithm>
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000014
Jamie Madillb1a85f42014-08-19 15:23:24 -040015#include "compiler/translator/Intermediate.h"
Geoff Lang17732822013-08-29 13:46:49 -040016#include "compiler/translator/SymbolTable.h"
daniel@transgaming.combbf56f72010-04-20 18:52:13 +000017
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000018////////////////////////////////////////////////////////////////////////////
19//
20// First set of functions are to help build the intermediate representation.
21// These functions are not member functions of the nodes.
22// They are called from parser productions.
23//
24/////////////////////////////////////////////////////////////////////////////
25
26//
27// Add a terminal node for an identifier in an expression.
28//
29// Returns the added node.
30//
Zhenyao Moe40d1e92014-07-16 17:40:36 -070031TIntermSymbol *TIntermediate::addSymbol(
32 int id, const TString &name, const TType &type, const TSourceLoc &line)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000033{
Zhenyao Moe40d1e92014-07-16 17:40:36 -070034 TIntermSymbol *node = new TIntermSymbol(id, name, type);
alokp@chromium.org2cf17712010-03-30 20:33:18 +000035 node->setLine(line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000036
alokp@chromium.org2cf17712010-03-30 20:33:18 +000037 return node;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000038}
39
40//
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000041// Connect two nodes through an index operator, where the left node is the base
42// of an array or struct, and the right node is a direct or indirect offset.
43//
44// Returns the added node.
45// The caller should set the type of the returned node.
46//
Olli Etuaho3272a6d2016-08-29 17:54:50 +030047TIntermTyped *TIntermediate::addIndex(TOperator op,
48 TIntermTyped *base,
49 TIntermTyped *index,
50 const TSourceLoc &line,
51 TDiagnostics *diagnostics)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000052{
Olli Etuaho3272a6d2016-08-29 17:54:50 +030053 TIntermBinary *node = new TIntermBinary(op, base, index);
alokp@chromium.org2cf17712010-03-30 20:33:18 +000054 node->setLine(line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000055
Olli Etuaho3272a6d2016-08-29 17:54:50 +030056 TIntermTyped *folded = node->fold(diagnostics);
57 if (folded)
58 {
59 return folded;
60 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000061
alokp@chromium.org2cf17712010-03-30 20:33:18 +000062 return node;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000063}
64
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000065// This is the safe way to change the operator on an aggregate, as it
66// does lots of error checking and fixing. Especially for establishing
Olli Etuaho6d40bbd2016-09-30 13:49:38 +010067// a function call's operation on it's set of parameters.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000068//
69// Returns an aggregate node, which could be the one passed in if
daniel@transgaming.com978702d2012-04-04 15:05:58 +000070// it was already an aggregate but no operator was set.
Zhenyao Moe40d1e92014-07-16 17:40:36 -070071TIntermAggregate *TIntermediate::setAggregateOperator(
72 TIntermNode *node, TOperator op, const TSourceLoc &line)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000073{
Zhenyao Moe40d1e92014-07-16 17:40:36 -070074 TIntermAggregate *aggNode;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000075
alokp@chromium.org2cf17712010-03-30 20:33:18 +000076 //
77 // Make sure we have an aggregate. If not turn it into one.
78 //
Zhenyao Moe40d1e92014-07-16 17:40:36 -070079 if (node)
80 {
alokp@chromium.org2cf17712010-03-30 20:33:18 +000081 aggNode = node->getAsAggregate();
Zhenyao Moe40d1e92014-07-16 17:40:36 -070082 if (aggNode == NULL || aggNode->getOp() != EOpNull)
83 {
alokp@chromium.org2cf17712010-03-30 20:33:18 +000084 //
85 // Make an aggregate containing this node.
86 //
87 aggNode = new TIntermAggregate();
Zhenyao Moe40d1e92014-07-16 17:40:36 -070088 aggNode->getSequence()->push_back(node);
alokp@chromium.org2cf17712010-03-30 20:33:18 +000089 }
Zhenyao Moe40d1e92014-07-16 17:40:36 -070090 }
91 else
92 {
alokp@chromium.org2cf17712010-03-30 20:33:18 +000093 aggNode = new TIntermAggregate();
Zhenyao Moe40d1e92014-07-16 17:40:36 -070094 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000095
alokp@chromium.org2cf17712010-03-30 20:33:18 +000096 //
97 // Set the operator.
98 //
alokp@chromium.org58e54292010-08-24 21:40:03 +000099 aggNode->setOp(op);
Jamie Madill075edd82013-07-08 13:30:19 -0400100 aggNode->setLine(line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000101
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000102 return aggNode;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000103}
104
105//
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000106// Safe way to combine two nodes into an aggregate. Works with null pointers,
107// a node that's not a aggregate yet, etc.
108//
109// Returns the resulting aggregate, unless 0 was passed in for
110// both existing nodes.
111//
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700112TIntermAggregate *TIntermediate::growAggregate(
113 TIntermNode *left, TIntermNode *right, const TSourceLoc &line)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000114{
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700115 if (left == NULL && right == NULL)
116 return NULL;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000117
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700118 TIntermAggregate *aggNode = NULL;
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000119 if (left)
120 aggNode = left->getAsAggregate();
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700121 if (!aggNode || aggNode->getOp() != EOpNull)
122 {
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000123 aggNode = new TIntermAggregate;
124 if (left)
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700125 aggNode->getSequence()->push_back(left);
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000126 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000127
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000128 if (right)
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700129 aggNode->getSequence()->push_back(right);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000130
Jamie Madill075edd82013-07-08 13:30:19 -0400131 aggNode->setLine(line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000132
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000133 return aggNode;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000134}
135
136//
137// Turn an existing node into an aggregate.
138//
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700139// Returns an aggregate, unless NULL was passed in for the existing node.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000140//
Olli Etuaho32db19b2016-10-04 14:43:16 +0100141TIntermAggregate *TIntermediate::MakeAggregate(TIntermNode *node, const TSourceLoc &line)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000142{
Olli Etuaho32db19b2016-10-04 14:43:16 +0100143 if (node == nullptr)
144 return nullptr;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000145
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700146 TIntermAggregate *aggNode = new TIntermAggregate;
147 aggNode->getSequence()->push_back(node);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000148
Jamie Madill075edd82013-07-08 13:30:19 -0400149 aggNode->setLine(line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000150
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000151 return aggNode;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000152}
153
Olli Etuaho7d7f8c42015-05-19 18:38:49 +0300154// If the input node is nullptr, return nullptr.
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100155// If the input node is a block node, return it.
156// If the input node is not a block node, put it inside a block node and return that.
157TIntermBlock *TIntermediate::EnsureBlock(TIntermNode *node)
Olli Etuaho7d7f8c42015-05-19 18:38:49 +0300158{
159 if (node == nullptr)
160 return nullptr;
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100161 TIntermBlock *blockNode = node->getAsBlock();
162 if (blockNode != nullptr)
163 return blockNode;
Olli Etuaho7d7f8c42015-05-19 18:38:49 +0300164
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100165 blockNode = new TIntermBlock();
166 blockNode->setLine(node->getLine());
167 blockNode->getSequence()->push_back(node);
168 return blockNode;
Olli Etuaho7d7f8c42015-05-19 18:38:49 +0300169}
170
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000171// For "if" test nodes. There are three children; a condition,
172// a true path, and a false path. The two paths are in the
173// nodePair.
174//
Olli Etuaho57961272016-09-14 13:57:46 +0300175// Returns the node created.
176TIntermNode *TIntermediate::addIfElse(TIntermTyped *cond,
177 TIntermNodePair nodePair,
178 const TSourceLoc &line)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000179{
Olli Etuaho57961272016-09-14 13:57:46 +0300180 // For compile time constant conditions, prune the code now.
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000181
Olli Etuaho7c3848e2015-11-04 13:19:17 +0200182 if (cond->getAsConstantUnion())
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700183 {
shannon.woods%transgaming.com@gtempaccount.comc0d0c222013-04-13 03:29:36 +0000184 if (cond->getAsConstantUnion()->getBConst(0) == true)
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700185 {
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100186 return EnsureBlock(nodePair.node1);
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700187 }
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000188 else
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700189 {
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100190 return EnsureBlock(nodePair.node2);
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700191 }
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000192 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000193
Olli Etuaho57961272016-09-14 13:57:46 +0300194 TIntermIfElse *node =
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100195 new TIntermIfElse(cond, EnsureBlock(nodePair.node1), EnsureBlock(nodePair.node2));
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000196 node->setLine(line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000197
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000198 return node;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000199}
200
Olli Etuaho4db7ded2016-10-13 12:23:11 +0100201TIntermTyped *TIntermediate::AddComma(TIntermTyped *left,
Olli Etuaho15200042015-11-04 16:56:31 +0200202 TIntermTyped *right,
203 const TSourceLoc &line,
204 int shaderVersion)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000205{
Olli Etuaho15200042015-11-04 16:56:31 +0200206 TIntermTyped *commaNode = nullptr;
207 if (!left->hasSideEffects())
208 {
209 commaNode = right;
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700210 }
211 else
212 {
Olli Etuaho4db7ded2016-10-13 12:23:11 +0100213 commaNode = new TIntermBinary(EOpComma, left, right);
214 commaNode->setLine(line);
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000215 }
Olli Etuaho4db7ded2016-10-13 12:23:11 +0100216 TQualifier resultQualifier = TIntermBinary::GetCommaQualifier(shaderVersion, left, right);
Olli Etuaho15200042015-11-04 16:56:31 +0200217 commaNode->getTypePointer()->setQualifier(resultQualifier);
218 return commaNode;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000219}
220
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000221// For "?:" test nodes. There are three children; a condition,
222// a true path, and a false path. The two paths are specified
223// as separate parameters.
224//
Olli Etuahod0bad2c2016-09-09 18:01:16 +0300225// Returns the ternary node created, or one of trueExpression and falseExpression if the expression
226// could be folded.
227TIntermTyped *TIntermediate::AddTernarySelection(TIntermTyped *cond,
228 TIntermTyped *trueExpression,
229 TIntermTyped *falseExpression,
230 const TSourceLoc &line)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000231{
Olli Etuaho7c3848e2015-11-04 13:19:17 +0200232 // Note that the node resulting from here can be a constant union without being qualified as
233 // constant.
234 if (cond->getAsConstantUnion())
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700235 {
Olli Etuahod0bad2c2016-09-09 18:01:16 +0300236 TQualifier resultQualifier =
237 TIntermTernary::DetermineQualifier(cond, trueExpression, falseExpression);
shannon.woods%transgaming.com@gtempaccount.comc0d0c222013-04-13 03:29:36 +0000238 if (cond->getAsConstantUnion()->getBConst(0))
Olli Etuaho7c3848e2015-11-04 13:19:17 +0200239 {
Olli Etuahod0bad2c2016-09-09 18:01:16 +0300240 trueExpression->getTypePointer()->setQualifier(resultQualifier);
241 return trueExpression;
Olli Etuaho7c3848e2015-11-04 13:19:17 +0200242 }
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000243 else
Olli Etuaho7c3848e2015-11-04 13:19:17 +0200244 {
Olli Etuahod0bad2c2016-09-09 18:01:16 +0300245 falseExpression->getTypePointer()->setQualifier(resultQualifier);
246 return falseExpression;
Olli Etuaho7c3848e2015-11-04 13:19:17 +0200247 }
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000248 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000249
Olli Etuahod0bad2c2016-09-09 18:01:16 +0300250 // Make a ternary node.
251 TIntermTernary *node = new TIntermTernary(cond, trueExpression, falseExpression);
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000252 node->setLine(line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000253
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000254 return node;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000255}
256
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100257TIntermSwitch *TIntermediate::addSwitch(TIntermTyped *init,
258 TIntermBlock *statementList,
259 const TSourceLoc &line)
Olli Etuahoa3a36662015-02-17 13:46:51 +0200260{
Olli Etuaho3c1dfb52015-02-20 11:34:03 +0200261 TIntermSwitch *node = new TIntermSwitch(init, statementList);
262 node->setLine(line);
263
264 return node;
Olli Etuahoa3a36662015-02-17 13:46:51 +0200265}
266
267TIntermCase *TIntermediate::addCase(
268 TIntermTyped *condition, const TSourceLoc &line)
269{
Olli Etuaho3c1dfb52015-02-20 11:34:03 +0200270 TIntermCase *node = new TIntermCase(condition);
271 node->setLine(line);
272
273 return node;
Olli Etuahoa3a36662015-02-17 13:46:51 +0200274}
275
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000276//
277// Constant terminal nodes. Has a union that contains bool, float or int constants
278//
279// Returns the constant union node created.
280//
281
Olli Etuaho5c0e0232015-11-11 15:55:59 +0200282TIntermConstantUnion *TIntermediate::addConstantUnion(const TConstantUnion *constantUnion,
283 const TType &type,
284 const TSourceLoc &line)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000285{
Jamie Madillb11e2482015-05-04 14:21:22 -0400286 TIntermConstantUnion *node = new TIntermConstantUnion(constantUnion, type);
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000287 node->setLine(line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000288
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000289 return node;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000290}
291
Olli Etuahob6fa0432016-09-28 16:28:05 +0100292TIntermTyped *TIntermediate::AddSwizzle(TIntermTyped *baseExpression,
293 const TVectorFields &fields,
294 const TSourceLoc &dotLocation)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000295{
Olli Etuahob6fa0432016-09-28 16:28:05 +0100296 TVector<int> fieldsVector;
297 for (int i = 0; i < fields.num; ++i)
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700298 {
Olli Etuahob6fa0432016-09-28 16:28:05 +0100299 fieldsVector.push_back(fields.offsets[i]);
300 }
301 TIntermSwizzle *node = new TIntermSwizzle(baseExpression, fieldsVector);
302 node->setLine(dotLocation);
303
304 TIntermTyped *folded = node->fold();
305 if (folded)
306 {
307 return folded;
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000308 }
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000309
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000310 return node;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000311}
312
313//
314// Create loop nodes.
315//
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700316TIntermNode *TIntermediate::addLoop(
317 TLoopType type, TIntermNode *init, TIntermTyped *cond, TIntermTyped *expr,
318 TIntermNode *body, const TSourceLoc &line)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000319{
Olli Etuaho6d40bbd2016-09-30 13:49:38 +0100320 TIntermNode *node = new TIntermLoop(type, init, cond, expr, EnsureBlock(body));
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000321 node->setLine(line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000322
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000323 return node;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000324}
325
326//
327// Add branches.
328//
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700329TIntermBranch* TIntermediate::addBranch(
330 TOperator branchOp, const TSourceLoc &line)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000331{
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000332 return addBranch(branchOp, 0, line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000333}
334
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700335TIntermBranch* TIntermediate::addBranch(
336 TOperator branchOp, TIntermTyped *expression, const TSourceLoc &line)
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000337{
Zhenyao Moe40d1e92014-07-16 17:40:36 -0700338 TIntermBranch *node = new TIntermBranch(branchOp, expression);
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000339 node->setLine(line);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000340
alokp@chromium.org2cf17712010-03-30 20:33:18 +0000341 return node;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +0000342}
343
Olli Etuahof119a262016-08-19 15:54:22 +0300344TIntermTyped *TIntermediate::foldAggregateBuiltIn(TIntermAggregate *aggregate,
345 TDiagnostics *diagnostics)
Arun Patole274f0702015-05-05 13:33:30 +0530346{
Olli Etuahob43846e2015-06-02 18:18:57 +0300347 switch (aggregate->getOp())
Arun Patole274f0702015-05-05 13:33:30 +0530348 {
Olli Etuaho1d122782015-11-06 15:35:17 +0200349 case EOpAtan:
350 case EOpPow:
351 case EOpMod:
352 case EOpMin:
353 case EOpMax:
354 case EOpClamp:
355 case EOpMix:
356 case EOpStep:
357 case EOpSmoothStep:
358 case EOpMul:
359 case EOpOuterProduct:
360 case EOpLessThan:
361 case EOpLessThanEqual:
362 case EOpGreaterThan:
363 case EOpGreaterThanEqual:
364 case EOpVectorEqual:
365 case EOpVectorNotEqual:
366 case EOpDistance:
367 case EOpDot:
368 case EOpCross:
369 case EOpFaceForward:
370 case EOpReflect:
371 case EOpRefract:
Olli Etuahof119a262016-08-19 15:54:22 +0300372 return aggregate->fold(diagnostics);
Olli Etuaho1d122782015-11-06 15:35:17 +0200373 default:
374 // TODO: Add support for folding array constructors
375 if (aggregate->isConstructor() && !aggregate->isArray())
376 {
Olli Etuahof119a262016-08-19 15:54:22 +0300377 return aggregate->fold(diagnostics);
Olli Etuaho1d122782015-11-06 15:35:17 +0200378 }
379 // Constant folding not supported for the built-in.
380 return nullptr;
Arun Patole274f0702015-05-05 13:33:30 +0530381 }
Arun Patole274f0702015-05-05 13:33:30 +0530382}