FLANG

Public Member Functions | Static Public Member Functions | List of all members
Fortran::lower::FirOpBuilder Class Reference

`#include <flang/Lower/FIRBuilder.h>`

Inheritance diagram for Fortran::lower::FirOpBuilder:

## Public Member Functions
| FirOpBuilder (mlir::Operation *op, const fir::KindMapping &kindMap)
mlir::Region & | getRegion ()
| Get the current Region of the insertion point.
mlir::ModuleOp | getModule ()
| Get the current Module.
mlir::FuncOp | getFunction ()
| Get the current Function.
const fir::KindMapping & | getKindMap ()
| Get a reference to the kind map.
mlir::Value | convertWithSemantics (mlir::Location loc, mlir::Type toTy, mlir::Value val)
mlir::Block * | getEntryBlock ()
| Get the entry block of the current Function.
mlir::Type | getRefType (mlir::Type eleTy)
| Safely create a reference type to the type `eleTy`.
mlir::Value | createNullConstant (mlir::Location loc)
mlir::Value | createIntegerConstant (mlir::Location loc, mlir::Type integerType, std::int64_t i)
| Create an integer constant of type `type` and value `i`.
mlir::Value | createRealConstant (mlir::Location loc, mlir::Type realType, const llvm::APFloat &val)
mlir::Value | createRealZeroConstant (mlir::Location loc, mlir::Type realType)
| Create a real constant of type `realType` with a value zero.
mlir::Value | allocateLocal (mlir::Location loc, mlir::Type ty, llvm::StringRef nm, llvm::ArrayRef< mlir::Value > shape, bool asTarget=false)
mlir::Value | createTemporary (mlir::Location loc, mlir::Type type, llvm::StringRef name={}, llvm::ArrayRef< mlir::Value > shape={})
mlir::Value | createTemporary (mlir::Location loc, mlir::Type type, llvm::ArrayRef< mlir::Value > shape)
| Create an unnamed and untracked temporary on the stack.
fir::GlobalOp | createGlobal (mlir::Location loc, mlir::Type type, llvm::StringRef name, mlir::StringAttr linkage={}, mlir::Attribute value={}, bool isConst=false)
| Create a global value. More...
fir::GlobalOp | createGlobal (mlir::Location loc, mlir::Type type, llvm::StringRef name, bool isConst, std::function< void(FirOpBuilder &)> bodyBuilder, mlir::StringAttr linkage={})
fir::GlobalOp | createGlobalConstant (mlir::Location loc, mlir::Type type, llvm::StringRef name, mlir::StringAttr linkage={}, mlir::Attribute value={})
| Create a global constant (read-only) value.
fir::GlobalOp | createGlobalConstant (mlir::Location loc, mlir::Type type, llvm::StringRef name, std::function< void(FirOpBuilder &)> bodyBuilder, mlir::StringAttr linkage={})
fir::StringLitOp | createStringLit (mlir::Location loc, mlir::Type eleTy, llvm::StringRef string)
| Convert a StringRef string into a fir::StringLitOp.
mlir::FuncOp | getNamedFunction (llvm::StringRef name)
fir::GlobalOp | getNamedGlobal (llvm::StringRef name)
mlir::Value | createConvert (mlir::Location loc, mlir::Type toTy, mlir::Value val)
| Lazy creation of fir.convert op.
mlir::FuncOp | createFunction (mlir::Location loc, llvm::StringRef name, mlir::FunctionType ty)
mlir::FuncOp | addNamedFunction (mlir::Location loc, llvm::StringRef name, mlir::FunctionType ty)
mlir::Value | convertToIndexType (mlir::Location loc, mlir::Value val)
| Cast the input value to IndexType.

## Static Public Member Functions
static mlir::FuncOp | getNamedFunction (mlir::ModuleOp module, llvm::StringRef name)
static fir::GlobalOp | getNamedGlobal (mlir::ModuleOp module, llvm::StringRef name)
static mlir::FuncOp | createFunction (mlir::Location loc, mlir::ModuleOp module, llvm::StringRef name, mlir::FunctionType ty)
static mlir::FuncOp | addNamedFunction (mlir::Location loc, mlir::ModuleOp module, llvm::StringRef name, mlir::FunctionType ty)

## Detailed Description

Extends the MLIR OpBuilder to provide methods for building common FIR patterns.

## Member Function Documentation

## ◆ addNamedFunction()

mlir::FuncOp Fortran::lower::FirOpBuilder::addNamedFunction | ( | mlir::Location | loc,
|  | llvm::StringRef | name,
|  | mlir::FunctionType | ty
| ) |  |
| inline

Determine if the named function is already in the module. Return the instance if found, otherwise add a new named function to the module.

## ◆ allocateLocal()

mlir::Value Fortran::lower::FirOpBuilder::allocateLocal | ( | mlir::Location | loc,
|  | mlir::Type | ty,
|  | llvm::StringRef | nm,
|  | llvm::ArrayRef< mlir::Value > | shape,
|  | bool | asTarget = `false`
| ) |  |

Create a slot for a local on the stack. Besides the variable's type and shape, it may be given name or target attributes.

## ◆ convertWithSemantics()

mlir::Value Fortran::lower::FirOpBuilder::convertWithSemantics | ( | mlir::Location | loc,
|  | mlir::Type | toTy,
|  | mlir::Value | val
| ) |  |

The LHS and RHS are not always in agreement in terms of type. In some cases, the disagreement is between COMPLEX and other scalar types. In that case, the conversion must insert/extract out of a COMPLEX value to have the proper semantics and be strongly typed.

## ◆ createFunction()

mlir::FuncOp Fortran::lower::FirOpBuilder::createFunction | ( | mlir::Location | loc,
|  | llvm::StringRef | name,
|  | mlir::FunctionType | ty
| ) |  |
| inline

Create a new FuncOp. If the function may have already been created, use `addNamedFunction` instead.

## ◆ createGlobal()

fir::GlobalOp Fortran::lower::FirOpBuilder::createGlobal | ( | mlir::Location | loc,
|  | mlir::Type | type,
|  | llvm::StringRef | name,
|  | mlir::StringAttr | linkage = `{}`,
|  | mlir::Attribute | value = `{}`,
|  | bool | isConst = `false`
| ) |  |

Create a global value.

Create a global variable in the (read-only) data section. A global variable must have a unique name to identify and reference it.

## ◆ createNullConstant()

mlir::Value Fortran::lower::FirOpBuilder::createNullConstant | ( | mlir::Location | loc | ) |

Create a null constant of type RefType and value 0. Need to pass in the Location information.

## ◆ createTemporary()

mlir::Value Fortran::lower::FirOpBuilder::createTemporary | ( | mlir::Location | loc,
|  | mlir::Type | type,
|  | llvm::StringRef | name = `{}`,
|  | llvm::ArrayRef< mlir::Value > | shape = `{}`
| ) |  |

Create a temporary. A temp is allocated using `fir.alloca` and can be read and written using `fir.load` and `fir.store`, resp. The temporary can be given a name via a front-end `Symbol` or a `StringRef`.

Create a temporary variable on the stack. Anonymous temporaries have no `name` value.

## ◆ getNamedFunction()

mlir::FuncOp Fortran::lower::FirOpBuilder::getNamedFunction | ( | llvm::StringRef | name | ) |
| inline

Get a function by name. If the function exists in the current module, it is returned. Otherwise, a null FuncOp is returned.

The documentation for this class was generated from the following files:

- include/flang/Lower/FIRBuilder.h
- lib/Lower/FIRBuilder.cpp