ArkScript
A small, fast, functional and scripting language for video games
Ark::internal::IROptimizer Class Referencefinal

#include <IROptimizer.hpp>

Collaboration diagram for Ark::internal::IROptimizer:
[legend]

Classes

struct  Rule
 

Public Member Functions

 IROptimizer (unsigned debug)
 Create a new IROptimizer.
 
void process (const std::vector< IR::Block > &pages, const std::vector< std::string > &symbols, const std::vector< ValTableElem > &values)
 Turn a given IR into bytecode.
 
const std::vector< IR::Block > & intermediateRepresentation () const noexcept
 Return the IR blocks (one per scope)
 

Private Types

using Entities = std::vector<IR::Entity>
 
using DualArgs = std::pair<uint16_t, uint16_t>
 

Private Member Functions

bool match (const std::vector< Instruction > &expected_insts, const Entities &entities) const
 
std::optional< IR::EntityreplaceWithRules (const std::vector< Rule > &rules, const Entities &entities)
 
bool isPositiveNumberInlinable (uint16_t id) const
 
uint16_t numberAsArg (uint16_t id) const
 

Private Attributes

std::vector< Rulem_ruleset_two
 
std::vector< Rulem_ruleset_three
 
Logger m_logger
 
std::vector< IR::Blockm_ir
 
std::vector< std::string > m_symbols
 
std::vector< ValTableElemm_values
 

Detailed Description

Definition at line 23 of file IROptimizer.hpp.

Member Typedef Documentation

◆ DualArgs

using Ark::internal::IROptimizer::DualArgs = std::pair<uint16_t, uint16_t>
private

Definition at line 51 of file IROptimizer.hpp.

◆ Entities

using Ark::internal::IROptimizer::Entities = std::vector<IR::Entity>
private

Definition at line 50 of file IROptimizer.hpp.

Constructor & Destructor Documentation

◆ IROptimizer()

Member Function Documentation

◆ intermediateRepresentation()

const std::vector< IR::Block > & Ark::internal::IROptimizer::intermediateRepresentation ( ) const
nodiscardnoexcept

Return the IR blocks (one per scope)

Returns
const std::vector<Block>&

Definition at line 176 of file IROptimizer.cpp.

References m_ir.

Referenced by Ark::Welder::generateBytecode().

◆ isPositiveNumberInlinable()

bool Ark::internal::IROptimizer::isPositiveNumberInlinable ( uint16_t id) const
nodiscardprivate

Definition at line 222 of file IROptimizer.cpp.

References m_values, Ark::internal::IR::MaxValueForDualArg, and Ark::internal::Number.

Referenced by IROptimizer().

◆ match()

bool Ark::internal::IROptimizer::match ( const std::vector< Instruction > & expected_insts,
const Entities & entities ) const
nodiscardprivate

Definition at line 181 of file IROptimizer.cpp.

Referenced by replaceWithRules().

◆ numberAsArg()

uint16_t Ark::internal::IROptimizer::numberAsArg ( uint16_t id) const
nodiscardprivate

Definition at line 234 of file IROptimizer.cpp.

References m_values.

Referenced by IROptimizer().

◆ process()

void Ark::internal::IROptimizer::process ( const std::vector< IR::Block > & pages,
const std::vector< std::string > & symbols,
const std::vector< ValTableElem > & values )

Turn a given IR into bytecode.

Parameters
pageslist of lists of IR entities generated by the compiler
symbolssymbol table generated by the compiler
valuesvalue table generated by the compiler

Definition at line 112 of file IROptimizer.cpp.

References m_ir, m_logger, m_ruleset_three, m_ruleset_two, m_symbols, m_values, replaceWithRules(), Ark::internal::Logger::traceEnd(), and Ark::internal::Logger::traceStart().

Referenced by Ark::Welder::generateBytecode().

◆ replaceWithRules()

std::optional< IR::Entity > Ark::internal::IROptimizer::replaceWithRules ( const std::vector< Rule > & rules,
const Entities & entities )
private

Definition at line 194 of file IROptimizer.cpp.

References match(), and Ark::internal::IR::MaxValueForDualArg.

Referenced by process().

Member Data Documentation

◆ m_ir

std::vector<IR::Block> Ark::internal::IROptimizer::m_ir
private

Definition at line 70 of file IROptimizer.hpp.

Referenced by intermediateRepresentation(), and process().

◆ m_logger

Logger Ark::internal::IROptimizer::m_logger
private

Definition at line 69 of file IROptimizer.hpp.

Referenced by process().

◆ m_ruleset_three

std::vector<Rule> Ark::internal::IROptimizer::m_ruleset_three
private

Definition at line 67 of file IROptimizer.hpp.

Referenced by IROptimizer(), and process().

◆ m_ruleset_two

std::vector<Rule> Ark::internal::IROptimizer::m_ruleset_two
private

Definition at line 66 of file IROptimizer.hpp.

Referenced by IROptimizer(), and process().

◆ m_symbols

std::vector<std::string> Ark::internal::IROptimizer::m_symbols
private

Definition at line 71 of file IROptimizer.hpp.

Referenced by process().

◆ m_values

std::vector<ValTableElem> Ark::internal::IROptimizer::m_values
private

Definition at line 72 of file IROptimizer.hpp.

Referenced by isPositiveNumberInlinable(), numberAsArg(), and process().


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