Commit 16004fca by Nicolas Capens

Eliminate conversion operations.

They've been replaced by using constructor nodes, so any code handling conversion operators can be removed. BUG=380353 Change-Id: I70413179e7443efccbf997a5dd0f053c23689589 Reviewed-on: https://chromium-review.googlesource.com/203453Tested-by: 's avatarNicolas Capens <nicolascapens@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent fd716586
// //
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -402,67 +402,6 @@ bool TOutputGLSLBase::visitUnary(Visit visit, TIntermUnary *node) ...@@ -402,67 +402,6 @@ bool TOutputGLSLBase::visitUnary(Visit visit, TIntermUnary *node)
case EOpPreIncrement: preString = "(++"; break; case EOpPreIncrement: preString = "(++"; break;
case EOpPreDecrement: preString = "(--"; break; case EOpPreDecrement: preString = "(--"; break;
case EOpConvIntToBool:
case EOpConvFloatToBool:
switch (node->getOperand()->getType().getNominalSize())
{
case 1:
preString = "bool(";
break;
case 2:
preString = "bvec2(";
break;
case 3:
preString = "bvec3(";
break;
case 4:
preString = "bvec4(";
break;
default:
UNREACHABLE();
}
break;
case EOpConvBoolToFloat:
case EOpConvIntToFloat:
switch (node->getOperand()->getType().getNominalSize())
{
case 1:
preString = "float(";
break;
case 2:
preString = "vec2(";
break;
case 3:
preString = "vec3(";
break;
case 4:
preString = "vec4(";
break;
default:
UNREACHABLE();
}
break;
case EOpConvFloatToInt:
case EOpConvBoolToInt:
switch (node->getOperand()->getType().getNominalSize())
{
case 1:
preString = "int(";
break;
case 2:
preString = "ivec2(";
break;
case 3:
preString = "ivec3(";
break;
case 4:
preString = "ivec4(";
break;
default:
UNREACHABLE();
}
break;
case EOpRadians: case EOpRadians:
preString = "radians("; preString = "radians(";
break; break;
......
...@@ -2148,61 +2148,13 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node) ...@@ -2148,61 +2148,13 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
{ {
switch (node->getOp()) switch (node->getOp())
{ {
case EOpNegative: outputTriplet(visit, "(-", "", ")"); break; case EOpNegative: outputTriplet(visit, "(-", "", ")"); break;
case EOpVectorLogicalNot: outputTriplet(visit, "(!", "", ")"); break; case EOpVectorLogicalNot: outputTriplet(visit, "(!", "", ")"); break;
case EOpLogicalNot: outputTriplet(visit, "(!", "", ")"); break; case EOpLogicalNot: outputTriplet(visit, "(!", "", ")"); break;
case EOpPostIncrement: outputTriplet(visit, "(", "", "++)"); break; case EOpPostIncrement: outputTriplet(visit, "(", "", "++)"); break;
case EOpPostDecrement: outputTriplet(visit, "(", "", "--)"); break; case EOpPostDecrement: outputTriplet(visit, "(", "", "--)"); break;
case EOpPreIncrement: outputTriplet(visit, "(++", "", ")"); break; case EOpPreIncrement: outputTriplet(visit, "(++", "", ")"); break;
case EOpPreDecrement: outputTriplet(visit, "(--", "", ")"); break; case EOpPreDecrement: outputTriplet(visit, "(--", "", ")"); break;
case EOpConvIntToBool:
case EOpConvUIntToBool:
case EOpConvFloatToBool:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: outputTriplet(visit, "bool(", "", ")"); break;
case 2: outputTriplet(visit, "bool2(", "", ")"); break;
case 3: outputTriplet(visit, "bool3(", "", ")"); break;
case 4: outputTriplet(visit, "bool4(", "", ")"); break;
default: UNREACHABLE();
}
break;
case EOpConvBoolToFloat:
case EOpConvIntToFloat:
case EOpConvUIntToFloat:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: outputTriplet(visit, "float(", "", ")"); break;
case 2: outputTriplet(visit, "float2(", "", ")"); break;
case 3: outputTriplet(visit, "float3(", "", ")"); break;
case 4: outputTriplet(visit, "float4(", "", ")"); break;
default: UNREACHABLE();
}
break;
case EOpConvFloatToInt:
case EOpConvBoolToInt:
case EOpConvUIntToInt:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: outputTriplet(visit, "int(", "", ")"); break;
case 2: outputTriplet(visit, "int2(", "", ")"); break;
case 3: outputTriplet(visit, "int3(", "", ")"); break;
case 4: outputTriplet(visit, "int4(", "", ")"); break;
default: UNREACHABLE();
}
break;
case EOpConvFloatToUInt:
case EOpConvBoolToUInt:
case EOpConvIntToUInt:
switch (node->getOperand()->getType().getNominalSize())
{
case 1: outputTriplet(visit, "uint(", "", ")"); break;
case 2: outputTriplet(visit, "uint2(", "", ")"); break;
case 3: outputTriplet(visit, "uint3(", "", ")"); break;
case 4: outputTriplet(visit, "uint4(", "", ")"); break;
default: UNREACHABLE();
}
break;
case EOpRadians: outputTriplet(visit, "radians(", "", ")"); break; case EOpRadians: outputTriplet(visit, "radians(", "", ")"); break;
case EOpDegrees: outputTriplet(visit, "degrees(", "", ")"); break; case EOpDegrees: outputTriplet(visit, "degrees(", "", ")"); break;
case EOpSin: outputTriplet(visit, "sin(", "", ")"); break; case EOpSin: outputTriplet(visit, "sin(", "", ")"); break;
......
...@@ -1591,102 +1591,6 @@ TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, co ...@@ -1591,102 +1591,6 @@ TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, co
return 0; return 0;
} }
// Function for constructor implementation. Calls addUnaryMath with appropriate EOp value
// for the parameter to the constructor (passed to this function). Essentially, it converts
// the parameter types correctly. If a constructor expects an int (like ivec2) and is passed a
// float, then float is converted to int.
//
// Returns 0 for an error or the constructed node.
//
TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, TIntermNode* node, const TSourceLoc& line, bool subset)
{
TIntermTyped* newNode;
TOperator basicOp;
//
// First, convert types as needed.
//
switch (op) {
case EOpConstructVec2:
case EOpConstructVec3:
case EOpConstructVec4:
case EOpConstructMat2:
case EOpConstructMat3:
case EOpConstructMat4:
case EOpConstructFloat:
basicOp = EOpConstructFloat;
break;
case EOpConstructIVec2:
case EOpConstructIVec3:
case EOpConstructIVec4:
case EOpConstructInt:
basicOp = EOpConstructInt;
break;
case EOpConstructUVec2:
case EOpConstructUVec3:
case EOpConstructUVec4:
case EOpConstructUInt:
basicOp = EOpConstructUInt;
break;
case EOpConstructBVec2:
case EOpConstructBVec3:
case EOpConstructBVec4:
case EOpConstructBool:
basicOp = EOpConstructBool;
break;
default:
error(line, "unsupported construction", "");
recover();
return 0;
}
newNode = intermediate.addUnaryMath(basicOp, node, node->getLine());
if (newNode == 0) {
error(line, "can't convert", "constructor");
return 0;
}
//
// Now, if there still isn't an operation to do the construction, and we need one, add one.
//
// Otherwise, skip out early.
if (subset || (newNode != node && newNode->getType() == *type))
return newNode;
// setAggregateOperator will insert a new node for the constructor, as needed.
return intermediate.setAggregateOperator(newNode, op, line);
}
// This function tests for the type of the parameters to the structures constructors. Raises
// an error message if the expected type does not match the parameter passed to the constructor.
//
// Returns 0 for an error or the input node itself if the expected and the given parameter types match.
//
TIntermTyped* TParseContext::constructStruct(TIntermNode* node, TType* type, int paramCount, const TSourceLoc& line, bool subset)
{
if (*type == node->getAsTyped()->getType()) {
if (subset)
return node->getAsTyped();
else
return intermediate.setAggregateOperator(node->getAsTyped(), EOpConstructStruct, line);
} else {
std::stringstream extraInfoStream;
extraInfoStream << "cannot convert parameter " << paramCount
<< " from '" << node->getAsTyped()->getType().getBasicString()
<< "' to '" << type->getBasicString() << "'";
std::string extraInfo = extraInfoStream.str();
error(line, "", "constructor", extraInfo.c_str());
recover();
}
return 0;
}
// //
// This function returns the tree representation for the vector field(s) being accessed from contant vector. // This function returns the tree representation for the vector field(s) being accessed from contant vector.
// If only one component of vector is accessed (v.x or v[0] where v is a contant vector), then a contant node is // If only one component of vector is accessed (v.x or v[0] where v is a contant vector), then a contant node is
......
// //
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -133,8 +133,6 @@ struct TParseContext { ...@@ -133,8 +133,6 @@ struct TParseContext {
TFunction *addConstructorFunc(TPublicType publicType); TFunction *addConstructorFunc(TPublicType publicType);
TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, const TSourceLoc&); TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, const TSourceLoc&);
TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type); TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type);
TIntermTyped* constructStruct(TIntermNode*, TType*, int, const TSourceLoc&, bool subset);
TIntermTyped* constructBuiltIn(const TType*, TOperator, TIntermNode*, const TSourceLoc&, bool subset);
TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, const TSourceLoc&); TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, const TSourceLoc&);
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, const TSourceLoc&); TIntermTyped* addConstMatrixNode(int , TIntermTyped*, const TSourceLoc&);
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, const TSourceLoc& line); TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, const TSourceLoc& line);
......
// //
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -153,18 +153,6 @@ bool TOutputTraverser::visitUnary(Visit visit, TIntermUnary* node) ...@@ -153,18 +153,6 @@ bool TOutputTraverser::visitUnary(Visit visit, TIntermUnary* node)
case EOpPreIncrement: out << "Pre-Increment"; break; case EOpPreIncrement: out << "Pre-Increment"; break;
case EOpPreDecrement: out << "Pre-Decrement"; break; case EOpPreDecrement: out << "Pre-Decrement"; break;
case EOpConvIntToBool: out << "Convert int to bool"; break;
case EOpConvUIntToBool: out << "Convert uint to bool"; break;
case EOpConvFloatToBool:out << "Convert float to bool";break;
case EOpConvBoolToFloat:out << "Convert bool to float";break;
case EOpConvIntToFloat: out << "Convert int to float"; break;
case EOpConvUIntToFloat:out << "Convert uint to float";break;
case EOpConvFloatToInt: out << "Convert float to int"; break;
case EOpConvBoolToInt: out << "Convert bool to int"; break;
case EOpConvIntToUInt: out << "Convert int to uint"; break;
case EOpConvFloatToUInt:out << "Convert float to uint";break;
case EOpConvBoolToUInt: out << "Convert bool to uint"; break;
case EOpRadians: out << "radians"; break; case EOpRadians: out << "radians"; break;
case EOpDegrees: out << "degrees"; break; case EOpDegrees: out << "degrees"; break;
case EOpSin: out << "sine"; break; case EOpSin: out << "sine"; break;
......
// //
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -50,19 +50,6 @@ enum TOperator { ...@@ -50,19 +50,6 @@ enum TOperator {
EOpPreIncrement, EOpPreIncrement,
EOpPreDecrement, EOpPreDecrement,
EOpConvIntToBool,
EOpConvUIntToBool,
EOpConvFloatToBool,
EOpConvBoolToFloat,
EOpConvIntToFloat,
EOpConvUIntToFloat,
EOpConvFloatToInt,
EOpConvBoolToInt,
EOpConvUIntToInt,
EOpConvIntToUInt,
EOpConvFloatToUInt,
EOpConvBoolToUInt,
// //
// binary operations // binary operations
// //
......
// //
// Copyright (c) 2002-2013 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2002-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -24,7 +24,6 @@ public: ...@@ -24,7 +24,6 @@ public:
TIntermediate(TInfoSink& i) : infoSink(i) { } TIntermediate(TInfoSink& i) : infoSink(i) { }
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TSourceLoc&); TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TSourceLoc&);
TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*);
TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&); TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&);
...@@ -36,7 +35,6 @@ public: ...@@ -36,7 +35,6 @@ public:
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&); TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&);
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&); TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, const TSourceLoc&); TIntermConstantUnion* addConstantUnion(ConstantUnion*, const TType&, const TSourceLoc&);
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
bool parseConstTree(const TSourceLoc&, TIntermNode*, ConstantUnion*, TOperator, TType, bool singleConstantParam = false); bool parseConstTree(const TSourceLoc&, TIntermNode*, ConstantUnion*, TOperator, TType, bool singleConstantParam = false);
TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, const TSourceLoc&); TIntermNode* addLoop(TLoopType, TIntermNode*, TIntermTyped*, TIntermTyped*, TIntermNode*, const TSourceLoc&);
TIntermBranch* addBranch(TOperator, const TSourceLoc&); TIntermBranch* addBranch(TOperator, const TSourceLoc&);
......
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