1//===- Utils.h - Utils for APFloat Conversion - C++ -----------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef MLIR_CONVERSION_ARITHANDMATHTOAPFLOAT_UTILS_H_
10#define MLIR_CONVERSION_ARITHANDMATHTOAPFLOAT_UTILS_H_
11
12#include "mlir/Dialect/Vector/IR/VectorOps.h"
13#include "mlir/IR/PatternMatch.h"
14
15namespace mlir {
16class Value;
17class OpBuilder;
18class Location;
19class FloatType;
20
21Value getAPFloatSemanticsValue(OpBuilder &b, Location loc, FloatType floatTy);
22
23/// Given two operands of vector type and vector result type (with the same
24/// shape), call the given function for each pair of scalar operands and
25/// package the result into a vector. If the given operands and result type are
26/// not vectors, call the function directly. The second operand is optional.
27Value forEachScalarValue(mlir::RewriterBase &rewriter, Location loc,
28 Value operand1, Value operand2, Type resultType,
29 llvm::function_ref<Value(Value, Value, Type)> fn);
30
31/// Check preconditions for the conversion:
32/// 1. All operands / results must be integers or floats (or vectors thereof).
33/// 2. The bitwidth of the operands / results must be <= 64.
34LogicalResult checkPreconditions(RewriterBase &rewriter, Operation *op);
35
36} // namespace mlir
37
38#endif // MLIR_CONVERSION_ARITHANDMATHTOAPFLOAT_UTILS_H_
39