ArkScript
A small, fast, functional and scripting language for video games
IROptimizer.hpp
Go to the documentation of this file.
1
/**
2
* @file IROptimizer.hpp
3
* @author Alexandre Plateau (
[email protected]
)
4
* @brief Optimize IR based on IR entity grouped by 2 (or more)
5
* @version 0.2
6
* @date 2024-10-11
7
*
8
* @copyright Copyright (c) 2024
9
*
10
*/
11
#ifndef ARK_COMPILER_INTERMEDIATEREPRESENTATION_IROPTIMIZER_HPP
12
#define ARK_COMPILER_INTERMEDIATEREPRESENTATION_IROPTIMIZER_HPP
13
14
#include <
Ark/Platform.hpp
>
15
#include <
Ark/Logger.hpp
>
16
#include <
Ark/Compiler/ValTableElem.hpp
>
17
#include <
Ark/Compiler/IntermediateRepresentation/Entity.hpp
>
18
19
#include <optional>
20
21
namespace
Ark::internal
22
{
23
class
ARK_API
IROptimizer
final
24
{
25
public
:
26
/**
27
* @brief Create a new IROptimizer
28
*
29
* @param debug debug level
30
*/
31
explicit
IROptimizer
(
unsigned
debug);
32
33
/**
34
* @brief Turn a given IR into bytecode
35
*
36
* @param pages list of lists of IR entities generated by the compiler
37
* @param symbols symbol table generated by the compiler
38
* @param values value table generated by the compiler
39
*/
40
void
process(
const
std::vector<IR::Block>& pages,
const
std::vector<std::string>& symbols,
const
std::vector<ValTableElem>& values);
41
42
/**
43
* @brief Return the IR blocks (one per scope)
44
*
45
* @return const std::vector<Block>&
46
*/
47
[[nodiscard]]
const
std::vector<IR::Block>& intermediateRepresentation()
const
noexcept
;
48
49
private
:
50
Logger
m_logger
;
51
std::vector<IR::Block>
m_ir
;
52
std::vector<std::string>
m_symbols
;
53
std::vector<ValTableElem>
m_values
;
54
55
[[nodiscard]] std::optional<IR::Entity> compactEntities(
const
IR::Entity
& first,
const
IR::Entity
& second);
56
[[nodiscard]] std::optional<IR::Entity> compactEntities(
const
IR::Entity
& first,
const
IR::Entity
& second,
const
IR::Entity
& third);
57
58
[[nodiscard]]
bool
isPositiveNumberInlinable(uint16_t
id
)
const
;
59
};
60
}
61
62
#endif
// ARK_COMPILER_INTERMEDIATEREPRESENTATION_IROPTIMIZER_HPP
Entity.hpp
An entity in the IR is a bundle of information.
Logger.hpp
Internal logger.
ARK_API
#define ARK_API
Definition
Module.hpp:28
Platform.hpp
ArkScript configuration macros.
ValTableElem.hpp
The basic value type handled by the compiler.
Ark::internal::IROptimizer
Definition
IROptimizer.hpp:24
Ark::internal::IROptimizer::m_values
std::vector< ValTableElem > m_values
Definition
IROptimizer.hpp:53
Ark::internal::IROptimizer::m_ir
std::vector< IR::Block > m_ir
Definition
IROptimizer.hpp:51
Ark::internal::IROptimizer::m_logger
Logger m_logger
Definition
IROptimizer.hpp:50
Ark::internal::IROptimizer::m_symbols
std::vector< std::string > m_symbols
Definition
IROptimizer.hpp:52
Ark::internal::IR::Entity
Definition
Entity.hpp:39
Ark::internal::Logger
Definition
Logger.hpp:25
Ark::internal
Definition
Builtins.hpp:26
include
Ark
Compiler
IntermediateRepresentation
IROptimizer.hpp
Generated on Wed Jan 15 2025 19:51:44 for ArkScript by
1.12.0