FLANG
fir Namespace Reference

Namespaces

namespace  factory

Classes

class  AbstractArrayBox
class  AbstractBox
 Abstract base class. More...
class  AbstractIrBox
 Base class for values associated to a fir.box or fir.ref<fir.box>. More...
struct  AliasAnalysis
struct  ArgLoweringRule
 Define how a given intrinsic argument must be lowered. More...
class  ArrayBoxValue
class  BaseBoxType
 This class provides a shared interface for box and class types. More...
class  BoxValue
class  CharArrayBoxValue
 Expressions of type CHARACTER and with rank > 0. More...
class  CharBoxValue
class  ClosedIntervalAttr
class  CodeGenSpecifics
class  ConvertFIRToLLVMPattern
class  CoordinateIndicesAdaptor
struct  DebuggingResource
 Model operations which affect global debugging information. More...
class  DebugTypeGenerator
 This converts FIR/mlir type to DITypeAttr. More...
class  DerivedTypeCache
class  ExactTypeAttr
class  ExtendedValue
class  FIRCodeGenDialect
class  FIROpAndTypeConversion
 FIR conversion pattern template. More...
class  FirOpBuilder
class  FIROpConversion
struct  FIRToLLVMPassOptions
 FIR to LLVM translation pass options. More...
class  FunctionDistance
struct  IntrinsicArgumentLoweringRules
 This is shared by intrinsics and intrinsic module procedures. More...
struct  IntrinsicDummyArgument
struct  IntrinsicHandler
struct  IntrinsicHandlerEntry
 Entry into the tables describing how an intrinsic must be lowered. More...
struct  IntrinsicLibrary
class  KindMapping
class  LLVMTypeConverter
struct  LocalitySpecifierOperands
class  LowerBoundAttr
struct  MathOperation
class  MustBeHeapAttr
class  MutableBoxValue
class  MutableProperties
struct  NameUniquer
struct  OpenMPFIRPassPipelineOpts
struct  ParamType
class  PointIntervalAttr
class  PolymorphicValue
 Polymorphic value associated with a dynamic type descriptor. More...
struct  PPCIntrinsicLibrary
class  ProcBoxValue
class  RealAttr
struct  RuntimeFunction
class  SubclassAttr
class  TBAABuilder
class  TBAAForrest
struct  TBAATree
class  UpperBoundAttr
struct  VecTypeInfo
struct  VolatileMemoryResource
 Model operations which read from/write to volatile memory. More...

Typedefs

using UnboxedValue = mlir::Value
using LLVMIRLoweringPrinter
using TypeBuilderFunc = mlir::Type (*)(mlir::MLIRContext *)
using KindTy = unsigned
using IntOrValue = llvm::PointerUnion<mlir::IntegerAttr, mlir::Value>
using PassConstructor = std::unique_ptr<mlir::Pass>()
using MustRewriteCallBack = llvm::function_ref<bool(fir::AllocaOp)>
using AllocaRewriterCallBack
using DeallocCallBack
using MinlocBodyOpGeneratorTy
using InitValGeneratorTy
using AddrGeneratorTy
using I = IntrinsicLibrary
using RtMap = Fortran::common::StaticMultimapView<MathOperation>
using PI = PPCIntrinsicLibrary

Enumerations

enum class  Extremum { Min , Max }
 Enums used to templatize and share lowering of MIN and MAX.
enum class  ExtremumBehavior {
  IeeeMinMaximumNumber , IeeeMinMaximum , MinMaxss , PgfortranLlvm ,
  IeeeMinMaxNum
}
enum class  LowerIntrinsicArgAs { Value , Addr , Box , Inquired }
enum class  ParamTypeId {
  Void , Address , Integer , Real ,
  Complex , IntegerVector , UnsignedVector , RealVector
}
enum class  VecOp {
  Abs , Add , And , Anyge ,
  Cmpge , Cmpgt , Cmple , Cmplt ,
  Convert , Ctf , Cvf , Ld ,
  Lde , Ldl , Lvsl , Lvsr ,
  Lxv , Lxvp , Mergeh , Mergel ,
  Msub , Mul , Nmadd , Perm ,
  Permi , Sel , Sl , Sld ,
  Sldw , Sll , Slo , Splat ,
  Splat_s32 , Splats , Sr , Srl ,
  Sro , St , Ste , Stxv ,
  Stxvp , Sub , Xl , Xlbe ,
  Xld2 , Xlw4 , Xor , Xst ,
  Xst_be , Xstd2 , Xstw4
}
enum class  MMAOp {
  AssembleAcc , AssemblePair , DisassembleAcc , DisassemblePair ,
  Xxmfacc , Xxmtacc , Xxsetaccz , Pmxvbf16ger2 ,
  Pmxvbf16ger2nn , Pmxvbf16ger2np , Pmxvbf16ger2pn , Pmxvbf16ger2pp ,
  Pmxvf16ger2 , Pmxvf16ger2nn , Pmxvf16ger2np , Pmxvf16ger2pn ,
  Pmxvf16ger2pp , Pmxvf32ger , Pmxvf32gernn , Pmxvf32gernp ,
  Pmxvf32gerpn , Pmxvf32gerpp , Pmxvf64ger , Pmxvf64gernn ,
  Pmxvf64gernp , Pmxvf64gerpn , Pmxvf64gerpp , Pmxvi16ger2 ,
  Pmxvi16ger2pp , Pmxvi16ger2s , Pmxvi16ger2spp , Pmxvi4ger8 ,
  Pmxvi4ger8pp , Pmxvi8ger4 , Pmxvi8ger4pp , Pmxvi8ger4spp ,
  Xvbf16ger2 , Xvbf16ger2nn , Xvbf16ger2np , Xvbf16ger2pn ,
  Xvbf16ger2pp , Xvf16ger2 , Xvf16ger2nn , Xvf16ger2np ,
  Xvf16ger2pn , Xvf16ger2pp , Xvf32ger , Xvf32gernn ,
  Xvf32gernp , Xvf32gerpn , Xvf32gerpp , Xvf64ger ,
  Xvf64gernn , Xvf64gernp , Xvf64gerpn , Xvf64gerpp ,
  Xvi16ger2 , Xvi16ger2pp , Xvi16ger2s , Xvi16ger2spp ,
  Xvi4ger8 , Xvi4ger8pp , Xvi8ger4 , Xvi8ger4pp ,
  Xvi8ger4spp
}
 Enums used to templatize and share lowering of PowerPC MMA intrinsics.
enum class  MMAHandlerOp { NoOp , SubToFunc , SubToFuncReverseArgOnLE , FirstArgIsResult }
enum class  EnableOpenMP { None , Simd , Full }
 Select which mode to enable OpenMP support in.
enum  MathRuntimeVersion { fastVersion , relaxedVersion , preciseVersion }

Functions

bool operator== (const AliasAnalysis::Source::SourceOrigin &lhs, const AliasAnalysis::Source::SourceOrigin &rhs)
bool operator!= (const AliasAnalysis::Source::SourceOrigin &lhs, const AliasAnalysis::Source::SourceOrigin &rhs)
llvm::raw_ostream & operator<< (llvm::raw_ostream &os, const AliasAnalysis::Source &op)
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const CharBoxValue &)
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const ArrayBoxValue &)
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const CharArrayBoxValue &)
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const ProcBoxValue &)
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const MutableBoxValue &)
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const BoxValue &)
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const PolymorphicValue &)
mlir::Value getBase (const ExtendedValue &exv)
mlir::Value getLen (const ExtendedValue &exv)
llvm::raw_ostream & operator<< (llvm::raw_ostream &, const ExtendedValue &)
 Pretty-print an extended value.
ExtendedValue substBase (const ExtendedValue &exv, mlir::Value base)
bool isArray (const ExtendedValue &exv)
llvm::SmallVector< mlir::Value > getTypeParams (const ExtendedValue &exv)
 Get the type parameters for exv.
bool isUnboxedValue (const ExtendedValue &exv)
 Is the extended value exv unboxed and non-null?
mlir::Type getBaseTypeOf (const ExtendedValue &exv)
mlir::Type getElementTypeOf (const ExtendedValue &exv)
bool isDerivedWithLenParameters (const ExtendedValue &exv)
 Is the extended value exv a derived type with LEN parameters?
mlir::Type getIntPtrType (mlir::OpBuilder &builder)
 Get the integer type with a pointer size.
std::pair< fir::ExtendedValue, bool > genIntrinsicCall (fir::FirOpBuilder &, mlir::Location, llvm::StringRef name, std::optional< mlir::Type > resultType, llvm::ArrayRef< fir::ExtendedValue > args, Fortran::lower::AbstractConverter *converter=nullptr)
std::pair< fir::ExtendedValue, bool > genIntrinsicCall (fir::FirOpBuilder &, mlir::Location, const IntrinsicHandlerEntry &, std::optional< mlir::Type > resultType, llvm::ArrayRef< fir::ExtendedValue > args, Fortran::lower::AbstractConverter *converter=nullptr)
mlir::Value genLibCall (fir::FirOpBuilder &builder, mlir::Location loc, const MathOperation &mathOp, mlir::FunctionType libFuncType, llvm::ArrayRef< mlir::Value > args)
template<typename T>
mlir::Value genMathOp (fir::FirOpBuilder &builder, mlir::Location loc, const MathOperation &mathOp, mlir::FunctionType mathLibFuncType, llvm::ArrayRef< mlir::Value > args)
template<typename T>
mlir::Value genComplexMathOp (fir::FirOpBuilder &builder, mlir::Location loc, const MathOperation &mathOp, mlir::FunctionType mathLibFuncType, llvm::ArrayRef< mlir::Value > args)
mlir::Value genLibSplitComplexArgsCall (fir::FirOpBuilder &builder, mlir::Location loc, const MathOperation &mathOp, mlir::FunctionType libFuncType, llvm::ArrayRef< mlir::Value > args)
std::optional< IntrinsicHandlerEntrylookupIntrinsicHandler (fir::FirOpBuilder &, llvm::StringRef intrinsicName, std::optional< mlir::Type > resultType)
void crashOnMissingIntrinsic (mlir::Location loc, llvm::StringRef name)
 Generate a TODO error message for an as yet unimplemented intrinsic.
const IntrinsicArgumentLoweringRulesgetIntrinsicArgumentLowering (llvm::StringRef intrinsicName)
ArgLoweringRule lowerIntrinsicArgumentAs (const IntrinsicArgumentLoweringRules &, unsigned position)
fir::ExtendedValue getAbsentIntrinsicArgument ()
 Return place-holder for absent intrinsic arguments.
mlir::SymbolRefAttr getUnrestrictedIntrinsicSymbolRefAttr (fir::FirOpBuilder &, mlir::Location, llvm::StringRef name, mlir::FunctionType signature)
 Get SymbolRefAttr of runtime (or wrapper function containing inlined.
mlir::Value genMax (fir::FirOpBuilder &, mlir::Location, llvm::ArrayRef< mlir::Value > args)
mlir::Value genMin (fir::FirOpBuilder &, mlir::Location, llvm::ArrayRef< mlir::Value > args)
 Generate minimum. Same constraints as genMax.
mlir::Value genDivC (fir::FirOpBuilder &builder, mlir::Location loc, mlir::Type resultType, mlir::Value x, mlir::Value y)
mlir::Value genPow (fir::FirOpBuilder &, mlir::Location, mlir::Type resultType, mlir::Value x, mlir::Value y)
const IntrinsicHandlerfindPPCIntrinsicHandler (llvm::StringRef name)
std::pair< const MathOperation *, const MathOperation * > checkPPCMathOperationsRange (llvm::StringRef name)
std::unique_ptr< mlir::Pass > createFIRToLLVMPass ()
 Convert FIR to the LLVM IR dialect with default options.
std::unique_ptr< mlir::Pass > createFIRToLLVMPass (FIRToLLVMPassOptions options)
 Convert FIR to the LLVM IR dialect.
std::unique_ptr< mlir::Pass > createLLVMDialectToLLVMPass (llvm::raw_ostream &output, LLVMIRLoweringPrinter printer=[](llvm::Module &m, llvm::raw_ostream &out) { m.print(out, nullptr);})
 Convert the LLVM IR dialect to LLVM-IR proper.
void populateFIRToLLVMConversionPatterns (const fir::LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns, fir::FIRToLLVMPassOptions &options)
 Populate the given list with patterns that convert from FIR to LLVM.
void populatePreCGRewritePatterns (mlir::RewritePatternSet &patterns, bool preserveDeclare)
 Populate the pattern set with the PreCGRewrite patterns.
void populateOpenMPFIRToLLVMConversionPatterns (const LLVMTypeConverter &converter, mlir::RewritePatternSet &patterns)
template<>
constexpr TypeBuilderFunc getModel< void * > ()
template<>
constexpr TypeBuilderFunc getModel< unsigned > ()
template<>
constexpr TypeBuilderFunc getModel< int > ()
template<>
constexpr TypeBuilderFunc getModel< unsigned long > ()
template<>
constexpr TypeBuilderFunc getModel< unsigned long long > ()
template<>
constexpr TypeBuilderFunc getModel< long long > ()
template<>
constexpr TypeBuilderFunc getModel< Fortran::ISO::CFI_rank_t > ()
template<>
constexpr TypeBuilderFunc getModel< Fortran::ISO::CFI_type_t > ()
template<>
constexpr TypeBuilderFunc getModel< long > ()
template<>
constexpr TypeBuilderFunc getModel< Fortran::ISO::CFI_dim_t > ()
template<>
constexpr TypeBuilderFunc getModel< Fortran::ISO::cfi_internal::FlexibleArray< Fortran::ISO::CFI_dim_t > > ()
llvm::FailureOr< mlir::Attribute > tryFoldingLLVMInsertChain (mlir::Value insertChainResult, mlir::OpBuilder &builder)
mlir::Attribute parseFirAttribute (FIROpsDialect *dialect, mlir::DialectAsmParser &parser, mlir::Type type)
void printFirAttribute (FIROpsDialect *dialect, mlir::Attribute attr, mlir::DialectAsmPrinter &p)
bool canLegallyInline (mlir::Operation *op, mlir::Region *reg, bool, mlir::IRMapping &map)
 Support for inlining on FIR.
bool canLegallyInline (mlir::Operation *, mlir::Operation *, bool)
void addFIRInlinerExtension (mlir::DialectRegistry &registry)
void addFIRToLLVMIRExtension (mlir::DialectRegistry &registry)
void registerFortranTempArrayCopyIsSafeExternalModels (mlir::DialectRegistry &registry)
void buildCmpCOp (mlir::OpBuilder &builder, mlir::OperationState &result, mlir::arith::CmpFPredicate predicate, mlir::Value lhs, mlir::Value rhs)
unsigned getCaseArgumentOffset (llvm::ArrayRef< mlir::Attribute > cases, unsigned dest)
DoLoopOp getForInductionVarOwner (mlir::Value val)
mlir::ParseResult isValidCaseAttr (mlir::Attribute attr)
mlir::ParseResult parseCmpcOp (mlir::OpAsmParser &parser, mlir::OperationState &result)
mlir::ParseResult parseSelector (mlir::OpAsmParser &parser, mlir::OperationState &result, mlir::OpAsmParser::UnresolvedOperand &selector, mlir::Type &type)
bool useStrictVolatileVerification ()
void addVolatileMemoryEffects (mlir::TypeRange type, llvm::SmallVectorImpl< mlir::SideEffects::EffectInstance< mlir::MemoryEffects::Effect > > &effects)
bool isaCall (mlir::Operation *op)
 Return true iff the Operation is a call.
bool impureCall (mlir::Operation *op)
bool pureCall (mlir::Operation *op)
mlir::func::FuncOp createFuncOp (mlir::Location loc, mlir::ModuleOp module, llvm::StringRef name, mlir::FunctionType type, llvm::ArrayRef< mlir::NamedAttribute > attrs={}, const mlir::SymbolTable *symbolTable=nullptr)
fir::GlobalOp createGlobalOp (mlir::Location loc, mlir::ModuleOp module, llvm::StringRef name, mlir::Type type, llvm::ArrayRef< mlir::NamedAttribute > attrs={}, const mlir::SymbolTable *symbolTable=nullptr)
constexpr llvm::StringRef getContiguousAttrName ()
 Attribute to mark Fortran entities with the CONTIGUOUS attribute.
constexpr llvm::StringRef getOptionalAttrName ()
 Attribute to mark Fortran entities with the OPTIONAL attribute.
bool hasHostAssociationArgument (mlir::func::FuncOp func)
bool isInternalProcedure (mlir::func::FuncOp func)
bool valueHasFirAttribute (mlir::Value value, llvm::StringRef attributeName)
bool valueMayHaveFirAttributes (mlir::Value value, llvm::ArrayRef< llvm::StringRef > attributeNames)
bool anyFuncArgsHaveAttr (mlir::func::FuncOp func, llvm::StringRef attr)
std::optional< std::int64_t > getIntIfConstant (mlir::Value value)
 Unwrap integer constant from an mlir::Value.
template<typename Builder>
mlir::NamedAttribute getAdaptToByRefAttr (Builder &builder)
bool isDummyArgument (mlir::Value v)
template<fir::FortranProcedureFlagsEnum Flag>
bool hasProcedureAttr (fir::FortranProcedureFlagsEnumAttr flags)
template<fir::FortranProcedureFlagsEnum Flag>
bool hasProcedureAttr (mlir::Operation *op)
bool hasBindcAttr (mlir::Operation *op)
std::optional< int64_t > getAllocaByteSize (fir::AllocaOp alloca, const mlir::DataLayout &dl, const fir::KindMapping &kindMap)
bool reboxPreservesContinuity (fir::ReboxOp rebox, bool mayHaveNonDefaultLowerBounds=true, bool checkWhole=true)
bool isContiguousEmbox (fir::EmboxOp embox, bool checkWhole=true)
bool isa_fir_type (mlir::Type t)
 Is t any of the FIR dialect types?
bool isa_std_type (mlir::Type t)
 Is t any of the Standard dialect types?
bool isa_fir_or_std_type (mlir::Type t)
 Is t any of the FIR dialect or Standard dialect types?
bool isa_ref_type (mlir::Type t)
 Is t a FIR dialect type that implies a memory (de)reference?
bool isa_box_type (mlir::Type t)
 Is t a boxed type?
bool isa_passbyref_type (mlir::Type t)
bool conformsWithPassByRef (mlir::Type t)
bool isa_derived (mlir::Type t)
 Is t a derived (record) type?
bool isa_builtin_cptr_type (mlir::Type t)
 Is t type(c_ptr) or type(c_funptr)?
bool isa_builtin_c_devptr_type (mlir::Type t)
bool isa_builtin_cdevptr_type (mlir::Type t)
 Is t type(c_devptr)?
bool isa_aggregate (mlir::Type t)
 Is t a FIR dialect aggregate type?
mlir::Type dyn_cast_ptrEleTy (mlir::Type t)
mlir::Type dyn_cast_ptrOrBoxEleTy (mlir::Type t)
bool isa_real (mlir::Type t)
 Is t a real type?
bool isa_integer (mlir::Type t)
 Is t an integral type?
bool isa_vector (mlir::Type t)
 Is t a vector type?
mlir::Type parseFirType (FIROpsDialect *, mlir::DialectAsmParser &parser)
void printFirType (FIROpsDialect *, mlir::Type ty, mlir::DialectAsmPrinter &p)
void verifyIntegralType (mlir::Type type)
bool isa_complex (mlir::Type t)
 Is t a floating point complex type?
bool isa_char (mlir::Type t)
 Is t a CHARACTER type? Does not check the length.
bool isa_trivial (mlir::Type t)
bool isa_char_string (mlir::Type t)
 Is t a CHARACTER type with a LEN other than 1?
bool isa_unknown_size_box (mlir::Type t)
bool isa_volatile_type (mlir::Type t)
bool characterWithDynamicLen (mlir::Type t)
 Returns true iff t is a fir.char type and has an unknown length.
bool sequenceWithNonConstantShape (fir::SequenceType seqTy)
bool hasDynamicSize (mlir::Type t)
 Returns true iff the type t does not have a constant size.
unsigned getRankOfShapeType (mlir::Type t)
mlir::Type boxMemRefType (fir::BaseBoxType t)
 Get the memory reference type of the data pointer from the box type,.
mlir::Type unwrapSequenceType (mlir::Type t)
 If t is a SequenceType return its element type, otherwise return t.
mlir::Type extractSequenceType (mlir::Type ty)
 Return the nested sequence type if any.
mlir::Type unwrapRefType (mlir::Type t)
mlir::Type unwrapPassByRefType (mlir::Type t)
mlir::Type getFortranElementType (mlir::Type ty)
mlir::Type unwrapSeqOrBoxedSeqType (mlir::Type ty)
mlir::Type unwrapAllRefAndSeqType (mlir::Type ty)
fir::SequenceType unwrapUntilSeqType (mlir::Type t)
fir::RecordType unwrapIfDerived (fir::BaseBoxType boxTy)
bool isDerivedTypeWithLenParams (fir::BaseBoxType boxTy)
 Return true iff boxTy wraps a fir::RecordType with length parameters.
bool isDerivedType (fir::BaseBoxType boxTy)
 Return true iff boxTy wraps a fir::RecordType.
bool singleIndirectionLevel (mlir::Type ty)
bool isPointerType (mlir::Type ty)
bool isAllocatableType (mlir::Type ty)
 Return true iff ty is the type of an ALLOCATABLE entity or value.
bool isBoxNone (mlir::Type ty)
 Return true iff ty is !fir.box<none>.
bool isBoxedRecordType (mlir::Type ty)
bool isTypeWithDescriptor (mlir::Type ty)
 Return true iff ty is a type that contains descriptor information.
bool isScalarBoxedRecordType (mlir::Type ty)
mlir::Type getDerivedType (mlir::Type ty)
 Return the nested RecordType if one if found. Return ty otherwise.
bool isPolymorphicType (mlir::Type ty)
bool isUnlimitedPolymorphicType (mlir::Type ty)
bool isAssumedType (mlir::Type ty)
bool isAssumedShape (mlir::Type ty)
 Return true iff ty is the type of an assumed shape array.
bool isAllocatableOrPointerArray (mlir::Type ty)
 Return true iff ty is the type of an allocatable array.
bool boxHasAddendum (fir::BaseBoxType boxTy)
unsigned getBoxRank (mlir::Type boxTy)
 Get the rank from a !fir.box type.
mlir::Type unwrapInnerType (mlir::Type ty)
 Return the inner type of the given type.
bool isRecordWithAllocatableMember (mlir::Type ty)
 Return true iff ty is a RecordType with members that are allocatable.
bool isRecordWithDescriptorMember (mlir::Type ty)
bool isRecordWithTypeParameters (mlir::Type ty)
 Return true iff ty is a RecordType with type parameters.
bool isCharacterProcedureTuple (mlir::Type type, bool acceptRawFunc=true)
 Is this tuple type holding a character function and its result length?
mlir::Type applyPathToType (mlir::Type rootTy, mlir::ValueRange path)
bool hasAbstractResult (mlir::FunctionType ty)
mlir::Type fromRealTypeID (mlir::MLIRContext *context, llvm::Type::TypeID typeID, fir::KindTy kind)
 Convert llvm::Type::TypeID to mlir::Type.
int getTypeCode (mlir::Type ty, const fir::KindMapping &kindMap)
 Return the ISO_C_BINDING intrinsic module value of type ty.
bool isNoneOrSeqNone (mlir::Type type)
 Return true iff ty is none or fir.array<none>.
mlir::Type wrapInClassOrBoxType (mlir::Type eleTy, bool isPolymorphic=false, bool isAssumedType=false)
mlir::Type updateTypeWithVolatility (mlir::Type type, bool isVolatile)
mlir::Type updateTypeForUnlimitedPolymorphic (mlir::Type ty)
mlir::Type changeElementType (mlir::Type type, mlir::Type newElementType, bool turnBoxIntoClass)
bool isBoxAddress (mlir::Type t)
 Is t an address to fir.box or class type?
bool isBoxAddressOrValue (mlir::Type t)
 Is t a fir.box or class address or value type?
bool isBoxProcAddressType (mlir::Type t)
 Is this a fir.boxproc address type?
bool isRefOfConstantSizeAggregateType (mlir::Type t)
std::string getTypeAsString (mlir::Type ty, const KindMapping &kindMap, llvm::StringRef prefix="")
std::pair< std::uint64_t, unsigned short > getTypeSizeAndAlignmentOrCrash (mlir::Location loc, mlir::Type ty, const mlir::DataLayout &dl, const fir::KindMapping &kindMap)
 This variant terminates the compilation if an unsupported type is passed.
std::optional< std::pair< uint64_t, unsigned short > > getTypeSizeAndAlignment (mlir::Location loc, mlir::Type ty, const mlir::DataLayout &dl, const fir::KindMapping &kindMap)
 This variant returns std::nullopt if an unsupported type is passed.
void setTargetTriple (mlir::ModuleOp mod, llvm::StringRef triple)
llvm::Triple getTargetTriple (mlir::ModuleOp mod)
 Get the Triple instance from the Module or return the default Triple.
void setKindMapping (mlir::ModuleOp mod, KindMapping &kindMap)
KindMapping getKindMapping (mlir::ModuleOp mod)
KindMapping getKindMapping (mlir::Operation *op)
void setTargetCPU (mlir::ModuleOp mod, llvm::StringRef cpu)
llvm::StringRef getTargetCPU (mlir::ModuleOp mod)
 Get the target CPU string from the Module or return a null reference.
void setAtomicIgnoreDenormalMode (mlir::ModuleOp mod, bool value)
bool getAtomicIgnoreDenormalMode (mlir::ModuleOp mod)
void setAtomicFineGrainedMemory (mlir::ModuleOp mod, bool value)
bool getAtomicFineGrainedMemory (mlir::ModuleOp mod)
void setAtomicRemoteMemory (mlir::ModuleOp mod, bool value)
bool getAtomicRemoteMemory (mlir::ModuleOp mod)
void setTuneCPU (mlir::ModuleOp mod, llvm::StringRef cpu)
llvm::StringRef getTuneCPU (mlir::ModuleOp mod)
 Get the tune CPU string from the Module or return a null reference.
void setTargetFeatures (mlir::ModuleOp mod, llvm::StringRef features)
 Set the target features for the module.
mlir::LLVM::TargetFeaturesAttr getTargetFeatures (mlir::ModuleOp mod)
 Get the target features from the Module.
void setIdent (mlir::ModuleOp mod, llvm::StringRef ident)
 Set the compiler identifier for the module.
llvm::StringRef getIdent (mlir::ModuleOp mod)
 Get the compiler identifier from the Module.
void setCommandline (mlir::ModuleOp mod, llvm::StringRef cmdLine)
 Set the command line used in this invocation.
llvm::StringRef getCommandline (mlir::ModuleOp mod)
 Get the command line used in this invocation.
std::string determineTargetTriple (llvm::StringRef triple)
template<typename F, typename OP>
void addNestedPassToOps (mlir::PassManager &pm, F ctor)
template<typename F, typename OP, typename... OPS, typename = std::enable_if_t<sizeof...(OPS) != 0>>
void addNestedPassToOps (mlir::PassManager &pm, F ctor)
template<typename F>
void addPassConditionally (mlir::PassManager &pm, llvm::cl::opt< bool > &disabled, F ctor)
 Generic for adding a pass to the pass manager if it is not disabled.
template<typename OP, typename F>
void addNestedPassConditionally (mlir::PassManager &pm, llvm::cl::opt< bool > &disabled, F ctor)
template<typename F>
void addNestedPassToAllTopLevelOperations (mlir::PassManager &pm, F ctor)
template<typename F>
void addNestedPassToAllTopLevelOperationsConditionally (mlir::PassManager &pm, llvm::cl::opt< bool > &disabled, F ctor)
void addCanonicalizerPassWithoutRegionSimplification (mlir::OpPassManager &pm)
void addCfgConversionPass (mlir::PassManager &pm, const MLIRToLLVMPassPipelineConfig &config)
void addAVC (mlir::PassManager &pm, const llvm::OptimizationLevel &optLevel)
void addMemoryAllocationOpt (mlir::PassManager &pm)
void addCodeGenRewritePass (mlir::PassManager &pm, bool preserveDeclare)
void addTargetRewritePass (mlir::PassManager &pm)
mlir::LLVM::DIEmissionKind getEmissionKind (llvm::codegenoptions::DebugInfoKind kind)
void addBoxedProcedurePass (mlir::PassManager &pm)
void addExternalNameConversionPass (mlir::PassManager &pm, bool appendUnderscore=true)
void addCompilerGeneratedNamesConversionPass (mlir::PassManager &pm)
void addDebugInfoPass (mlir::PassManager &pm, llvm::codegenoptions::DebugInfoKind debugLevel, llvm::OptimizationLevel optLevel, llvm::StringRef inputFilename, int32_t dwarfVersion)
void addFIRToLLVMPass (mlir::PassManager &pm, const MLIRToLLVMPassPipelineConfig &config)
void addLLVMDialectToLLVMPass (mlir::PassManager &pm, llvm::raw_ostream &output)
void registerDefaultInlinerPass (MLIRToLLVMPassPipelineConfig &config)
 Use inliner extension point callback to register the default inliner pass.
void createDefaultFIROptimizerPassPipeline (mlir::PassManager &pm, MLIRToLLVMPassPipelineConfig &pc)
void createHLFIRToFIRPassPipeline (mlir::PassManager &pm, EnableOpenMP enableOpenMP, llvm::OptimizationLevel optLevel=defaultOptLevel)
void createOpenMPFIRPassPipeline (mlir::PassManager &pm, OpenMPFIRPassPipelineOpts opts)
void createDebugPasses (mlir::PassManager &pm, llvm::codegenoptions::DebugInfoKind debugLevel, llvm::OptimizationLevel OptLevel, llvm::StringRef inputFilename, int32_t dwarfVersion)
void createDefaultFIRCodeGenPassPipeline (mlir::PassManager &pm, MLIRToLLVMPassPipelineConfig config, llvm::StringRef inputFilename={})
void createMLIRToLLVMPassPipeline (mlir::PassManager &pm, MLIRToLLVMPassPipelineConfig &config, llvm::StringRef inputFilename={})
void emitFatalError (mlir::Location loc, const llvm::Twine &message, bool genCrashDiag=true)
int characterBitsToTypeCode (unsigned bitwidth)
int complexBitsToTypeCode (unsigned bitwidth)
int integerBitsToTypeCode (unsigned bitwidth)
int logicalBitsToTypeCode (unsigned bitwidth)
int realBitsToTypeCode (unsigned bitwidth)
std::int64_t toInt (mlir::arith::ConstantOp cop)
 Return the integer value of a arith::ConstantOp.
std::vector< fir::KindTy > fromDefaultKinds (const Fortran::common::IntrinsicTypeDefaultKinds &defKinds)
std::string mlirTypeToString (mlir::Type type)
std::optional< int > mlirFloatTypeToKind (mlir::Type type)
std::string mlirTypeToIntrinsicFortran (fir::FirOpBuilder &builder, mlir::Type type, mlir::Location loc, const llvm::Twine &name)
void intrinsicTypeTODO (fir::FirOpBuilder &builder, mlir::Type type, mlir::Location loc, const llvm::Twine &intrinsicName)
void intrinsicTypeTODO2 (fir::FirOpBuilder &builder, mlir::Type type1, mlir::Type type2, mlir::Location loc, const llvm::Twine &intrinsicName)
std::pair< Fortran::common::TypeCategory, KindMapping::KindTy > mlirTypeToCategoryKind (mlir::Location loc, mlir::Type type)
fir::TypeInfoOp lookupTypeInfoOp (fir::RecordType recordType, mlir::ModuleOp module, const mlir::SymbolTable *symbolTable=nullptr)
fir::TypeInfoOp lookupTypeInfoOp (llvm::StringRef name, mlir::ModuleOp module, const mlir::SymbolTable *symbolTable=nullptr)
std::optional< llvm::ArrayRef< int64_t > > getComponentLowerBoundsIfNonDefault (fir::RecordType recordType, llvm::StringRef component, mlir::ModuleOp module, const mlir::SymbolTable *symbolTable=nullptr)
mlir::LLVM::ConstantOp genConstantIndex (mlir::Location loc, mlir::Type ity, mlir::ConversionPatternRewriter &rewriter, std::int64_t offset)
 Generate a LLVM constant value of type ity, using the provided offset.
mlir::Value computeElementDistance (mlir::Location loc, mlir::Type llvmObjectType, mlir::Type idxTy, mlir::ConversionPatternRewriter &rewriter, const mlir::DataLayout &dataLayout)
mlir::Value genAllocationScaleSize (mlir::Location loc, mlir::Type dataTy, mlir::Type ity, mlir::ConversionPatternRewriter &rewriter)
mlir::Value integerCast (const fir::LLVMTypeConverter &converter, mlir::Location loc, mlir::ConversionPatternRewriter &rewriter, mlir::Type ty, mlir::Value val, bool fold=false)
bool replaceAllocas (mlir::RewriterBase &rewriter, mlir::Operation *parentOp, MustRewriteCallBack, AllocaRewriterCallBack, DeallocCallBack)
std::unique_ptr< mlir::Pass > createAffineDemotionPass ()
std::unique_ptr< mlir::Pass > createArrayValueCopyPass (fir::ArrayValueCopyOptions options={})
std::unique_ptr< mlir::Pass > createMemDataFlowOptPass ()
std::unique_ptr< mlir::Pass > createPromoteToAffinePass ()
 Convert FIR loop constructs to the Affine dialect.
std::unique_ptr< mlir::Pass > createFIRToSCFPass ()
std::unique_ptr< mlir::Pass > createAddDebugInfoPass (fir::AddDebugInfoOptions options={})
std::unique_ptr< mlir::Pass > createAnnotateConstantOperandsPass ()
std::unique_ptr< mlir::Pass > createAlgebraicSimplificationPass ()
std::unique_ptr< mlir::Pass > createAlgebraicSimplificationPass (const mlir::GreedyRewriteConfig &config)
std::unique_ptr< mlir::Pass > createVScaleAttrPass ()
std::unique_ptr< mlir::Pass > createVScaleAttrPass (std::pair< unsigned, unsigned > vscaleAttr)
void populateCfgConversionRewrites (mlir::RewritePatternSet &patterns, bool forceLoopToExecuteOnce=false, bool setNSW=true)
 Expose conversion rewriters to other passes.
void populateSimplifyFIROperationsPatterns (mlir::RewritePatternSet &patterns, bool preferInlineImplementation)
void genMinMaxlocReductionLoop (fir::FirOpBuilder &builder, mlir::Value array, fir::InitValGeneratorTy initVal, fir::MinlocBodyOpGeneratorTy genBody, fir::AddrGeneratorTy getAddrFn, unsigned rank, mlir::Type elementType, mlir::Location loc, mlir::Type maskElemType, mlir::Value resultArr, bool maskMayBeLogicalScalar)
llvm::cl::opt< MathRuntimeVersionmathRuntimeVersion ("math-runtime", llvm::cl::desc("Select math operations' runtime behavior:"), llvm::cl::values(clEnumValN(fastVersion, "fast", "use fast runtime behavior"), clEnumValN(relaxedVersion, "relaxed", "use relaxed runtime behavior"), clEnumValN(preciseVersion, "precise", "use precise runtime behavior")), llvm::cl::init(fastVersion))
mlir::Value genComplexPow (fir::FirOpBuilder &builder, mlir::Location loc, const MathOperation &mathOp, mlir::FunctionType mathLibFuncType, llvm::ArrayRef< mlir::Value > args)
fir::ExtendedValue toExtendedValue (mlir::Value val, fir::FirOpBuilder &builder, mlir::Location loc)
 fir::ExtendedValue to mlir::Value translation layer
mlir::Value toValue (const fir::ExtendedValue &val, fir::FirOpBuilder &builder, mlir::Location loc)
llvm::StringRef genericName (llvm::StringRef specificName)
std::optional< IntrinsicHandlerEntry::RuntimeGeneratorRange > lookupRuntimeGenerator (llvm::StringRef name, bool isPPCTarget)
template<>
fir::ExtendedValue IntrinsicLibrary::genElementalCall< IntrinsicLibrary::ExtendedGenerator > (ExtendedGenerator generator, llvm::StringRef name, mlir::Type resultType, llvm::ArrayRef< fir::ExtendedValue > args, bool outline)
template<>
fir::ExtendedValue IntrinsicLibrary::genElementalCall< IntrinsicLibrary::SubroutineGenerator > (SubroutineGenerator generator, llvm::StringRef name, mlir::Type resultType, llvm::ArrayRef< fir::ExtendedValue > args, bool outline)
template<>
fir::ExtendedValue IntrinsicLibrary::genElementalCall< IntrinsicLibrary::DualGenerator > (DualGenerator generator, llvm::StringRef name, mlir::Type resultType, llvm::ArrayRef< fir::ExtendedValue > args, bool outline)
mlir::FunctionType genMmaDisassembleFuncType (mlir::MLIRContext *context, MMAOp mmaOp)
const char * getMmaIrIntrName (MMAOp mmaOp)
mlir::FunctionType getMmaIrFuncType (mlir::MLIRContext *context, MMAOp mmaOp)
template<typename A, typename B>
bool inbounds (A v, B lb, B ub)
template<typename F>
void addPassToGPUModuleOperations (mlir::PassManager &pm, F ctor)
template<int DescriptorField>
std::uint64_t getComponentOffset (const mlir::DataLayout &dl, mlir::MLIRContext *context, mlir::Type llvmFieldType)
 Calculate offset of any field in the descriptor.
template<>
std::uint64_t getComponentOffset< 0 > (const mlir::DataLayout &dl, mlir::MLIRContext *context, mlir::Type llvmFieldType)

Variables

constexpr auto asValue = fir::LowerIntrinsicArgAs::Value
constexpr auto asAddr = fir::LowerIntrinsicArgAs::Addr
constexpr auto asBox = fir::LowerIntrinsicArgAs::Box
constexpr auto asInquired = fir::LowerIntrinsicArgAs::Inquired
constexpr auto FuncTypeReal16Real16 = genFuncType<Ty::Real<16>, Ty::Real<16>>
constexpr auto FuncTypeReal16Real16Real16
constexpr auto FuncTypeReal16Real16Real16Real16
constexpr auto FuncTypeReal16Integer4Real16
constexpr auto FuncTypeInteger4Real16
constexpr auto FuncTypeInteger8Real16
constexpr auto FuncTypeReal16Complex16
constexpr auto FuncTypeComplex16Complex16
constexpr auto FuncTypeComplex16Complex16Complex16
constexpr auto FuncTypeComplex16Complex16Integer4
constexpr auto FuncTypeComplex16Complex16Integer8

Detailed Description

This file declares some utilties to setup FIR pass pipelines. These are common to flang and the test tools.

This file implements lowering of Fortran intrinsic procedures and Fortran intrinsic module procedures. A call may be inlined with a mix of FIR and MLIR operations, or as a call to a runtime function or LLVM intrinsic. Lowering of intrinsic procedure calls is based on a map that associates Fortran intrinsic generic names to FIR generator functions. All generator functions are member functions of the IntrinsicLibrary class and have the same interface. If no generator is given for an intrinsic name, a math runtime library is searched for an implementation and, if a runtime function is found, a call is generated for it. LLVM intrinsics are handled as a math runtime library here.

TODO: Should some loop content - for example calls to functions and subroutines inhibit the versioning of the loops. Plausibly, this could be part of the cost analysis above.

The general idea is that besides making the call simpler, it can also be inlined by other passes that run after this pass, which further improves performance, particularly when the work done in the function is trivial and small in size.

Typedef Documentation

◆ AddrGeneratorTy

using fir::AddrGeneratorTy
Initial value:
llvm::function_ref<mlir::Value(
fir::FirOpBuilder &, mlir::Location, const mlir::Type &, mlir::Value,
mlir::Value)>
Definition FIRBuilder.h:55

◆ AllocaRewriterCallBack

Initial value:
llvm::function_ref<mlir::Value(
mlir::OpBuilder &, fir::AllocaOp, bool allocaDominatesDeallocLocations)>

Type of callbacks that produce the replacement for a given fir.alloca. It is provided extra information about the dominance of the deallocation points that have been identified, and may refuse to replace the alloca, even if the MustRewriteCallBack previously returned true, in which case it should return a null value. The callback should not delete the alloca, the utility will do it.

◆ DeallocCallBack

Initial value:
llvm::function_ref<void(mlir::Location, mlir::OpBuilder &, mlir::Value)>

Type of callbacks that must generate deallocation of storage obtained via AllocaRewriterCallBack calls.

◆ InitValGeneratorTy

using fir::InitValGeneratorTy
Initial value:
llvm::function_ref<mlir::Value(
fir::FirOpBuilder &, mlir::Location, const mlir::Type &)>

◆ LLVMIRLoweringPrinter

using fir::LLVMIRLoweringPrinter
Initial value:
std::function<void(llvm::Module &, llvm::raw_ostream &)>

◆ MinlocBodyOpGeneratorTy

using fir::MinlocBodyOpGeneratorTy
Initial value:
llvm::function_ref<mlir::Value(
fir::FirOpBuilder &, mlir::Location, const mlir::Type &, mlir::Value,
mlir::Value, mlir::Value, const llvm::SmallVectorImpl<mlir::Value> &)>

◆ MustRewriteCallBack

using fir::MustRewriteCallBack = llvm::function_ref<bool(fir::AllocaOp)>

Type of callbacks that indicate if a given fir.alloca must be rewritten.

◆ UnboxedValue

using fir::UnboxedValue = mlir::Value

Most expressions of intrinsic type can be passed unboxed. Their properties are known statically.

Enumeration Type Documentation

◆ LowerIntrinsicArgAs

enum class fir::LowerIntrinsicArgAs
strong

Enum specifying how intrinsic argument evaluate::Expr should be lowered to fir::ExtendedValue to be passed to genIntrinsicCall.

Enumerator
Value 

Lower argument to a value. Mainly intended for scalar arguments.

Addr 

Lower argument to an address. Only valid when the argument properties are fully defined (e.g. allocatable is allocated...).

Box 

Lower argument to a box.

Inquired 

Lower argument without assuming that the argument is fully defined. It can be used on unallocated allocatable, disassociated pointer, or absent optional. This is meant for inquiry intrinsic arguments.

◆ MathRuntimeVersion

Command line option to modify math runtime behavior used to implement intrinsics. This option applies both to early and late math-lowering modes.

◆ VecOp

enum class fir::VecOp
strong

Enums used to templatize vector intrinsic function generators. Enum does not contain every vector intrinsic, only intrinsics that share generators.

Function Documentation

◆ addCanonicalizerPassWithoutRegionSimplification()

void fir::addCanonicalizerPassWithoutRegionSimplification ( mlir::OpPassManager & pm)

Add MLIR Canonicalizer pass with region simplification disabled. FIR does not support the promotion of some SSA value to block arguments (or into arith.select operands) that may be done by mlir block merging in the region simplification (e.g., !fir.shape<> SSA values are not supported as block arguments). Aside from the fir.shape issue, moving some abstract SSA value into block arguments may have a heavy cost since it forces their code generation that may be expensive (array temporary). The MLIR pass does not take these extra costs into account when doing block merging.

◆ addVolatileMemoryEffects()

void fir::addVolatileMemoryEffects ( mlir::TypeRange type,
llvm::SmallVectorImpl< mlir::SideEffects::EffectInstance< mlir::MemoryEffects::Effect > > & effects )
inline

The LLVM dialect represents volatile memory accesses as read and write effects to an unknown memory location, but this may be overly conservative. LLVM Language Reference only specifies that volatile memory accesses must not be reordered relative to other volatile memory accesses, so it is more precise to use a separate memory resource for volatile memory accesses.

◆ anyFuncArgsHaveAttr()

bool fir::anyFuncArgsHaveAttr ( mlir::func::FuncOp func,
llvm::StringRef attr )

Scan the arguments of a FuncOp to determine if any arguments have the attribute attr placed on them. This can be used to determine if the function has any host associations, for example.

◆ applyPathToType()

mlir::Type fir::applyPathToType ( mlir::Type rootTy,
mlir::ValueRange path )

Apply the components specified by path to rootTy to determine the type of the resulting component element. rootTy should be an aggregate type. Returns null on error.

◆ boxHasAddendum()

bool fir::boxHasAddendum ( fir::BaseBoxType boxTy)
inline

Return true iff boxTy wraps a record type or an unlimited polymorphic entity. Polymorphic entities with intrinsic type spec do not have addendum

◆ canLegallyInline()

bool fir::canLegallyInline ( mlir::Operation * op,
mlir::Region * reg,
bool ,
mlir::IRMapping & map )

Support for inlining on FIR.

Should we inline the callable op into region reg?

◆ changeElementType()

mlir::Type fir::changeElementType ( mlir::Type type,
mlir::Type newElementType,
bool turnBoxIntoClass )

Replace the element type of type by newElementType, preserving all other layers of the type (fir.ref/ptr/heap/array/box/class). If turnBoxIntoClass and the input is a fir.box, it will be turned into a fir.class in the result.

◆ computeElementDistance()

mlir::Value fir::computeElementDistance ( mlir::Location loc,
mlir::Type llvmObjectType,
mlir::Type idxTy,
mlir::ConversionPatternRewriter & rewriter,
const mlir::DataLayout & dataLayout )

Helper function for generating the LLVM IR that computes the distance in bytes between adjacent elements pointed to by a pointer of type ptrTy. The result is returned as a value of idxTy integer type.

◆ conformsWithPassByRef()

bool fir::conformsWithPassByRef ( mlir::Type t)
inline

Is t a type that can conform to be pass-by-reference? Depending on the context, these types may simply demote to pass-by-reference or a reference to them may have to be passed instead. Functions are always referent.

◆ createDefaultFIROptimizerPassPipeline()

void fir::createDefaultFIROptimizerPassPipeline ( mlir::PassManager & pm,
MLIRToLLVMPassPipelineConfig & pc )

Create a pass pipeline for running default optimization passes for incremental conversion of FIR.

Parameters
pm- MLIR pass manager that will hold the pipeline definition

◆ createFuncOp()

mlir::func::FuncOp fir::createFuncOp ( mlir::Location loc,
mlir::ModuleOp module,
llvm::StringRef name,
mlir::FunctionType type,
llvm::ArrayRef< mlir::NamedAttribute > attrs = {},
const mlir::SymbolTable * symbolTable = nullptr )

Get or create a FuncOp in a module.

If module already contains FuncOp name, it is returned. Otherwise, a new FuncOp is created, and that new FuncOp is returned. A symbol table can be provided to speed-up the lookups.

◆ createGlobalOp()

fir::GlobalOp fir::createGlobalOp ( mlir::Location loc,
mlir::ModuleOp module,
llvm::StringRef name,
mlir::Type type,
llvm::ArrayRef< mlir::NamedAttribute > attrs = {},
const mlir::SymbolTable * symbolTable = nullptr )

Get or create a GlobalOp in a module. A symbol table can be provided to speed-up the lookups.

◆ createHLFIRToFIRPassPipeline()

void fir::createHLFIRToFIRPassPipeline ( mlir::PassManager & pm,
EnableOpenMP enableOpenMP,
llvm::OptimizationLevel optLevel = defaultOptLevel )

Create a pass pipeline for lowering from HLFIR to FIR

Parameters
pm- MLIR pass manager that will hold the pipeline definition
optLevel- optimization level used for creating FIR optimization passes pipeline

◆ createMLIRToLLVMPassPipeline()

void fir::createMLIRToLLVMPassPipeline ( mlir::PassManager & pm,
MLIRToLLVMPassPipelineConfig & config,
llvm::StringRef inputFilename = {} )

Create a pass pipeline for lowering from MLIR to LLVM IR

Parameters
pm- MLIR pass manager that will hold the pipeline definition
optLevel- optimization level used for creating FIR optimization passes pipeline

◆ createOpenMPFIRPassPipeline()

void fir::createOpenMPFIRPassPipeline ( mlir::PassManager & pm,
OpenMPFIRPassPipelineOpts opts )

Create a pass pipeline for handling certain OpenMP transformations needed prior to FIR lowering.

WARNING: These passes must be run immediately after the lowering to ensure that the FIR is correct with respect to OpenMP operations/attributes.

Parameters
pm- MLIR pass manager that will hold the pipeline definition.
opts- options to control OpenMP code-gen; see struct docs for more details.

Create a pass pipeline for handling certain OpenMP transformations needed prior to FIR lowering.

WARNING: These passes must be run immediately after the lowering to ensure that the FIR is correct with respect to OpenMP operations/attributes.

Parameters
pm- MLIR pass manager that will hold the pipeline definition.
isTargetDevice- Whether code is being generated for a target device rather than the host device.

◆ determineTargetTriple()

std::string fir::determineTargetTriple ( llvm::StringRef triple)

Helper for determining the target from the host, etc. Tools may use this function to provide a consistent interpretation of the --target=<string> command-line option. An empty string ("") or "default" will specify that the default triple should be used. "native" will specify that the host machine be used to construct the triple.

◆ dyn_cast_ptrEleTy()

mlir::Type fir::dyn_cast_ptrEleTy ( mlir::Type t)

Extract the Type pointed to from a FIR memory reference type. If t is not a memory reference type, then returns a null Type.

◆ dyn_cast_ptrOrBoxEleTy()

mlir::Type fir::dyn_cast_ptrOrBoxEleTy ( mlir::Type t)

Extract the Type pointed to from a FIR memory reference or box type. If t is not a memory reference or box type, then returns a null Type.

◆ emitFatalError()

void fir::emitFatalError ( mlir::Location loc,
const llvm::Twine & message,
bool genCrashDiag = true )
inline

Fatal error reporting helper. Report a fatal error with a source location and immediately interrupt flang. If genCrashDiag is true, then the execution is aborted and the backtrace is printed, otherwise, flang exits with non-zero exit code and without backtrace printout.

◆ fromRealTypeID()

mlir::Type fir::fromRealTypeID ( mlir::MLIRContext * context,
llvm::Type::TypeID typeID,
fir::KindTy kind )

Convert llvm::Type::TypeID to mlir::Type.

Convert llvm::Type::TypeID to mlir::Type. kind is provided for error messages only.

◆ genDivC()

mlir::Value fir::genDivC ( fir::FirOpBuilder & builder,
mlir::Location loc,
mlir::Type resultType,
mlir::Value x,
mlir::Value y )

Generate Complex divide with the given expected result type.

◆ genericName()

llvm::StringRef fir::genericName ( llvm::StringRef specificName)

Return the generic name of an intrinsic module procedure specific name. Remove any "__builtin_" prefix, and any specific suffix of the form {_[ail]?[0-9]+}*, such as _1 or _a4.

◆ genIntrinsicCall() [1/2]

std::pair< fir::ExtendedValue, bool > fir::genIntrinsicCall ( fir::FirOpBuilder & builder,
mlir::Location loc,
const IntrinsicHandlerEntry & intrinsic,
std::optional< mlir::Type > resultType,
llvm::ArrayRef< fir::ExtendedValue > args,
Fortran::lower::AbstractConverter * converter = nullptr )

Same as the entry above except that instead of an intrinsic name it takes an IntrinsicHandlerEntry obtained by a previous lookup for a handler to lower this intrinsic (see lookupIntrinsicHandler).

◆ genIntrinsicCall() [2/2]

std::pair< fir::ExtendedValue, bool > fir::genIntrinsicCall ( fir::FirOpBuilder & builder,
mlir::Location loc,
llvm::StringRef name,
std::optional< mlir::Type > resultType,
llvm::ArrayRef< fir::ExtendedValue > args,
Fortran::lower::AbstractConverter * converter = nullptr )

Lower an intrinsic call given the intrinsic name, its resultType (that must be std::nullopt if and only if this is a subroutine call), and its lowered arguments args. The returned pair contains the result value (null mlir::Value for subroutine calls), and a boolean that indicates if this result must be freed after use.

◆ genMax()

mlir::Value fir::genMax ( fir::FirOpBuilder & builder,
mlir::Location loc,
llvm::ArrayRef< mlir::Value > args )

Generate maximum. There must be at least one argument and all arguments must have the same type.

◆ genPow()

mlir::Value fir::genPow ( fir::FirOpBuilder & builder,
mlir::Location loc,
mlir::Type resultType,
mlir::Value x,
mlir::Value y )

Generate power function x**y with the given expected result type.

◆ getAllocaByteSize()

std::optional< int64_t > fir::getAllocaByteSize ( fir::AllocaOp alloca,
const mlir::DataLayout & dl,
const fir::KindMapping & kindMap )

Get the allocation size of a given alloca if it has compile time constant size.

◆ getAtomicFineGrainedMemory()

bool fir::getAtomicFineGrainedMemory ( mlir::ModuleOp mod)

Gets whether fine grained memory can be used or not for lowering of atomic operations.

◆ getAtomicIgnoreDenormalMode()

bool fir::getAtomicIgnoreDenormalMode ( mlir::ModuleOp mod)

Gets whether Denormal Mode can be ignored or not for lowering of floating point atomic operations.

◆ getAtomicRemoteMemory()

bool fir::getAtomicRemoteMemory ( mlir::ModuleOp mod)

Gets whether remote memory can be used or not for lowering of atomic operations.

◆ getBase()

mlir::Value fir::getBase ( const ExtendedValue & exv)

Get the base value of an extended value. Every type of extended value has a base value or is null.

◆ getBaseTypeOf()

mlir::Type fir::getBaseTypeOf ( const ExtendedValue & exv)
inline

Returns the base type of exv. This is the type of exv without any memory or box type. The sequence type, if any, is kept.

◆ getComponentLowerBoundsIfNonDefault()

std::optional< llvm::ArrayRef< int64_t > > fir::getComponentLowerBoundsIfNonDefault ( fir::RecordType recordType,
llvm::StringRef component,
mlir::ModuleOp module,
const mlir::SymbolTable * symbolTable = nullptr )

Returns all lower bounds of component if it is an array component of recordType with non default lower bounds. Returns nullopt if this is not an array componnet of recordType or if its lower bounds are all ones.

◆ getElementTypeOf()

mlir::Type fir::getElementTypeOf ( const ExtendedValue & exv)
inline

Return the scalar type of exv type. This removes all reference, box, or sequence type from exv base.

◆ getFortranElementType()

mlir::Type fir::getFortranElementType ( mlir::Type ty)

Extracts the innermost type, T, potentially wrapped inside: <fir.[ref|ptr|heap] <fir.[ref|ptr|heap|box] <fir.array<T>>>

Any element absent from the above pattern does not affect the returned value: T.

◆ getIntrinsicArgumentLowering()

const IntrinsicArgumentLoweringRules * fir::getIntrinsicArgumentLowering ( llvm::StringRef intrinsicName)

Return argument lowering rules for an intrinsic. Returns a nullptr if all the intrinsic arguments should be lowered by value.

◆ getKindMapping() [1/2]

fir::KindMapping fir::getKindMapping ( mlir::ModuleOp mod)

Get the KindMapping instance from the Module. If none was set, returns a default.

◆ getKindMapping() [2/2]

fir::KindMapping fir::getKindMapping ( mlir::Operation * op)

Get the KindMapping instance that is in effect for the specified operation. The KindMapping is taken from the operation itself, if the operation is a ModuleOp, or from its parent ModuleOp. If a ModuleOp cannot be reached, the function returns default KindMapping.

◆ getLen()

mlir::Value fir::getLen ( const ExtendedValue & exv)

Get the LEN property value of an extended value. CHARACTER values have a LEN property.

◆ getTypeAsString()

std::string fir::getTypeAsString ( mlir::Type ty,
const KindMapping & kindMap,
llvm::StringRef prefix = "" )

Return a string representation of ty.

fir.array<10x10xf32> -> prefix_10x10xf32 fir.ref<i32> -> prefix_ref_i32

◆ getTypeSizeAndAlignmentOrCrash()

std::pair< std::uint64_t, unsigned short > fir::getTypeSizeAndAlignmentOrCrash ( mlir::Location loc,
mlir::Type ty,
const mlir::DataLayout & dl,
const fir::KindMapping & kindMap )

This variant terminates the compilation if an unsupported type is passed.

Return the size and alignment of FIR types. TODO: consider moving this to a DataLayoutTypeInterface implementation for FIR types. It should first be ensured that it is OK to open the gate of target dependent type size inquiries in lowering. It would also not be straightforward given the need for a kind map that would need to be converted in terms of mlir::DataLayoutEntryKey.

◆ hasAbstractResult()

bool fir::hasAbstractResult ( mlir::FunctionType ty)

Does this function type has a result that requires binding the result value with a storage in a fir.save_result operation in order to use the result?

◆ hasHostAssociationArgument()

bool fir::hasHostAssociationArgument ( mlir::func::FuncOp func)

Does the function, func, have a host-associations tuple argument? Some internal procedures may have access to host procedure variables.

◆ impureCall()

bool fir::impureCall ( mlir::Operation * op)
inline

Return true iff the Operation is a fir::CallOp, fir::DispatchOp, mlir::CallOp, or mlir::CallIndirectOp and not pure NB: This is not the same as !pureCall(op).

◆ integerCast()

mlir::Value fir::integerCast ( const fir::LLVMTypeConverter & converter,
mlir::Location loc,
mlir::ConversionPatternRewriter & rewriter,
mlir::Type ty,
mlir::Value val,
bool fold = false )

Perform an extension or truncation as needed on an integer value. Lowering to the specific target may involve some sign-extending or truncation of values, particularly to fit them from abstract box types to the appropriate reified structures.

◆ isa_passbyref_type()

bool fir::isa_passbyref_type ( mlir::Type t)
inline

Is t a type that is always trivially pass-by-reference? Specifically, this is testing if t is a ReferenceType or any box type. Compare this to conformsWithPassByRef(), which includes pointers and allocatables.

◆ isa_trivial()

bool fir::isa_trivial ( mlir::Type t)
inline

Is t a trivial intrinsic type? CHARACTER is excluded because it is a dependent type.

◆ isa_unknown_size_box()

bool fir::isa_unknown_size_box ( mlir::Type t)

Is t a box type for which it is not possible to deduce the box size? It is not possible to deduce the size of a box that describes an entity of unknown rank. Unknown type are always considered to have the size of derived type box (since they may hold one), and are not considered to be unknown size.

◆ isa_volatile_type()

bool fir::isa_volatile_type ( mlir::Type t)

Returns true iff t is a type capable of representing volatility and has the volatile attribute set.

◆ isArray()

bool fir::isArray ( const ExtendedValue & exv)

Is the extended value exv an array? Note that this returns true for assumed-ranks that could actually be scalars at runtime.

◆ isAssumedType()

bool fir::isAssumedType ( mlir::Type ty)

Return true iff ty is the type of an assumed type. In FIR, assumed types are of the form [fir.ref|ptr|heap]fir.box<[fir.array]none>, or fir.ref|ptr|heap<[fir.array]none>.

◆ isBoxedRecordType()

bool fir::isBoxedRecordType ( mlir::Type ty)

Return true iff ty is the type of a boxed record type. e.g. !fir.box<!fir.type<derived>>

◆ isContiguousEmbox()

bool fir::isContiguousEmbox ( fir::EmboxOp embox,
bool checkWhole = true )

Return true, if embox operation produces a contiguous entity. When checkWhole is false, then the checking is only done for continuity in the innermost dimension, otherwise, the checking is done for continuity of the whole result of embox

◆ isInternalProcedure()

bool fir::isInternalProcedure ( mlir::func::FuncOp func)
inline

Is the function, func an internal procedure ? Some internal procedures may have access to saved host procedure variables even when they do not have a tuple argument.

◆ isPointerType()

bool fir::isPointerType ( mlir::Type ty)

Return true iff ty is the type of a POINTER entity or value. isa_ref_type() can be used to distinguish.

◆ isPolymorphicType()

bool fir::isPolymorphicType ( mlir::Type ty)

Return true iff ty is the type of an polymorphic entity or value.

◆ isRecordWithDescriptorMember()

bool fir::isRecordWithDescriptorMember ( mlir::Type ty)

Return true iff ty is a scalar/array of RecordType with members that are descriptors.

◆ isScalarBoxedRecordType()

bool fir::isScalarBoxedRecordType ( mlir::Type ty)

Return true iff ty is a scalar boxed record type. e.g. !fir.box<!fir.type<derived>> !fir.box<!fir.heap<!fir.type<derived>>> !fir.class<!fir.type<derived>>

◆ isUnlimitedPolymorphicType()

bool fir::isUnlimitedPolymorphicType ( mlir::Type ty)

Return true iff ty is the type of an unlimited polymorphic entity or value.

◆ lookupIntrinsicHandler()

std::optional< IntrinsicHandlerEntry > fir::lookupIntrinsicHandler ( fir::FirOpBuilder & builder,
llvm::StringRef intrinsicName,
std::optional< mlir::Type > resultType )

Lookup for a handler or runtime call generator to lower intrinsic intrinsicName.

◆ lookupTypeInfoOp() [1/2]

fir::TypeInfoOp fir::lookupTypeInfoOp ( fir::RecordType recordType,
mlir::ModuleOp module,
const mlir::SymbolTable * symbolTable = nullptr )

Find the fir.type_info that was created for this recordType in module, if any. symbolTable can be provided to speed-up the lookup. This tool will match record type even if they have been "altered" in type conversion passes.

◆ lookupTypeInfoOp() [2/2]

fir::TypeInfoOp fir::lookupTypeInfoOp ( llvm::StringRef name,
mlir::ModuleOp module,
const mlir::SymbolTable * symbolTable = nullptr )

Find the fir.type_info named name in module, if any. symbolTable can be provided to speed-up the lookup. Prefer using the equivalent with a RecordType argument unless it is certain name has not been altered by a pass rewriting fir.type (see NameUniquer::dropTypeConversionMarkers).

◆ lowerIntrinsicArgumentAs()

fir::ArgLoweringRule fir::lowerIntrinsicArgumentAs ( const IntrinsicArgumentLoweringRules & rules,
unsigned position )

Return how argument argName should be lowered given the rules for the intrinsic function. The argument names are the one defined by the standard.

Return how argument argName should be lowered given the rules for the intrinsic function.

◆ populateOpenMPFIRToLLVMConversionPatterns()

void fir::populateOpenMPFIRToLLVMConversionPatterns ( const LLVMTypeConverter & converter,
mlir::RewritePatternSet & patterns )

Specialised conversion patterns of OpenMP operations for FIR to LLVM dialect, utilised in cases where the default OpenMP dialect handling cannot handle all cases for intermingled fir types and operations.

◆ pureCall()

bool fir::pureCall ( mlir::Operation * op)
inline

Return true iff the Operation is a fir::CallOp, fir::DispatchOp, mlir::CallOp, or mlir::CallIndirectOp and is also pure. NB: This is not the same as !impureCall(op).

◆ reboxPreservesContinuity()

bool fir::reboxPreservesContinuity ( fir::ReboxOp rebox,
bool mayHaveNonDefaultLowerBounds = true,
bool checkWhole = true )

Return true, if rebox operation keeps the input array continuous if it is initially continuous. When checkWhole is false, then the checking is only done for continuity in the innermost dimension, otherwise, the checking is done for continuity of the whole result of rebox. The caller may specify mayHaveNonDefaultLowerBounds, if it is known, to allow better handling of the rebox operations representing full array slices.

◆ replaceAllocas()

bool fir::replaceAllocas ( mlir::RewriterBase & rewriter,
mlir::Operation * parentOp,
MustRewriteCallBack mustReplace,
AllocaRewriterCallBack allocaRewriter,
DeallocCallBack deallocGenerator )

Utility to replace fir.alloca by dynamic allocations inside parentOp. MustRewriteCallBack lets the user control which fir.alloca should be replaced. AllocaRewriterCallBack lets the user define how the new memory should be allocated. DeallocCallBack lets the user decide how the memory should be deallocated. The boolean result indicates if the utility succeeded to replace all fir.alloca as requested by the user. Causes of failures are the presence of unregistered operations, or OpenMP/ACC recipe operations that return memory allocated inside their region.

◆ sequenceWithNonConstantShape()

bool fir::sequenceWithNonConstantShape ( fir::SequenceType seqTy)
inline

Returns true iff seqTy has either an unknown shape or a non-constant shape (where rank > 0).

◆ setAtomicFineGrainedMemory()

void fir::setAtomicFineGrainedMemory ( mlir::ModuleOp mod,
bool value )

Sets whether fine grained memory can be used or not for lowering of atomic operations.

◆ setAtomicIgnoreDenormalMode()

void fir::setAtomicIgnoreDenormalMode ( mlir::ModuleOp mod,
bool value )

Sets whether Denormal Mode can be ignored or not for lowering of floating point atomic operations.

◆ setAtomicRemoteMemory()

void fir::setAtomicRemoteMemory ( mlir::ModuleOp mod,
bool value )

Sets whether remote memory can be used or not for lowering of atomic operations.

◆ setKindMapping()

void fir::setKindMapping ( mlir::ModuleOp mod,
fir::KindMapping & kindMap )

Set the kind mapping for the module. kindMap must not be deallocated while module mod is still live.

◆ setTargetCPU()

void fir::setTargetCPU ( mlir::ModuleOp mod,
llvm::StringRef cpu )

Set the target CPU for the module. cpu must not be deallocated while module mod is still live.

◆ setTargetTriple()

void fir::setTargetTriple ( mlir::ModuleOp mod,
llvm::StringRef triple )

Set the target triple for the module. triple must not be deallocated while module mod is still live.

◆ setTuneCPU()

void fir::setTuneCPU ( mlir::ModuleOp mod,
llvm::StringRef cpu )

Set the tune CPU for the module. cpu must not be deallocated while module mod is still live.

◆ substBase()

fir::ExtendedValue fir::substBase ( const ExtendedValue & exv,
mlir::Value base )

Return a clone of the extended value exv with the base value base substituted.

◆ tryFoldingLLVMInsertChain()

llvm::FailureOr< mlir::Attribute > fir::tryFoldingLLVMInsertChain ( mlir::Value insertChainResult,
mlir::OpBuilder & builder )

Attempt to fold an llvm.insertvalue chain into an attribute representation suitable as llvm.constant operand. The returned value will be llvm::Failure if this is not an llvm.insertvalue result or if the chain is not a constant, or cannot be represented as an Attribute. The operations are not deleted, but some llvm.insertvalue value operands may be folded with the builder on the way.

◆ unwrapAllRefAndSeqType()

mlir::Type fir::unwrapAllRefAndSeqType ( mlir::Type ty)

Unwrap all referential and sequential outer types (if any). Returns the element type. This is useful for determining the element type of any object memory reference, whether it is a single instance or a series of instances.

◆ unwrapIfDerived()

fir::RecordType fir::unwrapIfDerived ( fir::BaseBoxType boxTy)
inline

Unwrap the referential and sequential outer types (if any). Returns the the element if type is fir::RecordType

◆ unwrapPassByRefType()

mlir::Type fir::unwrapPassByRefType ( mlir::Type t)
inline

If t conforms with a pass-by-reference type (box, ref, ptr, etc.) then return the element type of t. Otherwise, return t.

◆ unwrapSeqOrBoxedSeqType()

mlir::Type fir::unwrapSeqOrBoxedSeqType ( mlir::Type ty)

Unwrap either a sequence or a boxed sequence type, returning the element type of the sequence type. e.g., !fir.array<...xT> -> T !fir.box<!fir.ptr<!fir.array<...xT>>> -> T otherwise T -> T

◆ unwrapUntilSeqType()

fir::SequenceType fir::unwrapUntilSeqType ( mlir::Type t)
inline

Unwrap all pointer and box types and return the element type if it is a sequence type, otherwise return null.

◆ updateTypeForUnlimitedPolymorphic()

mlir::Type fir::updateTypeForUnlimitedPolymorphic ( mlir::Type ty)
inline

Return the elementType where intrinsic types are replaced with none for unlimited polymorphic entities.

i32 -> () !fir.array<2xf32> -> !fir.array<2xnone> !fir.heap<!fir.array<2xf32>> -> !fir.heap<!fir.array<2xnone>>

◆ updateTypeWithVolatility()

mlir::Type fir::updateTypeWithVolatility ( mlir::Type type,
bool isVolatile )

Re-create the given type with the given volatility, if this is a type that can represent volatility.

◆ valueHasFirAttribute()

bool fir::valueHasFirAttribute ( mlir::Value value,
llvm::StringRef attributeName )

Tell if value is:

  • a function argument that has attribute attributeName
  • or, the result of fir.alloca/fir.allocmem op that has attribute attributeName
  • or, the result of a fir.address_of of a fir.global that has attribute attributeName
  • or, a fir.box loaded from a fir.ref<fir.box> that matches one of the previous cases.

◆ valueMayHaveFirAttributes()

bool fir::valueMayHaveFirAttributes ( mlir::Value value,
llvm::ArrayRef< llvm::StringRef > attributeNames )

A more conservative version of valueHasFirAttribute(). If value is one of the operation/function-argument cases listed for valueHasFirAttribute():

  • if any of the attributeNames attributes is set, then the function will return true.
  • otherwise, it will return false.

Otherwise, the function will return true indicating that the attributes may actually be set but we were not able to reach the point of definition to confirm that.

◆ verifyIntegralType()

void fir::verifyIntegralType ( mlir::Type type)

Guarantee type is a scalar integral type (standard Integer, standard Index, or FIR Int). Aborts execution if condition is false.

◆ wrapInClassOrBoxType()

mlir::Type fir::wrapInClassOrBoxType ( mlir::Type eleTy,
bool isPolymorphic = false,
bool isAssumedType = false )
inline

Return a fir.box<T> or fir.class<T> if the type is polymorphic. If the type is polymorphic and assumed shape return fir.box<T>.

Variable Documentation

◆ FuncTypeComplex16Complex16

auto fir::FuncTypeComplex16Complex16
constexpr
Initial value:
=
genFuncType<Ty::Complex<16>, Ty::Complex<16>>

◆ FuncTypeComplex16Complex16Complex16

auto fir::FuncTypeComplex16Complex16Complex16
constexpr
Initial value:
=
genFuncType<Ty::Complex<16>, Ty::Complex<16>, Ty::Complex<16>>

◆ FuncTypeComplex16Complex16Integer4

auto fir::FuncTypeComplex16Complex16Integer4
constexpr
Initial value:
=
genFuncType<Ty::Complex<16>, Ty::Complex<16>, Ty::Integer<4>>

◆ FuncTypeComplex16Complex16Integer8

auto fir::FuncTypeComplex16Complex16Integer8
constexpr
Initial value:
=
genFuncType<Ty::Complex<16>, Ty::Complex<16>, Ty::Integer<8>>

◆ FuncTypeInteger4Real16

auto fir::FuncTypeInteger4Real16
constexpr
Initial value:
=
genFuncType<Ty::Integer<4>, Ty::Real<16>>

◆ FuncTypeInteger8Real16

auto fir::FuncTypeInteger8Real16
constexpr
Initial value:
=
genFuncType<Ty::Integer<8>, Ty::Real<16>>

◆ FuncTypeReal16Complex16

auto fir::FuncTypeReal16Complex16
constexpr
Initial value:
=
genFuncType<Ty::Real<16>, Ty::Complex<16>>

◆ FuncTypeReal16Integer4Real16

auto fir::FuncTypeReal16Integer4Real16
constexpr
Initial value:
=
genFuncType<Ty::Real<16>, Ty::Integer<4>, Ty::Real<16>>

◆ FuncTypeReal16Real16

auto fir::FuncTypeReal16Real16 = genFuncType<Ty::Real<16>, Ty::Real<16>>
constexpr

Mapping between mathematical intrinsic operations and MLIR operations of some appropriate dialect (math, complex, etc.) or libm calls. TODO: support remaining Fortran math intrinsics. See https://gcc.gnu.org/onlinedocs/gcc-12.1.0/gfortran/\ Intrinsic-Procedures.html for a reference.

◆ FuncTypeReal16Real16Real16

auto fir::FuncTypeReal16Real16Real16
constexpr
Initial value:
=
genFuncType<Ty::Real<16>, Ty::Real<16>, Ty::Real<16>>

◆ FuncTypeReal16Real16Real16Real16

auto fir::FuncTypeReal16Real16Real16Real16
constexpr
Initial value:
=
genFuncType<Ty::Real<16>, Ty::Real<16>, Ty::Real<16>, Ty::Real<16>>