#include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h"
#include "mlir/Conversion/ArithCommon/AttrToLLVMConverter.h"
#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"
#include "mlir/Conversion/LLVMCommon/ConversionTarget.h"
#include "mlir/Conversion/LLVMCommon/VectorPattern.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Pass/Pass.h"
#include <type_traits>
namespace mlir {
#define GEN_PASS_DEF_ARITHTOLLVMCONVERSIONPASS
#include "mlir/Conversion/Passes.h.inc"
}
usingnamespacemlir;
namespace {
template <typename SourceOp, typename TargetOp, bool Constrained,
template <typename, typename> typename AttrConvert =
AttrConvertPassThrough>
struct ConstrainedVectorConvertToLLVMPattern
: public VectorConvertToLLVMPattern<SourceOp, TargetOp, AttrConvert> { … };
AddFOpLowering;
AddIOpLowering;
AndIOpLowering;
BitcastOpLowering;
DivFOpLowering;
DivSIOpLowering;
DivUIOpLowering;
ExtFOpLowering;
ExtSIOpLowering;
ExtUIOpLowering;
FPToSIOpLowering;
FPToUIOpLowering;
MaximumFOpLowering;
MaxNumFOpLowering;
MaxSIOpLowering;
MaxUIOpLowering;
MinimumFOpLowering;
MinNumFOpLowering;
MinSIOpLowering;
MinUIOpLowering;
MulFOpLowering;
MulIOpLowering;
NegFOpLowering;
OrIOpLowering;
RemFOpLowering;
RemSIOpLowering;
RemUIOpLowering;
SelectOpLowering;
ShLIOpLowering;
ShRSIOpLowering;
ShRUIOpLowering;
SIToFPOpLowering;
SubFOpLowering;
SubIOpLowering;
TruncFOpLowering;
ConstrainedTruncFOpLowering;
TruncIOpLowering;
UIToFPOpLowering;
XOrIOpLowering;
struct ConstantOpLowering : public ConvertOpToLLVMPattern<arith::ConstantOp> { … };
template <typename OpTy, typename ExtCastTy>
struct IndexCastOpLowering : public ConvertOpToLLVMPattern<OpTy> { … };
IndexCastOpSILowering;
IndexCastOpUILowering;
struct AddUIExtendedOpLowering
: public ConvertOpToLLVMPattern<arith::AddUIExtendedOp> { … };
template <typename ArithMulOp, bool IsSigned>
struct MulIExtendedOpLowering : public ConvertOpToLLVMPattern<ArithMulOp> { … };
MulSIExtendedOpLowering;
MulUIExtendedOpLowering;
struct CmpIOpLowering : public ConvertOpToLLVMPattern<arith::CmpIOp> { … };
struct CmpFOpLowering : public ConvertOpToLLVMPattern<arith::CmpFOp> { … };
}
LogicalResult
ConstantOpLowering::matchAndRewrite(arith::ConstantOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const { … }
template <typename OpTy, typename ExtCastTy>
LogicalResult IndexCastOpLowering<OpTy, ExtCastTy>::matchAndRewrite(
OpTy op, typename OpTy::Adaptor adaptor,
ConversionPatternRewriter &rewriter) const { … }
LogicalResult AddUIExtendedOpLowering::matchAndRewrite(
arith::AddUIExtendedOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const { … }
template <typename ArithMulOp, bool IsSigned>
LogicalResult MulIExtendedOpLowering<ArithMulOp, IsSigned>::matchAndRewrite(
ArithMulOp op, typename ArithMulOp::Adaptor adaptor,
ConversionPatternRewriter &rewriter) const { … }
template <typename LLVMPredType, typename PredType>
static LLVMPredType convertCmpPredicate(PredType pred) { … }
LogicalResult
CmpIOpLowering::matchAndRewrite(arith::CmpIOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const { … }
LogicalResult
CmpFOpLowering::matchAndRewrite(arith::CmpFOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const { … }
namespace {
struct ArithToLLVMConversionPass
: public impl::ArithToLLVMConversionPassBase<ArithToLLVMConversionPass> { … };
}
namespace {
struct ArithToLLVMDialectInterface : public ConvertToLLVMPatternInterface { … };
}
void mlir::arith::registerConvertArithToLLVMInterface(
DialectRegistry ®istry) { … }
void mlir::arith::populateArithToLLVMConversionPatterns(
LLVMTypeConverter &converter, RewritePatternSet &patterns) { … }