[Mlir-commits] [mlir] 521277c - [mlir][spirv] Add `CL.mix` op (#72800)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Tue Nov 21 04:31:42 PST 2023
Author: Ivan Butygin
Date: 2023-11-21T15:31:38+03:00
New Revision: 521277cd1a8044c5930608fd2f056d8ce5181b4f
URL: https://github.com/llvm/llvm-project/commit/521277cd1a8044c5930608fd2f056d8ce5181b4f
DIFF: https://github.com/llvm/llvm-project/commit/521277cd1a8044c5930608fd2f056d8ce5181b4f.diff
LOG: [mlir][spirv] Add `CL.mix` op (#72800)
Added:
Modified:
mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td
mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td
index c4900fb79f346f3..026f59b2afd8e24 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td
@@ -111,6 +111,37 @@ class SPIRV_CLTernaryArithmeticOp<string mnemonic, int opcode, Type type,
+// -----
+
+def SPIRV_CLMixOp : SPIRV_CLTernaryArithmeticOp<"mix", 99, SPIRV_Float> {
+ let summary = "Returns the linear blend of x & y implemented as: x + (y - x) * a";
+
+ let description = [{
+ Result Type, x, y and a must be floating-point or vector(2,3,4,8,16) of
+ floating-point values.
+
+ All of the operands, including the Result Type operand, must be of the
+ same type.
+
+ Note: This instruction can be implemented using contractions such as mad
+ or fma.
+
+ <!-- End of AutoGen section -->
+
+ ```
+ mix-op ::= ssa-id `=` `spirv.CL.mix` ssa-use, ssa-use, ssa-use `:`
+ float-scalar-vector-type
+ ```
+
+ #### Example:
+
+ ```mlir
+ %0 = spirv.CL.mix %a, %b, %c : f32
+ %1 = spirv.CL.mix %a, %b, %c : vector<3xf16>
+ ```
+ }];
+}
+
// -----
def SPIRV_CLCeilOp : SPIRV_CLUnaryArithmeticOp<"ceil", 12, SPIRV_Float> {
diff --git a/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir b/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir
index 29a4a46136156a9..f4e3a83e39f2479 100644
--- a/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir
+++ b/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir
@@ -188,6 +188,26 @@ func.func @fma(%a : vector<3xf32>, %b : vector<3xf32>, %c : vector<3xf32>) -> ()
// -----
+//===----------------------------------------------------------------------===//
+// spirv.CL.mix
+//===----------------------------------------------------------------------===//
+
+func.func @mix(%a : f32, %b : f32, %c : f32) -> () {
+ // CHECK: spirv.CL.mix {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32
+ %2 = spirv.CL.mix %a, %b, %c : f32
+ return
+}
+
+// -----
+
+func.func @mix(%a : vector<3xf32>, %b : vector<3xf32>, %c : vector<3xf32>) -> () {
+ // CHECK: spirv.CL.mix {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32>
+ %2 = spirv.CL.mix %a, %b, %c : vector<3xf32>
+ return
+}
+
+// -----
+
//===----------------------------------------------------------------------===//
// spirv.CL.{F|S|U}{Max|Min}
//===----------------------------------------------------------------------===//
More information about the Mlir-commits
mailing list