MLIR  16.0.0git
Namespaces | Macros | Functions
MathToSPIRV.cpp File Reference
#include "../SPIRVCommon/Pattern.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormatVariadic.h"
+ Include dependency graph for MathToSPIRV.cpp:

Go to the source code of this file.


 Include the generated interface declarations.


#define DEBUG_TYPE   "math-to-spirv-pattern"


static Value getScalarOrVectorI32Constant (Type type, int value, OpBuilder &builder, Location loc)
 Creates a 32-bit scalar/vector integer constant. More...
static bool isSupportedSourceType (Type originalType)
 Check if the type is supported by math-to-spirv conversion. More...
static LogicalResult checkSourceOpTypes (ConversionPatternRewriter &rewriter, Operation *sourceOp)
 Check if all sourceOp types are supported by math-to-spirv conversion. More...
void mlir::populateMathToSPIRVPatterns (SPIRVTypeConverter &typeConverter, RewritePatternSet &patterns)
 Appends to a pattern list additional patterns for translating Math ops to SPIR-V ops. More...

Macro Definition Documentation


#define DEBUG_TYPE   "math-to-spirv-pattern"

Definition at line 25 of file MathToSPIRV.cpp.

Function Documentation

◆ checkSourceOpTypes()

static LogicalResult checkSourceOpTypes ( ConversionPatternRewriter rewriter,
Operation sourceOp 

Check if all sourceOp types are supported by math-to-spirv conversion.

Notify of a match failure othwerise and return a failure result. This is intended to simplify type checks in OpConversionPatterns.

Definition at line 75 of file MathToSPIRV.cpp.

References mlir::Operation::getOperandTypes(), mlir::Operation::getResultTypes(), isSupportedSourceType(), mlir::ConversionPatternRewriter::notifyMatchFailure(), and mlir::success().

◆ getScalarOrVectorI32Constant()

static Value getScalarOrVectorI32Constant ( Type  type,
int  value,
OpBuilder builder,
Location  loc 

Creates a 32-bit scalar/vector integer constant.

Returns nullptr if the given type is not a 32-bit scalar/vector type.

Definition at line 35 of file MathToSPIRV.cpp.

References mlir::OpBuilder::create(), mlir::Type::dyn_cast(), mlir::Builder::getI32IntegerAttr(), mlir::Builder::getI32VectorAttr(), mlir::Type::isInteger(), and value.

◆ isSupportedSourceType()

static bool isSupportedSourceType ( Type  originalType)

Check if the type is supported by math-to-spirv conversion.

We expect to only see scalars and vectors at this point, with higher-level types already lowered.

Definition at line 54 of file MathToSPIRV.cpp.

References mlir::Type::dyn_cast(), and mlir::Type::isIntOrIndexOrFloat().

Referenced by checkSourceOpTypes().