MLIR
17.0.0git
|
#include "mlir/Conversion/ArithToSPIRV/ArithToSPIRV.h"
#include "../SPIRVCommon/Pattern.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVAttributes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/Debug.h"
#include <cassert>
#include <memory>
#include "mlir/Conversion/Passes.h.inc"
Go to the source code of this file.
Namespaces | |
mlir | |
This header declares functions that assit transformations in the MemRef dialect. | |
Macros | |
#define | GEN_PASS_DEF_CONVERTARITHTOSPIRV |
#define | DEBUG_TYPE "arith-to-spirv-pattern" |
#define | DISPATCH(cmpPredicate, spirvOp) |
#define | DISPATCH(cmpPredicate, spirvOp) |
Functions | |
static BoolAttr | convertBoolAttr (Attribute srcAttr, Builder builder) |
Converts the given srcAttr into a boolean attribute if it holds an integral value. More... | |
static IntegerAttr | convertIntegerAttr (IntegerAttr srcAttr, IntegerType dstType, Builder builder) |
Converts the given srcAttr to a new attribute of the given dstType . More... | |
static FloatAttr | convertFloatAttr (FloatAttr srcAttr, FloatType dstType, Builder builder) |
Converts the given srcAttr to a new attribute of the given dstType . More... | |
static bool | isBoolScalarOrVector (Type type) |
Returns true if the given type is a boolean scalar or vector type. More... | |
static bool | hasSameBitwidth (Type a, Type b) |
Returns true if scalar/vector type a and b have the same number of bitwidth. More... | |
static LogicalResult | getTypeConversionFailure (ConversionPatternRewriter &rewriter, Operation *op, Type srcType) |
Returns a source type conversion failure for srcType and operation op . More... | |
static LogicalResult | getTypeConversionFailure (ConversionPatternRewriter &rewriter, Operation *op) |
Returns a source type conversion failure for the result type of op . More... | |
template<typename SignedAbsOp > | |
static Value | emulateSignedRemainder (Location loc, Value lhs, Value rhs, Value signOperand, OpBuilder &builder) |
Returns signed remainder for lhs and rhs and lets the result follow the sign of signOperand . More... | |
#define DEBUG_TYPE "arith-to-spirv-pattern" |
Definition at line 31 of file ArithToSPIRV.cpp.
#define DISPATCH | ( | cmpPredicate, | |
spirvOp | |||
) |
#define DISPATCH | ( | cmpPredicate, | |
spirvOp | |||
) |
#define GEN_PASS_DEF_CONVERTARITHTOSPIRV |
Definition at line 27 of file ArithToSPIRV.cpp.
Converts the given srcAttr
into a boolean attribute if it holds an integral value.
Returns null attribute if conversion fails.
Definition at line 263 of file ArithToSPIRV.cpp.
References mlir::Builder::getBoolAttr().
Converts the given srcAttr
to a new attribute of the given dstType
.
Returns null attribute if dstType
is not 32-bit or conversion fails.
Definition at line 300 of file ArithToSPIRV.cpp.
References mlir::Builder::getF32FloatAttr(), and mlir::Type::isF32().
|
static |
Converts the given srcAttr
to a new attribute of the given dstType
.
Returns null attribute if conversion fails.
Definition at line 273 of file ArithToSPIRV.cpp.
References mlir::Builder::getIntegerAttr().
|
static |
Returns signed remainder for lhs
and rhs
and lets the result follow the sign of signOperand
.
Note that this is needed for Vulkan. Per the Vulkan's SPIR-V environment spec, "for the OpSRem and OpSMod instructions, if either operand is negative the result is undefined." So we cannot directly use spirv.SRem/spirv.SMod if either operand can be negative. Emulate it via spirv.UMod.
Definition at line 526 of file ArithToSPIRV.cpp.
References mlir::presburger::abs(), mlir::OpBuilder::create(), and mlir::Value::getType().
|
static |
Returns a source type conversion failure for the result type of op
.
Definition at line 360 of file ArithToSPIRV.cpp.
|
static |
Returns a source type conversion failure for srcType
and operation op
.
Definition at line 351 of file ArithToSPIRV.cpp.
Returns true if scalar/vector type a
and b
have the same number of bitwidth.
Definition at line 335 of file ArithToSPIRV.cpp.
|
static |
Returns true if the given type
is a boolean scalar or vector type.
Definition at line 322 of file ArithToSPIRV.cpp.
References mlir::Type::isInteger().