MLIR 22.0.0git
EmulateWideInt.cpp File Reference
#include "mlir/Dialect/Arith/Transforms/Passes.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Transforms/WideIntEmulationConverter.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/Func/Transforms/FuncConversions.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MathExtras.h"
#include <cassert>
#include "mlir/Dialect/Arith/Transforms/Passes.h.inc"

Go to the source code of this file.

Classes

class  mlir::arith::impl::ArithEmulateWideIntBase< DerivedT >

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::arith
namespace  mlir::arith::impl

Macros

#define GEN_PASS_DEF_ARITHEMULATEWIDEINT

Functions

std::unique_ptr<::mlir::Passmlir::arith::impl::createArithEmulateWideInt ()
std::unique_ptr<::mlir::Passmlir::arith::impl::createArithEmulateWideInt (ArithEmulateWideIntOptions options)
std::unique_ptr<::mlir::Passmlir::arith::createArithEmulateWideInt ()
std::unique_ptr<::mlir::Passmlir::arith::createArithEmulateWideInt (ArithEmulateWideIntOptions options)
static std::pair< APInt, APInt > getHalves (const APInt &value, unsigned newBitWidth)
 Returns N bottom and N top bits from value, where N = newBitWidth.
static Type reduceInnermostDim (VectorType type)
 Returns the type with the last (innermost) dimension reduced to x1.
static Value extractLastDimSlice (ConversionPatternRewriter &rewriter, Location loc, Value input, int64_t lastOffset)
 Extracts the input vector slice with elements at the last dimension offset by lastOffset.
static std::pair< Value, ValueextractLastDimHalves (ConversionPatternRewriter &rewriter, Location loc, Value input)
 Extracts two vector slices from the input whose type is vector<...x2T>, with the first element at offset 0 and the second element at offset 1.
static Value dropTrailingX1Dim (ConversionPatternRewriter &rewriter, Location loc, Value input)
static Value appendX1Dim (ConversionPatternRewriter &rewriter, Location loc, Value input)
 Performs a vector shape cast to append an x1 dimension.
static Value insertLastDimSlice (ConversionPatternRewriter &rewriter, Location loc, Value source, Value dest, int64_t lastOffset)
 Inserts the source vector slice into the dest vector at offset lastOffset in the last dimension.
static Value constructResultVector (ConversionPatternRewriter &rewriter, Location loc, VectorType resultType, ValueRange resultComponents)
 Constructs a new vector of type resultType by creating a series of insertions of resultComponents, each at the next offset of the last vector dimension.

Macro Definition Documentation

◆ GEN_PASS_DEF_ARITHEMULATEWIDEINT

#define GEN_PASS_DEF_ARITHEMULATEWIDEINT

Definition at line 27 of file EmulateWideInt.cpp.

Function Documentation

◆ appendX1Dim()

Value appendX1Dim ( ConversionPatternRewriter & rewriter,
Location loc,
Value input )
static

Performs a vector shape cast to append an x1 dimension.

If the input is a scalar, this is a noop.

Definition at line 115 of file EmulateWideInt.cpp.

References mlir::Value::getType().

◆ constructResultVector()

Value constructResultVector ( ConversionPatternRewriter & rewriter,
Location loc,
VectorType resultType,
ValueRange resultComponents )
static

Constructs a new vector of type resultType by creating a series of insertions of resultComponents, each at the next offset of the last vector dimension.

When all resultComponents are scalars, the result type is vector<NxT>; when resultComponents are vector<...x1xT>s, the result type is vector<...xNxT>, where N is the number of resultComponents.

Definition at line 154 of file EmulateWideInt.cpp.

◆ dropTrailingX1Dim()

Value dropTrailingX1Dim ( ConversionPatternRewriter & rewriter,
Location loc,
Value input )
static

Definition at line 98 of file EmulateWideInt.cpp.

References mlir::Value::getType().

◆ extractLastDimHalves()

std::pair< Value, Value > extractLastDimHalves ( ConversionPatternRewriter & rewriter,
Location loc,
Value input )
static

Extracts two vector slices from the input whose type is vector<...x2T>, with the first element at offset 0 and the second element at offset 1.

Definition at line 90 of file EmulateWideInt.cpp.

References extractLastDimSlice().

◆ extractLastDimSlice()

Value extractLastDimSlice ( ConversionPatternRewriter & rewriter,
Location loc,
Value input,
int64_t lastOffset )
static

Extracts the input vector slice with elements at the last dimension offset by lastOffset.

Returns a value of vector type with the last dimension reduced to x1 or fully scalarized, e.g.:

Definition at line 67 of file EmulateWideInt.cpp.

References mlir::Value::getType().

Referenced by extractLastDimHalves().

◆ getHalves()

std::pair< APInt, APInt > getHalves ( const APInt & value,
unsigned newBitWidth )
static

Returns N bottom and N top bits from value, where N = newBitWidth.

Treats value as a 2*N bits-wide integer. The bottom bits are returned in the first pair element, while the top bits in the second one.

Definition at line 41 of file EmulateWideInt.cpp.

Referenced by mlir::arith::impl::ArithEmulateWideIntBase< DerivedT >::createArithEmulateWideInt.

◆ insertLastDimSlice()

Value insertLastDimSlice ( ConversionPatternRewriter & rewriter,
Location loc,
Value source,
Value dest,
int64_t lastOffset )
static

Inserts the source vector slice into the dest vector at offset lastOffset in the last dimension.

source can be a scalar when dest is a 1D vector.

Definition at line 131 of file EmulateWideInt.cpp.

References mlir::Value::getType().

◆ reduceInnermostDim()

Type reduceInnermostDim ( VectorType type)
static

Returns the type with the last (innermost) dimension reduced to x1.

Scalarizes 1D vector inputs to match how we extract/insert vector values, e.g.:

Definition at line 53 of file EmulateWideInt.cpp.