![]() |
ArkScript
A small, fast, functional and scripting language for video games
|
#include <IROptimizer.hpp>
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 Member Functions | |
std::optional< IR::Entity > | compactEntities (const IR::Entity &first, const IR::Entity &second) |
std::optional< IR::Entity > | compactEntities (const IR::Entity &first, const IR::Entity &second, const IR::Entity &third) |
bool | isPositiveNumberInlinable (uint16_t id) const |
Private Attributes | |
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.
|
explicit |
Create a new IROptimizer.
debug | debug level |
Definition at line 14 of file IROptimizer.cpp.
|
nodiscardprivate |
Definition at line 87 of file IROptimizer.cpp.
References Ark::internal::BUILTIN, Ark::internal::Builtins::builtins, Ark::internal::CALL, Ark::internal::CALL_BUILTIN, Ark::internal::IR::Entity::inst(), 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::IR::MaxValueForDualArg, Ark::internal::IR::Entity::primaryArg(), Ark::internal::SET_VAL, Ark::internal::SET_VAL_FROM, Ark::internal::STORE, and Ark::internal::STORE_FROM.
Referenced by process().
|
nodiscardprivate |
Definition at line 120 of file IROptimizer.cpp.
References Ark::internal::ADD, Ark::internal::DECREMENT, Ark::internal::HEAD, Ark::internal::INCREMENT, Ark::internal::IR::Entity::inst(), isPositiveNumberInlinable(), Ark::internal::LOAD_CONST, Ark::internal::LOAD_SYMBOL, m_values, Ark::internal::IR::MaxValueForDualArg, Ark::internal::IR::Entity::primaryArg(), Ark::internal::SET_VAL, Ark::internal::SET_VAL_HEAD, Ark::internal::SET_VAL_TAIL, Ark::internal::STORE, Ark::internal::STORE_HEAD, Ark::internal::STORE_TAIL, Ark::internal::SUB, and Ark::internal::TAIL.
|
nodiscardnoexcept |
Return the IR blocks (one per scope)
Definition at line 82 of file IROptimizer.cpp.
References m_ir.
Referenced by Ark::Welder::generateBytecode().
|
nodiscardprivate |
Definition at line 151 of file IROptimizer.cpp.
References m_values, Ark::internal::IR::MaxValueForDualArg, and Ark::internal::Number.
Referenced by compactEntities().
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 18 of file IROptimizer.cpp.
References compactEntities(), m_ir, m_logger, m_symbols, m_values, Ark::internal::Logger::traceEnd(), and Ark::internal::Logger::traceStart().
Referenced by Ark::Welder::generateBytecode().
|
private |
Definition at line 51 of file IROptimizer.hpp.
Referenced by intermediateRepresentation(), and process().
|
private |
Definition at line 50 of file IROptimizer.hpp.
Referenced by process().
|
private |
Definition at line 52 of file IROptimizer.hpp.
Referenced by process().
|
private |
Definition at line 53 of file IROptimizer.hpp.
Referenced by compactEntities(), isPositiveNumberInlinable(), and process().