The vector.fma operation is portable enough across targets that we do not want
to keep it wrapped under vector.outerproduct and llvm.intrin.fmuladd.
This revision lifts the op into the vector dialect and implements the lowering to LLVM by using two patterns:
- a pattern that lowers from n-D to (n-1)-D by unrolling when n > 2
- a pattern that converts from 1-D to the proper LLVM representation
clang-format: please reformat the code
+def Vector_FMAOp : + Op<Vector_Dialect, "fma", [NoSideEffect, + AllTypesMatch<["lhs", "rhs", "acc", "result"]>]>, + Arguments<(ins AnyVector:$lhs, AnyVector:$rhs, AnyVector:$acc)>, + Results<(outs AnyVector:$result)> { + let summary = "vector fused multiply-add"; + let description = [{ + Multiply-add expressions operate on n-D vectors and compute a fused + pointwise multiply followed by accumulate. In the particular case of + lowering to LLVM, this is guaranteed to lower to the `llvm.fmuladd.*` + intrinsic. + + Example: + ++ %3 = vector.fma %0, %1, %2: vector<8x16xf32>
+ `
+ }];
+ // Fully specified by traits.
+ let verifier = ?;
+ let assemblyFormat = "$lhs , $rhs , $acc attr-dict : type($lhs)";
+ let builders = [OpBuilder<
+ "Builder *b, OperationState &result, Value lhs, Value rhs, Value acc",
+ "build(b, result, lhs.getType(), lhs, rhs, acc);">];
+ let extraClassDeclaration = [{
+ VectorType getVectorType() { return lhs().getType().cast<VectorType>(); }
+ }];
+}
+