1 /*
2  * Copyright (c) 2018, NVIDIA CORPORATION.  All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef ILMUTIL_H_
19 #define ILMUTIL_H_
20 
21 #include "gbldefs.h"
22 #include "symtab.h"
23 #include "ilmtp.h"
24 
25 /**
26    \brief ...
27  */
28 ILM_T *save_ilms0(void *area);
29 
30 /**
31    \brief ...
32  */
33 ILM_T *save_ilms(int area);
34 
35 /**
36    \brief ...
37  */
38 int ad1ilm(int opc);
39 
40 /**
41    \brief ...
42  */
43 int ad2ilm(int opc, int opr1);
44 
45 /**
46    \brief ...
47  */
48 int ad3ilm(int opc, int opr1, int opr2);
49 
50 /**
51    \brief ...
52  */
53 int ad4ilm(int opc, int opr1, int opr2, int opr3);
54 
55 /**
56    \brief ...
57  */
58 int ad5ilm(int opc, int opr1, int opr2, int opr3, int opr4);
59 
60 /**
61    \brief ...
62  */
63 int adNilm(int n, int opc, ...);
64 
65 /**
66    \brief ...
67  */
68 int count_ilms(void);
69 
70 /**
71    \brief ...
72  */
73 int _dumponeilm(ILM_T *ilm_base, int i, int check);
74 
75 /**
76    \brief ...
77  */
78 int get_entry(void);
79 
80 /**
81    \brief FIXME
82    \return index of callee for given operation, which must have type IMTY_PROC.
83    index+k is the index for the kth argument.  index-1 is the index of the dtype
84    for the function signature if there is one.
85  */
86 int ilm_callee_index(ILM_OP opc);
87 
88 /**
89    \brief Determine if the ILM performs a call and the call has a pointer to a
90    return slot.  If so, return the operand index of the slot.  Otherwise return
91    0.  Returns 0 for non-call ILMs.
92  */
93 int ilm_return_slot_index(ILM_T *ilmp);
94 
95 /**
96    \brief ...
97  */
98 int rdgilms(int mode);
99 
100 /**
101    \brief ...
102  */
103 int rdilms(void);
104 
105 /**
106    \brief ...
107  */
108 long get_ilmpos(void);
109 
110 /**
111    \brief ...
112  */
113 long get_ilmstart(void);
114 
115 #ifdef ST_UNKNOWN /* Use ST_UNKNOWN to detect if SYMTYPE is defined. */
116 /**
117    \brief If a function returning a value of type ret_type needs to have a
118    pointer to a temporary for possible use as as return slot, return the SYMTYPE
119    for that temporary.  Otherwise return ST_UNKNOWN.
120 
121    The result is a property of ILM, not the ABI.
122  */
123 SYMTYPE ilm_symtype_of_return_slot(DTYPE ret_type);
124 #endif
125 
126 /**
127    \brief ...
128  */
129 void add_ilms(ILM_T *p);
130 
131 /**
132    \brief ...
133  */
134 void addlabel(int sptr);
135 
136 /**
137    \brief ...
138  */
139 void dmpilms(void);
140 
141 /**
142    \brief ...
143  */
144 void _dumpilms(ILM_T *ilm_base, int check);
145 
146 /**
147    \brief ...
148  */
149 void dumpilms(void);
150 
151 /**
152    \brief ...
153  */
154 void dumpilmtree(int ilmptr);
155 
156 /**
157    \brief ...
158  */
159 void dumpilmtrees(void);
160 
161 /**
162    \brief ...
163  */
164 void dumpsingleilm(ILM_T *ilm_base, int i);
165 
166 /**
167    \brief ...
168  */
169 void fini_ilm(void);
170 
171 /**
172    \brief ...
173  */
174 void fini_next_gilm(void);
175 
176 /**
177    \brief ...
178  */
179 void gwrilms(int nilms);
180 
181 /**
182    \brief ...
183  */
184 void init_global_ilm_mode(void);
185 
186 /**
187    \brief ...
188  */
189 void init_global_ilm_position(void);
190 
191 /**
192    \brief ...
193  */
194 void init_ilm(int ilmsize);
195 
196 /**
197    \brief ...
198  */
199 void init_next_gilm(void);
200 
201 /**
202    \brief ...
203  */
204 void mkbranch(int ilmptr, int truelb, int flag);
205 
206 /**
207    \brief ...
208  */
209 void reloc_ilms(ILM_T *p);
210 
211 /**
212    \brief ...
213  */
214 void reset_global_ilm_position(void);
215 
216 /**
217    \brief ...
218  */
219 void restartilms(void);
220 
221 /**
222    \brief ...
223  */
224 void RestoreGilms(FILE *fil);
225 
226 /**
227    \brief ...
228  */
229 void rewindilms(void);
230 
231 /**
232    \brief ...
233  */
234 void SaveGilms(FILE *fil);
235 
236 /**
237    \brief ...
238  */
239 void set_gilmb_mode(int mode);
240 
241 /**
242    \brief ...
243  */
244 void set_ilmpos(long pos);
245 
246 /**
247    \brief ...
248  */
249 void set_ilmstart(int start);
250 
251 /**
252    \brief ...
253  */
254 void swap_next_gilm(void);
255 
256 /**
257    \brief ...
258  */
259 void wrilms(int linenum);
260 
261 #endif // ILMUTIL_H_
262