-
Notifications
You must be signed in to change notification settings - Fork 0
/
ir.h
59 lines (51 loc) · 1.2 KB
/
ir.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
//
// Created by whz on 15-11-20.
//
//
// 中间代码相关模块
//
#ifndef __IR_H__
#define __IR_H__
#include "lib.h"
#include <stdio.h>
typedef struct DagNode_ *pDagNode;
typedef struct Operand_ *Operand;
typedef struct Block *pBlock;
typedef struct {
int liveness;
int next_use;
} OptimizeInfo;
typedef struct {
IR_Type type;
union {
struct {
Operand rd; // 目的操作数
Operand rs; // 第一源操作数
Operand rt; // 第二源操作数
};
Operand operand[NR_OPE];
};
int block;
pDagNode depend;
union {
struct {
OptimizeInfo rd_info;
OptimizeInfo rs_info;
OptimizeInfo rt_info;
};
OptimizeInfo info[NR_OPE];
};
} IR;
//
// 中间代码模块对外接都口
//
int new_instr(IR_Type type, Operand rs, Operand rt, Operand rd);
void print_instr(FILE *stream);
IR_Type get_relop(const char *sym);
int replace_operand_global(Operand newbie, Operand old);
bool is_const(Operand ope);
Operand calc_const(IR_Type op, Operand left, Operand right);
int is_branch(IR *pIR);
bool can_jump(IR *pIR);
const char *ir_to_s(IR *);
#endif // __IR_H__