-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathir_transformer.h
67 lines (54 loc) · 1.96 KB
/
ir_transformer.h
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
64
65
66
67
#ifndef _IR_TRANSFORMER_H
#define _IR_TRANSFORMER_H
#include "intermediate.h"
#include "debugprint.h"
namespace IR {
class IRTransformer: public DebugPrinter {
private:
IREnvironment *ir_env;
void pullStatementsOutOfTwoOperands(Expression *&left,
Expression *&right, StatementSequence *&collected_statements);
void canonicalizeMemoryExp(Expression *&exp);
void canonicalizeBinaryOpExp(Expression *&exp);
void canonicalizeCallExp(Expression *&exp,
Expression *parentExpression, Statement *parentStatement);
void combineStatExpSequences(StatExpSequence *exp);
void canonicalizeMoveStatement(Statement *&statm);
void canonicalizeExpressionStatement(Statement *&statm);
void canonicalizeJumpStatement(Statement *&statm);
void canonicalizeCondJumpStatement(Statement *&statm);
void doChildrenAndMergeChildStatSequences(StatementSequence *statm);
struct StatementBlock {
std::list<Statement *> statements;
Label *start_label;
bool used_in_trace;
};
struct BlockSequence {
std::list<StatementBlock> blocks;
Label *finish_label;
};
typedef std::list<StatementBlock*> BlockOrdering;
struct BlockInfo {
StatementBlock *block;
std::list<StatementBlock *>::iterator position_in_remaining_list;
BlockInfo(StatementBlock *_block,
std::list<StatementBlock *>::iterator _position) :
block(_block), position_in_remaining_list(_position) {}
};
void splitToBlocks(StatementSequence *sequence, BlockSequence &blocks);
void arrangeBlocksForPrettyJumps(BlockSequence &blocks,
BlockOrdering &new_order);
public:
IRTransformer(IREnvironment *_ir_env) : ir_env(_ir_env),
DebugPrinter("canonicalize.log") {}
/**
* Either parentExpression or parentStatement (or both) must be NULL
*/
void canonicalizeExpression(Expression *&exp,
Expression *parentExpression, Statement *parentStatement);
void canonicalizeStatement(Statement *&statm);
void arrangeJumps(StatementSequence *sequence);
void arrangeJumpsInExpression(Expression *expression);
};
}
#endif