Files
clang-p2996/mlir/lib/Dialect/Complex/IR/ComplexDialect.cpp
Mogball a54f4eae0e [MLIR] Replace std ops with arith dialect ops
Precursor: https://reviews.llvm.org/D110200

Removed redundant ops from the standard dialect that were moved to the
`arith` or `math` dialects.

Renamed all instances of operations in the codebase and in tests.

Reviewed By: rriddle, jpienaar

Differential Revision: https://reviews.llvm.org/D110797
2021-10-13 03:07:03 +00:00

35 lines
1.3 KiB
C++

//===- ComplexDialect.cpp - MLIR Complex Dialect --------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/Complex/IR/Complex.h"
#include "mlir/Dialect/StandardOps/IR/Ops.h"
using namespace mlir;
#include "mlir/Dialect/Complex/IR/ComplexOpsDialect.cpp.inc"
void complex::ComplexDialect::initialize() {
addOperations<
#define GET_OP_LIST
#include "mlir/Dialect/Complex/IR/ComplexOps.cpp.inc"
>();
}
Operation *complex::ComplexDialect::materializeConstant(OpBuilder &builder,
Attribute value,
Type type,
Location loc) {
// TODO complex.constant
if (type.isa<ComplexType>())
return builder.create<ConstantOp>(loc, type, value);
if (arith::ConstantOp::isBuildableWith(value, type))
return builder.create<arith::ConstantOp>(loc, type, value);
return nullptr;
}