![]() |
ArkScript
A small, fast, functional and scripting language for video games
|
#include <IROptimizer.hpp>
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::Entity > | replaceWithRules (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< Rule > | m_ruleset_two |
std::vector< Rule > | m_ruleset_three |
Logger | m_logger |
std::vector< IR::Block > | m_ir |
std::vector< std::string > | m_symbols |
std::vector< ValTableElem > | m_values |
Definition at line 23 of file IROptimizer.hpp.
|
private |
Definition at line 51 of file IROptimizer.hpp.
|
private |
Definition at line 50 of file IROptimizer.hpp.
|
explicit |
Create a new IROptimizer.
debug | debug level |
Definition at line 15 of file IROptimizer.cpp.
References Ark::internal::ADD, Ark::internal::BUILTIN, Ark::internal::Builtins::builtins, Ark::internal::CALL, Ark::internal::CALL_BUILTIN, Ark::internal::DECREMENT, Ark::internal::DECREMENT_BY_INDEX, Ark::internal::HEAD, Ark::internal::INCREMENT, Ark::internal::INCREMENT_BY_INDEX, isPositiveNumberInlinable(), Ark::internal::LOAD_CONST, Ark::internal::LOAD_CONST_LOAD_CONST, Ark::internal::LOAD_CONST_SET_VAL, Ark::internal::LOAD_CONST_STORE, Ark::internal::LOAD_SYMBOL, Ark::internal::LOAD_SYMBOL_BY_INDEX, m_ruleset_three, m_ruleset_two, numberAsArg(), Ark::internal::SET_VAL, Ark::internal::SET_VAL_FROM, Ark::internal::SET_VAL_FROM_INDEX, Ark::internal::SET_VAL_HEAD, Ark::internal::SET_VAL_HEAD_BY_INDEX, Ark::internal::SET_VAL_TAIL, Ark::internal::SET_VAL_TAIL_BY_INDEX, Ark::internal::STORE, Ark::internal::STORE_FROM, Ark::internal::STORE_FROM_INDEX, Ark::internal::STORE_HEAD, Ark::internal::STORE_HEAD_BY_INDEX, Ark::internal::STORE_TAIL, Ark::internal::STORE_TAIL_BY_INDEX, Ark::internal::SUB, and Ark::internal::TAIL.
|
nodiscardnoexcept |
Return the IR blocks (one per scope)
Definition at line 176 of file IROptimizer.cpp.
References m_ir.
Referenced by Ark::Welder::generateBytecode().
|
nodiscardprivate |
Definition at line 222 of file IROptimizer.cpp.
References m_values, Ark::internal::IR::MaxValueForDualArg, and Ark::internal::Number.
Referenced by IROptimizer().
|
nodiscardprivate |
Definition at line 181 of file IROptimizer.cpp.
Referenced by replaceWithRules().
|
nodiscardprivate |
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.
pages | list of lists of IR entities generated by the compiler |
symbols | symbol table generated by the compiler |
values | value 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().
|
private |
Definition at line 194 of file IROptimizer.cpp.
References match(), and Ark::internal::IR::MaxValueForDualArg.
Referenced by process().
|
private |
Definition at line 70 of file IROptimizer.hpp.
Referenced by intermediateRepresentation(), and process().
|
private |
Definition at line 69 of file IROptimizer.hpp.
Referenced by process().
|
private |
Definition at line 67 of file IROptimizer.hpp.
Referenced by IROptimizer(), and process().
|
private |
Definition at line 66 of file IROptimizer.hpp.
Referenced by IROptimizer(), and process().
|
private |
Definition at line 71 of file IROptimizer.hpp.
Referenced by process().
|
private |
Definition at line 72 of file IROptimizer.hpp.
Referenced by isPositiveNumberInlinable(), numberAsArg(), and process().