Factor out all operators that are invalid for ES2.

TRAC #11347 Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/trunk@20 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 41430498
......@@ -513,7 +513,6 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable)
symbolTable.relateToOperator("not", EOpVectorLogicalNot);
symbolTable.relateToOperator("matrixCompMult", EOpMul);
symbolTable.relateToOperator("mod", EOpMod);
symbolTable.relateToOperator("equal", EOpVectorEqual);
symbolTable.relateToOperator("notEqual", EOpVectorNotEqual);
......@@ -544,6 +543,7 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable)
symbolTable.relateToOperator("floor", EOpFloor);
symbolTable.relateToOperator("ceil", EOpCeil);
symbolTable.relateToOperator("fract", EOpFract);
symbolTable.relateToOperator("mod", EOpMod);
symbolTable.relateToOperator("min", EOpMin);
symbolTable.relateToOperator("max", EOpMax);
symbolTable.relateToOperator("clamp", EOpClamp);
......@@ -568,21 +568,9 @@ void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable)
case EShLangVertex:
break;
case EShLangFragment:
// symbolTable.relateToOperator("dFdx", EOpDPdx);
// symbolTable.relateToOperator("dFdy", EOpDPdy);
// symbolTable.relateToOperator("fwidth", EOpFwidth);
break;
case EShLangPack:
case EShLangUnpack:
symbolTable.relateToOperator("itof", EOpItof);
symbolTable.relateToOperator("ftoi", EOpFtoi);
symbolTable.relateToOperator("skipPixels", EOpSkipPixels);
symbolTable.relateToOperator("readInput", EOpReadInput);
symbolTable.relateToOperator("writePixel", EOpWritePixel);
symbolTable.relateToOperator("bitmapLSB", EOpBitmapLsb);
symbolTable.relateToOperator("bitmapMSB", EOpBitmapMsb);
symbolTable.relateToOperator("writeOutput", EOpWriteOutput);
symbolTable.relateToOperator("readPixel", EOpReadPixel);
// symbolTable.relateToOperator("dFdx", EOpDPdx); // OES_standard_derivatives extension
// symbolTable.relateToOperator("dFdy", EOpDPdy); // OES_standard_derivatives extension
// symbolTable.relateToOperator("fwidth", EOpFwidth); // OES_standard_derivatives extension
break;
default: assert(false && "Language not supported");
}
......
......@@ -679,12 +679,6 @@ bool TIntermOperator::modifiesState() const
case EOpMatrixTimesScalarAssign:
case EOpMatrixTimesMatrixAssign:
case EOpDivAssign:
case EOpModAssign:
case EOpAndAssign:
case EOpInclusiveOrAssign:
case EOpExclusiveOrAssign:
case EOpLeftShiftAssign:
case EOpRightShiftAssign:
return true;
default:
return false;
......@@ -731,10 +725,6 @@ bool TIntermUnary::promote(TInfoSink&)
if (operand->getBasicType() != EbtBool)
return false;
break;
case EOpBitwiseNot:
if (operand->getBasicType() != EbtInt)
return false;
break;
case EOpNegative:
case EOpPostIncrement:
case EOpPostDecrement:
......@@ -847,28 +837,6 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
break;
//
// Check for integer only operands.
//
case EOpMod:
case EOpRightShift:
case EOpLeftShift:
case EOpAnd:
case EOpInclusiveOr:
case EOpExclusiveOr:
if (left->getBasicType() != EbtInt || right->getBasicType() != EbtInt)
return false;
break;
case EOpModAssign:
case EOpAndAssign:
case EOpInclusiveOrAssign:
case EOpExclusiveOrAssign:
case EOpLeftShiftAssign:
case EOpRightShiftAssign:
if (left->getBasicType() != EbtInt || right->getBasicType() != EbtInt)
return false;
// fall through
//
// Everything else should have matching types
//
default:
......@@ -957,11 +925,9 @@ bool TIntermBinary::promote(TInfoSink& infoSink)
case EOpAdd:
case EOpSub:
case EOpDiv:
case EOpMod:
case EOpAddAssign:
case EOpSubAssign:
case EOpDivAssign:
case EOpModAssign:
if (left->isMatrix() && right->isVector() ||
left->isVector() && right->isMatrix() ||
left->getBasicType() != right->getBasicType())
......@@ -996,12 +962,6 @@ default:
case EOpSubAssign:
case EOpMulAssign:
case EOpDivAssign:
case EOpModAssign:
case EOpAndAssign:
case EOpInclusiveOrAssign:
case EOpExclusiveOrAssign:
case EOpLeftShiftAssign:
case EOpRightShiftAssign:
if (getType() != left->getType())
return false;
break;
......@@ -1200,52 +1160,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
}
break;
case EOpMod:
tempConstArray = new constUnion[objectSize];
{// support MSVC++6.0
for (int i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] % rightUnionArray[i];
}
break;
case EOpRightShift:
tempConstArray = new constUnion[objectSize];
{// support MSVC++6.0
for (int i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] >> rightUnionArray[i];
}
break;
case EOpLeftShift:
tempConstArray = new constUnion[objectSize];
{// support MSVC++6.0
for (int i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] << rightUnionArray[i];
}
break;
case EOpAnd:
tempConstArray = new constUnion[objectSize];
{// support MSVC++6.0
for (int i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] & rightUnionArray[i];
}
break;
case EOpInclusiveOr:
tempConstArray = new constUnion[objectSize];
{// support MSVC++6.0
for (int i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] | rightUnionArray[i];
}
break;
case EOpExclusiveOr:
tempConstArray = new constUnion[objectSize];
{// support MSVC++6.0
for (int i = 0; i < objectSize; i++)
tempConstArray[i] = unionArray[i] ^ rightUnionArray[i];
}
break;
case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
tempConstArray = new constUnion[objectSize];
{// support MSVC++6.0
......
......@@ -406,12 +406,6 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
case EOpMatrixTimesScalarAssign: UNIMPLEMENTED(); /* FIXME */ out << "matrix scale second child into first child"; break;
case EOpMatrixTimesMatrixAssign: UNIMPLEMENTED(); /* FIXME */ out << "matrix mult second child into first child"; break;
case EOpDivAssign: outputTriplet(visit, NULL, " /= ", NULL); break;
case EOpModAssign: UNIMPLEMENTED(); /* FIXME */ out << "mod second child into first child"; break;
case EOpAndAssign: UNIMPLEMENTED(); /* FIXME */ out << "and second child into first child"; break;
case EOpInclusiveOrAssign: UNIMPLEMENTED(); /* FIXME */ out << "or second child into first child"; break;
case EOpExclusiveOrAssign: UNIMPLEMENTED(); /* FIXME */ out << "exclusive or second child into first child"; break;
case EOpLeftShiftAssign: UNIMPLEMENTED(); /* FIXME */ out << "left shift second child into first child"; break;
case EOpRightShiftAssign: UNIMPLEMENTED(); /* FIXME */ out << "right shift second child into first child"; break;
case EOpIndexDirect: outputTriplet(visit, NULL, "[", "]"); break;
case EOpIndexIndirect: outputTriplet(visit, NULL, "[", "]"); break;
case EOpIndexDirectStruct: outputTriplet(visit, NULL, ".", NULL); break;
......@@ -455,12 +449,6 @@ bool OutputHLSL::visitBinary(Visit visit, TIntermBinary *node)
case EOpSub: outputTriplet(visit, "(", " - ", ")"); break;
case EOpMul: outputTriplet(visit, "(", " * ", ")"); break;
case EOpDiv: outputTriplet(visit, "(", " / ", ")"); break;
case EOpMod: UNIMPLEMENTED(); /* FIXME */ out << "mod"; break;
case EOpRightShift: UNIMPLEMENTED(); /* FIXME */ out << "right-shift"; break;
case EOpLeftShift: UNIMPLEMENTED(); /* FIXME */ out << "left-shift"; break;
case EOpAnd: UNIMPLEMENTED(); /* FIXME */ out << "bitwise and"; break;
case EOpInclusiveOr: UNIMPLEMENTED(); /* FIXME */ out << "inclusive-or"; break;
case EOpExclusiveOr: UNIMPLEMENTED(); /* FIXME */ out << "exclusive-or"; break;
case EOpEqual: outputTriplet(visit, "(", " == ", ")"); break;
case EOpNotEqual: outputTriplet(visit, "(", " != ", ")"); break;
case EOpLessThan: outputTriplet(visit, "(", " < ", ")"); break;
......@@ -490,7 +478,6 @@ bool OutputHLSL::visitUnary(Visit visit, TIntermUnary *node)
case EOpNegative: outputTriplet(visit, "(-", NULL, ")"); break;
case EOpVectorLogicalNot: outputTriplet(visit, "(!", NULL, ")"); break;
case EOpLogicalNot: outputTriplet(visit, "(!", NULL, ")"); break;
case EOpBitwiseNot: outputTriplet(visit, "(~", NULL, ")"); break;
case EOpPostIncrement: outputTriplet(visit, "(", NULL, "++)"); break;
case EOpPostDecrement: outputTriplet(visit, "(", NULL, "--)"); break;
case EOpPreIncrement: outputTriplet(visit, "(++", NULL, ")"); break;
......@@ -881,15 +868,6 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpReflect: outputTriplet(visit, "reflect(", ", ", ")"); break;
case EOpRefract: outputTriplet(visit, "refract(", ", ", ")"); break;
case EOpMul: outputTriplet(visit, "(", " * ", ")"); break;
case EOpItof: UNIMPLEMENTED(); /* FIXME */ out << "itof"; break;
case EOpFtoi: UNIMPLEMENTED(); /* FIXME */ out << "ftoi"; break;
case EOpSkipPixels: UNIMPLEMENTED(); /* FIXME */ out << "skipPixels"; break;
case EOpReadInput: UNIMPLEMENTED(); /* FIXME */ out << "readInput"; break;
case EOpWritePixel: UNIMPLEMENTED(); /* FIXME */ out << "writePixel"; break;
case EOpBitmapLsb: UNIMPLEMENTED(); /* FIXME */ out << "bitmapLSB"; break;
case EOpBitmapMsb: UNIMPLEMENTED(); /* FIXME */ out << "bitmapMSB"; break;
case EOpWriteOutput: UNIMPLEMENTED(); /* FIXME */ out << "writeOutput"; break;
case EOpReadPixel: UNIMPLEMENTED(); /* FIXME */ out << "readPixel"; break;
default: UNREACHABLE();
}
......
......@@ -38,8 +38,6 @@ int __fastcall ShFinalize();
typedef enum {
EShLangVertex,
EShLangFragment,
EShLangPack,
EShLangUnpack,
EShLangCount,
} EShLanguage;
......@@ -48,8 +46,6 @@ typedef enum {
//
typedef enum {
EShExVertexFragment,
EShExPackFragment,
EShExUnpackFragment,
EShExFragment
} EShExecutable;
......
......@@ -474,16 +474,8 @@ function_call
TFunction* fnCall = $1.function;
TOperator op = fnCall->getBuiltInOp();
if (op == EOpArrayLength) {
if ($1.intermNode->getAsTyped() == 0 || $1.intermNode->getAsTyped()->getType().getArraySize() == 0) {
parseContext.error($1.line, "", fnCall->getName().c_str(), "array must be declared with a size before using this method");
parseContext.recover();
}
constUnion *unionArray = new constUnion[1];
unionArray->setIConst($1.intermNode->getAsTyped()->getType().getArraySize());
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.line);
} else if (op != EOpNull) {
if (op != EOpNull)
{
//
// Then this should be a constructor.
// Don't go through the symbol table for constructors.
......@@ -744,7 +736,6 @@ unary_expression
switch($1.op) {
case EOpNegative: errorOp = "-"; break;
case EOpLogicalNot: errorOp = "!"; break;
case EOpBitwiseNot: errorOp = "~"; break;
default: break;
}
parseContext.unaryOpError($1.line, errorOp, $2->getCompleteString());
......@@ -761,8 +752,6 @@ unary_operator
: PLUS { $$.line = $1.line; $$.op = EOpNull; }
| DASH { $$.line = $1.line; $$.op = EOpNegative; }
| BANG { $$.line = $1.line; $$.op = EOpLogicalNot; }
| TILDE { PACK_UNPACK_ONLY("~", $1.line);
$$.line = $1.line; $$.op = EOpBitwiseNot; }
;
// Grammar Note: No '*' or '&' unary ops. Pointers are not supported.
......@@ -786,15 +775,6 @@ multiplicative_expression
$$ = $1;
}
}
| multiplicative_expression PERCENT unary_expression {
PACK_UNPACK_ONLY("%", $2.line);
$$ = parseContext.intermediate.addBinaryMath(EOpMod, $1, $3, $2.line, parseContext.symbolTable);
if ($$ == 0) {
parseContext.binaryOpError($2.line, "%", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover();
$$ = $1;
}
}
;
additive_expression
......@@ -819,24 +799,6 @@ additive_expression
shift_expression
: additive_expression { $$ = $1; }
| shift_expression LEFT_OP additive_expression {
PACK_UNPACK_ONLY("<<", $2.line);
$$ = parseContext.intermediate.addBinaryMath(EOpLeftShift, $1, $3, $2.line, parseContext.symbolTable);
if ($$ == 0) {
parseContext.binaryOpError($2.line, "<<", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover();
$$ = $1;
}
}
| shift_expression RIGHT_OP additive_expression {
PACK_UNPACK_ONLY(">>", $2.line);
$$ = parseContext.intermediate.addBinaryMath(EOpRightShift, $1, $3, $2.line, parseContext.symbolTable);
if ($$ == 0) {
parseContext.binaryOpError($2.line, ">>", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover();
$$ = $1;
}
}
;
relational_expression
......@@ -911,41 +873,14 @@ equality_expression
and_expression
: equality_expression { $$ = $1; }
| and_expression AMPERSAND equality_expression {
PACK_UNPACK_ONLY("&", $2.line);
$$ = parseContext.intermediate.addBinaryMath(EOpAnd, $1, $3, $2.line, parseContext.symbolTable);
if ($$ == 0) {
parseContext.binaryOpError($2.line, "&", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover();
$$ = $1;
}
}
;
exclusive_or_expression
: and_expression { $$ = $1; }
| exclusive_or_expression CARET and_expression {
PACK_UNPACK_ONLY("^", $2.line);
$$ = parseContext.intermediate.addBinaryMath(EOpExclusiveOr, $1, $3, $2.line, parseContext.symbolTable);
if ($$ == 0) {
parseContext.binaryOpError($2.line, "^", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover();
$$ = $1;
}
}
;
inclusive_or_expression
: exclusive_or_expression { $$ = $1; }
| inclusive_or_expression VERTICAL_BAR exclusive_or_expression {
PACK_UNPACK_ONLY("|", $2.line);
$$ = parseContext.intermediate.addBinaryMath(EOpInclusiveOr, $1, $3, $2.line, parseContext.symbolTable);
if ($$ == 0) {
parseContext.binaryOpError($2.line, "|", $1->getCompleteString(), $3->getCompleteString());
parseContext.recover();
$$ = $1;
}
}
;
logical_and_expression
......@@ -1027,14 +962,8 @@ assignment_operator
: EQUAL { $$.line = $1.line; $$.op = EOpAssign; }
| MUL_ASSIGN { FRAG_VERT_ONLY("*=", $1.line); $$.line = $1.line; $$.op = EOpMulAssign; }
| DIV_ASSIGN { FRAG_VERT_ONLY("/=", $1.line); $$.line = $1.line; $$.op = EOpDivAssign; }
| MOD_ASSIGN { PACK_UNPACK_ONLY("%=", $1.line); $$.line = $1.line; $$.op = EOpModAssign; }
| ADD_ASSIGN { $$.line = $1.line; $$.op = EOpAddAssign; }
| SUB_ASSIGN { $$.line = $1.line; $$.op = EOpSubAssign; }
| LEFT_ASSIGN { PACK_UNPACK_ONLY("<<=", $1.line); $$.line = $1.line; $$.op = EOpLeftShiftAssign; }
| RIGHT_ASSIGN { PACK_UNPACK_ONLY("<<=", $1.line); $$.line = $1.line; $$.op = EOpRightShiftAssign; }
| AND_ASSIGN { PACK_UNPACK_ONLY("&=", $1.line); $$.line = $1.line; $$.op = EOpAndAssign; }
| XOR_ASSIGN { PACK_UNPACK_ONLY("^=", $1.line); $$.line = $1.line; $$.op = EOpExclusiveOrAssign; }
| OR_ASSIGN { PACK_UNPACK_ONLY("|=", $1.line); $$.line = $1.line; $$.op = EOpInclusiveOrAssign; }
;
expression
......
......@@ -105,13 +105,6 @@ bool TOutputTraverser::visitBinary(Visit visit, TIntermBinary* node)
case EOpMatrixTimesScalarAssign: out.debug << "matrix scale second child into first child"; break;
case EOpMatrixTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break;
case EOpDivAssign: out.debug << "divide second child into first child"; break;
case EOpModAssign: out.debug << "mod second child into first child"; break;
case EOpAndAssign: out.debug << "and second child into first child"; break;
case EOpInclusiveOrAssign: out.debug << "or second child into first child"; break;
case EOpExclusiveOrAssign: out.debug << "exclusive or second child into first child"; break;
case EOpLeftShiftAssign: out.debug << "left shift second child into first child"; break;
case EOpRightShiftAssign: out.debug << "right shift second child into first child"; break;
case EOpIndexDirect: out.debug << "direct index"; break;
case EOpIndexIndirect: out.debug << "indirect index"; break;
case EOpIndexDirectStruct: out.debug << "direct index for structure"; break;
......@@ -121,12 +114,6 @@ bool TOutputTraverser::visitBinary(Visit visit, TIntermBinary* node)
case EOpSub: out.debug << "subtract"; break;
case EOpMul: out.debug << "component-wise multiply"; break;
case EOpDiv: out.debug << "divide"; break;
case EOpMod: out.debug << "mod"; break;
case EOpRightShift: out.debug << "right-shift"; break;
case EOpLeftShift: out.debug << "left-shift"; break;
case EOpAnd: out.debug << "bitwise and"; break;
case EOpInclusiveOr: out.debug << "inclusive-or"; break;
case EOpExclusiveOr: out.debug << "exclusive-or"; break;
case EOpEqual: out.debug << "Compare Equal"; break;
case EOpNotEqual: out.debug << "Compare Not Equal"; break;
case EOpLessThan: out.debug << "Compare Less Than"; break;
......@@ -163,7 +150,6 @@ bool TOutputTraverser::visitUnary(Visit visit, TIntermUnary* node)
case EOpNegative: out.debug << "Negate value"; break;
case EOpVectorLogicalNot:
case EOpLogicalNot: out.debug << "Negate conditional"; break;
case EOpBitwiseNot: out.debug << "Bitwise not"; break;
case EOpPostIncrement: out.debug << "Post-Increment"; break;
case EOpPostDecrement: out.debug << "Post-Decrement"; break;
......@@ -280,16 +266,6 @@ bool TOutputTraverser::visitAggregate(Visit visit, TIntermAggregate* node)
case EOpRefract: out.debug << "refract"; break;
case EOpMul: out.debug << "component-wise multiply"; break;
case EOpItof: out.debug << "itof"; break;
case EOpFtoi: out.debug << "ftoi"; break;
case EOpSkipPixels: out.debug << "skipPixels"; break;
case EOpReadInput: out.debug << "readInput"; break;
case EOpWritePixel: out.debug << "writePixel"; break;
case EOpBitmapLsb: out.debug << "bitmapLSB"; break;
case EOpBitmapMsb: out.debug << "bitmapMSB"; break;
case EOpWriteOutput: out.debug << "writeOutput"; break;
case EOpReadPixel: out.debug << "readPixel"; break;
default: out.debug.message(EPrefixError, "Bad aggregation op");
}
......
......@@ -38,7 +38,6 @@ enum TOperator {
EOpNegative,
EOpLogicalNot,
EOpVectorLogicalNot,
EOpBitwiseNot,
EOpPostIncrement,
EOpPostDecrement,
......@@ -60,12 +59,6 @@ enum TOperator {
EOpSub,
EOpMul,
EOpDiv,
EOpMod,
EOpRightShift,
EOpLeftShift,
EOpAnd,
EOpInclusiveOr,
EOpExclusiveOr,
EOpEqual,
EOpNotEqual,
EOpVectorEqual,
......@@ -117,6 +110,7 @@ enum TOperator {
EOpFloor,
EOpCeil,
EOpFract,
EOpMod,
EOpMin,
EOpMax,
EOpClamp,
......@@ -133,25 +127,15 @@ enum TOperator {
EOpReflect,
EOpRefract,
// EOpDPdx, // Fragment only
// EOpDPdy, // Fragment only
// EOpFwidth, // Fragment only
// EOpDPdx, // Fragment only, OES_standard_derivatives extension
// EOpDPdy, // Fragment only, OES_standard_derivatives extension
// EOpFwidth, // Fragment only, OES_standard_derivatives extension
EOpMatrixTimesMatrix,
EOpAny,
EOpAll,
EOpItof, // pack/unpack only
EOpFtoi, // pack/unpack only
EOpSkipPixels, // pack/unpack only
EOpReadInput, // unpack only
EOpWritePixel, // unpack only
EOpBitmapLsb, // unpack only
EOpBitmapMsb, // unpack only
EOpWriteOutput, // pack only
EOpReadPixel, // pack only
//
// Branch
//
......@@ -196,18 +180,6 @@ enum TOperator {
EOpMatrixTimesScalarAssign,
EOpMatrixTimesMatrixAssign,
EOpDivAssign,
EOpModAssign,
EOpAndAssign,
EOpInclusiveOrAssign,
EOpExclusiveOrAssign,
EOpLeftShiftAssign,
EOpRightShiftAssign,
//
// Array operators
//
EOpArrayLength,
};
class TIntermTraverser;
......
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