-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptimizations.h
More file actions
executable file
·63 lines (40 loc) · 1.61 KB
/
optimizations.h
File metadata and controls
executable file
·63 lines (40 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// Created by tadzi on 12/7/2022.
//
#ifndef COMPILERS_2_OPTIMIZATIONS_H
#define COMPILERS_2_OPTIMIZATIONS_H
#include "cfg.h"
#include "cfg_transform.h"
#include "live_vregs.h"
class ConstantPropagation : public ControlFlowGraphTransform {
private:
std::shared_ptr<ControlFlowGraph> cfg;
public:
explicit ConstantPropagation(const std::shared_ptr<ControlFlowGraph>& cfg);
std::shared_ptr<ControlFlowGraph> transform_cfg() override;
std::shared_ptr<InstructionSequence> transform_basic_block(const InstructionSequence *orig_bb) override;
static std::shared_ptr<InstructionSequence> constant_propagation(InstructionSequence *block);
static bool match_hl(int base, int hl_opcode);
};
class CopyPropagation : public ControlFlowGraphTransform {
private:
std::shared_ptr<ControlFlowGraph> cfg;
std::map<int, Operand> constants;
public:
explicit CopyPropagation(const std::shared_ptr<ControlFlowGraph>& cfg);
std::shared_ptr<InstructionSequence> transform_basic_block(const InstructionSequence *orig_bb) override;
static bool match_hl(int base, int hl_opcode);
std::shared_ptr<InstructionSequence> copy_propagation(InstructionSequence *block);
static bool is_caller_saved(int vreg_num);
};
class LiveRegisters : public ControlFlowGraphTransform {
private:
LiveVregs m_live_vregs;
public:
explicit LiveRegisters(const std::shared_ptr<ControlFlowGraph> &cfg);
~LiveRegisters();
std::shared_ptr<InstructionSequence>
transform_basic_block(const InstructionSequence *orig_bb) override;
bool is_caller_saved(int vreg_num);
};
#endif //COMPILERS_2_OPTIMIZATIONS_H