mesa: remove unused/obsolete __NormalMatrixTranspose matrix
[mesa.git] / src / mesa / shader / slang / library / slang_core.gc
old mode 100755 (executable)
new mode 100644 (file)
index 4c18e6d..10a6bb5
 //    specification to provide all valid operator prototypes.
 //
 
-//bp:
-vec4 vec4(const float a1, const float b1, const float c1, const float d1)
+
+
+//// Basic, scalar constructors/casts
+
+int __constructor(const float f)
+{
+   __asm vec4_to_ivec4 __retVal, f;
+}
+
+int __constructor(const bool b)
 {
-   __retVal.x = a1;
-   __retVal.y = b1;
-   __retVal.z = c1;
-   __retVal.w = d1;
+   __retVal = b;
 }
 
-////
-//// Assorted constructors
-////
+int __constructor(const int i)
+{
+   __retVal = i;
+}
+
+bool __constructor(const int i)
+{
+   __asm vec4_sne __retVal, i, 0.0;
+}
 
-int __constructor (const float f) {
-    int i;
-    __asm float_to_int i, f;
-    return i;
+bool __constructor(const float f)
+{
+   __asm vec4_sne __retVal, f, 0.0;
 }
 
-bool __constructor (const int i) {
-    return i != 0;
+bool __constructor(const bool b)
+{
+   __retVal = b;
+}
+
+float __constructor(const int i)
+{
+    __asm ivec4_to_vec4 __retVal, i;
+}
+
+float __constructor(const bool b)
+{
+    __asm ivec4_to_vec4 __retVal, b;
+}
+
+float __constructor(const float f)
+{
+   __retVal = f;
+}
+
+
+//// vec2 constructors
+
+vec2 __constructor(const float x, const float y)
+{
+   __retVal.x = x;
+   __retVal.y = y;
+}
+
+vec2 __constructor(const float f)
+{
+   __asm vec4_move __retVal.xy, f;
+}
+
+vec2 __constructor(const int i)
+{
+   __asm ivec4_to_vec4 __retVal.xy, i;
+}
+
+vec2 __constructor(const bool b)
+{
+   __asm ivec4_to_vec4 __retVal.xy, b;
+}
+
+vec2 __constructor(const bvec2 b)
+{
+//   __retVal = b;
+   __asm ivec4_to_vec4 __retVal.xy, b;
+}
+
+vec2 __constructor(const vec3 v)
+{
+   __asm vec4_move __retVal.xy, v.xy;
+}
+
+vec2 __constructor(const vec4 v)
+{
+   __asm vec4_move __retVal.xy, v.xy;
 }
 
-bool __constructor (const float f) {
-    return f != 0.0;
+
+//// vec3 constructors
+
+vec3 __constructor(const float x, const float y, const float z)
+{
+   __retVal.x = x;
+   __retVal.y = y;
+   __retVal.z = z;
+}
+
+vec3 __constructor(const float f)
+{
+   // Note: this could be "__retVal.xyz = f" but that's an illegal assignment
+   __asm vec4_move __retVal.xyz, f;
+}
+
+vec3 __constructor(const int i)
+{
+   __asm ivec4_to_vec4 __retVal.xyz, i;
+}
+
+vec3 __constructor(const bool b)
+{
+   __asm ivec4_to_vec4 __retVal.xyz, b;
+}
+
+vec3 __constructor(const bvec3 b)
+{
+   __asm ivec4_to_vec4 __retVal.xyz, b;
+}
+
+vec3 __constructor(const vec4 v)
+{
+   __asm vec4_move __retVal.xyz, v;
+}
+
+
+//// vec4 constructors
+
+vec4 __constructor(const float x, const float y, const float z, const float w)
+{
+   __retVal.x = x;
+   __retVal.y = y;
+   __retVal.z = z;
+   __retVal.w = w;
+}
+
+vec4 __constructor(const float f)
+{
+   // Note: this could be "__retVal = f" but that's an illegal assignment
+   __asm vec4_move __retVal, f;
+}
+
+vec4 __constructor(const int i)
+{
+   __asm ivec4_to_vec4 __retVal, i;
+}
+
+vec4 __constructor(const bool b)
+{
+   __asm ivec4_to_vec4 __retVal, b;
+}
+
+vec4 __constructor(const bvec4 b)
+{
+   __asm ivec4_to_vec4 __retVal, b;
+}
+
+vec4 __constructor(const ivec4 i)
+{
+   __asm ivec4_to_vec4 __retVal, i;
+}
+
+vec4 __constructor(const vec3 v3, const float f)
+{
+   // XXX this constructor shouldn't be needed anymore
+   __retVal.xyz = v3;
+   __retVal.w = f;
+}
+
+vec4 __constructor(const vec2 v2, const float f1, const float f2)
+{
+   // XXX this constructor shouldn't be needed anymore
+   __retVal.xy = v2;
+   __retVal.z = f1;
+   __retVal.w = f2;
 }
 
-int __constructor (const bool b) {
-    return b ? 1 : 0;
+
+//// ivec2 constructors
+
+ivec2 __constructor(const int i, const int j)
+{
+   __retVal.x = i;
+   __retVal.y = j;
 }
 
-float __constructor (const bool b) {
-    return b ? 1.0 : 0.0;
+ivec2 __constructor(const int i)
+{
+   __asm vec4_move __retVal.xy, i;
 }
 
-float __constructor (const int i) {
-    float f;
-    __asm int_to_float f, i;
-    return f;
+ivec2 __constructor(const float f)
+{
+   __asm vec4_to_ivec4 __retVal.xy, f;
 }
 
-bool __constructor (const bool b) {
-    return b;
+ivec2 __constructor(const bool b)
+{
+   __asm vec4_to_ivec4 __retVal.xy, b;
 }
 
-int __constructor (const int i) {
-    return i;
+
+//// ivec3 constructors
+
+ivec3 __constructor(const int i, const int j, const int k)
+{
+   __retVal.x = i;
+   __retVal.y = j;
+   __retVal.z = k;
 }
 
-float __constructor (const float f) {
-    return f;
+ivec3 __constructor(const int i)
+{
+   __asm vec4_move __retVal.xyz, i;
 }
 
-vec2 __constructor (const float f) {
-    return vec2 (f, f);
+ivec3 __constructor(const float f)
+{
+   __asm vec4_to_ivec4 __retVal.xyz, f;
 }
 
-vec2 __constructor (const int i) {
-    float x;
-    __asm int_to_float x, i;
-    return vec2 (x);
+ivec3 __constructor(const bool b)
+{
+   __asm vec4_move __retVal.xyz, b;
 }
 
-vec2 __constructor (const bool b) {
-    return vec2 (b ? 1.0 : 0.0);
+
+//// ivec4 constructors
+
+ivec4 __constructor(const int x, const int y, const int z, const int w)
+{
+   __retVal.x = x;
+   __retVal.y = y;
+   __retVal.z = z;
+   __retVal.w = w;
 }
 
-vec3 __constructor (const float f) {
-    return vec3 (f, f, f);
+ivec4 __constructor(const int i)
+{
+   __asm vec4_move __retVal, i;
 }
 
-vec3 __constructor (const int i) {
-    float x;
-    __asm int_to_float x, i;
-    return vec3 (x);
+ivec4 __constructor(const float f)
+{
+   __asm vec4_to_ivec4 __retVal, f;
 }
 
-vec3 __constructor (const bool b) {
-    return vec3 (b ? 1.0 : 0.0);
+ivec4 __constructor(const bool b)
+{
+   __asm vec4_to_ivec4 __retVal, b;
 }
 
-//bp: TODO replace with asm == f.xxxx
-vec4 __constructor (const float f) {
-    return vec4 (f, f, f, f);
+
+//// bvec2 constructors
+
+bvec2 __constructor(const bool b1, const bool b2)
+{
+   __retVal.x = b1;
+   __retVal.y = b2;
 }
 
-vec4 __constructor (const int i) {
-    float x;
-    __asm int_to_float x, i;
-    return vec4 (x);
+bvec2 __constructor(const int i1, const int i2)
+{
+   __asm vec4_sne __retVal.x, i1, 0.0;
+   __asm vec4_sne __retVal.y, i2, 0.0;
 }
 
-vec4 __constructor (const bool b) {
-    return vec4 (b ? 1.0 : 0.0);
+
+bvec2 __constructor(const bool b)
+{
+   __asm vec4_move __retVal.xy, b;
 }
 
-ivec2 __constructor (const int i) {
-    return ivec2 (i, i);
+bvec2 __constructor(const float f)
+{
+   __asm vec4_sne __retVal.xy, f, 0.0;
 }
 
-ivec2 __constructor (const float f) {
-    return ivec2 (int (f));
+bvec2 __constructor(const int i)
+{
+   __asm vec4_sne __retVal.xy, i, 0.0;
 }
 
-ivec2 __constructor (const bool b) {
-    return ivec2 (int (b));
+bvec2 __constructor(const vec2 v)
+{
+   __asm vec4_sne __retVal.xy, v, 0.0;
 }
 
-ivec3 __constructor (const int i) {
-    return ivec3 (i, i, i);
+bvec2 __constructor(const ivec2 v)
+{
+   __asm vec4_sne __retVal.xy, v, 0.0;
 }
 
-ivec3 __constructor (const float f) {
-    return ivec3 (int (f));
+
+
+//// bvec3 constructors
+
+bvec3 __constructor(const bool b1, const bool b2, const bool b3)
+{
+   __retVal.x = b1;
+   __retVal.y = b2;
+   __retVal.z = b3;
 }
 
-ivec3 __constructor (const bool b) {
-    return ivec3 (int (b));
+bvec3 __constructor(const float f1, const float f2, const float f3)
+{
+   __asm vec4_sne __retVal.x, f1, 0.0;
+   __asm vec4_sne __retVal.y, f2, 0.0;
+   __asm vec4_sne __retVal.z, f3, 0.0;
 }
 
-ivec4 __constructor (const int i) {
-    return ivec4 (i, i, i, i);
+bvec3 __constructor(const bool b)
+{
+   __asm vec4_move __retVal.xyz, b;
 }
 
-ivec4 __constructor (const float f) {
-    return ivec4 (int (f));
+bvec3 __constructor(const float f)
+{
+   __asm vec4_sne __retVal.xyz, f, 0.0;
 }
 
-ivec4 __constructor (const bool b) {
-    return ivec4 (int (b));
+bvec3 __constructor(const int i)
+{
+   __asm vec4_sne __retVal.xyz, i, 0.0;
 }
 
-bvec2 __constructor (const bool b) {
-    return bvec2 (b, b);
+bvec3 __constructor(const vec3 v)
+{
+   __asm vec4_sne __retVal.xyz, v, 0.0;
 }
 
-bvec2 __constructor (const float f) {
-    return bvec2 (bool (f));
+bvec3 __constructor(const ivec3 v)
+{
+   __asm vec4_sne __retVal.xyz, v, 0.0;
 }
 
-bvec2 __constructor (const int i) {
-    return bvec2 (bool (i));
+
+
+//// bvec4 constructors
+
+bvec4 __constructor(const bool b1, const bool b2, const bool b3, const bool b4)
+{
+   __retVal.x = b1;
+   __retVal.y = b2;
+   __retVal.z = b3;
+   __retVal.w = b4;
 }
 
-bvec3 __constructor (const bool b) {
-    return bvec3 (b, b, b);
+bvec4 __constructor(const float f1, const float f2, const float f3, const float f4)
+{
+   const float zero = 0.0;
+   __asm vec4_sne __retVal.x, f1, zero;   
+   __asm vec4_sne __retVal.y, f2, zero;   
+   __asm vec4_sne __retVal.z, f3, zero;   
+   __asm vec4_sne __retVal.w, f4, zero;   
 }
 
-bvec3 __constructor (const float f) {
-    return bvec3 (bool (f));
+bvec4 __constructor(const bool b)
+{
+   __asm vec4_move __retVal.xyzw, b;
 }
 
-bvec3 __constructor (const int i) {
-    return bvec3 (bool (i));
+bvec4 __constructor(const float f)
+{
+   __asm vec4_sne __retVal.xyzw, f, 0.0;
 }
 
-bvec4 __constructor (const bool b) {
-    return bvec4 (b, b, b, b);
+bvec4 __constructor(const int i)
+{
+   __asm vec4_sne __retVal.xyzw, i, 0.0;
 }
 
-bvec4 __constructor (const float f) {
-    return bvec4 (bool (f));
+bvec4 __constructor(const vec4 v)
+{
+   __asm vec4_sne __retVal.xyzw, v, 0.0;
 }
 
-bvec4 __constructor (const int i) {
-    return bvec4 (bool (i));
+bvec4 __constructor(const ivec4 v)
+{
+   __asm vec4_sne __retVal.xyzw, v, 0.0;
 }
 
 
 
 //// mat2 constructors
 
-mat2 __constructor (const float f) {
-    return mat2 (f, 0.0, 0.0, f);
+mat2 __constructor(const float m00, const float m10,
+                   const float m01, const float m11)
+{
+   __retVal[0].x = m00;
+   __retVal[0].y = m10;
+   __retVal[1].x = m01;
+   __retVal[1].y = m11;
 }
 
-mat2 __constructor (const int i) {
-    float x;
-    __asm int_to_float x, i;
-    return mat2 (x);
+mat2 __constructor(const float f)
+{
+   __retVal[0].x = f;
+   __retVal[0].y = 0.0;
+   __retVal[1].x = 0.0;
+   __retVal[1].y = f;
+}
+
+mat2 __constructor(const int i)
+{
+   return mat2(float(i));
+}
+
+mat2 __constructor(const bool b)
+{
+   return mat2(float(b));
 }
 
-mat2 __constructor (const bool b) {
-    return mat2 (b ? 1.0 : 0.0);
+mat2 __constructor(const vec2 c0, const vec2 c1)
+{
+   __retVal[0] = c0;
+   __retVal[1] = c1;
 }
 
 
 //// mat3 constructors
 
-mat3 __constructor (const float f) {
-    return mat3 (f, 0.0, 0.0, 0.0, f, 0.0, 0.0, 0.0, f);
+mat3 __constructor(const float m00, const float m10, const float m20,
+                   const float m01, const float m11, const float m21,
+                   const float m02, const float m12, const float m22)
+{
+   __retVal[0].x = m00;
+   __retVal[0].y = m10;
+   __retVal[0].z = m20;
+   __retVal[1].x = m01;
+   __retVal[1].y = m11;
+   __retVal[1].z = m21;
+   __retVal[2].x = m02;
+   __retVal[2].y = m12;
+   __retVal[2].z = m22;
 }
 
-mat3 __constructor (const int i) {
-    float x;
-    __asm int_to_float x, i;
-    return mat3 (x);
+mat3 __constructor(const float f)
+{
+   vec2 v = vec2(f, 0.0);
+   __retVal[0] = v.xyy;
+   __retVal[1] = v.yxy;
+   __retVal[2] = v.yyx;
 }
 
-mat3 __constructor (const bool b) {
-    return mat3 (b ? 1.0 : 0.0);
+mat3 __constructor(const int i)
+{
+   return mat3(float(i));
+}
+
+mat3 __constructor(const bool b)
+{
+   return mat3(float(b));
+}
+
+mat3 __constructor(const vec3 c0, const vec3 c1, const vec3 c2)
+{
+   __retVal[0] = c0;
+   __retVal[1] = c1;
+   __retVal[2] = c2;
 }
 
 
 //// mat4 constructors
 
-mat4 __constructor (const float f) {
-    return mat4 (f, 0.0, 0.0, 0.0, 0.0, f, 0.0, 0.0, 0.0, 0.0, f, 0.0, 0.0, 0.0, 0.0, f);
+mat4 __constructor(const float m00, const float m10, const float m20, const float m30,
+                   const float m01, const float m11, const float m21, const float m31,
+                   const float m02, const float m12, const float m22, const float m32,
+                   const float m03, const float m13, const float m23, const float m33)
+{
+   __retVal[0].x = m00;
+   __retVal[0].y = m10;
+   __retVal[0].z = m20;
+   __retVal[0].w = m30;
+   __retVal[1].x = m01;
+   __retVal[1].y = m11;
+   __retVal[1].z = m21;
+   __retVal[1].w = m31;
+   __retVal[2].x = m02;
+   __retVal[2].y = m12;
+   __retVal[2].z = m22;
+   __retVal[2].w = m32;
+   __retVal[3].x = m03;
+   __retVal[3].y = m13;
+   __retVal[3].z = m23;
+   __retVal[3].w = m33;
+}
+
+
+mat4 __constructor(const float f)
+{
+   vec2 v = vec2(f, 0.0);
+   __retVal[0] = v.xyyy;
+   __retVal[1] = v.yxyy;
+   __retVal[2] = v.yyxy;
+   __retVal[3] = v.yyyx;
 }
 
-mat4 __constructor (const int i) {
-    float x;
-    __asm int_to_float x, i;
-    return mat4 (x);
+mat4 __constructor(const int i)
+{
+   return mat4(float(i));
 }
 
-mat4 __constructor (const bool b) {
-    return mat4 (b ? 1.0 : 0.0);
+mat4 __constructor(const bool b)
+{
+   return mat4(float(b));
 }
 
-mat4 __constructor (const vec4 r0, const vec4 r1, const vec4 r2, const vec4 r3)
+mat4 __constructor(const vec4 c0, const vec4 c1, const vec4 c2, const vec4 c3)
 {
-   __retVal[0] = r0;
-   __retVal[1] = r1;
-   __retVal[2] = r2;
-   __retVal[3] = r3;
+   __retVal[0] = c0;
+   __retVal[1] = c1;
+   __retVal[2] = c2;
+   __retVal[3] = c3;
 }
 
 
@@ -335,116 +623,109 @@ mat4 __constructor (const vec4 r0, const vec4 r1, const vec4 r2, const vec4 r3)
 
 int __operator + (const int a, const int b)
 {
-    float x, y;
-    int c;
-    __asm int_to_float x, a;
-    __asm int_to_float y, b;
-    __asm float_add    x, x, y;
-    __asm float_to_int c, x;
-    return c;
+   __asm vec4_add __retVal, a, b;
 }
 
 int __operator - (const int a, const int b)
 {
-    float x, y;
-    int c;
-    __asm int_to_float x, a;
-    __asm int_to_float y, b;
-    __asm float_negate y, y;
-    __asm float_add    x, x, y;
-    __asm float_to_int c, x;
-    return c;
+   __asm vec4_subtract __retVal, a, b;
 }
 
 int __operator * (const int a, const int b)
 {
-    float x, y;
-    int c;
-    __asm int_to_float   x, a;
-    __asm int_to_float   y, b;
-    __asm float_multiply x, x, y;
-    __asm float_to_int   c, x;
-    return c;
+   __asm vec4_multiply __retVal, a, b;
 }
 
 int __operator / (const int a, const int b)
 {
-    float x, y;
-    int c;
-    __asm int_to_float x, a;
-    __asm int_to_float y, b;
-    __asm float_divide x, x, y;
-    __asm float_to_int c, x;
-    return c;
+   float bInv, x;
+   __asm float_rcp bInv, b;
+   __asm vec4_multiply x, a, bInv;
+   __asm vec4_to_ivec4 __retVal, x;
 }
 
 
 //// Basic ivec2 operators
 
-ivec2 __operator + (const ivec2 v, const ivec2 u)
+ivec2 __operator + (const ivec2 a, const ivec2 b)
 {
-    return ivec2 (v.x + u.x, v.y + u.y);
+   __asm vec4_add __retVal, a, b;
 }
 
-ivec2 __operator - (const ivec2 v, const ivec2 u)
+ivec2 __operator - (const ivec2 a, const ivec2 b)
 {
-    return ivec2 (v.x - u.x, v.y - u.y);
+   __asm vec4_subtract __retVal, a, b;
 }
 
-ivec2 __operator * (const ivec2 v, const ivec2 u)
+ivec2 __operator * (const ivec2 a, const ivec2 b)
 {
-    return ivec2 (v.x * u.x, v.y * u.y);
+   __asm vec4_multiply __retVal, a, b;
 }
 
-ivec2 __operator / (const ivec2 v, const ivec2 u)
+ivec2 __operator / (const ivec2 a, const ivec2 b)
 {
-    return ivec2 (v.x / u.x, v.y / u.y);
+   vec2 bInv, x;
+   __asm float_rcp bInv.x, b.x;
+   __asm float_rcp bInv.y, b.y;
+   __asm vec4_multiply x, a, bInv;
+   __asm vec4_to_ivec4 __retVal, x;
 }
 
 
 //// Basic ivec3 operators
 
-ivec3 __operator + (const ivec3 v, const ivec3 u)
+ivec3 __operator + (const ivec3 a, const ivec3 b)
 {
-    return ivec3 (v.x + u.x, v.y + u.y, v.z + u.z);
+   __asm vec4_add __retVal, a, b;
 }
 
-ivec3 __operator - (const ivec3 v, const ivec3 u)
+ivec3 __operator - (const ivec3 a, const ivec3 b)
 {
-    return ivec3 (v.x - u.x, v.y - u.y, v.z - u.z);
+   __asm vec4_subtract __retVal, a, b;
 }
 
-ivec3 __operator * (const ivec3 v, const ivec3 u)
+ivec3 __operator * (const ivec3 a, const ivec3 b)
 {
-    return ivec3 (v.x * u.x, v.y * u.y, v.z * u.z);
+   __asm vec4_multiply __retVal, a, b;
 }
 
-ivec3 __operator / (const ivec3 v, const ivec3 u)
+ivec3 __operator / (const ivec3 a, const ivec3 b)
 {
-    return ivec3 (v.x / u.x, v.y / u.y, v.z / u.z);
+   vec3 bInv, x;
+   __asm float_rcp bInv.x, b.x;
+   __asm float_rcp bInv.y, b.y;
+   __asm float_rcp bInv.z, b.z;
+   __asm vec4_multiply x, a, bInv;
+   __asm vec4_to_ivec4 __retVal, x;
 }
 
 
 //// Basic ivec4 operators
 
-ivec4 __operator + (const ivec4 v, const ivec4 u)
+ivec4 __operator + (const ivec4 a, const ivec4 b)
 {
-    return ivec4 (v.x + u.x, v.y + u.y, v.z + u.z, v.w + u.w);
+   __asm vec4_add __retVal, a, b;
 }
 
-ivec4 __operator - (const ivec4 v, const ivec4 u)
+ivec4 __operator - (const ivec4 a, const ivec4 b)
 {
-    return ivec4 (v.x - u.x, v.y - u.y, v.z - u.z, v.w - u.w);
+   __asm vec4_subtract __retVal, a, b;
 }
 
-ivec4 __operator * (const ivec4 v, const ivec4 u)
+ivec4 __operator * (const ivec4 a, const ivec4 b)
 {
-    return ivec4 (v.x * u.x, v.y * u.y, v.z * u.z, v.w * u.w);
+   __asm vec4_multiply __retVal, a, b;
 }
 
-ivec4 __operator / (const ivec4 v, const ivec4 u)
+ivec4 __operator / (const ivec4 a, const ivec4 b)
 {
-    return ivec4 (v.x / u.x, v.y / u.y, v.z / u.z, v.w / u.w);
+   vec4 bInv, x;
+   __asm float_rcp bInv.x, b.x;
+   __asm float_rcp bInv.y, b.y;
+   __asm float_rcp bInv.z, b.z;
+   __asm float_rcp bInv.w, b.w;
+   __asm vec4_multiply x, a, bInv;
+   __asm vec4_to_ivec4 __retVal, x;
 }
 
 
@@ -452,23 +733,24 @@ ivec4 __operator / (const ivec4 v, const ivec4 u)
 
 float __operator + (const float a, const float b)
 {
-//   __asm float_add __retVal, a, b;
-   __asm vec4_add __retVal.x, a, b;
+   __asm vec4_add __retVal, a, b;
 }
 
 float __operator - (const float a, const float b)
 {
-   __asm vec4_subtract __retVal.x, a, b;
+   __asm vec4_subtract __retVal, a, b;
 }
 
 float __operator * (const float a, const float b)
 {
-    __asm float_multiply __retVal, a, b;
+    __asm vec4_multiply __retVal, a, b;
 }
 
 float __operator / (const float a, const float b)
 {
-   __asm float_divide __retVal, a, b;
+   float bInv;
+   __asm float_rcp bInv.x, b;
+   __asm vec4_multiply __retVal, a, bInv;
 }
 
 
@@ -559,32 +841,32 @@ vec4 __operator / (const vec4 v, const vec4 u)
 
 vec2 __operator + (const float a, const vec2 u)
 {
-   __asm vec4_add __retVal.xy, a.xx, u.xy;
+   __asm vec4_add __retVal.xy, a, u.xy;
 }
 
 vec2 __operator + (const vec2 v, const float b)
 {
-   __asm vec4_add __retVal.xy, v.xy, b.xx;
+   __asm vec4_add __retVal.xy, v.xy, b;
 }
 
 vec2 __operator - (const float a, const vec2 u)
 {
-   __asm vec4_subtract __retVal.xy, a.xx, u.xy;
+   __asm vec4_subtract __retVal.xy, a, u.xy;
 }
 
 vec2 __operator - (const vec2 v, const float b)
 {
-   __asm vec4_subtract __retVal.xy, v.xy, b.xx;
+   __asm vec4_subtract __retVal.xy, v.xy, b;
 }
 
 vec2 __operator * (const float a, const vec2 u)
 {
-   __asm vec4_multiply __retVal.xy, a.xx, u.xy;
+   __asm vec4_multiply __retVal.xy, a, u.xy;
 }
 
 vec2 __operator * (const vec2 v, const float b)
 {
-   __asm vec4_multiply __retVal.xy, v.xy, b.xx;
+   __asm vec4_multiply __retVal.xy, v.xy, b;
 }
 
 vec2 __operator / (const float a, const vec2 u)
@@ -592,14 +874,14 @@ vec2 __operator / (const float a, const vec2 u)
    vec2 invU;
    __asm float_rcp invU.x, u.x;
    __asm float_rcp invU.y, u.y;
-   __asm vec4_multiply __retVal.xy, a.xx, invU.xy;
+   __asm vec4_multiply __retVal.xy, a, invU.xy;
 }
 
 vec2 __operator / (const vec2 v, const float b)
 {
    float invB;
    __asm float_rcp invB, b;
-   __asm vec4_multiply __retVal.xy, v.xy, invB.xx;
+   __asm vec4_multiply __retVal.xy, v.xy, invB;
 }
 
 
@@ -607,32 +889,32 @@ vec2 __operator / (const vec2 v, const float b)
 
 vec3 __operator + (const float a, const vec3 u)
 {
-   __asm vec4_add __retVal.xyz, a.xxx, u.xyz;
+   __asm vec4_add __retVal.xyz, a, u.xyz;
 }
 
 vec3 __operator + (const vec3 v, const float b)
 {
-   __asm vec4_add __retVal.xyz, v.xyz, b.xxx;
+   __asm vec4_add __retVal.xyz, v.xyz, b;
 }
 
 vec3 __operator - (const float a, const vec3 u)
 {
-   __asm vec4_subtract __retVal.xyz, a.xxx, u.xyz;
+   __asm vec4_subtract __retVal.xyz, a, u.xyz;
 }
 
 vec3 __operator - (const vec3 v, const float b)
 {
-   __asm vec4_subtract __retVal.xyz, v.xyz, b.xxx;
+   __asm vec4_subtract __retVal.xyz, v.xyz, b;
 }
 
 vec3 __operator * (const float a, const vec3 u)
 {
-   __asm vec4_multiply __retVal.xyz, a.xxx, u.xyz;
+   __asm vec4_multiply __retVal.xyz, a, u.xyz;
 }
 
 vec3 __operator * (const vec3 v, const float b)
 {
-   __asm vec4_multiply __retVal.xyz, v.xyz, b.xxx;
+   __asm vec4_multiply __retVal.xyz, v.xyz, b;
 }
 
 vec3 __operator / (const float a, const vec3 u)
@@ -641,14 +923,14 @@ vec3 __operator / (const float a, const vec3 u)
    __asm float_rcp invU.x, u.x;
    __asm float_rcp invU.y, u.y;
    __asm float_rcp invU.z, u.z;
-   __asm vec4_multiply __retVal.xyz, a.xxx, invU.xyz;
+   __asm vec4_multiply __retVal.xyz, a, invU.xyz;
 }
 
 vec3 __operator / (const vec3 v, const float b)
 {
    float invB;
    __asm float_rcp invB, b;
-   __asm vec4_multiply __retVal.xyz, v.xyz, invB.xxx;
+   __asm vec4_multiply __retVal.xyz, v.xyz, invB;
 }
 
 
@@ -656,32 +938,32 @@ vec3 __operator / (const vec3 v, const float b)
 
 vec4 __operator + (const float a, const vec4 u)
 {
-   __asm vec4_add __retVal, a.xxxx, u;
+   __asm vec4_add __retVal, a, u;
 }
 
 vec4 __operator + (const vec4 v, const float b)
 {
-   __asm vec4_add __retVal, v, b.xxxx;
+   __asm vec4_add __retVal, v, b;
 }
 
 vec4 __operator - (const float a, const vec4 u)
 {
-   __asm vec4_subtract __retVal, a.xxxx, u;
+   __asm vec4_subtract __retVal, a, u;
 }
 
 vec4 __operator - (const vec4 v, const float b)
 {
-   __asm vec4_subtract __retVal, v, b.xxxx;
+   __asm vec4_subtract __retVal, v, b;
 }
 
 vec4 __operator * (const float a, const vec4 u)
 {
-   __asm vec4_multiply __retVal, a.xxxx, u;
+   __asm vec4_multiply __retVal, a, u;
 }
 
 vec4 __operator * (const vec4 v, const float b)
 {
-   __asm vec4_multiply __retVal, v, b.xxxx;
+   __asm vec4_multiply __retVal, v, b;
 }
 
 vec4 __operator / (const float a, const vec4 u)
@@ -691,120 +973,144 @@ vec4 __operator / (const float a, const vec4 u)
    __asm float_rcp invU.y, u.y;
    __asm float_rcp invU.z, u.z;
    __asm float_rcp invU.w, u.w;
-   __asm vec4_multiply __retVal, a.xxxx, invU;
+   __asm vec4_multiply __retVal, a, invU;
 }
 
 vec4 __operator / (const vec4 v, const float b)
 {
    float invB;
    __asm float_rcp invB, b;
-   __asm vec4_multiply __retVal, v, invB.xxxx;
+   __asm vec4_multiply __retVal, v, invB;
 }
 
 
 
 //// Basic ivec2/int operators
 
-ivec2 __operator + (const int a, const ivec2 u) {
-    return ivec2 (a) + u;
+ivec2 __operator + (const int a, const ivec2 u)
+{
+   __retVal = ivec2(a) + u;
 }
 
-ivec2 __operator + (const ivec2 v, const int b) {
-    return v + ivec2 (b);
+ivec2 __operator + (const ivec2 v, const int b)
+{
+   __retVal = v + ivec2(b);
 }
 
-ivec2 __operator - (const int a, const ivec2 u) {
-    return ivec2 (a) - u;
+ivec2 __operator - (const int a, const ivec2 u)
+{
+   __retVal = ivec2(a) - u;
 }
 
-ivec2 __operator - (const ivec2 v, const int b) {
-    return v - ivec2 (b);
+ivec2 __operator - (const ivec2 v, const int b)
+{
+   __retVal = v - ivec2(b);
 }
 
-ivec2 __operator * (const int a, const ivec2 u) {
-    return ivec2 (a) * u;
+ivec2 __operator * (const int a, const ivec2 u)
+{
+   __retVal = ivec2(a) * u;
 }
 
-ivec2 __operator * (const ivec2 v, const int b) {
-    return v * ivec2 (b);
+ivec2 __operator * (const ivec2 v, const int b)
+{
+   __retVal = v * ivec2(b);
 }
 
-ivec2 __operator / (const int a, const ivec2 u) {
-    return ivec2 (a) / u;
+ivec2 __operator / (const int a, const ivec2 u)
+{
+   __retVal = ivec2(a) / u;
 }
 
-ivec2 __operator / (const ivec2 v, const int b) {
-    return v / ivec2 (b);
+ivec2 __operator / (const ivec2 v, const int b)
+{
+   __retVal = v / ivec2(b);
 }
 
 
 //// Basic ivec3/int operators
 
-ivec3 __operator + (const int a, const ivec3 u) {
-    return ivec3 (a) + u;
+ivec3 __operator + (const int a, const ivec3 u)
+{
+   __retVal = ivec3(a) + u;
 }
 
-ivec3 __operator + (const ivec3 v, const int b) {
-    return v + ivec3 (b);
+ivec3 __operator + (const ivec3 v, const int b)
+{
+   __retVal = v + ivec3(b);
 }
 
-ivec3 __operator - (const int a, const ivec3 u) {
-    return ivec3 (a) - u;
+ivec3 __operator - (const int a, const ivec3 u)
+{
+   __retVal = ivec3(a) - u;
 }
 
-ivec3 __operator - (const ivec3 v, const int b) {
-    return v - ivec3 (b);
+ivec3 __operator - (const ivec3 v, const int b)
+{
+   __retVal = v - ivec3(b);
 }
 
-ivec3 __operator * (const int a, const ivec3 u) {
-    return ivec3 (a) * u;
+ivec3 __operator * (const int a, const ivec3 u)
+{
+   __retVal = ivec3(a) * u;
 }
 
-ivec3 __operator * (const ivec3 v, const int b) {
-    return v * ivec3 (b);
+ivec3 __operator * (const ivec3 v, const int b)
+{
+   __retVal = v * ivec3(b);
 }
 
-ivec3 __operator / (const int a, const ivec3 u) {
-    return ivec3 (a) / u;
+ivec3 __operator / (const int a, const ivec3 u)
+{
+   __retVal = ivec3(a) / u;
 }
 
-ivec3 __operator / (const ivec3 v, const int b) {
-    return v / ivec3 (b);
+ivec3 __operator / (const ivec3 v, const int b)
+{
+   __retVal = v / ivec3(b);
 }
 
 
 //// Basic ivec4/int operators
 
-ivec4 __operator + (const int a, const ivec4 u) {
-    return ivec4 (a) + u;
+ivec4 __operator + (const int a, const ivec4 u)
+{
+   __retVal = ivec4(a) + u;
 }
 
-ivec4 __operator + (const ivec4 v, const int b) {
-    return v + ivec4 (b);
+ivec4 __operator + (const ivec4 v, const int b)
+{
+   __retVal = v + ivec4(b);
 }
 
-ivec4 __operator - (const int a, const ivec4 u) {
-    return ivec4 (a) - u;
+ivec4 __operator - (const int a, const ivec4 u)
+{
+   __retVal = ivec4(a) - u;
 }
 
-ivec4 __operator - (const ivec4 v, const int b) {
-    return v - ivec4 (b);
+ivec4 __operator - (const ivec4 v, const int b)
+{
+   __retVal = v - ivec4(b);
 }
 
-ivec4 __operator * (const int a, const ivec4 u) {
-    return ivec4 (a) * u;
+ivec4 __operator * (const int a, const ivec4 u)
+{
+   __retVal = ivec4(a) * u;
 }
 
-ivec4 __operator * (const ivec4 v, const int b) {
-    return v * ivec4 (b);
+ivec4 __operator * (const ivec4 v, const int b)
+{
+   __retVal = v * ivec4(b);
 }
 
-ivec4 __operator / (const int a, const ivec4 u) {
-    return ivec4 (a) / u;
+ivec4 __operator / (const int a, const ivec4 u)
+{
+   __retVal = ivec4(a) / u;
 }
 
-ivec4 __operator / (const ivec4 v, const int b) {
-    return v / ivec4 (b);
+ivec4 __operator / (const ivec4 v, const int b)
+{
+   __retVal = v / ivec4(b);
 }
 
 
@@ -814,31 +1120,22 @@ ivec4 __operator / (const ivec4 v, const int b) {
 
 int __operator - (const int a)
 {
-// XXX redo
-    float x;
-    int b;
-    __asm int_to_float x, a;
-    __asm float_negate x, x;
-    __asm float_to_int b, x;
-    return b;
+   __asm vec4_negate __retVal.x, a;
 }
 
 ivec2 __operator - (const ivec2 v)
 {
-// XXX redo
-    return ivec2 (-v.x, -v.y);
+   __asm vec4_negate __retVal, v;
 }
 
 ivec3 __operator - (const ivec3 v)
 {
-// XXX redo
-    return ivec3 (-v.x, -v.y, -v.z);
+   __asm vec4_negate __retVal, v;
 }
 
 ivec4 __operator - (const ivec4 v)
 {
-// XXX redo
-    return ivec4 (-v.x, -v.y, -v.z, -v.w);
+   __asm vec4_negate __retVal, v;
 }
 
 float __operator - (const float a)
@@ -888,12 +1185,12 @@ mat4 __operator - (const mat4 m)
 
 float dot(const float a, const float b)
 {
-   return a * b;
+   __retVal = a * b;
 }
 
 float dot(const vec2 a, const vec2 b)
 {
-   return a.x * b.x + a.y * b.y;
+   __retVal = a.x * b.x + a.y * b.y;
 }
 
 float dot(const vec3 a, const vec3 b)
@@ -912,22 +1209,25 @@ float dot(const vec4 a, const vec4 b)
 
 void __operator += (inout int a, const int b)
 {
-    a = int (float (a) + float (b));
+   __asm vec4_add a, a, b;
 }
 
 void __operator -= (inout int a, const int b)
 {
-    a += -b;
+   __asm vec4_subtract a, a, b;
 }
 
 void __operator *= (inout int a, const int b)
 {
-    a = int (float (a) * float (b));
+   __asm vec4_multiply a, a, b;
 }
 
 void __operator /= (inout int a, const int b)
 {
-    a = int (float (a) / float (b));
+   float invB;
+   __asm float_rcp invB, b;
+   __asm vec4_multiply a, a, invB;
+   __asm vec4_to_ivec4 a, a;
 }
 
 
@@ -935,26 +1235,26 @@ void __operator /= (inout int a, const int b)
 
 void __operator += (inout ivec2 v, const ivec2 u)
 {
-    v.x += u.x;
-    v.y += u.y;
+   __asm vec4_add v, v, u;
 }
 
 void __operator -= (inout ivec2 v, const ivec2 u)
 {
-    v.x -= u.x;
-    v.y -= u.y;
+   __asm vec4_subtract v, v, u;
 }
 
 void __operator *= (inout ivec2 v, const ivec2 u)
 {
-    v.x *= u.x;
-    v.y *= u.y;
+   __asm vec4_multiply v, v, u;
 }
 
 void __operator /= (inout ivec2 v, const ivec2 u)
 {
-    v.x /= u.x;
-    v.y /= u.y;
+   ivec2 inv, z;
+   __asm float_rcp inv.x, u.x;
+   __asm float_rcp inv.y, u.y;
+   __asm vec4_multiply z, v, inv;
+   __asm vec4_to_ivec4 v, z;
 }
 
 
@@ -962,61 +1262,53 @@ void __operator /= (inout ivec2 v, const ivec2 u)
 
 void __operator += (inout ivec3 v, const ivec3 u)
 {
-    v.x += u.x;
-    v.y += u.y;
-    v.z += u.z;
+   __asm vec4_add v, v, u;
 }
 
 void __operator -= (inout ivec3 v, const ivec3 u)
 {
-    v.x -= u.x;
-    v.y -= u.y;
-    v.z -= u.z;
+   __asm vec4_subtract v, v, u;
 }
 
 void __operator *= (inout ivec3 v, const ivec3 u)
 {
-    v.x *= u.x;
-    v.y *= u.y;
-    v.z *= u.z;
+   __asm vec4_multiply v, v, u;
 }
 
 void __operator /= (inout ivec3 v, const ivec3 u)
 {
-    v.x /= u.x;
-    v.y /= u.y;
-    v.z /= u.z;
+   ivec3 inv, z;
+   __asm float_rcp inv.x, u.x;
+   __asm float_rcp inv.y, u.y;
+   __asm vec4_multiply z, v, inv;
+   __asm vec4_to_ivec4 v, z;
 }
 
 
 //// ivec4 assignment operators
 
-void __operator += (inout ivec4 v, const ivec4 u) {
-    v.x += u.x;
-    v.y += u.y;
-    v.z += u.z;
-    v.w += u.w;
+void __operator += (inout ivec4 v, const ivec4 u)
+{
+   __asm vec4_add v, v, u;
 }
 
-void __operator -= (inout ivec4 v, const ivec4 u) {
-    v.x -= u.x;
-    v.y -= u.y;
-    v.z -= u.z;
-    v.w -= u.w;
+void __operator -= (inout ivec4 v, const ivec4 u)
+{
+   __asm vec4_subtract v, v, u;
 }
 
-void __operator *= (inout ivec4 v, const ivec4 u) {
-    v.x *= u.x;
-    v.y *= u.y;
-    v.z *= u.z;
-    v.w *= u.w;
+void __operator *= (inout ivec4 v, const ivec4 u)
+{
+   __asm vec4_multiply v, v, u;
 }
 
-void __operator /= (inout ivec4 v, const ivec4 u) {
-    v.x /= u.x;
-    v.y /= u.y;
-    v.z /= u.z;
-    v.w /= u.w;
+void __operator /= (inout ivec4 v, const ivec4 u)
+{
+   ivec4 inv, z;
+   __asm float_rcp inv.x, u.x;
+   __asm float_rcp inv.y, u.y;
+   __asm vec4_multiply z, v, inv;
+   __asm vec4_to_ivec4 v, z;
 }
 
 
@@ -1024,7 +1316,7 @@ void __operator /= (inout ivec4 v, const ivec4 u) {
 
 void __operator += (inout float a, const float b)
 {
-    __asm vec4_add a.x, a, b;
+    __asm vec4_add a.x, a.x, b.x;
 }
 
 void __operator -= (inout float a, const float b)
@@ -1049,26 +1341,25 @@ void __operator /= (inout float a, const float b)
 
 void __operator += (inout vec2 v, const vec2 u)
 {
-    v.x += u.x;
-    v.y += u.y;
+   __asm vec4_add v.xy, v.xy, u.xy;
 }
 
 void __operator -= (inout vec2 v, const vec2 u)
 {
-    v.x -= u.x;
-    v.y -= u.y;
+   __asm vec4_subtract v.xy, v.xy, u.xy;
 }
 
 void __operator *= (inout vec2 v, const vec2 u)
 {
-    v.x *= u.x;
-    v.y *= u.y;
+   __asm vec4_multiply v.xy, v.xy, u.xy;
 }
 
 void __operator /= (inout vec2 v, const vec2 u)
 {
-    v.x /= u.x;
-    v.y /= u.y;
+   vec2 w;
+   __asm float_rcp w.x, u.x;
+   __asm float_rcp w.y, u.y;
+   __asm vec4_multiply v.xy, v.xy, w.xy;
 }
 
 
@@ -1091,10 +1382,11 @@ void __operator *= (inout vec3 v, const vec3 u)
 
 void __operator /= (inout vec3 v, const vec3 u)
 {
-// XXX rcp
-    v.x /= u.x;
-    v.y /= u.y;
-    v.z /= u.z;
+   vec3 w;
+   __asm float_rcp w.x, u.x;
+   __asm float_rcp w.y, u.y;
+   __asm float_rcp w.z, u.z;
+   __asm vec4_multiply v.xyz, v.xyz, w.xyz;
 }
 
 
@@ -1117,11 +1409,12 @@ void __operator *= (inout vec4 v, const vec4 u)
 
 void __operator /= (inout vec4 v, const vec4 u)
 {
-// XXX rcp
-    v.x /= u.x;
-    v.y /= u.y;
-    v.z /= u.z;
-    v.w /= u.w;
+   vec4 w;
+   __asm float_rcp w.x, u.x;
+   __asm float_rcp w.y, u.y;
+   __asm float_rcp w.z, u.z;
+   __asm float_rcp w.w, u.w;
+   __asm vec4_multiply v, v, w;
 }
 
 
@@ -1130,18 +1423,17 @@ void __operator /= (inout vec4 v, const vec4 u)
 
 void __operator += (inout ivec2 v, const int a)
 {
-   v.x += a;
-   v.y += a;
+   __asm vec4_add v.xy, v.xy, a;
 }
 
 void __operator -= (inout ivec2 v, const int a)
 {
-   v.x -= a;
-   v.y -= a;
+   __asm vec4_subtract v.xy, v.xy, a;
 }
 
 void __operator *= (inout ivec2 v, const int a)
 {
+   __asm vec4_multiply v.xy, v.xy, a;
    v.x *= a;
    v.y *= a;
 }
@@ -1158,27 +1450,22 @@ void __operator /= (inout ivec2 v, const int a)
 
 void __operator += (inout ivec3 v, const int a)
 {
-   v.x += a;
-   v.y += a;
-   v.z += a;
+   __asm vec4_add v.xyz, v.xyz, a;
 }
 
 void __operator -= (inout ivec3 v, const int a)
 {
-   v.x -= a;
-   v.y -= a;
-   v.z -= a;
+   __asm vec4_subtract v.xyz, v.xyz, a;
 }
 
 void __operator *= (inout ivec3 v, const int a)
 {
-   v.x *= a;
-   v.y *= a;
-   v.z *= a;
+   __asm vec4_multiply v.xyz, v.xyz, a;
 }
 
 void __operator /= (inout ivec3 v, const int a)
 {
+   // XXX rcp
     v.x /= a;
     v.y /= a;
     v.z /= a;
@@ -1189,17 +1476,17 @@ void __operator /= (inout ivec3 v, const int a)
 
 void __operator += (inout ivec4 v, const int a)
 {
-   __asm vec4_add v, v, a.xxxx;
+   __asm vec4_add v, v, a;
 }
 
 void __operator -= (inout ivec4 v, const int a)
 {
-   __asm vec4_subtract v, v, a.xxxx;
+   __asm vec4_subtract v, v, a;
 }
 
 void __operator *= (inout ivec4 v, const int a)
 {
-   __asm vec4_multiply v, v, a.xxxx;
+   __asm vec4_multiply v, v, a;
 }
 
 void __operator /= (inout ivec4 v, const int a)
@@ -1216,24 +1503,24 @@ void __operator /= (inout ivec4 v, const int a)
 
 void __operator += (inout vec2 v, const float a)
 {
-   __asm vec4_add v.xy, v, a.xx;
+   __asm vec4_add v.xy, v, a;
 }
 
 void __operator -= (inout vec2 v, const float a)
 {
-   __asm vec4_subtract v.xy, v, a.xx;
+   __asm vec4_subtract v.xy, v, a;
 }
 
 void __operator *= (inout vec2 v, const float a)
 {
-   __asm vec4_multiply v.xy, v, a.xx;
+   __asm vec4_multiply v.xy, v, a;
 }
 
 void __operator /= (inout vec2 v, const float a)
 {
    float invA;
    __asm float_rcp invA, a;
-   __asm vec4_multiply v.xy, v.xy, a.xx;
+   __asm vec4_multiply v.xy, v.xy, invA;
 }
 
 
@@ -1241,24 +1528,24 @@ void __operator /= (inout vec2 v, const float a)
 
 void __operator += (inout vec3 v, const float a)
 {
-   __asm vec4_add v.xyz, v, a.xxx;
+   __asm vec4_add v.xyz, v, a;
 }
 
 void __operator -= (inout vec3 v, const float a)
 {
-   __asm vec4_subtract v.xyz, v, a.xxx;
+   __asm vec4_subtract v.xyz, v, a;
 }
 
 void __operator *= (inout vec3 v, const float a)
 {
-   __asm vec4_multiply v.xyz, v, a.xxx;
+   __asm vec4_multiply v.xyz, v, a;
 }
 
 void __operator /= (inout vec3 v, const float a)
 {
    float invA;
    __asm float_rcp invA, a;
-   __asm vec4_multiply v.xyz, v.xyz, a.xxx;
+   __asm vec4_multiply v.xyz, v.xyz, invA;
 }
 
 
@@ -1266,24 +1553,24 @@ void __operator /= (inout vec3 v, const float a)
 
 void __operator += (inout vec4 v, const float a)
 {
-   __asm vec4_add v, v, a.xxxx;
+   __asm vec4_add v, v, a;
 }
 
 void __operator -= (inout vec4 v, const float a)
 {
-   __asm vec4_subtract v, v, a.xxxx;
+   __asm vec4_subtract v, v, a;
 }
 
 void __operator *= (inout vec4 v, const float a)
 {
-   __asm vec4_multiply v, v, a.xxxx;
+   __asm vec4_multiply v, v, a;
 }
 
 void __operator /= (inout vec4 v, const float a)
 {
    float invA;
    __asm float_rcp invA, a;
-   __asm vec4_multiply v, v, a.xxxx;
+   __asm vec4_multiply v, v, invA;
 }
 
 
@@ -1306,15 +1593,8 @@ mat2 __operator - (const mat2 m, const mat2 n)
 
 mat2 __operator * (const mat2 m, const mat2 n)
 {
-   vec2 mRow0, mRow1;
-   mRow0.x = m[0].x;
-   mRow0.y = m[1].x;
-   mRow1.x = m[0].y;
-   mRow1.y = m[1].y;
-   __retVal[0].x = dot(mRow0, n[0]);
-   __retVal[1].x = dot(mRow0, n[1]);
-   __retVal[0].y = dot(mRow1, n[0]);
-   __retVal[1].y = dot(mRow1, n[1]);
+   __retVal[0] = m[0] * n[0].xx + m[1] * n[0].yy;
+   __retVal[1] = m[0] * n[1].xx + m[1] * n[1].yy;
 }
 
 mat2 __operator / (const mat2 m, const mat2 n)
@@ -1342,25 +1622,9 @@ mat3 __operator - (const mat3 m, const mat3 n)
 
 mat3 __operator * (const mat3 m, const mat3 n)
 {
-   vec3 mRow0, mRow1, mRow2;
-   mRow0.x = m[0].x;
-   mRow0.y = m[1].x;
-   mRow0.z = m[2].x;
-   mRow1.x = m[0].y;
-   mRow1.y = m[1].y;
-   mRow1.z = m[2].y;
-   mRow2.x = m[0].z;
-   mRow2.y = m[1].z;
-   mRow2.z = m[2].z;
-   __retVal[0].x = dot(mRow0, n[0]);
-   __retVal[1].x = dot(mRow0, n[1]);
-   __retVal[2].x = dot(mRow0, n[2]);
-   __retVal[0].y = dot(mRow1, n[0]);
-   __retVal[1].y = dot(mRow1, n[1]);
-   __retVal[2].y = dot(mRow1, n[2]);
-   __retVal[0].z = dot(mRow2, n[0]);
-   __retVal[1].z = dot(mRow2, n[1]);
-   __retVal[2].z = dot(mRow2, n[2]);
+   __retVal[0] = m[0] * n[0].xxx + m[1] * n[0].yyy + m[2] * n[0].zzz;
+   __retVal[1] = m[0] * n[1].xxx + m[1] * n[1].yyy + m[2] * n[1].zzz;
+   __retVal[2] = m[0] * n[2].xxx + m[1] * n[2].yyy + m[2] * n[2].zzz;
 }
 
 mat3 __operator / (const mat3 m, const mat3 n)
@@ -1391,39 +1655,10 @@ mat4 __operator - (const mat4 m, const mat4 n)
 
 mat4 __operator * (const mat4 m, const mat4 n)
 {
-   vec4 mRow0, mRow1, mRow2, mRow3;
-   mRow0.x = m[0].x;
-   mRow0.y = m[1].x;
-   mRow0.z = m[2].x;
-   mRow0.w = m[3].x;
-   mRow1.x = m[0].y;
-   mRow1.y = m[1].y;
-   mRow1.z = m[2].y;
-   mRow1.w = m[3].y;
-   mRow2.x = m[0].z;
-   mRow2.y = m[1].z;
-   mRow2.z = m[2].z;
-   mRow2.w = m[3].z;
-   mRow3.x = m[0].w;
-   mRow3.y = m[1].w;
-   mRow3.z = m[2].w;
-   mRow3.w = m[3].w;
-   __retVal[0].x = dot(mRow0, n[0]);
-   __retVal[1].x = dot(mRow0, n[1]);
-   __retVal[2].x = dot(mRow0, n[2]);
-   __retVal[3].x = dot(mRow0, n[3]);
-   __retVal[0].y = dot(mRow1, n[0]);
-   __retVal[1].y = dot(mRow1, n[1]);
-   __retVal[2].y = dot(mRow1, n[2]);
-   __retVal[3].y = dot(mRow1, n[3]);
-   __retVal[0].z = dot(mRow2, n[0]);
-   __retVal[1].z = dot(mRow2, n[1]);
-   __retVal[2].z = dot(mRow2, n[2]);
-   __retVal[3].z = dot(mRow2, n[3]);
-   __retVal[0].w = dot(mRow3, n[0]);
-   __retVal[1].w = dot(mRow3, n[1]);
-   __retVal[2].w = dot(mRow3, n[2]);
-   __retVal[3].w = dot(mRow3, n[3]);
+   __retVal[0] = m[0] * n[0].xxxx + m[1] * n[0].yyyy + m[2] * n[0].zzzz + m[3] * n[0].wwww;
+   __retVal[1] = m[0] * n[1].xxxx + m[1] * n[1].yyyy + m[2] * n[1].zzzz + m[3] * n[1].wwww;
+   __retVal[2] = m[0] * n[2].xxxx + m[1] * n[2].yyyy + m[2] * n[2].zzzz + m[3] * n[2].wwww;
+   __retVal[3] = m[0] * n[3].xxxx + m[1] * n[3].yyyy + m[2] * n[3].zzzz + m[3] * n[3].wwww;
 }
 
 mat4 __operator / (const mat4 m, const mat4 n)
@@ -1617,142 +1852,107 @@ mat4 __operator / (const mat4 m, const float b)
 
 vec2 __operator * (const mat2 m, const vec2 v)
 {
-   __retVal.x = dot(m[0], v);
-   __retVal.y = dot(m[1], v);
+   __retVal = m[0] * v.xx
+            + m[1] * v.yy;
 }
 
 vec2 __operator * (const vec2 v, const mat2 m)
 {
-   vec2 r0, r1;
-   r0.x = m[0].x;
-   r0.y = m[1].x;
-   r1.x = m[0].y;
-   r1.y = m[1].y;
-   __retVal.x = dot(v, r0);
-   __retVal.y = dot(v, r1);
+   __retVal.x = dot(v, m[0]);
+   __retVal.y = dot(v, m[1]);
 }
 
 vec3 __operator * (const mat3 m, const vec3 v)
 {
-   __retVal.x = dot(m[0], v);
-   __retVal.y = dot(m[1], v);
-   __retVal.z = dot(m[2], v);
+   __retVal = m[0] * v.xxx
+            + m[1] * v.yyy
+            + m[2] * v.zzz;
 }
 
 vec3 __operator * (const vec3 v, const mat3 m)
 {
-   vec3 r0, r1, r2;
-   r0.x = m[0].x;
-   r0.y = m[1].x;
-   r0.z = m[2].x;
-   r1.x = m[0].y;
-   r1.y = m[1].y;
-   r1.z = m[2].y;
-   r2.x = m[0].z;
-   r2.y = m[1].z;
-   r2.z = m[2].z;
-   __asm vec3_dot __retVal.x, v, r0;
-   __asm vec3_dot __retVal.y, v, r1;
-   __asm vec3_dot __retVal.z, v, r2;
+   __retVal.x = dot(v, m[0]);
+   __retVal.y = dot(v, m[1]);
+   __retVal.z = dot(v, m[2]);
 }
 
 vec4 __operator * (const mat4 m, const vec4 v)
 {
-   __retVal.x = dot(m[0], v);
-   __retVal.y = dot(m[1], v);
-   __retVal.z = dot(m[2], v);
-   __retVal.w = dot(m[3], v);
+   __retVal = m[0] * v.xxxx
+            + m[1] * v.yyyy
+            + m[2] * v.zzzz
+            + m[3] * v.wwww;
 }
 
 vec4 __operator * (const vec4 v, const mat4 m)
 {
-   vec4 r0, r1, r2, r3;
-   r0.x = m[0].x;
-   r0.y = m[1].x;
-   r0.z = m[2].x;
-   r0.w = m[3].x;
-   r1.x = m[0].y;
-   r1.y = m[1].y;
-   r1.z = m[2].y;
-   r1.w = m[3].y;
-   r2.x = m[0].z;
-   r2.y = m[1].z;
-   r2.z = m[2].z;
-   r2.w = m[3].z;
-   r3.x = m[0].w;
-   r3.y = m[1].w;
-   r3.z = m[2].w;
-   r3.w = m[3].w;
-   __asm vec4_dot __retVal.x, v, r0;
-   __asm vec4_dot __retVal.y, v, r1;
-   __asm vec4_dot __retVal.z, v, r2;
-   __asm vec4_dot __retVal.w, v, r3;
+   __retVal.x = dot(v, m[0]);
+   __retVal.y = dot(v, m[1]);
+   __retVal.z = dot(v, m[2]);
+   __retVal.w = dot(v, m[3]);
 }
 
 
 
+//// mat2 assignment operators
 
-
-
-
-
-
-
-
-////end
-
-
-
-
-void __operator += (inout mat2 m, const mat2 n) {
+void __operator += (inout mat2 m, const mat2 n)
+{
     m[0] += n[0];
     m[1] += n[1];
 }
 
-void __operator -= (inout mat2 m, const mat2 n) {
+void __operator -= (inout mat2 m, const mat2 n)
+{
     m[0] -= n[0];
     m[1] -= n[1];
 }
 
-
-
-void __operator *= (inout mat2 m, const mat2 n) {
+void __operator *= (inout mat2 m, const mat2 n)
+{
     m = m * n;
 }
 
-void __operator /= (inout mat2 m, const mat2 n) {
+void __operator /= (inout mat2 m, const mat2 n)
+{
     m[0] /= n[0];
     m[1] /= n[1];
 }
 
-void __operator += (inout mat3 m, const mat3 n) {
+
+//// mat3 assignment operators
+
+void __operator += (inout mat3 m, const mat3 n)
+{
     m[0] += n[0];
     m[1] += n[1];
     m[2] += n[2];
 }
 
-void __operator -= (inout mat3 m, const mat3 n) {
+void __operator -= (inout mat3 m, const mat3 n)
+{
     m[0] -= n[0];
     m[1] -= n[1];
     m[2] -= n[2];
 }
 
-
-
-
-
-
-void __operator *= (inout mat3 m, const mat3 n) {
+void __operator *= (inout mat3 m, const mat3 n)
+{
     m = m * n;
 }
 
-void __operator /= (inout mat3 m, const mat3 n) {
+void __operator /= (inout mat3 m, const mat3 n)
+{
     m[0] /= n[0];
     m[1] /= n[1];
     m[2] /= n[2];
 }
 
-void __operator += (inout mat4 m, const mat4 n) {
+
+// mat4 assignment operators
+
+void __operator += (inout mat4 m, const mat4 n)
+{
     m[0] += n[0];
     m[1] += n[1];
     m[2] += n[2];
@@ -1766,15 +1966,13 @@ void __operator -= (inout mat4 m, const mat4 n) {
     m[3] -= n[3];
 }
 
-
-
-
-
-void __operator *= (inout mat4 m, const mat4 n) {
+void __operator *= (inout mat4 m, const mat4 n)
+{
     m = m * n;
 }
 
-void __operator /= (inout mat4 m, const mat4 n) {
+void __operator /= (inout mat4 m, const mat4 n)
+{
     m[0] /= n[0];
     m[1] /= n[1];
     m[2] /= n[2];
@@ -1782,6 +1980,8 @@ void __operator /= (inout mat4 m, const mat4 n) {
 }
 
 
+//// mat2/float assignment operators
+
 void __operator += (inout mat2 m, const float a) {
     m[0] += a;
     m[1] += a;
@@ -1802,6 +2002,9 @@ void __operator /= (inout mat2 m, const float a) {
     m[1] /= a;
 }
 
+
+//// mat3/float assignment operators
+
 void __operator += (inout mat3 m, const float a) {
     m[0] += a;
     m[1] += a;
@@ -1826,6 +2029,9 @@ void __operator /= (inout mat3 m, const float a) {
     m[2] /= a;
 }
 
+
+//// mat4/float assignment operators
+
 void __operator += (inout mat4 m, const float a) {
     m[0] += a;
     m[1] += a;
@@ -1855,269 +2061,342 @@ void __operator /= (inout mat4 m, const float a) {
 }
 
 
-void __operator *= (inout vec2 v, const mat2 m) {
+
+//// vec/mat assignment operators
+
+void __operator *= (inout vec2 v, const mat2 m)
+{
     v = v * m;
 }
 
-void __operator *= (inout vec3 v, const mat3 m) {
-//    v = v * m;
+void __operator *= (inout vec3 v, const mat3 m)
+{
+    v = v * m;
 }
 
-
-
-
-
-
-
-
 void __operator *= (inout vec4 v, const mat4 m)
 {
-// xxx improve codegen for this case
     v = v * m;
 }
 
 
 
+//// pre-decrement operators
 
+int __operator --(inout int a)
+{
+    a = a - 1;
+   __retVal = a;
+}
 
+ivec2 __operator --(inout ivec2 v)
+{
+   v = v - ivec2(1);
+   __retVal = v;
+}
 
+ivec3 __operator --(inout ivec3 v)
+{
+   v = v - ivec3(1);
+   __retVal = v;
+}
 
+ivec4 __operator --(inout ivec4 v)
+{
+   v = v - ivec4(1);
+   __retVal = v;
+}
 
 
+float __operator --(inout float a)
+{
+   a = a - 1.0;
+   __retVal = a;
+}
 
+vec2 __operator --(inout vec2 v)
+{
+   v = v - vec2(1.0);
+   __retVal = v;
+}
 
-//next
-
-
+vec3 __operator --(inout vec3 v)
+{
+   v = v - vec3(1.0);
+   __retVal = v;
+}
 
+vec4 __operator --(inout vec4 v)
+{
+   v = v - vec4(1.0);
+   __retVal = v;
+}
 
 
-void __operator -- (inout float a) {
-    a -= 1.0;
+mat2 __operator --(inout mat2 m)
+{
+   m[0] = m[0] - vec2(1.0);
+   m[1] = m[1] - vec2(1.0);
+   __retVal = m;
 }
 
-void __operator -- (inout int a) {
-    a -= 1;
+mat3 __operator --(inout mat3 m)
+{
+   m[0] = m[0] - vec3(1.0);
+   m[1] = m[1] - vec3(1.0);
+   m[2] = m[2] - vec3(1.0);
+   __retVal = m;
 }
 
-void __operator -- (inout vec2 v) {
-    --v.x;
-    --v.y;
+mat4 __operator --(inout mat4 m)
+{
+   m[0] = m[0] - vec4(1.0);
+   m[1] = m[1] - vec4(1.0);
+   m[2] = m[2] - vec4(1.0);
+   m[3] = m[3] - vec4(1.0);
+   __retVal = m;
 }
 
-void __operator -- (inout vec3 v) {
-    --v.x;
-    --v.y;
-    --v.z;
-}
 
-void __operator -- (inout vec4 v) {
-    --v.x;
-    --v.y;
-    --v.z;
-    --v.w;
-}
+//// pre-increment operators
 
-void __operator -- (inout ivec2 v) {
-    --v.x;
-    --v.y;
+int __operator ++(inout int a)
+{
+    a = a + 1;
+    __retVal = a;
 }
 
-void __operator -- (inout ivec3 v) {
-    --v.x;
-    --v.y;
-    --v.z;
+ivec2 __operator ++(inout ivec2 v)
+{
+   v = v + ivec2(1);
+   __retVal = v;
 }
 
-void __operator -- (inout ivec4 v) {
-    --v.x;
-    --v.y;
-    --v.z;
-    --v.w;
+ivec3 __operator ++(inout ivec3 v)
+{
+   v = v + ivec3(1);
+   __retVal = v;
 }
 
-void __operator -- (inout mat2 m) {
-    --m[0];
-    --m[1];
+ivec4 __operator ++(inout ivec4 v)
+{
+   v = v + ivec4(1);
+   __retVal = v;
 }
 
-void __operator -- (inout mat3 m) {
-    --m[0];
-    --m[1];
-    --m[2];
-}
 
-void __operator -- (inout mat4 m) {
-    --m[0];
-    --m[1];
-    --m[2];
-    --m[3];
+float __operator ++(inout float a)
+{
+    a = a + 1.0;
+    __retVal = a;
 }
 
-void __operator ++ (inout float a) {
-    a += 1.0;
+vec2 __operator ++(inout vec2 v)
+{
+   v = v + vec2(1.0);
+   __retVal = v;
 }
 
-void __operator ++ (inout int a) {
-    a += 1;
+vec3 __operator ++(inout vec3 v)
+{
+   v = v + vec3(1.0);
+   __retVal = v;
 }
 
-void __operator ++ (inout vec2 v) {
-    ++v.x;
-    ++v.y;
+vec4 __operator ++(inout vec4 v)
+{
+   v = v + vec4(1.0);
+   __retVal = v;
 }
 
-void __operator ++ (inout vec3 v) {
-    ++v.x;
-    ++v.y;
-    ++v.z;
-}
 
-void __operator ++ (inout vec4 v) {
-    ++v.x;
-    ++v.y;
-    ++v.z;
-    ++v.w;
+mat2 __operator ++(inout mat2 m)
+{
+   m[0] = m[0] + vec2(1.0);
+   m[1] = m[1] + vec2(1.0);
+   __retVal = m;
 }
 
-void __operator ++ (inout ivec2 v) {
-    ++v.x;
-    ++v.y;
+mat3 __operator ++(inout mat3 m)
+{
+   m[0] = m[0] + vec3(1.0);
+   m[1] = m[1] + vec3(1.0);
+   m[2] = m[2] + vec3(1.0);
+   __retVal = m;
 }
 
-void __operator ++ (inout ivec3 v) {
-    ++v.x;
-    ++v.y;
-    ++v.z;
+mat4 __operator ++(inout mat4 m)
+{
+   m[0] = m[0] + vec4(1.0);
+   m[1] = m[1] + vec4(1.0);
+   m[2] = m[2] + vec4(1.0);
+   m[3] = m[3] + vec4(1.0);
+   __retVal = m;
 }
 
-void __operator ++ (inout ivec4 v) {
-    ++v.x;
-    ++v.y;
-    ++v.z;
-    ++v.w;
+
+
+//// post-decrement
+
+int __postDecr(inout int a)
+{
+   __retVal = a;
+   a = a - 1;
 }
 
-void __operator ++ (inout mat2 m) {
-    ++m[0];
-    ++m[1];
+ivec2 __postDecr(inout ivec2 v)
+{
+   __retVal = v;
+   v = v - ivec2(1);
 }
 
-void __operator ++ (inout mat3 m) {
-    ++m[0];
-    ++m[1];
-    ++m[2];
+ivec3 __postDecr(inout ivec3 v)
+{
+   __retVal = v;
+   v = v - ivec3(1);
 }
 
-void __operator ++ (inout mat4 m) {
-    ++m[0];
-    ++m[1];
-    ++m[2];
-    ++m[3];
+ivec4 __postDecr(inout ivec4 v)
+{
+   __retVal = v;
+   v = v - ivec4(1);
 }
 
-//
-// NOTE: postfix increment and decrement operators take additional dummy int parameter to
-//       distinguish their prototypes from prefix ones.
-//
 
-float __operator -- (inout float a, const int) {
-    float b = a;
-    --a;
-    return b;
+float __postDecr(inout float a)
+{
+   __retVal = a;
+   a = a - 1.0;
 }
 
-int __operator -- (inout int a, const int) {
-    int b = a;
-    --a;
-    return b;
+vec2 __postDecr(inout vec2 v)
+{
+   __retVal = v;
+   v = v - vec2(1.0);
 }
 
-vec2 __operator -- (inout vec2 v, const int) {
-    return vec2 (v.x--, v.y--);
+vec3 __postDecr(inout vec3 v)
+{
+   __retVal = v;
+   v = v - vec3(1.0);
 }
 
-vec3 __operator -- (inout vec3 v, const int) {
-    return vec3 (v.x--, v.y--, v.z--);
+vec4 __postDecr(inout vec4 v)
+{
+   __retVal = v;
+   v = v - vec4(1.0);
 }
 
-vec4 __operator -- (inout vec4 v, const int) {
-    return vec4 (v.x--, v.y--, v.z--, v.w--);
-}
 
-ivec2 __operator -- (inout ivec2 v, const int) {
-    return ivec2 (v.x--, v.y--);
+mat2 __postDecr(inout mat2 m)
+{
+   __retVal = m;
+   m[0] = m[0] - vec2(1.0);
+   m[1] = m[1] - vec2(1.0);
 }
 
-ivec3 __operator -- (inout ivec3 v, const int) {
-    return ivec3 (v.x--, v.y--, v.z--);
+mat3 __postDecr(inout mat3 m)
+{
+   __retVal = m;
+   m[0] = m[0] - vec3(1.0);
+   m[1] = m[1] - vec3(1.0);
+   m[2] = m[2] - vec3(1.0);
 }
 
-ivec4 __operator -- (inout ivec4 v, const int) {
-    return ivec4 (v.x--, v.y--, v.z--, v.w--);
+mat4 __postDecr(inout mat4 m)
+{
+   __retVal = m;
+   m[0] = m[0] - vec4(1.0);
+   m[1] = m[1] - vec4(1.0);
+   m[2] = m[2] - vec4(1.0);
+   m[3] = m[3] - vec4(1.0);
 }
 
-mat2 __operator -- (inout mat2 m, const int) {
-    return mat2 (m[0]--, m[1]--);
-}
 
-mat3 __operator -- (inout mat3 m, const int) {
-    return mat3 (m[0]--, m[1]--, m[2]--);
-}
+//// post-increment
 
-mat4 __operator -- (inout mat4 m, const int) {
-    return mat4 (m[0]--, m[1]--, m[2]--, m[3]--);
+float __postIncr(inout float a)
+{
+   __retVal = a;
+   a = a + 1;
 }
 
-float __operator ++ (inout float a, const int) {
-    float b = a;
-    ++a;
-    return b;
+vec2 __postIncr(inout vec2 v)
+{
+   __retVal = v;
+   v = v + vec2(1.0);
 }
 
-int __operator ++ (inout int a, const int) {
-    int b = a;
-    ++a;
-    return b;
+vec3 __postIncr(inout vec3 v)
+{
+   __retVal = v;
+   v = v + vec3(1.0);
 }
 
-vec2 __operator ++ (inout vec2 v, const int) {
-    return vec2 (v.x++, v.y++);
+vec4 __postIncr(inout vec4 v)
+{
+   __retVal = v;
+   v = v + vec4(1.0);
 }
 
-vec3 __operator ++ (inout vec3 v, const int) {
-    return vec3 (v.x++, v.y++, v.z++);
-}
 
-vec4 __operator ++ (inout vec4 v, const int) {
-    return vec4 (v.x++, v.y++, v.z++, v.w++);
+int __postIncr(inout int a)
+{
+   __retVal = a;
+   a = a + 1;
 }
 
-ivec2 __operator ++ (inout ivec2 v, const int) {
-    return ivec2 (v.x++, v.y++);
+ivec2 __postIncr(inout ivec2 v)
+{
+   __retVal = v;
+   v = v + ivec2(1);
 }
 
-ivec3 __operator ++ (inout ivec3 v, const int) {
-    return ivec3 (v.x++, v.y++, v.z++);
+ivec3 __postIncr(inout ivec3 v)
+{
+   __retVal = v;
+   v = v + ivec3(1);
 }
 
-ivec4 __operator ++ (inout ivec4 v, const int) {
-    return ivec4 (v.x++, v.y++, v.z++, v.w++);
+ivec4 __postIncr(inout ivec4 v)
+{
+   __retVal = v;
+   v = v + ivec3(1);
 }
 
-mat2 __operator ++ (inout mat2 m, const int) {
-    return mat2 (m[0]++, m[1]++);
+
+mat2 __postIncr(inout mat2 m)
+{
+   mat2 n = m;
+   m[0] = m[0] + vec2(1.0);
+   m[1] = m[1] + vec2(1.0);
+   return n;
 }
 
-mat3 __operator ++ (inout mat3 m, const int) {
-    return mat3 (m[0]++, m[1]++, m[2]++);
+mat3 __postIncr(inout mat3 m)
+{
+   mat3 n = m;
+   m[0] = m[0] + vec3(1.0);
+   m[1] = m[1] + vec3(1.0);
+   m[2] = m[2] + vec3(1.0);
+   return n;
 }
 
-mat4 __operator ++ (inout mat4 m, const int) {
-    return mat4 (m[0]++, m[1]++, m[2]++, m[3]++);
+mat4 __postIncr(inout mat4 m)
+{
+   mat4 n = m;
+   m[0] = m[0] + vec4(1.0);
+   m[1] = m[1] + vec4(1.0);
+   m[2] = m[2] + vec4(1.0);
+   m[3] = m[3] + vec4(1.0);
+   return n;
 }
 
 
+
+//// inequality operators
+
+
 // XXX are the inequality operators for floats/ints really needed????
 bool __operator < (const float a, const float b)
 {
@@ -2161,24 +2440,7 @@ bool __operator <= (const int a, const int b) {
     return float (a) <= float (b);
 }
 
-bool __operator ^^ (const bool a, const bool b) {
-    return a != b;
-}
 
-//
-// These operators are handled internally by the compiler:
-//
-// bool __operator && (bool a, bool b) {
-//     return a ? b : false;
-// }
-// bool __operator || (bool a, bool b) {
-//     return a ? true : b;
-// }
-//
-
-bool __operator ! (const bool a) {
-    return a == false;
-}
 
 //
 // MESA-specific extension functions.