hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
IRLinker Class Reference

#include <IRLinker.hpp>

Public Member Functions

 IRLinker ()
 
std::shared_ptr< IRObjectFilelink (const std::shared_ptr< compilerContext > &context, indexT entryModuleId)
 Links all compiled modules from the context into a single IRObjectFile.
 

Private Member Functions

wstr mangleName (indexT moduleId, const wstr &originalName)
 Mangles a symbol name with its module ID, unless it's the main function in the entry module.
 
void linkStringLiterals ()
 
void linkStructsAndInterfaces ()
 
void linkDataStructs ()
 
void linkInterfaceImplementations ()
 
void linkGlobals ()
 
void linkFunctions ()
 
void linkMetadata ()
 
void createEntryFunction ()
 
void patchIRFFITable ()
 
std::tuple< IRValueType::valueType, indexT, indexTpatchUniqueKey (const std::tuple< IRValueType::valueType, indexT, indexT > &key)
 
std::shared_ptr< IRValueTypepatchType (const std::shared_ptr< IRValueType > &oldType)
 
IR patchInstruction (const IR &instr, indexT currentModuleId)
 

Private Attributes

std::shared_ptr< compilerContextcompilerCtx
 
std::shared_ptr< IRModulefinalModule
 
indexT entryModuleId
 
std::map< indexT, std::map< indexT, indexT > > structRemapping
 
std::map< indexT, std::map< indexT, indexT > > datastructRemapping
 
std::map< indexT, std::map< indexT, indexT > > interfaceRemapping
 
std::map< indexT, std::map< indexT, indexT > > interfaceImplRemapping
 
std::map< indexT, std::map< indexT, indexT > > globalRemapping
 
std::map< indexT, std::map< indexT, indexT > > functionRemapping
 
std::map< indexT, std::map< indexT, indexT > > stringRemapping
 
yoi::vec< yoi::indexTglobInitializerIndexes
 

Detailed Description

Definition at line 16 of file IRLinker.hpp.

Constructor & Destructor Documentation

◆ IRLinker()

IRLinker ( )
default

Member Function Documentation

◆ createEntryFunction()

◆ link()

std::shared_ptr< IRObjectFile > link ( const std::shared_ptr< compilerContext > &  context,
indexT  entryModuleId 
)

Links all compiled modules from the context into a single IRObjectFile.

Parameters
contextThe compiler context containing all compiled modules.
entryModuleIdThe ID of the main entry module.
Returns
A shared pointer to the final IRObjectFile.

Definition at line 18 of file IRLinker.cpp.

References IRLinker::compilerCtx, IRLinker::createEntryFunction(), ENTRY_MODULE_ID_CONST, IRLinker::entryModuleId, IRLinker::finalModule, IRLinker::linkDataStructs(), IRLinker::linkFunctions(), IRLinker::linkGlobals(), IRLinker::linkInterfaceImplementations(), IRLinker::linkMetadata(), IRLinker::linkStringLiterals(), IRLinker::linkStructsAndInterfaces(), and IRLinker::patchIRFFITable().

Referenced by IRLinker::linkMetadata(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linkDataStructs()

void linkDataStructs ( )
private

Definition at line 426 of file IRLinker.cpp.

References IRLinker::compilerCtx, IRLinker::datastructRemapping, IRLinker::finalModule, yoi::managedPtr(), and IRLinker::patchType().

Referenced by IRLinker::link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linkFunctions()

void linkFunctions ( )
private

Definition at line 156 of file IRLinker.cpp.

References IRLinker::compilerCtx, IRLinker::finalModule, IRLinker::functionRemapping, IRLinker::globInitializerIndexes, IRLinker::mangleName(), IRLinker::patchInstruction(), and IRLinker::patchType().

Referenced by IRLinker::link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linkGlobals()

void linkGlobals ( )
private

Definition at line 142 of file IRLinker.cpp.

References IRLinker::compilerCtx, IRLinker::finalModule, IRLinker::globalRemapping, IRLinker::mangleName(), and IRLinker::patchType().

Referenced by IRLinker::link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linkInterfaceImplementations()

void linkInterfaceImplementations ( )
private

Definition at line 358 of file IRLinker.cpp.

References IRLinker::finalModule, IRLinker::patchType(), IRLinker::patchUniqueKey(), and virtualMethod.

Referenced by IRLinker::link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linkMetadata()

void linkMetadata ( )
private

Definition at line 412 of file IRLinker.cpp.

References ENTRY_MODULE_ID_CONST, IRLinker::finalModule, IRLinker::interfaceImplRemapping, and IRLinker::link().

Referenced by IRLinker::link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ linkStringLiterals()

void linkStringLiterals ( )
private

Definition at line 55 of file IRLinker.cpp.

References IRLinker::compilerCtx, IRLinker::finalModule, and IRLinker::stringRemapping.

Referenced by IRLinker::link().

Here is the caller graph for this function:

◆ linkStructsAndInterfaces()

void linkStructsAndInterfaces ( )
private

Definition at line 67 of file IRLinker.cpp.

References IRLinker::compilerCtx, ENTRY_MODULE_ID_CONST, IRLinker::finalModule, IRLinker::interfaceImplRemapping, IRLinker::interfaceRemapping, IRLinker::mangleName(), IRLinker::patchType(), and IRLinker::structRemapping.

Referenced by IRLinker::link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mangleName()

wstr mangleName ( indexT  moduleId,
const wstr originalName 
)
private

Mangles a symbol name with its module ID, unless it's the main function in the entry module.

Definition at line 45 of file IRLinker.cpp.

References IRLinker::entryModuleId.

Referenced by IRLinker::linkFunctions(), IRLinker::linkGlobals(), and IRLinker::linkStructsAndInterfaces().

Here is the caller graph for this function:

◆ patchInstruction()

◆ patchIRFFITable()

void patchIRFFITable ( )
private

Definition at line 366 of file IRLinker.cpp.

References IRLinker::compilerCtx, ENTRY_MODULE_ID_CONST, IRLinker::functionRemapping, and IRLinker::patchType().

Referenced by IRLinker::link().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ patchType()

◆ patchUniqueKey()

Member Data Documentation

◆ compilerCtx

◆ datastructRemapping

std::map<indexT, std::map<indexT, indexT> > datastructRemapping
private

◆ entryModuleId

indexT entryModuleId
private

Definition at line 31 of file IRLinker.hpp.

Referenced by IRLinker::link(), and IRLinker::mangleName().

◆ finalModule

◆ functionRemapping

std::map<indexT, std::map<indexT, indexT> > functionRemapping
private

◆ globalRemapping

std::map<indexT, std::map<indexT, indexT> > globalRemapping
private

Definition at line 38 of file IRLinker.hpp.

Referenced by IRLinker::linkGlobals(), and IRLinker::patchInstruction().

◆ globInitializerIndexes

yoi::vec<yoi::indexT> globInitializerIndexes
private

Definition at line 41 of file IRLinker.hpp.

Referenced by IRLinker::createEntryFunction(), and IRLinker::linkFunctions().

◆ interfaceImplRemapping

std::map<indexT, std::map<indexT, indexT> > interfaceImplRemapping
private

◆ interfaceRemapping

std::map<indexT, std::map<indexT, indexT> > interfaceRemapping
private

◆ stringRemapping

std::map<indexT, std::map<indexT, indexT> > stringRemapping
private

Definition at line 40 of file IRLinker.hpp.

Referenced by IRLinker::linkStringLiterals(), and IRLinker::patchInstruction().

◆ structRemapping

std::map<indexT, std::map<indexT, indexT> > structRemapping
private

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