Commit bd674557 by Olli Etuaho Committed by Commit Bot

Separate function info from TIntermAggregate

This change will make it easier to split types of TIntermAggregate nodes representing functions and function calls into different node classes. BUG=angleproject:1490 TEST=angle_unittests Change-Id: I730aa7858fe31fda86218fc685980c6ad486f5e0 Reviewed-on: https://chromium-review.googlesource.com/394706Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent bd3f8780
......@@ -103,7 +103,7 @@ class PullGradient : public TIntermTraverser
{
if (node->isUserDefined())
{
size_t calleeIndex = mDag.findIndex(node);
size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);
UNUSED_ASSERTION_VARIABLE(mIndex);
......@@ -113,7 +113,8 @@ class PullGradient : public TIntermTraverser
}
else
{
TString name = TFunction::unmangleName(node->getName());
TString name =
TFunction::unmangleName(node->getFunctionSymbolInfo()->getName());
if (name == "texture2D" ||
name == "texture2DProj" ||
......@@ -275,7 +276,7 @@ class PullComputeDiscontinuousAndGradientLoops : public TIntermTraverser
{
if (node->isUserDefined())
{
size_t calleeIndex = mDag.findIndex(node);
size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);
UNUSED_ASSERTION_VARIABLE(mIndex);
......@@ -356,7 +357,7 @@ class PushDiscontinuousLoops : public TIntermTraverser
case EOpFunctionCall:
if (visit == PreVisit && node->isUserDefined() && mNestedDiscont > 0)
{
size_t calleeIndex = mDag.findIndex(node);
size_t calleeIndex = mDag.findIndex(node->getFunctionSymbolInfo());
ASSERT(calleeIndex != CallDAG::InvalidIndex && calleeIndex < mIndex);
UNUSED_ASSERTION_VARIABLE(mIndex);
......
......@@ -41,8 +41,7 @@ TIntermAggregate *CreateReplacementCall(TIntermAggregate *originalCall, TIntermT
TIntermAggregate *replacementCall = new TIntermAggregate(EOpFunctionCall);
replacementCall->setType(TType(EbtVoid));
replacementCall->setUserDefined();
replacementCall->setNameObj(originalCall->getNameObj());
replacementCall->setFunctionId(originalCall->getFunctionId());
*replacementCall->getFunctionSymbolInfo() = *originalCall->getFunctionSymbolInfo();
replacementCall->setLine(originalCall->getLine());
TIntermSequence *replacementParameters = replacementCall->getSequence();
TIntermSequence *originalParameters = originalCall->getSequence();
......@@ -118,8 +117,7 @@ bool ArrayReturnValueToOutParameterTraverser::visitAggregate(Visit visit, TInter
CopyAggregateChildren(node, replacement);
replacement->getSequence()->push_back(CreateReturnValueOutSymbol(node->getType()));
replacement->setUserDefined();
replacement->setNameObj(node->getNameObj());
replacement->setFunctionId(node->getFunctionId());
*replacement->getFunctionSymbolInfo() = *node->getFunctionSymbolInfo();
replacement->setLine(node->getLine());
replacement->setType(TType(EbtVoid));
......
......@@ -76,7 +76,8 @@ class CallDAG::CallDAGCreator : public TIntermTraverser
record.callees.push_back(static_cast<int>(callee->index));
}
(*idToIndex)[data.node->getFunctionId()] = static_cast<int>(data.index);
(*idToIndex)[data.node->getFunctionSymbolInfo()->getId()] =
static_cast<int>(data.index);
}
}
......@@ -109,8 +110,8 @@ class CallDAG::CallDAGCreator : public TIntermTraverser
if (visit == PreVisit)
{
// Function declaration, create an empty record.
auto& record = mFunctions[node->getName()];
record.name = node->getName();
auto &record = mFunctions[node->getFunctionSymbolInfo()->getName()];
record.name = node->getFunctionSymbolInfo()->getName();
}
break;
case EOpFunction:
......@@ -118,11 +119,11 @@ class CallDAG::CallDAGCreator : public TIntermTraverser
// Function definition, create the record if need be and remember the node.
if (visit == PreVisit)
{
auto it = mFunctions.find(node->getName());
auto it = mFunctions.find(node->getFunctionSymbolInfo()->getName());
if (it == mFunctions.end())
{
mCurrentFunction = &mFunctions[node->getName()];
mCurrentFunction = &mFunctions[node->getFunctionSymbolInfo()->getName()];
}
else
{
......@@ -130,8 +131,7 @@ class CallDAG::CallDAGCreator : public TIntermTraverser
}
mCurrentFunction->node = node;
mCurrentFunction->name = node->getName();
mCurrentFunction->name = node->getFunctionSymbolInfo()->getName();
}
else if (visit == PostVisit)
{
......@@ -147,7 +147,7 @@ class CallDAG::CallDAGCreator : public TIntermTraverser
// Do not handle calls to builtin functions
if (node->isUserDefined())
{
auto it = mFunctions.find(node->getName());
auto it = mFunctions.find(node->getFunctionSymbolInfo()->getName());
ASSERT(it != mFunctions.end());
// We might be in a top-level function call to set a global variable
......@@ -283,13 +283,9 @@ CallDAG::~CallDAG()
const size_t CallDAG::InvalidIndex = std::numeric_limits<size_t>::max();
size_t CallDAG::findIndex(const TIntermAggregate *function) const
size_t CallDAG::findIndex(const TFunctionSymbolInfo *functionInfo) const
{
TOperator op = function->getOp();
ASSERT(op == EOpPrototype || op == EOpFunction || op == EOpFunctionCall);
UNUSED_ASSERTION_VARIABLE(op);
auto it = mFunctionIdToIndex.find(function->getFunctionId());
auto it = mFunctionIdToIndex.find(functionInfo->getId());
if (it == mFunctionIdToIndex.end())
{
......@@ -309,7 +305,7 @@ const CallDAG::Record &CallDAG::getRecordFromIndex(size_t index) const
const CallDAG::Record &CallDAG::getRecord(const TIntermAggregate *function) const
{
size_t index = findIndex(function);
size_t index = findIndex(function->getFunctionSymbolInfo());
ASSERT(index != InvalidIndex && index < mRecords.size());
return mRecords[index];
}
......
......@@ -57,7 +57,7 @@ class CallDAG : angle::NonCopyable
InitResult init(TIntermNode *root, TInfoSinkBase *info);
// Returns InvalidIndex if the function wasn't found
size_t findIndex(const TIntermAggregate *function) const;
size_t findIndex(const TFunctionSymbolInfo *functionInfo) const;
const Record &getRecordFromIndex(size_t index) const;
const Record &getRecord(const TIntermAggregate *function) const;
......
......@@ -769,7 +769,7 @@ class TCompiler::UnusedPredicate
return false;
}
size_t callDagIndex = mCallDag->findIndex(asAggregate);
size_t callDagIndex = mCallDag->findIndex(asAggregate->getFunctionSymbolInfo());
if (callDagIndex == CallDAG::InvalidIndex)
{
// This happens only for unimplemented prototypes which are thus unused
......
......@@ -18,23 +18,23 @@
namespace
{
void SetInternalFunctionName(TIntermAggregate *functionNode, const char *name)
void SetInternalFunctionName(TFunctionSymbolInfo *functionInfo, const char *name)
{
TString nameStr(name);
nameStr = TFunction::mangleName(nameStr);
TName nameObj(nameStr);
nameObj.setInternal(true);
functionNode->setNameObj(nameObj);
functionInfo->setNameObj(nameObj);
}
TIntermAggregate *CreateFunctionPrototypeNode(const char *name, const int functionId)
{
TIntermAggregate *functionNode = new TIntermAggregate(EOpPrototype);
SetInternalFunctionName(functionNode, name);
SetInternalFunctionName(functionNode->getFunctionSymbolInfo(), name);
TType returnType(EbtVoid);
functionNode->setType(returnType);
functionNode->setFunctionId(functionId);
functionNode->getFunctionSymbolInfo()->setId(functionId);
return functionNode;
}
......@@ -47,10 +47,10 @@ TIntermAggregate *CreateFunctionDefinitionNode(const char *name,
functionNode->getSequence()->push_back(paramsNode);
functionNode->getSequence()->push_back(functionBody);
SetInternalFunctionName(functionNode, name);
SetInternalFunctionName(functionNode->getFunctionSymbolInfo(), name);
TType returnType(EbtVoid);
functionNode->setType(returnType);
functionNode->setFunctionId(functionId);
functionNode->getFunctionSymbolInfo()->setId(functionId);
return functionNode;
}
......@@ -59,10 +59,10 @@ TIntermAggregate *CreateFunctionCallNode(const char *name, const int functionId)
TIntermAggregate *functionNode = new TIntermAggregate(EOpFunctionCall);
functionNode->setUserDefined();
SetInternalFunctionName(functionNode, name);
SetInternalFunctionName(functionNode->getFunctionSymbolInfo(), name);
TType returnType(EbtVoid);
functionNode->setType(returnType);
functionNode->setFunctionId(functionId);
functionNode->getFunctionSymbolInfo()->setId(functionId);
return functionNode;
}
......@@ -165,7 +165,7 @@ void DeferGlobalInitializersTraverser::insertInitFunction(TIntermBlock *root)
{
TIntermAggregate *nodeAgg = node->getAsAggregate();
if (nodeAgg != nullptr && nodeAgg->getOp() == EOpFunction &&
TFunction::unmangleName(nodeAgg->getName()) == "main")
nodeAgg->getFunctionSymbolInfo()->isMain())
{
TIntermAggregate *functionCallNode =
CreateFunctionCallNode(functionName, initFunctionId);
......
......@@ -81,7 +81,7 @@ bool GLFragColorBroadcastTraverser::visitAggregate(Visit visit, TIntermAggregate
case EOpFunction:
// Function definition.
ASSERT(visit == PreVisit);
if (node->getName() == "main(")
if (node->getFunctionSymbolInfo()->isMain())
{
TIntermSequence *sequence = node->getSequence();
ASSERT(sequence->size() == 2);
......
......@@ -430,7 +430,7 @@ TIntermAggregate *createInternalFunctionCallNode(TString name, TIntermNode *chil
callNode->setOp(EOpFunctionCall);
TName nameObj(TFunction::mangleName(name));
nameObj.setInternal(true);
callNode->setNameObj(nameObj);
callNode->getFunctionSymbolInfo()->setNameObj(nameObj);
callNode->getSequence()->push_back(child);
return callNode;
}
......
......@@ -49,7 +49,7 @@ bool VariableInitializer::visitAggregate(Visit visit, TIntermAggregate *node)
{
// Function definition.
ASSERT(visit == PreVisit);
if (node->getName() == "main(")
if (node->getFunctionSymbolInfo()->isMain())
{
TIntermSequence *sequence = node->getSequence();
ASSERT(sequence->size() == 2);
......
......@@ -305,7 +305,7 @@ void TIntermAggregate::setBuiltInFunctionPrecision()
}
// ESSL 3.0 spec section 8: textureSize always gets highp precision.
// All other functions that take a sampler are assumed to be texture functions.
if (mName.getString().find("textureSize") == 0)
if (mFunctionInfo.getName().find("textureSize") == 0)
mType.setPrecision(EbpHigh);
else
mType.setPrecision(precision);
......@@ -455,13 +455,18 @@ TIntermConstantUnion::TIntermConstantUnion(const TIntermConstantUnion &node) : T
mUnionArrayPointer = node.mUnionArrayPointer;
}
void TFunctionSymbolInfo::setFromFunction(const TFunction &function)
{
setName(function.getMangledName());
setId(function.getUniqueId());
}
TIntermAggregate::TIntermAggregate(const TIntermAggregate &node)
: TIntermOperator(node),
mName(node.mName),
mUserDefined(node.mUserDefined),
mFunctionId(node.mFunctionId),
mUseEmulatedFunction(node.mUseEmulatedFunction),
mGotPrecisionFromChildren(node.mGotPrecisionFromChildren)
mGotPrecisionFromChildren(node.mGotPrecisionFromChildren),
mFunctionInfo(node.mFunctionInfo)
{
for (TIntermNode *child : node.mSequence)
{
......
......@@ -49,6 +49,7 @@ class TIntermRaw;
class TIntermBranch;
class TSymbolTable;
class TFunction;
// Encapsulate an identifier string and track whether it is coming from the original shader code
// (not internal) or from ANGLE (internal). Usually internal names shouldn't be decorated or hashed.
......@@ -524,6 +525,31 @@ class TIntermUnary : public TIntermOperator
TIntermUnary(const TIntermUnary &node); // note: not deleted, just private!
};
class TFunctionSymbolInfo
{
public:
POOL_ALLOCATOR_NEW_DELETE();
TFunctionSymbolInfo() : mId(0) {}
TFunctionSymbolInfo(const TFunctionSymbolInfo &) = default;
TFunctionSymbolInfo &operator=(const TFunctionSymbolInfo &) = default;
void setFromFunction(const TFunction &function);
void setNameObj(const TName &name) { mName = name; }
const TName &getNameObj() const { return mName; }
const TString &getName() const { return mName.getString(); }
void setName(const TString &name) { mName.setString(name); }
bool isMain() const { return mName.getString() == "main("; }
void setId(int functionId) { mId = functionId; }
int getId() const { return mId; }
private:
TName mName;
int mId;
};
typedef TVector<TIntermNode *> TIntermSequence;
typedef TVector<int> TQualifierList;
......@@ -554,7 +580,6 @@ class TIntermAggregate : public TIntermOperator, public TIntermAggregateBase
TIntermAggregate()
: TIntermOperator(EOpNull),
mUserDefined(false),
mFunctionId(0),
mUseEmulatedFunction(false),
mGotPrecisionFromChildren(false)
{
......@@ -562,7 +587,6 @@ class TIntermAggregate : public TIntermOperator, public TIntermAggregateBase
TIntermAggregate(TOperator op)
: TIntermOperator(op),
mUserDefined(false),
mFunctionId(0),
mUseEmulatedFunction(false),
mGotPrecisionFromChildren(false)
{
......@@ -585,18 +609,9 @@ class TIntermAggregate : public TIntermOperator, public TIntermAggregateBase
TIntermSequence *getSequence() override { return &mSequence; }
const TIntermSequence *getSequence() const override { return &mSequence; }
void setNameObj(const TName &name) { mName = name; }
const TName &getNameObj() const { return mName; }
void setName(const TString &name) { mName.setString(name); }
const TString &getName() const { return mName.getString(); }
void setUserDefined() { mUserDefined = true; }
bool isUserDefined() const { return mUserDefined; }
void setFunctionId(int functionId) { mFunctionId = functionId; }
int getFunctionId() const { return mFunctionId; }
void setUseEmulatedFunction() { mUseEmulatedFunction = true; }
bool getUseEmulatedFunction() { return mUseEmulatedFunction; }
......@@ -607,11 +622,12 @@ class TIntermAggregate : public TIntermOperator, public TIntermAggregateBase
// Returns true if changing parameter precision may affect the return value.
bool gotPrecisionFromChildren() const { return mGotPrecisionFromChildren; }
TFunctionSymbolInfo *getFunctionSymbolInfo() { return &mFunctionInfo; }
const TFunctionSymbolInfo *getFunctionSymbolInfo() const { return &mFunctionInfo; }
protected:
TIntermSequence mSequence;
TName mName;
bool mUserDefined; // used for user defined function names
int mFunctionId;
// If set to true, replace the built-in function call with an emulated one
// to work around driver bugs.
......@@ -619,6 +635,8 @@ class TIntermAggregate : public TIntermOperator, public TIntermAggregateBase
bool mGotPrecisionFromChildren;
TFunctionSymbolInfo mFunctionInfo;
private:
TIntermAggregate(const TIntermAggregate &node); // note: not deleted, just private!
};
......
......@@ -199,13 +199,14 @@ void TLValueTrackingTraverser::addToFunctionMap(const TName &name, TIntermSequen
bool TLValueTrackingTraverser::isInFunctionMap(const TIntermAggregate *callNode) const
{
ASSERT(callNode->getOp() == EOpFunctionCall);
return (mFunctionMap.find(callNode->getNameObj()) != mFunctionMap.end());
return (mFunctionMap.find(callNode->getFunctionSymbolInfo()->getNameObj()) !=
mFunctionMap.end());
}
TIntermSequence *TLValueTrackingTraverser::getFunctionParameters(const TIntermAggregate *callNode)
{
ASSERT(isInFunctionMap(callNode));
return mFunctionMap[callNode->getNameObj()];
return mFunctionMap[callNode->getFunctionSymbolInfo()->getNameObj()];
}
void TLValueTrackingTraverser::setInFunctionCallOutParameter(bool inOutParameter)
......@@ -507,11 +508,11 @@ void TLValueTrackingTraverser::traverseAggregate(TIntermAggregate *node)
TIntermAggregate *params = sequence->front()->getAsAggregate();
ASSERT(params != nullptr);
ASSERT(params->getOp() == EOpParameters);
addToFunctionMap(node->getNameObj(), params->getSequence());
addToFunctionMap(node->getFunctionSymbolInfo()->getNameObj(), params->getSequence());
break;
}
case EOpPrototype:
addToFunctionMap(node->getNameObj(), sequence);
addToFunctionMap(node->getFunctionSymbolInfo()->getNameObj(), sequence);
break;
default:
break;
......
......@@ -803,7 +803,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
out << arrayBrackets(type);
}
out << " " << hashFunctionNameIfNeeded(node->getNameObj());
out << " " << hashFunctionNameIfNeeded(node->getFunctionSymbolInfo()->getNameObj());
out << "(";
writeFunctionParameters(*(node->getSequence()));
......@@ -821,7 +821,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
out << arrayBrackets(type);
}
out << " " << hashFunctionNameIfNeeded(node->getNameObj());
out << " " << hashFunctionNameIfNeeded(node->getFunctionSymbolInfo()->getNameObj());
incrementDepth(node);
// Function definition node contains two child nodes representing the function parameters
......@@ -847,7 +847,7 @@ bool TOutputGLSLBase::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpFunctionCall:
// Function call.
if (visit == PreVisit)
out << hashFunctionNameIfNeeded(node->getNameObj()) << "(";
out << hashFunctionNameIfNeeded(node->getFunctionSymbolInfo()->getNameObj()) << "(";
else if (visit == InVisit)
out << ", ";
else
......
......@@ -1533,7 +1533,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpPrototype:
if (visit == PreVisit)
{
size_t index = mCallDag.findIndex(node);
size_t index = mCallDag.findIndex(node->getFunctionSymbolInfo());
// Skip the prototype if it is not implemented (and thus not used)
if (index == CallDAG::InvalidIndex)
{
......@@ -1542,7 +1542,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
TIntermSequence *arguments = node->getSequence();
TString name = DecorateFunctionIfNeeded(node->getNameObj());
TString name =
DecorateFunctionIfNeeded(node->getFunctionSymbolInfo()->getNameObj());
out << TypeString(node->getType()) << " " << name
<< DisambiguateFunctionName(arguments) << (mOutputLod0Function ? "Lod0(" : "(");
......@@ -1583,9 +1584,8 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpFunction:
{
ASSERT(mCurrentFunctionMetadata == nullptr);
TString name = TFunction::unmangleName(node->getNameObj().getString());
size_t index = mCallDag.findIndex(node);
size_t index = mCallDag.findIndex(node->getFunctionSymbolInfo());
ASSERT(index != CallDAG::InvalidIndex);
mCurrentFunctionMetadata = &mASTMetadataList[index];
......@@ -1594,13 +1594,13 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
TIntermSequence *sequence = node->getSequence();
TIntermSequence *arguments = (*sequence)[0]->getAsAggregate()->getSequence();
if (name == "main")
if (node->getFunctionSymbolInfo()->isMain())
{
out << "gl_main(";
}
else
{
out << DecorateFunctionIfNeeded(node->getNameObj())
out << DecorateFunctionIfNeeded(node->getFunctionSymbolInfo()->getNameObj())
<< DisambiguateFunctionName(arguments) << (mOutputLod0Function ? "Lod0(" : "(");
}
......@@ -1637,7 +1637,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
bool needsLod0 = mASTMetadataList[index].mNeedsLod0;
if (needsLod0 && !mOutputLod0Function && mShaderType == GL_FRAGMENT_SHADER)
{
ASSERT(name != "main");
ASSERT(!node->getFunctionSymbolInfo()->isMain());
mOutputLod0Function = true;
node->traverse(this);
mOutputLod0Function = false;
......@@ -1656,23 +1656,23 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{
UNIMPLEMENTED();
}
size_t index = mCallDag.findIndex(node);
size_t index = mCallDag.findIndex(node->getFunctionSymbolInfo());
ASSERT(index != CallDAG::InvalidIndex);
lod0 &= mASTMetadataList[index].mNeedsLod0;
out << DecorateFunctionIfNeeded(node->getNameObj());
out << DecorateFunctionIfNeeded(node->getFunctionSymbolInfo()->getNameObj());
out << DisambiguateFunctionName(node->getSequence());
out << (lod0 ? "Lod0(" : "(");
}
else if (node->getNameObj().isInternal())
else if (node->getFunctionSymbolInfo()->getNameObj().isInternal())
{
// This path is used for internal functions that don't have their definitions in the
// AST, such as precision emulation functions.
out << DecorateFunctionIfNeeded(node->getNameObj()) << "(";
out << DecorateFunctionIfNeeded(node->getFunctionSymbolInfo()->getNameObj()) << "(";
}
else
{
TString name = TFunction::unmangleName(node->getNameObj().getString());
TString name = TFunction::unmangleName(node->getFunctionSymbolInfo()->getName());
TBasicType samplerType = (*arguments)[0]->getAsTyped()->getType().getBasicType();
int coords = (*arguments)[1]->getAsTyped()->getNominalSize();
TString textureFunctionName = mTextureFunctionHLSL->useTextureFunction(
......
......@@ -2026,8 +2026,7 @@ TIntermAggregate *TParseContext::addFunctionPrototypeDeclaration(const TFunction
// TODO(oetuaho@nvidia.com): Instead of converting the function information here, the node could
// point to the data that already exists in the symbol table.
prototype->setType(function->getReturnType());
prototype->setName(function->getMangledName());
prototype->setFunctionId(function->getUniqueId());
prototype->getFunctionSymbolInfo()->setFromFunction(*function);
for (size_t i = 0; i < function->getParamCount(); i++)
{
......@@ -2084,9 +2083,8 @@ TIntermAggregate *TParseContext::addFunctionDefinition(const TFunction &function
}
functionNode->getSequence()->push_back(functionBody);
functionNode->setName(function.getMangledName().c_str());
functionNode->getFunctionSymbolInfo()->setFromFunction(function);
functionNode->setType(function.getReturnType());
functionNode->setFunctionId(function.getUniqueId());
symbolTable.pop();
return functionNode;
......@@ -3688,7 +3686,7 @@ TIntermBranch *TParseContext::addBranch(TOperator op,
void TParseContext::checkTextureOffsetConst(TIntermAggregate *functionCall)
{
ASSERT(!functionCall->isUserDefined());
const TString &name = functionCall->getName();
const TString &name = functionCall->getFunctionSymbolInfo()->getName();
TIntermNode *offset = nullptr;
TIntermSequence *arguments = functionCall->getSequence();
if (name.compare(0, 16, "texelFetchOffset") == 0 ||
......@@ -3877,10 +3875,9 @@ TIntermTyped *TParseContext::addFunctionCallOrMethod(TFunction *fnCall,
// if builtIn == true, it's definitely a builtIn function with EOpNull
if (!builtIn)
aggregate->setUserDefined();
aggregate->setName(fnCandidate->getMangledName());
aggregate->setFunctionId(fnCandidate->getUniqueId());
aggregate->getFunctionSymbolInfo()->setFromFunction(*fnCandidate);
// This needs to happen after the name is set
// This needs to happen after the function info including name is set
if (builtIn)
{
aggregate->setBuiltInFunctionPrecision();
......
......@@ -181,7 +181,7 @@ TIntermAggregate *GetIndexFunctionDefinition(TType type, bool write)
// principle this code could be used with multiple backends.
type.setPrecision(EbpHigh);
TIntermAggregate *indexingFunction = new TIntermAggregate(EOpFunction);
indexingFunction->setNameObj(GetIndexFunctionName(type, write));
indexingFunction->getFunctionSymbolInfo()->setNameObj(GetIndexFunctionName(type, write));
TType fieldType = GetFieldType(type);
int numCases = 0;
......@@ -350,7 +350,8 @@ TIntermAggregate *CreateIndexFunctionCall(TIntermBinary *node,
TIntermAggregate *indexingCall = new TIntermAggregate(EOpFunctionCall);
indexingCall->setLine(node->getLine());
indexingCall->setUserDefined();
indexingCall->setNameObj(GetIndexFunctionName(indexedNode->getType(), false));
indexingCall->getFunctionSymbolInfo()->setNameObj(
GetIndexFunctionName(indexedNode->getType(), false));
indexingCall->getSequence()->push_back(indexedNode);
indexingCall->getSequence()->push_back(index);
......@@ -368,7 +369,8 @@ TIntermAggregate *CreateIndexedWriteFunctionCall(TIntermBinary *node,
ASSERT(leftCopy != nullptr && leftCopy->getAsTyped() != nullptr);
TIntermAggregate *indexedWriteCall =
CreateIndexFunctionCall(node, leftCopy->getAsTyped(), index);
indexedWriteCall->setNameObj(GetIndexFunctionName(node->getLeft()->getType(), true));
indexedWriteCall->getFunctionSymbolInfo()->setNameObj(
GetIndexFunctionName(node->getLeft()->getType(), true));
indexedWriteCall->setType(TType(EbtVoid));
indexedWriteCall->getSequence()->push_back(writtenValue);
return indexedWriteCall;
......
......@@ -75,7 +75,7 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
return true;
}
if (node->getName().compare(0, 16, "texelFetchOffset") != 0)
if (node->getFunctionSymbolInfo()->getName().compare(0, 16, "texelFetchOffset") != 0)
{
return true;
}
......@@ -85,11 +85,12 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
ASSERT(sequence->size() == 4u);
// Decide if there is a 2DArray sampler.
bool is2DArray = node->getName().find("s2a1") != TString::npos;
bool is2DArray = node->getFunctionSymbolInfo()->getName().find("s2a1") != TString::npos;
// Create new argument list from node->getName().
// e.g. Get "(is2a1;vi3;i1;" from "texelFetchOffset(is2a1;vi3;i1;vi2;"
TString newArgs = node->getName().substr(16, node->getName().length() - 20);
TString newArgs = node->getFunctionSymbolInfo()->getName().substr(
16, node->getFunctionSymbolInfo()->getName().length() - 20);
TString newName = "texelFetch" + newArgs;
TSymbol *texelFetchSymbol = symbolTable->findBuiltIn(newName, shaderVersion);
ASSERT(texelFetchSymbol);
......@@ -98,8 +99,8 @@ bool Traverser::visitAggregate(Visit visit, TIntermAggregate *node)
// Create new node that represents the call of function texelFetch.
// Its argument list will be: texelFetch(sampler, Position+offset, lod).
TIntermAggregate *texelFetchNode = new TIntermAggregate(EOpFunctionCall);
texelFetchNode->setName(newName);
texelFetchNode->setFunctionId(uniqueId);
texelFetchNode->getFunctionSymbolInfo()->setName(newName);
texelFetchNode->getFunctionSymbolInfo()->setId(uniqueId);
texelFetchNode->setType(node->getType());
texelFetchNode->setLine(node->getLine());
......
......@@ -59,12 +59,11 @@ TIntermAggregate *CopyAggregateNode(TIntermAggregate *node)
TIntermSequence *copySeq = copyNode->getSequence();
copySeq->insert(copySeq->begin(), node->getSequence()->begin(), node->getSequence()->end());
copyNode->setType(node->getType());
copyNode->setFunctionId(node->getFunctionId());
*copyNode->getFunctionSymbolInfo() = *node->getFunctionSymbolInfo();
if (node->isUserDefined())
{
copyNode->setUserDefined();
}
copyNode->setNameObj(node->getNameObj());
return copyNode;
}
......
......@@ -423,7 +423,8 @@ bool ValidateLimitations::validateFunctionCall(TIntermAggregate *node)
bool valid = true;
TSymbolTable& symbolTable = GetGlobalParseContext()->symbolTable;
TSymbol* symbol = symbolTable.find(node->getName(), GetGlobalParseContext()->getShaderVersion());
TSymbol *symbol = symbolTable.find(node->getFunctionSymbolInfo()->getName(),
GetGlobalParseContext()->getShaderVersion());
ASSERT(symbol && symbol->isFunction());
TFunction *function = static_cast<TFunction *>(symbol);
for (ParamIndex::const_iterator i = pIndex.begin();
......
......@@ -12,8 +12,9 @@ namespace
void OutputFunction(TInfoSinkBase &out, const char *str, TIntermAggregate *node)
{
const char *internal = node->getNameObj().isInternal() ? " (internal function)" : "";
out << str << internal << ": " << node->getNameObj().getString();
const char *internal =
node->getFunctionSymbolInfo()->getNameObj().isInternal() ? " (internal function)" : "";
out << str << internal << ": " << node->getFunctionSymbolInfo()->getNameObj().getString();
}
//
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment