23 int32_t sem = llvm::APFloatBase::SemanticsToEnum(floatTy.getFloatSemantics());
24 return arith::ConstantOp::create(
b, loc,
b.getI32Type(),
25 b.getIntegerAttr(
b.getI32Type(), sem));
31 auto vecTy1 = dyn_cast<VectorType>(operand1.
getType());
34 assert(vecTy1 == dyn_cast<VectorType>(operand2.
getType()) &&
35 "expected same vector types");
39 return fn(operand1, operand2, resultType);
44 vector::ToElementsOp::create(rewriter, loc, operand1)->getResults();
48 scalars2.assign(vecTy1.getNumElements(),
Value());
52 vector::ToElementsOp::create(rewriter, loc, operand2)->getResults());
56 auto resultVecType = cast<VectorType>(resultType);
58 for (
auto [scalar1, scalar2] : llvm::zip_equal(sclars1, scalars2)) {
59 Value result = fn(scalar1, scalar2, resultVecType.getElementType());
64 return vector::FromElementsOp::create(
66 vecTy1.cloneWith(std::nullopt, results.front().getType()),
72 Type type = value.getType();
73 if (
auto vecTy = dyn_cast<VectorType>(type)) {
74 type = vecTy.getElementType();
78 op,
"only integers and floats (or vectors thereof) are supported");
82 "bitwidth > 64 bits is not supported");
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
This class helps build Operations.
Operation is the basic unit of execution within MLIR.
operand_range getOperands()
Returns an iterator on the underlying Value's.
result_range getResults()
This class implements the result iterators for the Operation class.
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
std::enable_if_t<!std::is_convertible< CallbackT, Twine >::value, LogicalResult > notifyMatchFailure(Location loc, CallbackT &&reasonCallback)
Used to notify the listener that the IR failed to be rewritten because of a match failure,...
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
bool isIntOrFloat() const
Return true if this is an integer (of any signedness) or a float type.
unsigned getIntOrFloatBitWidth() const
Return the bit width of an integer or a float type, assert failure on other types.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Type getType() const
Return the type of this value.
Include the generated interface declarations.
LogicalResult checkPreconditions(RewriterBase &rewriter, Operation *op)
Check preconditions for the conversion:
Value getAPFloatSemanticsValue(OpBuilder &b, Location loc, FloatType floatTy)
Value forEachScalarValue(mlir::RewriterBase &rewriter, Location loc, Value operand1, Value operand2, Type resultType, llvm::function_ref< Value(Value, Value, Type)> fn)
Given two operands of vector type and vector result type (with the same shape), call the given functi...