FLANG
Classes | Public Types | Static Public Member Functions | List of all members
fir::NameUniquer Struct Reference

#include <flang/Optimizer/Support/InternalNames.h>

Classes

struct  DeconstructedName
 Components of an unparsed unique name. More...
 

Public Types

enum class  IntrinsicType {
  CHARACTER , COMPLEX , INTEGER , LOGICAL ,
  REAL
}
 
enum class  NameKind {
  NOT_UNIQUED , BLOCK_DATA_NAME , COMMON , CONSTANT ,
  DERIVED_TYPE , DISPATCH_TABLE , GENERATED , INTRINSIC_TYPE_DESC ,
  NAMELIST_GROUP , PROCEDURE , TYPE_DESC , VARIABLE
}
 The sort of the unique name.
 

Static Public Member Functions

static std::string doCommonBlock (llvm::StringRef name)
 Unique a common block name.
 
static std::string doConstant (llvm::ArrayRef< llvm::StringRef > modules, llvm::ArrayRef< llvm::StringRef > procs, std::int64_t block, llvm::StringRef name)
 Unique a (global) constant name.
 
static std::string doDispatchTable (llvm::ArrayRef< llvm::StringRef > modules, llvm::ArrayRef< llvm::StringRef > procs, std::int64_t block, llvm::StringRef name, llvm::ArrayRef< std::int64_t > kinds)
 Unique a dispatch table name.
 
static std::string doGenerated (llvm::StringRef name)
 Unique a compiler generated name without scope context.
 
static std::string doGenerated (llvm::ArrayRef< llvm::StringRef > modules, llvm::ArrayRef< llvm::StringRef > procs, std::int64_t blockId, llvm::StringRef name)
 Unique a compiler generated name with scope context.
 
static std::string doIntrinsicTypeDescriptor (llvm::ArrayRef< llvm::StringRef > modules, llvm::ArrayRef< llvm::StringRef > procs, std::int64_t block, IntrinsicType type, std::int64_t kind)
 Unique an intrinsic type descriptor.
 
static std::string doProcedure (llvm::ArrayRef< llvm::StringRef > modules, llvm::ArrayRef< llvm::StringRef > procs, llvm::StringRef name)
 Unique a procedure name.
 
static std::string doType (llvm::ArrayRef< llvm::StringRef > modules, llvm::ArrayRef< llvm::StringRef > procs, std::int64_t block, llvm::StringRef name, llvm::ArrayRef< std::int64_t > kinds)
 Unique a derived type name.
 
static std::string doTypeDescriptor (llvm::ArrayRef< llvm::StringRef > modules, llvm::ArrayRef< llvm::StringRef > procs, std::int64_t block, llvm::StringRef name, llvm::ArrayRef< std::int64_t > kinds)
 Unique a (derived) type descriptor name.
 
static std::string doTypeDescriptor (llvm::ArrayRef< std::string > modules, llvm::ArrayRef< std::string > procs, std::int64_t block, llvm::StringRef name, llvm::ArrayRef< std::int64_t > kinds)
 
static std::string doVariable (llvm::ArrayRef< llvm::StringRef > modules, llvm::ArrayRef< llvm::StringRef > procs, std::int64_t block, llvm::StringRef name)
 
static std::string doNamelistGroup (llvm::ArrayRef< llvm::StringRef > modules, llvm::ArrayRef< llvm::StringRef > procs, llvm::StringRef name)
 Unique a namelist group name.
 
static llvm::StringRef doProgramEntry ()
 
static std::pair< NameKind, DeconstructedNamedeconstruct (llvm::StringRef uniquedName)
 Decompose uniquedName into the parse name, symbol type, and scope info.
 
static bool isExternalFacingUniquedName (const std::pair< NameKind, DeconstructedName > &deconstructResult)
 Check if the name is an external facing name.
 
static bool needExternalNameMangling (llvm::StringRef uniquedName)
 Check whether the name should be re-mangle with external ABI convention.
 
static bool belongsToModule (llvm::StringRef uniquedName, llvm::StringRef moduleName)
 Does uniquedName belong to module moduleName?
 
static std::string getTypeDescriptorName (llvm::StringRef mangledTypeName)
 
static std::string getTypeDescriptorAssemblyName (llvm::StringRef mangledTypeName)
 
static std::string getTypeDescriptorBindingTableName (llvm::StringRef mangledTypeName)
 
static std::string getComponentInitName (llvm::StringRef mangledTypeName, llvm::StringRef componentName)
 
static llvm::StringRef dropTypeConversionMarkers (llvm::StringRef mangledTypeName)
 
static std::string replaceSpecialSymbols (const std::string &name)
 
static bool isSpecialSymbol (llvm::StringRef name)
 

Detailed Description

Internal name mangling of identifiers

In order to generate symbolically referencable artifacts in a ModuleOp, it is required that those symbols be uniqued. This is a simple interface for converting Fortran symbols into unique names.

This is intentionally bijective. Given a symbol's parse name, type, and scope-like information, we can generate a uniqued (mangled) name. Given a uniqued name, we can return the symbol parse name, type of the symbol, and any scope-like information for that symbol.

Member Function Documentation

◆ doProgramEntry()

llvm::StringRef fir::NameUniquer::doProgramEntry ( )
static

Entry point for the PROGRAM (called by the runtime) Can be overridden with the --main-entry-name=<name> option.

◆ doVariable()

std::string fir::NameUniquer::doVariable ( llvm::ArrayRef< llvm::StringRef >  modules,
llvm::ArrayRef< llvm::StringRef >  procs,
std::int64_t  block,
llvm::StringRef  name 
)
static

Unique a (global) variable name. A variable with save attribute defined inside a subprogram also needs to be handled here

◆ dropTypeConversionMarkers()

llvm::StringRef fir::NameUniquer::dropTypeConversionMarkers ( llvm::StringRef  mangledTypeName)
static

Remove markers that have been added when doing partial type conversions. mlir::Type cannot be mutated in a pass, so new fir::RecordType must be created when lowering member types. Suffixes added to these new types are meaningless and are dropped in the names passed to LLVM.

◆ getComponentInitName()

std::string fir::NameUniquer::getComponentInitName ( llvm::StringRef  mangledTypeName,
llvm::StringRef  componentName 
)
static

Given a mangled derived type name and a component name, get the name of the global object containing the component default initialization.

◆ getTypeDescriptorBindingTableName()

std::string fir::NameUniquer::getTypeDescriptorBindingTableName ( llvm::StringRef  mangledTypeName)
static

Given a mangled derived type name, get the name of the related binding table object. Returns an empty string if mangledTypeName is not a valid mangled derived type name.

◆ getTypeDescriptorName()

std::string fir::NameUniquer::getTypeDescriptorName ( llvm::StringRef  mangledTypeName)
static

Given a mangled derived type name, get the name of the related derived type descriptor object. Returns an empty string if mangledTypeName is not a valid mangled derived type name.

◆ isSpecialSymbol()

bool fir::NameUniquer::isSpecialSymbol ( llvm::StringRef  name)
static

Returns true if the passed name denotes a special symbol (e.g. global symbol generated for derived type description).


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