1 //===- ComplexOps.cpp - MLIR Complex Operations ---------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "mlir/Dialect/Complex/IR/Complex.h" 10 11 using namespace mlir; 12 using namespace mlir::complex; 13 14 //===----------------------------------------------------------------------===// 15 // TableGen'd op method definitions 16 //===----------------------------------------------------------------------===// 17 18 #define GET_OP_CLASSES 19 #include "mlir/Dialect/Complex/IR/ComplexOps.cpp.inc" 20 21 OpFoldResult ReOp::fold(ArrayRef<Attribute> operands) { 22 assert(operands.size() == 1 && "unary op takes 1 operand"); 23 ArrayAttr arrayAttr = operands[0].dyn_cast_or_null<ArrayAttr>(); 24 if (arrayAttr && arrayAttr.size() == 2) 25 return arrayAttr[0]; 26 return {}; 27 } 28 29 OpFoldResult ImOp::fold(ArrayRef<Attribute> operands) { 30 assert(operands.size() == 1 && "unary op takes 1 operand"); 31 ArrayAttr arrayAttr = operands[0].dyn_cast_or_null<ArrayAttr>(); 32 if (arrayAttr && arrayAttr.size() == 2) 33 return arrayAttr[1]; 34 return {}; 35 } 36