MLIR 24.0.0git
XeVMDialect.cpp File Reference
#include "mlir/Dialect/LLVMIR/XeVMDialect.h"
#include "mlir/Dialect/GPU/IR/CompilationInterfaces.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/DialectImplementation.h"
#include "mlir/IR/TypeUtilities.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MathExtras.h"
#include "mlir/Dialect/LLVMIR/XeVMOpsDialect.cpp.inc"
#include "mlir/Dialect/LLVMIR/XeVMOpsEnums.cpp.inc"
#include "mlir/Dialect/LLVMIR/XeVMOps.cpp.inc"
#include "mlir/Dialect/LLVMIR/XeVMOpsAttributes.cpp.inc"

Go to the source code of this file.

Macros

#define GET_OP_LIST
#define GET_ATTRDEF_LIST
#define GET_OP_CLASSES
#define GET_ATTRDEF_CLASSES

Functions

template<typename OpType, typename = std::enable_if_t<llvm::is_one_of< OpType, BlockLoadOp, BlockStoreOp>::value>>
LogicalResult verify1DBlockArg (OpType op)
static int64_t getNarrowFloatBitWidth (TruncfDstElemTypes etype)
 Number of bits one narrow float value occupies.
static int64_t getNarrowFloatBitWidth (ExtfSrcElemTypes etype)
static int64_t getNumValues (Type ty)
 Number of values ty holds: its length if it is a vector, and one otherwise.
static int64_t getPackedBitWidth (Type ty)
 Total bit width of ty, which is a scalar or a vector of a scalar.
static LogicalResult verifyPackedWidth (Operation *op, StringRef packedName, Type packedTy, int64_t numValues, int64_t narrowBits)
 Verifies that packedTy is exactly wide enough to hold numValues values of narrowBits bits each, rounded up to whole bytes.
static const llvm::fltSemantics * getFloatSemantics (TruncfSrcElemTypes etype)
 Float semantics the element type attributes of xevm.truncf and xevm.extf stand for.
static const llvm::fltSemantics * getFloatSemantics (ExtfDstElemTypes etype)
static const llvm::fltSemantics * getFloatSemantics (TruncfDstElemTypes etype)
static const llvm::fltSemantics * getFloatSemantics (ExtfSrcElemTypes etype)

Macro Definition Documentation

◆ GET_ATTRDEF_CLASSES

#define GET_ATTRDEF_CLASSES

Definition at line 570 of file XeVMDialect.cpp.

◆ GET_ATTRDEF_LIST

#define GET_ATTRDEF_LIST

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 567 of file XeVMDialect.cpp.

◆ GET_OP_LIST

#define GET_OP_LIST

Function Documentation

◆ getFloatSemantics() [1/4]

const llvm::fltSemantics * getFloatSemantics ( ExtfDstElemTypes etype)
static

Definition at line 439 of file XeVMDialect.cpp.

◆ getFloatSemantics() [2/4]

const llvm::fltSemantics * getFloatSemantics ( ExtfSrcElemTypes etype)
static

Definition at line 461 of file XeVMDialect.cpp.

◆ getFloatSemantics() [3/4]

const llvm::fltSemantics * getFloatSemantics ( TruncfDstElemTypes etype)
static

Definition at line 449 of file XeVMDialect.cpp.

◆ getFloatSemantics() [4/4]

const llvm::fltSemantics * getFloatSemantics ( TruncfSrcElemTypes etype)
static

Float semantics the element type attributes of xevm.truncf and xevm.extf stand for.

The narrow formats are the OCP FP8 and FP4 ones: bf8 is E5M2, f8 is E4M3 and e2m1 is FP4.

Definition at line 429 of file XeVMDialect.cpp.

Referenced by createFloatConst(), createInitialValueForReduceOp(), createLinalgBodyCalculationForElementwiseOp(), mlir::detail::Parser::parseFloatAttr(), mlir::AsmPrinter::Impl::printDenseArrayAttr(), and reduceMatchAndRewriteHelper().

◆ getNarrowFloatBitWidth() [1/2]

int64_t getNarrowFloatBitWidth ( ExtfSrcElemTypes etype)
static

Definition at line 368 of file XeVMDialect.cpp.

◆ getNarrowFloatBitWidth() [2/2]

int64_t getNarrowFloatBitWidth ( TruncfDstElemTypes etype)
static

Number of bits one narrow float value occupies.

The narrow values of a xevm.truncf destination, or a xevm.extf source, are packed into whole bytes, so a sub-byte format fits several values per byte.

Definition at line 365 of file XeVMDialect.cpp.

◆ getNumValues()

int64_t getNumValues ( Type ty)
static

Number of values ty holds: its length if it is a vector, and one otherwise.

SPIR-V has no vector of length one and uses a scalar instead, so a conversion of two fp4 values, which pack into a single byte, has a scalar on its packed side.

Definition at line 376 of file XeVMDialect.cpp.

◆ getPackedBitWidth()

int64_t getPackedBitWidth ( Type ty)
static

Total bit width of ty, which is a scalar or a vector of a scalar.

Definition at line 383 of file XeVMDialect.cpp.

References mlir::Type::getIntOrFloatBitWidth().

Referenced by verifyPackedWidth().

◆ verify1DBlockArg()

template<typename OpType, typename = std::enable_if_t<llvm::is_one_of< OpType, BlockLoadOp, BlockStoreOp>::value>>
LogicalResult verify1DBlockArg ( OpType op)

Definition at line 314 of file XeVMDialect.cpp.

References success().

◆ verifyPackedWidth()

LogicalResult verifyPackedWidth ( Operation * op,
StringRef packedName,
Type packedTy,
int64_t numValues,
int64_t narrowBits )
static

Verifies that packedTy is exactly wide enough to hold numValues values of narrowBits bits each, rounded up to whole bytes.

Definition at line 391 of file XeVMDialect.cpp.

References mlir::Operation::emitOpError(), getPackedBitWidth(), and success().