1 //===-- FIRBuilder.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/FIRBuilder.h"
10 
11 mlir::Value fir::FirOpBuilder::createIntegerConstant(mlir::Location loc,
12                                                      mlir::Type ty,
13                                                      std::int64_t cst) {
14   return create<mlir::ConstantOp>(loc, ty, getIntegerAttr(ty, cst));
15 }
16 
17 mlir::Value fir::FirOpBuilder::createConvert(mlir::Location loc,
18                                              mlir::Type toTy, mlir::Value val) {
19   if (val.getType() != toTy) {
20     assert(!fir::isa_derived(toTy));
21     return create<fir::ConvertOp>(loc, toTy, val);
22   }
23   return val;
24 }
25