-
Notifications
You must be signed in to change notification settings - Fork 1
/
AtomiccIR.h
195 lines (170 loc) · 5.75 KB
/
AtomiccIR.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
Copyright (C) 2018, The Connectal Project
This program is free software; you can redistribute it and/or modify
it under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __ATOMICIR_H__
#define __ATOMICIR_H__
#include <stdio.h>
#include <string>
#include <list>
#include <set>
#include <map>
#define MAX_READ_LINE 10000000
static inline std::string autostr(uint64_t X, bool isNeg = false) {
char Buffer[21];
char *BufPtr = std::end(Buffer);
if (X == 0) *--BufPtr = '0'; // Handle special case...
while (X) {
*--BufPtr = '0' + char(X % 10);
X /= 10;
}
if (isNeg) *--BufPtr = '-'; // Add negative sign...
return std::string(BufPtr, std::end(Buffer));
}
static bool inline endswith(std::string str, std::string suffix)
{
int skipl = str.length() - suffix.length();
return skipl >= 0 && str.substr(skipl) == suffix;
}
static bool inline startswith(std::string str, std::string suffix)
{
return str.substr(0, suffix.length()) == suffix;
}
typedef struct ACCExpr {
std::list<ACCExpr *>operands;
std::string value;
} ACCExpr;
typedef struct {
ACCExpr *target;
ACCExpr *source;
std::string type;
bool isForward;
} InterfaceConnectType;
enum {MetaNone, MetaRead, MetaInvoke, MetaMax};
typedef std::set<std::string> MetaSet;
typedef std::map<std::string,MetaSet> MetaRef;
typedef struct {
ACCExpr *dest;
ACCExpr *value;
ACCExpr *cond;
std::string clockName;
} StoreListElement;
typedef struct {
ACCExpr *dest;
ACCExpr *value;
ACCExpr *cond;
std::string type;
} LetListElement;
typedef struct {
ACCExpr *value;
ACCExpr *cond;
} AssertListElement;
typedef struct {
ACCExpr *value;
ACCExpr *cond;
bool isAction;
bool isAsync;
} CallListElement;
typedef struct {
std::string name;
std::string type;
std::string init;
} ParamElement;
typedef struct {
std::string name;
std::string type;
} UnionItem;
typedef struct {
std::string type;
bool noReplace;
} AllocaItem;
typedef struct {
ACCExpr *cond;
std::string var;
ACCExpr *init;
ACCExpr *limit;
ACCExpr *incr;
std::string body;
} GenerateForItem;
typedef struct {
ACCExpr *cond;
std::string var;
ACCExpr *init;
ACCExpr *limit;
ACCExpr *incr;
ACCExpr *sub;
std::string body;
} InstantiateForItem;
typedef struct {
ACCExpr *guard;
ACCExpr *subscript;
std::string generateSection;
std::string name;
bool isRule;
bool action;
bool async;
std::list<StoreListElement *> storeList;
std::list<LetListElement *> letList;
std::list<AssertListElement *> assertList;
std::list<CallListElement *> callList;
std::list<CallListElement *> printfList;
std::string type;
std::list<ParamElement> params;
std::list<GenerateForItem> generateFor;
std::list<InstantiateForItem> instantiateFor;
std::map<std::string, AllocaItem> alloca;
std::list<InterfaceConnectType> interfaceConnect; // from __connectInterface() processing
MetaRef meta[MetaMax];
} MethodInfo;
typedef struct {
std::string fldName;
std::string vecCount;
std::string type;
std::string clockName;
bool isPtr;
bool isInput; // used for verilog interfaces
bool isOutput; // used for verilog interfaces
bool isInout; // used for verilog interfaces
std::string isParameter; // used for verilog interfaces (initial value)
bool isShared; // used for __shared (common CSE) support
bool isLocalInterface; // interface declaration that is used to connect to local objects (does not appear in module signature)
bool isExternal; // used for non-heirarchical references
} FieldElement;
typedef struct ModuleIR {
std::string name;
std::list<std::string> metaList;
std::list<std::string> softwareName;
std::list<MethodInfo *> methods;
std::map<std::string, MethodInfo *> generateBody;
std::map<std::string, std::string> priority; // indexed by rulename, result is 'high'/etc
std::list<FieldElement> fields;
std::map<std::string, std::string> moduleParams;
std::list<UnionItem> unionList;
std::list<FieldElement> interfaces;
std::list<FieldElement> parameters;
std::list<InterfaceConnectType> interfaceConnect;
std::map<std::string, std::string> overTable;
int genvarCount;
std::string isTrace;
bool isExt;
bool isInterface;
bool isStruct;
bool isSerialize;
bool isVerilog;
bool isPrintf;
bool isTopModule;
bool transformGeneric;
std::string interfaceVecCount;
std::string interfaceName;
std::string sourceFilename;
} ModuleIR;
#endif /* __ATOMICIR_H__ */