FLANG
ConvertConstant.h
1//===-- ConvertConstant.h -- lowering of constants --------------*- C++ -*-===//
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// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10//
11//===----------------------------------------------------------------------===//
15//===----------------------------------------------------------------------===//
16
17#ifndef FORTRAN_LOWER_CONVERTCONSTANT_H
18#define FORTRAN_LOWER_CONVERTCONSTANT_H
19
20#include "flang/Evaluate/constant.h"
21#include "flang/Lower/Support/Utils.h"
22#include "flang/Optimizer/Builder/BoxValue.h"
23#include "flang/Optimizer/Builder/FIRBuilder.h"
24
25namespace Fortran::lower {
26class AbstractConverter;
27
29template <typename T>
31public:
41 mlir::Location loc,
42 const evaluate::Constant<T> &constant,
43 bool outlineBigConstantsInReadOnlyMemory);
44};
45using namespace evaluate;
46FOR_EACH_SPECIFIC_TYPE(extern template class ConstantBuilder, )
47
48template <typename T>
49fir::ExtendedValue convertConstant(Fortran::lower::AbstractConverter &converter,
50 mlir::Location loc,
51 const evaluate::Constant<T> &constant,
52 bool outlineBigConstantsInReadOnlyMemory) {
53 return ConstantBuilder<T>::gen(converter, loc, constant,
54 outlineBigConstantsInReadOnlyMemory);
55}
56
63fir::GlobalOp tryCreatingDenseGlobal(fir::FirOpBuilder &builder,
64 mlir::Location loc, mlir::Type symTy,
65 llvm::StringRef globalName,
66 mlir::StringAttr linkage, bool isConst,
67 const Fortran::lower::SomeExpr &initExpr,
68 cuf::DataAttributeAttr dataAttr = {});
69
77 mlir::Location loc,
79
80} // namespace Fortran::lower
81
82#endif // FORTRAN_LOWER_CONVERTCONSTANT_H
Definition: constant.h:141
Definition: expression.h:740
Definition: AbstractConverter.h:82
Class to lower evaluate::Constant to fir::ExtendedValue.
Definition: ConvertConstant.h:30
static fir::ExtendedValue gen(Fortran::lower::AbstractConverter &converter, mlir::Location loc, const evaluate::Constant< T > &constant, bool outlineBigConstantsInReadOnlyMemory)
Definition: ConvertConstant.cpp:738
Definition: BoxValue.h:478
Definition: FIRBuilder.h:55
Definition: AbstractConverter.h:59
fir::ExtendedValue genInlinedStructureCtorLit(Fortran::lower::AbstractConverter &converter, mlir::Location loc, const Fortran::evaluate::StructureConstructor &ctor)
Definition: ConvertConstant.cpp:822
fir::GlobalOp tryCreatingDenseGlobal(fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type symTy, llvm::StringRef globalName, mlir::StringAttr linkage, bool isConst, const Fortran::lower::SomeExpr &initExpr, cuf::DataAttributeAttr dataAttr={})
Definition: ConvertConstant.cpp:202
Definition: bit-population-count.h:20
Definition: AbstractConverter.h:31
Definition: AbstractConverter.h:27