-
Notifications
You must be signed in to change notification settings - Fork 0
/
trance_fun.h
171 lines (113 loc) · 3.59 KB
/
trance_fun.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//Copyright 2019 Hust.
//Author: HYL
//Descriptor:
/* This file include all trance fun that dedicate how to trance instr
*/
#include <iostream>
#include "memory_manage_data.h"
#include "memory_manage_reg.h"
#include "key_data.h"
#ifndef _TRANCE_FUN_H_
#define _TRANCE_FUN_H_
using namespace std;
/*During the transform of some statement like the
*control statement in tranceBr fun, we should use
*the last instr infomation
*/
static string lastInstrName(" ");
/*record how many parameter have been deliver.
*for the fun getRegValue_funPara
*/
static int indexNumPara = 0;
/*record a fun have how many parameter
*/
static int numPara = 0;
/*firstFun is used for main fun*/
static bool firstFun = true;
//In IR instr there are same addr between two different IR_var_name
//EX: %4 and %3 have same actual addr.
//we record the message, that we just need to allocate
static unordered_map<string, string> IR_var_correspond_map;
//clear some special comma in the singleLine
void ChangeComma(string&);
//the beginning of program, deal with the enter and inerrupt
void ProgramBegin();
//the interrupt of the program
void ProgramHint();
//core code of add, and, xor and other
void CoreFunOfLogicOperator(SplitWord, string, string);
//for load instr
void TranceLoad(SplitWord, string);
//for store instr
void TranceStore(SplitWord, string);
//for alloca instr
void TranceAlloca(SplitWord, string);
//for add instr
void TranceAdd(SplitWord, string);
//for sub instr
void TranceSub(SplitWord, string);
//for cmp instr
void TranceFcmp(SplitWord, string);
//for jump instr
void TranceBr(SplitWord, string);
//for zext instr
void TranceZext(SplitWord, string);
//for label instr
void TranceLabel(SplitWord, string);
//for global var
void TranceGlobal(SplitWord, string);
//for fun
void TranceDefine(SplitWord, string);
//for call
void TranceCall(SplitWord, string);
//for and
void TranceAnd(SplitWord, string);
//for or
void TranceOr(SplitWord, string);
//for xor
void TranceXor(SplitWord, string);
//for shl(不带进位的向左移位)
void TranceShl(SplitWord, string);
//for ashr(不带进位的向右移位)
void TranceAshr(SplitWord, string);
//for phi
void TrancePhi(SplitWord, string);
//for constant
void TranceConstant(SplitWord, string);
//fro struct
void TranceType(SplitWord, string);
void TranceGetelementptr(SplitWord, string);
void TranceBitcast(SplitWord, string);
void TranceSext(SplitWord, string);
void TranceTrunc(SplitWord, string);
void TranceSelect(SplitWord, string);
void getDataFromInstr(vector<string> &, SplitWord);
void GetElemFromTwoDimensionArray(vector<string> &, SplitWord);
//get array elem num
int GetArrayElemNum(SplitWord);
string GetArrayElemType(SplitWord);
//change string to int
int getNum(string);
//get struct value from IR instr
vector<string> GetStructValueFromIRInstr(SplitWord);
//get parameter name and parameter type when we deal with
//call fun
void GetParameterNameAndParameterType(SplitWord, \
vector<string>&, \
vector<string>&);
//deal with gdb statement
void TranceGdb(SplitWord, string, string, unordered_map<string, string>&);
//process the first gdb info
void TranceFirstGdb(SplitWord, string);
//deal with switch statement
void TranceSwitch(SplitWord, string);
void TranceLabelSwitch(SplitWord, string);
void TranceSwitchEnd(SplitWord, string);
void TranceMul(SplitWord, string);
void TranceSdiv(SplitWord, string);
void TrancePtrToInt(SplitWord, string);
void CheckDifferentSignal(string, string, string, string);
void TranceRem(SplitWord, string);
//for ret instr
void TranceRet(SplitWord, string);
#endif