#include "mlir/Conversion/ComplexToStandard/ComplexToStandard.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/Math/IR/Math.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Transforms/DialectConversion.h"
#include <memory>
#include <type_traits>
namespace mlir {
#define GEN_PASS_DEF_CONVERTCOMPLEXTOSTANDARD
#include "mlir/Conversion/Passes.h.inc"
}
usingnamespacemlir;
namespace {
enum class AbsFn { … };
Value computeAbs(Value real, Value imag, arith::FastMathFlags fmf,
ImplicitLocOpBuilder &b, AbsFn fn = AbsFn::abs) { … }
struct AbsOpConversion : public OpConversionPattern<complex::AbsOp> { … };
struct Atan2OpConversion : public OpConversionPattern<complex::Atan2Op> { … };
template <typename ComparisonOp, arith::CmpFPredicate p>
struct ComparisonOpConversion : public OpConversionPattern<ComparisonOp> { … };
template <typename BinaryComplexOp, typename BinaryStandardOp>
struct BinaryComplexOpConversion : public OpConversionPattern<BinaryComplexOp> { … };
template <typename TrigonometricOp>
struct TrigonometricOpConversion : public OpConversionPattern<TrigonometricOp> { … };
struct CosOpConversion : public TrigonometricOpConversion<complex::CosOp> { … };
struct DivOpConversion : public OpConversionPattern<complex::DivOp> { … };
struct ExpOpConversion : public OpConversionPattern<complex::ExpOp> { … };
struct Expm1OpConversion : public OpConversionPattern<complex::Expm1Op> { … };
struct LogOpConversion : public OpConversionPattern<complex::LogOp> { … };
struct Log1pOpConversion : public OpConversionPattern<complex::Log1pOp> { … };
struct MulOpConversion : public OpConversionPattern<complex::MulOp> { … };
struct NegOpConversion : public OpConversionPattern<complex::NegOp> { … };
struct SinOpConversion : public TrigonometricOpConversion<complex::SinOp> { … };
struct SqrtOpConversion : public OpConversionPattern<complex::SqrtOp> { … };
struct SignOpConversion : public OpConversionPattern<complex::SignOp> { … };
template <typename Op>
struct TanTanhOpConversion : public OpConversionPattern<Op> { … };
struct ConjOpConversion : public OpConversionPattern<complex::ConjOp> { … };
static Value powOpConversionImpl(mlir::ImplicitLocOpBuilder &builder,
ComplexType type, Value lhs, Value c, Value d,
arith::FastMathFlags fmf) { … }
struct PowOpConversion : public OpConversionPattern<complex::PowOp> { … };
struct RsqrtOpConversion : public OpConversionPattern<complex::RsqrtOp> { … };
struct AngleOpConversion : public OpConversionPattern<complex::AngleOp> { … };
}
void mlir::populateComplexToStandardConversionPatterns(
RewritePatternSet &patterns) { … }
namespace {
struct ConvertComplexToStandardPass
: public impl::ConvertComplexToStandardBase<ConvertComplexToStandardPass> { … };
void ConvertComplexToStandardPass::runOnOperation() { … }
}
std::unique_ptr<Pass> mlir::createConvertComplexToStandardPass() { … }