@@ -1029,6 +1029,108 @@ def SPIRV_GLFMixOp :
1029
1029
let hasVerifier = 0;
1030
1030
}
1031
1031
1032
+ // -----
1033
+
1034
+ def SPIRV_GLDistanceOp : SPIRV_GLOp<"Distance", 67, [Pure]> {
1035
+ let summary = "Return distance between two points";
1036
+
1037
+ let description = [{
1038
+ Result is the distance between x and y. This is |x - y|, where |x| is the
1039
+ length of x computed as sqrt(x * x).
1040
+
1041
+ The operands must all be vectors whose component type is floating-point.
1042
+ Result Type must be a scalar floating-point type.
1043
+
1044
+ #### Example:
1045
+
1046
+ ```mlir
1047
+ %2 = spirv.GL.Distance %0, %1 : vector<3xf32>, vector<3xf32> -> f32
1048
+ ```
1049
+ }];
1050
+
1051
+ let arguments = (ins
1052
+ SPIRV_ScalarOrVectorOf<SPIRV_Float>:$p0,
1053
+ SPIRV_ScalarOrVectorOf<SPIRV_Float>:$p1
1054
+ );
1055
+
1056
+ let results = (outs
1057
+ SPIRV_Float:$result
1058
+ );
1059
+
1060
+ let assemblyFormat = [{
1061
+ operands attr-dict `:` type($p0) `,` type($p1) `->` type($result)
1062
+ }];
1063
+ }
1064
+
1065
+ // -----
1066
+
1067
+ def SPIRV_GLCrossOp : SPIRV_GLBinaryArithmeticOp<"Cross", 68, SPIRV_Float> {
1068
+ let summary = "Return the cross product of two 3-component vectors";
1069
+
1070
+ let description = [{
1071
+ Result is the cross product of x and y, i.e. dot(x,y).
1072
+
1073
+ Arguments x and y must be vectors of size 3, of floating-point type.
1074
+ Results are computed per component.
1075
+ The result is a vector of the same type as the inputs.
1076
+
1077
+ #### Example:
1078
+
1079
+ ```mlir
1080
+ %2 = spirv.GL.Cross %0, %1 : vector<3xf32>
1081
+ %3 = spirv.GL.Cross %0, %1 : vector<3xf16>
1082
+ ```
1083
+ }];
1084
+ }
1085
+
1086
+ // -----
1087
+
1088
+ def SPIRV_GLNormalizeOp : SPIRV_GLUnaryArithmeticOp<"Normalize", 69, SPIRV_Float> {
1089
+ let summary = "Normalizes a vector operand";
1090
+
1091
+ let description = [{
1092
+ Result is the vector v/sqrt(dot(v,v)).
1093
+ The result is undefined if dot(v,v) is less than or equal to 0.
1094
+
1095
+ The operand v must be a vector whose component type is floating-point.
1096
+ The Result Type must be the same type as v.
1097
+ Results are computed per component.
1098
+
1099
+ #### Example:
1100
+
1101
+ ```mlir
1102
+ %2 = spirv.GL.Normalize %0 : vector<3xf32>
1103
+ %3 = spirv.GL.Normalize %1 : vector<4xf16>
1104
+ ```
1105
+ }];
1106
+ }
1107
+
1108
+ // -----
1109
+
1110
+ def SPIRV_GLReflectOp : SPIRV_GLBinaryArithmeticOp<"Reflect", 71, SPIRV_Float> {
1111
+ let summary = "Calculate reflection direction vector";
1112
+
1113
+ let description = [{
1114
+ Result is the reflection direction vector: I - 2 * dot(N, I) * N, where I is
1115
+ the incident vector and N is the surface orientation vector.
1116
+
1117
+ N must be normalized to achieve the desired result.
1118
+
1119
+ The operands must all be a scalar or vector whose component type is floating-point.
1120
+ Result Type and the type of all operands must be the same type.
1121
+ Results are computed per component.
1122
+
1123
+ #### Example:
1124
+
1125
+ ```mlir
1126
+ %2 = spirv.GL.Reflect %0, %1 : f32
1127
+ %3 = spirv.GL.Reflect %0, %1 : vector<3xf32>
1128
+ ```
1129
+ }];
1130
+ }
1131
+
1132
+ // ----
1133
+
1032
1134
def SPIRV_GLFindUMsbOp : SPIRV_GLUnaryArithmeticOp<"FindUMsb", 75, SPIRV_Int32> {
1033
1135
let summary = "Unsigned-integer most-significant bit";
1034
1136
0 commit comments