![]() |
ArkScript
A small, lisp-inspired, functional scripting language
|
#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) | |
Public Member Functions inherited from Ark::internal::Pass | |
| Pass (std::string name, unsigned debug_level) | |
| Construct a new Pass object. | |
| virtual | ~Pass ()=default |
| void | configureLogger (std::ostream &os) |
| Set a custom output stream for the logger. | |
Private Types | |
| using | Entities = std::span<const IR::Entity> |
| using | Condition_t = std::function<bool(const Entities, const std::size_t)> |
| using | Replacement_t = std::function<IR::Entity(const Entities)> |
Private Member Functions | |
| bool | match (const std::vector< Instruction > &expected_insts, std::span< const IR::Entity > entities) const |
| std::optional< EntityWithOffset > | replaceWithRules (std::span< const IR::Entity > entities, std::size_t position_in_block) |
| bool | isPositiveNumberInlinable (uint16_t id) const |
| bool | isSmallerNumberInlinable (uint16_t id) const |
| bool | isNumberEqualTo (uint16_t id, int number) const |
| uint16_t | numberAsArg (uint16_t id) const |
| uint16_t | smallerNumberAsArg (uint16_t id) const |
Static Private Member Functions | |
| static bool | canBeOptimisedSafely (std::span< const IR::Entity > entities, std::size_t window_size, std::size_t position_in_block) |
Private Attributes | |
| std::vector< Rule > | m_ruleset |
| std::vector< IR::Block > | m_ir |
| std::vector< std::string > | m_symbols |
| std::vector< ValTableElem > | m_values |
Additional Inherited Members | |
Protected Attributes inherited from Ark::internal::Pass | |
| Logger | m_logger |
Definition at line 31 of file IROptimizer.hpp.
|
private |
Definition at line 59 of file IROptimizer.hpp.
|
private |
Definition at line 58 of file IROptimizer.hpp.
|
private |
Definition at line 60 of file IROptimizer.hpp.
|
explicit |
Create a new IROptimizer.
| debug | debug level |
Definition at line 22 of file IROptimizer.cpp.
References Ark::internal::Logger::debug(), Ark::internal::fuseMathOps2(), Ark::internal::fuseMathOps3(), Ark::internal::IR::Entity::GotoWithArg(), isPositiveNumberInlinable(), isSmallerNumberInlinable(), Ark::internal::Pass::m_logger, m_ruleset, numberAsArg(), and smallerNumberAsArg().
|
staticnodiscardprivate |
Definition at line 322 of file IROptimizer.cpp.
References Ark::internal::IR::Entity::hasLabel(), Ark::internal::IR::MaxValueForDualArg, and Ark::internal::IR::Entity::primaryArg().
Referenced by replaceWithRules().
|
nodiscardnoexcept |
Return the IR blocks (one per scope)
Definition at line 300 of file IROptimizer.cpp.
References m_ir.
Referenced by Ark::Welder::generateBytecode().
|
nodiscardprivate |
Definition at line 386 of file IROptimizer.cpp.
References m_values, and Ark::internal::Number.
|
nodiscardprivate |
Definition at line 362 of file IROptimizer.cpp.
References m_values, Ark::internal::IR::MaxValueForDualArg, and Ark::internal::Number.
Referenced by IROptimizer().
|
nodiscardprivate |
Definition at line 374 of file IROptimizer.cpp.
References m_values, Ark::internal::IR::MaxValueForDualArg, Ark::internal::IR::MaxValueForSmallNumber, and Ark::internal::Number.
Referenced by IROptimizer().
|
nodiscardprivate |
Definition at line 305 of file IROptimizer.cpp.
References Ark::internal::IR::Label.
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 261 of file IROptimizer.cpp.
References Ark::internal::IR::Block::InitWithMetadata(), m_ir, Ark::internal::Pass::m_logger, m_symbols, m_values, replaceWithRules(), Ark::internal::Logger::traceEnd(), and Ark::internal::Logger::traceStart().
Referenced by Ark::Welder::generateBytecode().
|
private |
Definition at line 337 of file IROptimizer.cpp.
References canBeOptimisedSafely(), m_ruleset, and match().
Referenced by process().
|
nodiscardprivate |
Definition at line 402 of file IROptimizer.cpp.
References m_values, and Ark::internal::IR::MaxValueForSmallNumber.
Referenced by IROptimizer().
|
private |
Definition at line 91 of file IROptimizer.hpp.
Referenced by intermediateRepresentation(), and process().
|
private |
Definition at line 89 of file IROptimizer.hpp.
Referenced by IROptimizer(), and replaceWithRules().
|
private |
Definition at line 92 of file IROptimizer.hpp.
Referenced by process().
|
private |
Definition at line 93 of file IROptimizer.hpp.
Referenced by isNumberEqualTo(), isPositiveNumberInlinable(), isSmallerNumberInlinable(), numberAsArg(), process(), and smallerNumberAsArg().