#include "mlir/Conversion/ArithToEmitC/ArithToEmitC.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/EmitC/IR/EmitC.h"
#include "mlir/Dialect/EmitC/Transforms/TypeConversions.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/Transforms/DialectConversion.h"
usingnamespacemlir;
namespace {
class ArithConstantOpConversionPattern
: public OpConversionPattern<arith::ConstantOp> { … };
Type adaptIntegralTypeSignedness(Type ty, bool needsUnsigned) { … }
Value adaptValueType(Value val, ConversionPatternRewriter &rewriter, Type ty) { … }
class CmpFOpConversion : public OpConversionPattern<arith::CmpFOp> { … };
class CmpIOpConversion : public OpConversionPattern<arith::CmpIOp> { … };
class NegFOpConversion : public OpConversionPattern<arith::NegFOp> { … };
template <typename ArithOp, bool castToUnsigned>
class CastConversion : public OpConversionPattern<ArithOp> { … };
template <typename ArithOp>
class UnsignedCastConversion : public CastConversion<ArithOp, true> { … };
template <typename ArithOp>
class SignedCastConversion : public CastConversion<ArithOp, false> { … };
template <typename ArithOp, typename EmitCOp>
class ArithOpConversion final : public OpConversionPattern<ArithOp> { … };
template <class ArithOp, class EmitCOp>
class BinaryUIOpConversion final : public OpConversionPattern<ArithOp> { … };
template <typename ArithOp, typename EmitCOp>
class IntegerOpConversion final : public OpConversionPattern<ArithOp> { … };
template <typename ArithOp, typename EmitCOp>
class BitwiseOpConversion : public OpConversionPattern<ArithOp> { … };
template <typename ArithOp, typename EmitCOp, bool isUnsignedOp>
class ShiftOpConversion : public OpConversionPattern<ArithOp> { … };
template <typename ArithOp, typename EmitCOp>
class SignedShiftOpConversion final
: public ShiftOpConversion<ArithOp, EmitCOp, false> { … };
template <typename ArithOp, typename EmitCOp>
class UnsignedShiftOpConversion final
: public ShiftOpConversion<ArithOp, EmitCOp, true> { … };
class SelectOpConversion : public OpConversionPattern<arith::SelectOp> { … };
template <typename CastOp>
class FtoICastOpConversion : public OpConversionPattern<CastOp> { … };
template <typename CastOp>
class ItoFCastOpConversion : public OpConversionPattern<CastOp> { … };
}
void mlir::populateArithToEmitCPatterns(TypeConverter &typeConverter,
RewritePatternSet &patterns) { … }