Gyoji Compiler
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Gyoji::mir::MIR Class Reference

The middle-tier intermediate representation (MIR) of a translation unit. More...

#include <gyoji-mir.hpp>

Public Member Functions

const Typesget_types () const
 Immutable type container.
 
Typesget_types ()
 Mutable type container.
 
const Symbolsget_symbols () const
 Immutable symbol table.
 
Symbolsget_symbols ()
 
const Functionsget_functions () const
 Immutable function table.
 
Functionsget_functions ()
 Mutable function table.
 
void dump (FILE *out) const
 Dump MIR for debugging.
 

Detailed Description

The middle-tier intermediate representation (MIR) of a translation unit.

The MIR class represents the semantic information about everything expressed in a single translation-unit. The main actors are Types, Symbols, anf Functions. The Types represent data stored in a variable, or identifier. The Symbols represent global variables and functions that will ultimately wind up in the symbol table of the generated binary file. The Functions represent the callable entities and contain the blocks and operations it will perform including primitive operations, flow-control instructions, variable declarations, and things that happen inside functions.

Member Function Documentation

◆ dump()

void MIR::dump ( FILE *  out) const

Dump MIR for debugging.

This method is a debugging helper to assist in vizualizing the MIR so we can examine it as we work on other layers like the analysis and code-generation phases.

The following gives a minimal example of what is contained in the MIR dump. This gives a sense of the information available to the analysis and code-generation stages.

Types:
u32 : primitive
u8 : primitive
void : primitive
Symbol Table:
preamble_function_call : u32(*)()
write : u32(*)(u32,u8*,u32)
Function Definitions
preamble_function_call
return-value : u32
temporary variables
_0 : u32(*)(u32,u8*,u32)
_1 : u8
_2 : u8*
_3 : u32
_4 : u32
{
BB0:
_0 = symbol ( write )
_1 = literal-int ( 0 )
_2 = literal-string ( "abcXXdef" )
_3 = literal-int ( 5 )
_4 = function-call ( _0 _1 _2 _3 )
}

◆ get_functions() [1/2]

Functions & MIR::get_functions ( )

Mutable function table.

This method returns a mutable reference to the functions themselves.

This is intended for use in constructing the MIR and should not be used after the front-end stage has finished parsing.

◆ get_functions() [2/2]

const Functions & MIR::get_functions ( ) const

Immutable function table.

This method returns an immutable reference to the functions themselves.

It is used after the front-end has finished creating the MIR and is used by analysis passes and code-generation passes which will not modify the MIR during the course of operations.

◆ get_symbols() [1/2]

Symbols & MIR::get_symbols ( )

This method returns a mutable reference to the symbol table.

This is intended for use in constructing the MIR and should not be used after the front-end stage has finished parsing.

◆ get_symbols() [2/2]

const Symbols & MIR::get_symbols ( ) const

Immutable symbol table.

This method returns an immutable reference to the symbol table. It is used after the front-end has finished creating the MIR and is used by analysis passes and code-generation passes which will not modify the MIR during the course of operations.

◆ get_types() [1/2]

Types & MIR::get_types ( )

Mutable type container.

This method returns a mutable reference to the container of types. This is intended for use in constructing the MIR and should not be used after the front-end stage has finished parsing.

◆ get_types() [2/2]

const Types & MIR::get_types ( ) const

Immutable type container.

This method returns an immutable reference to the container of types. It is used after the front-end has finished creating the MIR and is used by analysis passes and code-generation passes which will not modify the MIR during the course of operations.


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