Use generic types to compact the symbol table initialization.

Just like in the spec text, use symbolic types that represent multiple
concrete types. The few signatures that get generated more than once
are only added to the symbol table once because it ignores duplicates.

BUG=angle:926

Change-Id: I216f03d22502b724dbefc87c5a021d6021c3a434
Reviewed-on: https://chromium-review.googlesource.com/251620
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Tested-by: Nicolas Capens <capn@chromium.org>
diff --git a/src/compiler/translator/BaseTypes.h b/src/compiler/translator/BaseTypes.h
index fd09d7d..ee1428b 100644
--- a/src/compiler/translator/BaseTypes.h
+++ b/src/compiler/translator/BaseTypes.h
@@ -7,7 +7,7 @@
 #ifndef COMPILER_TRANSLATOR_BASETYPES_H_
 #define COMPILER_TRANSLATOR_BASETYPES_H_
 
-#include <assert.h>
+#include "compiler/translator/compilerdebug.h"
 
 //
 // Precision qualifiers
@@ -42,7 +42,15 @@
     EbtInt,
     EbtUInt,
     EbtBool,
-    EbtGVec4,              // non type: represents vec4, ivec4 and uvec4
+    EbtGVec4,              // non type: represents vec4, ivec4, and uvec4
+    EbtGenType,            // non type: represents float, vec2, vec3, and vec4
+    EbtGenIType,           // non type: represents int, ivec2, ivec3, and ivec4
+    EbtGenUType,           // non type: represents uint, uvec2, uvec3, and uvec4
+    EbtGenBType,           // non type: represents bool, bvec2, bvec3, and bvec4
+    EbtVec,                // non type: represents vec2, vec3, and vec4
+    EbtIVec,               // non type: represents ivec2, ivec3, and ivec4
+    EbtUVec,               // non type: represents uvec2, uvec3, and uvec4
+    EbtBVec,               // non type: represents bvec2, bvec3, and bvec4
     EbtGuardSamplerBegin,  // non type: see implementation of IsSampler()
     EbtSampler2D,
     EbtSampler3D,
@@ -62,10 +70,10 @@
     EbtSamplerCubeShadow,
     EbtSampler2DArrayShadow,
     EbtGuardSamplerEnd,    // non type: see implementation of IsSampler()
-    EbtGSampler2D,         // non type: represents sampler2D, isampler2D and usampler2D
-    EbtGSampler3D,         // non type: represents sampler3D, isampler3D and usampler3D
-    EbtGSamplerCube,       // non type: represents samplerCube, isamplerCube and usamplerCube
-    EbtGSampler2DArray,    // non type: represents sampler2DArray, isampler2DArray and usampler2DArray
+    EbtGSampler2D,         // non type: represents sampler2D, isampler2D, and usampler2D
+    EbtGSampler3D,         // non type: represents sampler3D, isampler3D, and usampler3D
+    EbtGSamplerCube,       // non type: represents samplerCube, isamplerCube, and usamplerCube
+    EbtGSampler2DArray,    // non type: represents sampler2DArray, isampler2DArray, and usampler2DArray
     EbtStruct,
     EbtInterfaceBlock,
     EbtAddress,            // should be deprecated??
@@ -411,7 +419,7 @@
     case EvqFlatIn:         return "flat in";        break;
     case EvqLastFragColor:  return "LastFragColor";  break;
     case EvqLastFragData:   return "LastFragData";   break;
-    default:                return "unknown qualifier";
+    default: UNREACHABLE(); return "unknown qualifier";
     }
 }
 
@@ -422,7 +430,7 @@
     case EmpUnspecified:    return "mp_unspecified";
     case EmpRowMajor:       return "row_major";
     case EmpColumnMajor:    return "column_major";
-    default:                return "unknown matrix packing";
+    default: UNREACHABLE(); return "unknown matrix packing";
     }
 }
 
@@ -434,7 +442,7 @@
     case EbsShared:         return "shared";
     case EbsPacked:         return "packed";
     case EbsStd140:         return "std140";
-    default:                return "unknown block storage";
+    default: UNREACHABLE(); return "unknown block storage";
     }
 }
 
@@ -448,7 +456,7 @@
     case EvqSmoothIn:       return "smooth";   break;
     case EvqCentroidIn:     return "centroid"; break;
     case EvqFlatIn:         return "flat";     break;
-    default:                return "unknown interpolation";
+    default: UNREACHABLE(); return "unknown interpolation";
     }
 }
 
diff --git a/src/compiler/translator/Initialize.cpp b/src/compiler/translator/Initialize.cpp
index d4f81c7..a873d51 100644
--- a/src/compiler/translator/Initialize.cpp
+++ b/src/compiler/translator/Initialize.cpp
@@ -21,274 +21,82 @@
     TType *float2 = new TType(EbtFloat, 2);
     TType *float3 = new TType(EbtFloat, 3);
     TType *float4 = new TType(EbtFloat, 4);
-
     TType *int1 = new TType(EbtInt);
     TType *int2 = new TType(EbtInt, 2);
     TType *int3 = new TType(EbtInt, 3);
-    TType *int4 = new TType(EbtInt, 4);
+    TType *uint1 = new TType(EbtUInt);
+    TType *bool1 = new TType(EbtBool);
+    TType *genType = new TType(EbtGenType);
+    TType *genIType = new TType(EbtGenIType);
+    TType *genUType = new TType(EbtGenUType);
+    TType *genBType = new TType(EbtGenBType);
 
     //
     // Angle and Trigonometric Functions.
     //
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "radians", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "radians", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "radians", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "radians", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "degrees", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "degrees", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "degrees", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "degrees", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sin", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sin", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sin", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sin", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "cos", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "cos", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cos", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "cos", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "tan", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "tan", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "tan", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "tan", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "asin", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "asin", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "asin", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "asin", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "acos", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "acos", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "acos", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "acos", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "atan", float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "atan", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "atan", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "atan", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "atan", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "atan", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "atan", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "atan", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "sinh", float1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "sinh", float2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "sinh", float3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "sinh", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "cosh", float1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "cosh", float2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "cosh", float3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "cosh", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "tanh", float1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "tanh", float2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "tanh", float3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "tanh", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "asinh", float1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "asinh", float2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "asinh", float3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "asinh", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "acosh", float1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "acosh", float2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "acosh", float3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "acosh", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "atanh", float1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "atanh", float2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "atanh", float3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "atanh", float4);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "radians", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "degrees", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "sin", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "cos", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "tan", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "asin", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "acos", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "atan", genType, genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "atan", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "sinh", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "cosh", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "tanh", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "asinh", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "acosh", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "atanh", genType);
 
     //
     // Exponential Functions.
     //
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "pow", float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "pow", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "pow", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "pow", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "exp2", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "exp2", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "exp2", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "exp2", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "log2", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "log2", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "log2", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "log2", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sqrt", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sqrt", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sqrt", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sqrt", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "inversesqrt", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "inversesqrt", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "inversesqrt", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "inversesqrt", float4);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "pow", genType, genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "exp", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "log", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "exp2", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "log2", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "sqrt", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "inversesqrt", genType);
 
     //
     // Common Functions.
     //
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "abs", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "abs", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "abs", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "abs", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "abs", int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "abs", int2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "abs", int3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "abs", int4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "sign", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "sign", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "sign", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "sign", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "sign", int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "sign", int2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "sign", int3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "sign", int4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "floor", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "floor", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "floor", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "floor", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "ceil", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "ceil", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "ceil", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "ceil", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "fract", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "fract", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "fract", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "fract", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mod", float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mod", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mod", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mod", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "min", float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "min", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "min", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "min", float4, float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "min", int1, int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "min", int2, int2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "min", int3, int3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "min", int4, int4);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "min", int2, int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "min", int3, int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "min", int4, int1);
-
-    TType *uint1 = new TType(EbtUInt);
-    TType *uint2 = new TType(EbtUInt, 2);
-    TType *uint3 = new TType(EbtUInt, 3);
-    TType *uint4 = new TType(EbtUInt, 4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "min", uint1, uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "min", uint2, uint2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "min", uint3, uint3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "min", uint4, uint4);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "min", uint2, uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "min", uint3, uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "min", uint4, uint1);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "max", float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "max", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "max", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "max", float4, float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "max", int1, int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "max", int2, int2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "max", int3, int3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "max", int4, int4);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "max", int2, int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "max", int3, int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "max", int4, int1);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "max", uint1, uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "max", uint2, uint2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "max", uint3, uint3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "max", uint4, uint4);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "max", uint2, uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "max", uint3, uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "max", uint4, uint1);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "clamp", float1, float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "clamp", float2, float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "clamp", float3, float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "clamp", float4, float4, float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "clamp", int1, int1, int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "clamp", int2, int1, int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "clamp", int3, int1, int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "clamp", int4, int1, int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "clamp", int2, int2, int2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "clamp", int3, int3, int3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "clamp", int4, int4, int4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "clamp", uint1, uint1, uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "clamp", uint2, uint1, uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "clamp", uint3, uint1, uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "clamp", uint4, uint1, uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "clamp", uint2, uint2, uint2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "clamp", uint3, uint3, uint3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "clamp", uint4, uint4, uint4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "mix", float1, float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "mix", float2, float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "mix", float3, float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "mix", float4, float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "step", float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float4, float4);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "step", float1, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "step", float1, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "step", float1, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "smoothstep", float1, float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float2, float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float3, float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float4, float4, float4);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "smoothstep", float1, float1, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "smoothstep", float1, float1, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "smoothstep", float1, float1, float4);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "abs", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genIType, "abs", genIType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "sign", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genIType, "sign", genIType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "floor", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "ceil", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "fract", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "mod", genType, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "mod", genType, genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "min", genType, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "min", genType, genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genIType, "min", genIType, genIType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genIType, "min", genIType, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genIType, "min", genIType, genIType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genUType, "min", genUType, uint1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "max", genType, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "max", genType, genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genIType, "max", genIType, genIType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genIType, "max", genIType, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genUType, "max", genUType, genUType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genUType, "max", genUType, uint1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "clamp", genType, float1, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "clamp", genType, genType, genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genIType, "clamp", genIType, int1, int1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genIType, "clamp", genIType, genIType, genIType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genUType, "clamp", genUType, uint1, uint1);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genUType, "clamp", genUType, genUType, genUType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "mix", genType, genType, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "mix", genType, genType, genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "step", genType, genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "step", float1, genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "smoothstep", genType, genType, genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "smoothstep", float1, float1, genType);
 
     TType *outFloat1 = new TType(EbtFloat);
     TType *outFloat2 = new TType(EbtFloat, 2);
@@ -304,40 +112,12 @@
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "modf", float3, outFloat3);
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "modf", float4, outFloat4);
 
-    TType *bool1 = new TType(EbtBool);
-    TType *bool2 = new TType(EbtBool, 2);
-    TType *bool3 = new TType(EbtBool, 3);
-    TType *bool4 = new TType(EbtBool, 4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool1, "isnan", float1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "isnan", float2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "isnan", float3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "isnan", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool1, "isinf", float1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "isinf", float2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "isinf", float3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "isinf", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int1, "floatBitsToInt", float1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "floatBitsToInt", float2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "floatBitsToInt", float3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, int4, "floatBitsToInt", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "floatBitsToUint", float1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint2, "floatBitsToUint", float2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint3, "floatBitsToUint", float3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint4, "floatBitsToUint", float4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "intBitsToFloat", int1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "intBitsToFloat", int2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "intBitsToFloat", int3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "intBitsToFloat", int4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "uintBitsToFloat", uint1);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "uintBitsToFloat", uint2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "uintBitsToFloat", uint3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "uintBitsToFloat", uint4);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genBType, "isnan", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genBType, "isinf", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genIType, "floatBitsToInt", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genUType, "floatBitsToUint", genType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "intBitsToFloat", genIType);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "uintBitsToFloat", genUType);
 
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packSnorm2x16", float2);
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, uint1, "packUnorm2x16", float2);
@@ -349,41 +129,14 @@
     //
     // Geometric Functions.
     //
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", float4, float4);
-
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "length", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "distance", genType, genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "dot", genType, genType);
     symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "cross", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "normalize", float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "normalize", float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "normalize", float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "normalize", float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "faceforward", float1, float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "faceforward", float2, float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "faceforward", float3, float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "faceforward", float4, float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "reflect", float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "reflect", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "reflect", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "reflect", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float1, "refract", float1, float1, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float2, "refract", float2, float2, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float3, "refract", float3, float3, float1);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, float4, "refract", float4, float4, float1);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "normalize", genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "faceforward", genType, genType, genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "reflect", genType, genType);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, genType, "refract", genType, genType, float1);
 
     TType *mat2 = new TType(EbtFloat, 2, 2);
     TType *mat3 = new TType(EbtFloat, 3, 3);
@@ -436,100 +189,37 @@
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat3, "inverse", mat3);
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, mat4, "inverse", mat4);
 
+    TType *vec = new TType(EbtVec);
+    TType *ivec = new TType(EbtIVec);
+    TType *uvec = new TType(EbtUVec);
+    TType *bvec = new TType(EbtBVec);
+
     //
     // Vector relational functions.
     //
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThan", int2, int2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThan", int3, int3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThan", int4, int4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "lessThan", uint2, uint2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "lessThan", uint3, uint3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "lessThan", uint4, uint4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "lessThanEqual", int2, int2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "lessThanEqual", int3, int3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "lessThanEqual", int4, int4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "lessThanEqual", uint2, uint2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "lessThanEqual", uint3, uint3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "lessThanEqual", uint4, uint4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThan", int2, int2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThan", int3, int3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThan", int4, int4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "greaterThan", uint2, uint2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "greaterThan", uint3, uint3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "greaterThan", uint4, uint4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "greaterThanEqual", int2, int2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "greaterThanEqual", int3, int3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "greaterThanEqual", int4, int4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "greaterThanEqual", uint2, uint2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "greaterThanEqual", uint3, uint3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "greaterThanEqual", uint4, uint4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", int2, int2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", int3, int3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", int4, int4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "equal", uint2, uint2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "equal", uint3, uint3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "equal", uint4, uint4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "equal", bool2, bool2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "equal", bool3, bool3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "equal", bool4, bool4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", float2, float2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", float3, float3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", float4, float4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", int2, int2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", int3, int3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", int4, int4);
-
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool2, "notEqual", uint2, uint2);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool3, "notEqual", uint3, uint3);
-    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bool4, "notEqual", uint4, uint4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "notEqual", bool2, bool2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "notEqual", bool3, bool3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "notEqual", bool4, bool4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bool4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bool4);
-
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool2, "not", bool2);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool3, "not", bool3);
-    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool4, "not", bool4);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "lessThan", vec, vec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "lessThan", ivec, ivec);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bvec, "lessThan", uvec, uvec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "lessThanEqual", vec, vec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "lessThanEqual", ivec, ivec);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bvec, "lessThanEqual", uvec, uvec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "greaterThan", vec, vec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "greaterThan", ivec, ivec);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bvec, "greaterThan", uvec, uvec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "greaterThanEqual", vec, vec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "greaterThanEqual", ivec, ivec);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bvec, "greaterThanEqual", uvec, uvec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "equal", vec, vec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "equal", ivec, ivec);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bvec, "equal", uvec, uvec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "equal", bvec, bvec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "notEqual", vec, vec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "notEqual", ivec, ivec);
+    symbolTable.insertBuiltIn(ESSL3_BUILTINS, bvec, "notEqual", uvec, uvec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "notEqual", bvec, bvec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "any", bvec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bool1, "all", bvec);
+    symbolTable.insertBuiltIn(COMMON_BUILTINS, bvec, "not", bvec);
 
     TType *sampler2D = new TType(EbtSampler2D);
     TType *samplerCube = new TType(EbtSamplerCube);
@@ -580,20 +270,9 @@
 
         if (resources.OES_standard_derivatives)
         {
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdx", float1);
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdx", float2);
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdx", float3);
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdx", float4);
-
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "dFdy", float1);
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "dFdy", float2);
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "dFdy", float3);
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "dFdy", float4);
-
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float1, "fwidth", float1);
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float2, "fwidth", float2);
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float3, "fwidth", float3);
-            symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "fwidth", float4);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, genType, "dFdx", genType);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, genType, "dFdy", genType);
+            symbolTable.insertBuiltIn(ESSL1_BUILTINS, genType, "fwidth", genType);
         }
 
         if (resources.EXT_shader_texture_lod)
@@ -605,7 +284,7 @@
         }
     }
 
-    if(type == GL_VERTEX_SHADER)
+    if (type == GL_VERTEX_SHADER)
     {
         symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DLod", sampler2D, float2, float1);
         symbolTable.insertBuiltIn(ESSL1_BUILTINS, float4, "texture2DProjLod", sampler2D, float3, float1);
@@ -671,22 +350,11 @@
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, int2, "textureSize", samplerCubeShadow, int1);
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, int3, "textureSize", sampler2DArrayShadow, int1);
 
-    if(type == GL_FRAGMENT_SHADER)
+    if (type == GL_FRAGMENT_SHADER)
     {
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdx", float1);
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdx", float2);
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdx", float3);
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdx", float4);
-            
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "dFdy", float1);
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "dFdy", float2);
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "dFdy", float3);
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "dFdy", float4);
-
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "fwidth", float1);
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float2, "fwidth", float2);
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float3, "fwidth", float3);
-        symbolTable.insertBuiltIn(ESSL3_BUILTINS, float4, "fwidth", float4);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "dFdx", genType);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "dFdy", genType);
+        symbolTable.insertBuiltIn(ESSL3_BUILTINS, genType, "fwidth", genType);
     }
 
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2);
@@ -694,7 +362,7 @@
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureOffset", sampler2DShadow, float3, int2);
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2DArray, float3, int2);
 
-    if(type == GL_FRAGMENT_SHADER)
+    if (type == GL_FRAGMENT_SHADER)
     {
         symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler2D, float2, int2, float1);
         symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureOffset", gsampler3D, float3, int3, float1);
@@ -707,7 +375,7 @@
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler3D, float4, int3);
     symbolTable.insertBuiltIn(ESSL3_BUILTINS, float1, "textureProjOffset", sampler2DShadow, float4, int2);
 
-    if(type == GL_FRAGMENT_SHADER)
+    if (type == GL_FRAGMENT_SHADER)
     {
         symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float3, int2, float1);
         symbolTable.insertBuiltIn(ESSL3_BUILTINS, gvec4, "textureProjOffset", gsampler2D, float4, int2, float1);
diff --git a/src/compiler/translator/SymbolTable.cpp b/src/compiler/translator/SymbolTable.cpp
index d756f3e..08dbcca 100644
--- a/src/compiler/translator/SymbolTable.cpp
+++ b/src/compiler/translator/SymbolTable.cpp
@@ -142,68 +142,148 @@
         pop();
 }
 
-void TSymbolTable::insertBuiltIn(
-    ESymbolLevel level, TType *rvalue, const char *name,
-    TType *ptype1, TType *ptype2, TType *ptype3, TType *ptype4, TType *ptype5)
+bool IsGenType(const TType *type)
+{
+    if (type)
+    {
+        TBasicType basicType = type->getBasicType();
+        return basicType == EbtGenType || basicType == EbtGenIType || basicType == EbtGenUType || basicType == EbtGenBType;
+    }
+
+    return false;
+}
+
+bool IsVecType(const TType *type)
+{
+    if (type)
+    {
+        TBasicType basicType = type->getBasicType();
+        return basicType == EbtVec || basicType == EbtIVec || basicType == EbtUVec || basicType == EbtBVec;
+    }
+
+    return false;
+}
+
+TType *SpecificType(TType *type, int size)
+{
+    ASSERT(size >= 1 && size <= 4);
+
+    if (!type)
+    {
+        return nullptr;
+    }
+
+    ASSERT(!IsVecType(type));
+
+    switch(type->getBasicType())
+    {
+      case EbtGenType:  return new TType(EbtFloat, size);
+      case EbtGenIType: return new TType(EbtInt, size);
+      case EbtGenUType: return new TType(EbtUInt, size);
+      case EbtGenBType: return new TType(EbtBool, size);
+      default: return type;
+    }
+}
+
+TType *VectorType(TType *type, int size)
+{
+    ASSERT(size >= 2 && size <= 4);
+
+    if (!type)
+    {
+        return nullptr;
+    }
+
+    ASSERT(!IsGenType(type));
+
+    switch(type->getBasicType())
+    {
+      case EbtVec:  return new TType(EbtFloat, size);
+      case EbtIVec: return new TType(EbtInt, size);
+      case EbtUVec: return new TType(EbtUInt, size);
+      case EbtBVec: return new TType(EbtBool, size);
+      default: return type;
+    }
+}
+
+void TSymbolTable::insertBuiltIn(ESymbolLevel level, TType *rvalue, const char *name, TType *ptype1, TType *ptype2, TType *ptype3, TType *ptype4, TType *ptype5)
 {
     if (ptype1->getBasicType() == EbtGSampler2D)
     {
         bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
-        insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name,
-                      new TType(EbtSampler2D), ptype2, ptype3, ptype4, ptype5);
-        insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name,
-                      new TType(EbtISampler2D), ptype2, ptype3, ptype4, ptype5);
-        insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name,
-                      new TType(EbtUSampler2D), ptype2, ptype3, ptype4, ptype5);
-        return;
+        insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2D), ptype2, ptype3, ptype4, ptype5);
+        insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler2D), ptype2, ptype3, ptype4, ptype5);
+        insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler2D), ptype2, ptype3, ptype4, ptype5);
     }
-    if (ptype1->getBasicType() == EbtGSampler3D)
+    else if (ptype1->getBasicType() == EbtGSampler3D)
     {
         bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
-        insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name,
-                      new TType(EbtSampler3D), ptype2, ptype3, ptype4, ptype5);
-        insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name,
-                      new TType(EbtISampler3D), ptype2, ptype3, ptype4, ptype5);
-        insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name,
-                      new TType(EbtUSampler3D), ptype2, ptype3, ptype4, ptype5);
-        return;
+        insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler3D), ptype2, ptype3, ptype4, ptype5);
+        insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler3D), ptype2, ptype3, ptype4, ptype5);
+        insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler3D), ptype2, ptype3, ptype4, ptype5);
     }
-    if (ptype1->getBasicType() == EbtGSamplerCube)
+    else if (ptype1->getBasicType() == EbtGSamplerCube)
     {
         bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
-        insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name,
-                      new TType(EbtSamplerCube), ptype2, ptype3, ptype4, ptype5);
-        insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name,
-                      new TType(EbtISamplerCube), ptype2, ptype3, ptype4, ptype5);
-        insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name,
-                      new TType(EbtUSamplerCube), ptype2, ptype3, ptype4, ptype5);
-        return;
+        insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSamplerCube), ptype2, ptype3, ptype4, ptype5);
+        insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISamplerCube), ptype2, ptype3, ptype4, ptype5);
+        insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSamplerCube), ptype2, ptype3, ptype4, ptype5);
     }
-    if (ptype1->getBasicType() == EbtGSampler2DArray)
+    else if (ptype1->getBasicType() == EbtGSampler2DArray)
     {
         bool gvec4 = (rvalue->getBasicType() == EbtGVec4);
-        insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name,
-                      new TType(EbtSampler2DArray), ptype2, ptype3, ptype4, ptype5);
-        insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name,
-                      new TType(EbtISampler2DArray), ptype2, ptype3, ptype4, ptype5);
-        insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name,
-                      new TType(EbtUSampler2DArray), ptype2, ptype3, ptype4, ptype5);
-        return;
+        insertBuiltIn(level, gvec4 ? new TType(EbtFloat, 4) : rvalue, name, new TType(EbtSampler2DArray), ptype2, ptype3, ptype4, ptype5);
+        insertBuiltIn(level, gvec4 ? new TType(EbtInt, 4) : rvalue, name, new TType(EbtISampler2DArray), ptype2, ptype3, ptype4, ptype5);
+        insertBuiltIn(level, gvec4 ? new TType(EbtUInt, 4) : rvalue, name, new TType(EbtUSampler2DArray), ptype2, ptype3, ptype4, ptype5);
     }
+    else if (IsGenType(rvalue) || IsGenType(ptype1) || IsGenType(ptype2) || IsGenType(ptype3))
+    {
+        ASSERT(!ptype4 && !ptype5);
+        insertBuiltIn(level, SpecificType(rvalue, 1), name, SpecificType(ptype1, 1), SpecificType(ptype2, 1), SpecificType(ptype3, 1));
+        insertBuiltIn(level, SpecificType(rvalue, 2), name, SpecificType(ptype1, 2), SpecificType(ptype2, 2), SpecificType(ptype3, 2));
+        insertBuiltIn(level, SpecificType(rvalue, 3), name, SpecificType(ptype1, 3), SpecificType(ptype2, 3), SpecificType(ptype3, 3));
+        insertBuiltIn(level, SpecificType(rvalue, 4), name, SpecificType(ptype1, 4), SpecificType(ptype2, 4), SpecificType(ptype3, 4));
+    }
+    else if (IsVecType(rvalue) || IsVecType(ptype1) || IsVecType(ptype2) || IsVecType(ptype3))
+    {
+        ASSERT(!ptype4 && !ptype5);
+        insertBuiltIn(level, VectorType(rvalue, 2), name, VectorType(ptype1, 2), VectorType(ptype2, 2), VectorType(ptype3, 2));
+        insertBuiltIn(level, VectorType(rvalue, 3), name, VectorType(ptype1, 3), VectorType(ptype2, 3), VectorType(ptype3, 3));
+        insertBuiltIn(level, VectorType(rvalue, 4), name, VectorType(ptype1, 4), VectorType(ptype2, 4), VectorType(ptype3, 4));
+    }
+    else
+    {
+        TFunction *function = new TFunction(NewPoolTString(name), *rvalue);
 
-    TFunction *function = new TFunction(NewPoolTString(name), *rvalue);
+        TParameter param1 = {0, ptype1};
+        function->addParameter(param1);
 
-    TType *types[] = {ptype1, ptype2, ptype3, ptype4, ptype5};
-    for (size_t ii = 0; ii < sizeof(types) / sizeof(types[0]); ++ii)
-    {
-        if (types[ii])
+        if (ptype2)
         {
-            TParameter param = {NULL, types[ii]};
-            function->addParameter(param);
+            TParameter param2 = {0, ptype2};
+            function->addParameter(param2);
         }
-    }
 
-    insert(level, function);
+        if (ptype3)
+        {
+            TParameter param3 = {0, ptype3};
+            function->addParameter(param3);
+        }
+
+        if (ptype4)
+        {
+            TParameter param4 = {0, ptype4};
+            function->addParameter(param4);
+        }
+
+        if (ptype5)
+        {
+            TParameter param5 = {0, ptype5};
+            function->addParameter(param5);
+        }
+
+        insert(level, function);
+    }
 }
 
 TPrecision TSymbolTable::getDefaultPrecision(TBasicType type) const