-
Notifications
You must be signed in to change notification settings - Fork 0
/
Middleend.hpp
33 lines (23 loc) · 1.14 KB
/
Middleend.hpp
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
#ifndef MIDDLEEND_HPP
#define MIDDLEEND_HPP
#include "AbstractSyntaxTreeDumpLanguageAnalyser.hpp"
class Middleend {
public:
Middleend();
void MiddleendDtor();
void optimize(const char *abstractSyntaxTreeFileName);
private:
AbstractSyntaxTreeDumpLanguageAnalyser analyser;
void lookForDifferentiationOperatorRecursively(AbstractSyntaxTree::Node *node);
AbstractSyntaxTree::Node *differentiateNode(const AbstractSyntaxTree::Node *node);
AbstractSyntaxTree::Node *differentiateNodeRecursively(const AbstractSyntaxTree::Node *node);
void optimizeTree(AbstractSyntaxTree::Node **root);
bool optimizeNeutralElementNodesRecursively(AbstractSyntaxTree::Node **node);
bool optimizeEvaluableNodesRecursively(AbstractSyntaxTree::Node *node);
bool optimizeSpecialConstantNodesRecursively(AbstractSyntaxTree::Node **node);
static void optimizeLeftNode(AbstractSyntaxTree::Node **node);
static void optimizeRightNode(AbstractSyntaxTree::Node **node);
static void zeroNode(AbstractSyntaxTree::Node *node);
static bool isConstant(const AbstractSyntaxTree::Node *node, int constant);
};
#endif /* MIDDLEEND_HPP */