![]() |
ArkScript
A small, lisp-inspired, functional scripting language
|
#include <IRInliner.hpp>
Public Member Functions | |
| IRInliner (unsigned debug) | |
| Create a new IRInliner. | |
| void | process (const std::vector< IR::Block > &pages, const std::vector< std::string > &symbols, const std::vector< ValTableElem > &values, IR::label_t last_label) |
| Attempt to inline IR blocks to avoid function calls when possible. | |
| 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 | |
| enum class | CallKind { Symbol , Constant } |
Private Member Functions | |
| std::optional< BlockInfo > | blockToInlineInCall (CallKind kind, const std::vector< IR::Block > &pages, std::optional< uint16_t > maybe_id, const IR::Block ¤t, std::size_t argc) const noexcept |
| See if a block can be inlined in the current call site. | |
| void | inlineBlock (const IR::Block &inlinee, IR::Block &destination) |
| Perform the inlining. | |
| void | extractPagesMetadata (const std::vector< IR::Block > &pages) |
| Extract metadata from the IR entities pages, to have a name, constant id, and potentially symbol id per page. | |
| std::optional< BlockInfo > | findBlockBy (CallKind kind, uint16_t id) const noexcept |
| Search for a block by one of its IDs. | |
Static Private Member Functions | |
| static bool | canBeInlined (const IR::Block &candidate, const IR::Block &source, std::size_t argc) noexcept |
| Check if a block can be inlined in another one. | |
| static std::optional< IR::Entity > | isBuiltinProxy (const IR::Block &block) |
| Check if an IR block represents a builtin proxy, and return its CALL instruction if it is. | |
Private Attributes | |
| std::vector< IR::Block > | m_ir |
| std::vector< std::string > | m_symbols |
| std::vector< ValTableElem > | m_values |
| std::vector< BlockInfo > | m_funcs |
| std::unordered_map< long, SymbolData > | m_symbols_data |
| IR::label_t | m_current_label |
Additional Inherited Members | |
Protected Attributes inherited from Ark::internal::Pass | |
| Logger | m_logger |
Definition at line 40 of file IRInliner.hpp.
|
strongprivate |
| Enumerator | |
|---|---|
| Symbol | |
| Constant | |
Definition at line 75 of file IRInliner.hpp.
|
explicit |
|
nodiscardprivatenoexcept |
See if a block can be inlined in the current call site.
| kind | kind of call instruction being used (by symbol or constant) |
| pages | |
| maybe_id | optional identifier of a block (constant id or symbol id) |
| current | current block where inlining could take place |
| argc | argument count in source to candidate |
Definition at line 102 of file IRInliner.cpp.
Referenced by process().
|
staticnodiscardprivatenoexcept |
Check if a block can be inlined in another one.
| candidate | block to inline |
| source | where the inlining will take place |
| argc | argument count in source to candidate |
Definition at line 86 of file IRInliner.cpp.
References Ark::internal::IR::AnonymousBlockName, and Ark::MaxValue16Bits.
|
private |
Extract metadata from the IR entities pages, to have a name, constant id, and potentially symbol id per page.
| pages | pages of IR entities |
Definition at line 258 of file IRInliner.cpp.
References Ark::internal::IR::AnonymousBlockName, Ark::internal::IR::Entity::inst(), m_funcs, m_symbols, m_symbols_data, m_values, Ark::internal::PageAddr, Ark::internal::IR::Entity::primaryArg(), Ark::internal::IR::Entity::relatedResourceId(), Ark::internal::ValTableElem::type, and Ark::internal::ValTableElem::value.
Referenced by process().
|
nodiscardprivatenoexcept |
Search for a block by one of its IDs.
| kind | kind of call instruction being used (by symbol or constant) |
| id |
Definition at line 332 of file IRInliner.cpp.
References Ark::internal::BlockInfo::constant_id, and Ark::internal::BlockInfo::symbol_id.
|
private |
Perform the inlining.
Definition at line 191 of file IRInliner.cpp.
References Ark::internal::IR::Block::Metadata::addr, Ark::internal::IR::Block::data, Ark::internal::IR::Block::debugName(), Ark::internal::IR::Entity::filename(), Ark::internal::IR::Entity::hasLabel(), Ark::internal::Logger::info(), Ark::internal::IR::Entity::inst(), isBuiltinProxy(), Ark::internal::IR::Entity::label(), m_current_label, Ark::internal::Pass::m_logger, Ark::internal::IR::Block::metadata, Ark::internal::IR::Block::metadataRepr(), Ark::internal::IR::Entity::relatedResourceId(), Ark::internal::IR::Entity::replaceLabel(), Ark::internal::IR::Entity::secondaryArg(), and Ark::internal::IR::Entity::sourceLine().
Referenced by process().
|
nodiscardnoexcept |
Return the IR blocks (one per scope)
Definition at line 81 of file IRInliner.cpp.
References m_ir.
Referenced by Ark::Welder::generateBytecode().
|
staticnodiscardprivate |
Check if an IR block represents a builtin proxy, and return its CALL instruction if it is.
| block | IR block |
Definition at line 128 of file IRInliner.cpp.
References Ark::internal::IR::Block::data, and Ark::internal::IR::Label.
Referenced by inlineBlock().
| void Ark::internal::IRInliner::process | ( | const std::vector< IR::Block > & | pages, |
| const std::vector< std::string > & | symbols, | ||
| const std::vector< ValTableElem > & | values, | ||
| IR::label_t | last_label ) |
Attempt to inline IR blocks to avoid function calls when possible.
| 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 |
| last_label | last label generated by the AST lowerer |
Definition at line 14 of file IRInliner.cpp.
References blockToInlineInCall(), Constant, Ark::internal::IR::Block::data, extractPagesMetadata(), Ark::internal::IR::Block::InitWithMetadata(), inlineBlock(), Ark::internal::IR::Label, m_current_label, m_ir, Ark::internal::Pass::m_logger, m_symbols, m_values, Symbol, Ark::internal::Logger::traceEnd(), and Ark::internal::Logger::traceStart().
Referenced by Ark::Welder::generateBytecode().
|
private |
Definition at line 73 of file IRInliner.hpp.
Referenced by inlineBlock(), and process().
|
private |
Definition at line 71 of file IRInliner.hpp.
Referenced by extractPagesMetadata().
|
private |
Definition at line 68 of file IRInliner.hpp.
Referenced by intermediateRepresentation(), and process().
|
private |
Definition at line 69 of file IRInliner.hpp.
Referenced by extractPagesMetadata(), and process().
|
private |
Definition at line 72 of file IRInliner.hpp.
Referenced by extractPagesMetadata().
|
private |
Definition at line 70 of file IRInliner.hpp.
Referenced by extractPagesMetadata(), and process().