Debian Codegraph @

flang/lib/Optimizer/Builder/Complex.cpp

raw
1 //===-- Complex.cpp -------------------------------------------------------===//
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 "flang/Optimizer/Builder/Complex.h"
10
11 //===----------------------------------------------------------------------===//
12 // Complex Factory implementation
13 //===----------------------------------------------------------------------===//
14
15 mlir::Type
16 fir::factory::Complex::getComplexPartType(mlir::Type complexType) const {
17 return builder.getRealType(
18 mlir::cast<fir::ComplexType>(complexType).getFKind());
19 }
20
21 mlir::Type fir::factory::Complex::getComplexPartType(mlir::Value cplx) const {
22 return getComplexPartType(cplx.getType());
23 }
24
25 mlir::Value fir::factory::Complex::createComplex(fir::KindTy kind,
26 mlir::Value real,
27 mlir::Value imag) {
28 auto complexTy = fir::ComplexType::get(builder.getContext(), kind);
29 return createComplex(complexTy, real, imag);
30 }
31
32 mlir::Value fir::factory::Complex::createComplex(mlir::Type cplxTy,
33 mlir::Value real,
34 mlir::Value imag) {
35 mlir::Value und = builder.create<fir::UndefOp>(loc, cplxTy);
36 return insert<Part::Imag>(insert<Part::Real>(und, real), imag);
37 }