Mercurial > hg > CbC > CbC_gcc
comparison gcc/go/gofrontend/runtime.def @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 // runtime.def -- runtime functions called by generated code. -*- C++ -*- | |
2 | |
3 // Copyright 2011 The Go Authors. All rights reserved. | |
4 // Use of this source code is governed by a BSD-style | |
5 // license that can be found in the LICENSE file. | |
6 | |
7 // Definitions for the Go runtime functions. | |
8 | |
9 // Parameter type helper macros. | |
10 #define ABFT6(T1, T2, T3, T4, T5, T6) \ | |
11 { RFT_ ## T1, RFT_ ## T2, RFT_ ## T3, RFT_ ## T4, RFT_ ## T5, RFT_ ## T6 } | |
12 #define P0() ABFT6(VOID, VOID, VOID, VOID, VOID, VOID) | |
13 #define P1(T) ABFT6(T, VOID, VOID, VOID, VOID, VOID) | |
14 #define P2(T1, T2) ABFT6(T1, T2, VOID, VOID, VOID, VOID) | |
15 #define P3(T1, T2, T3) ABFT6(T1, T2, T3, VOID, VOID, VOID) | |
16 #define P4(T1, T2, T3, T4) ABFT6(T1, T2, T3, T4, VOID, VOID) | |
17 #define P5(T1, T2, T3, T4, T5) ABFT6(T1, T2, T3, T4, T5, VOID) | |
18 #define P6(T1,T2,T3,T4,T5,T6) ABFT6(T1, T2, T3, T4, T5, T6) | |
19 | |
20 // Result type helper macros. | |
21 #define ABFT2(T1, T2) { RFT_ ## T1, RFT_ ## T2 } | |
22 #define R0() ABFT2(VOID, VOID) | |
23 #define R1(T) ABFT2(T, VOID) | |
24 #define R2(T1, T2) ABFT2(T1, T2) | |
25 | |
26 // Define all the Go runtime functions. The first parameter is the | |
27 // enum code used to refer to the function. The second parameter is | |
28 // the name. The third is the parameter types and the fourth is the | |
29 // result types. | |
30 | |
31 // The standard C memcmp function, used for struct comparisons. | |
32 DEF_GO_RUNTIME(MEMCMP, "__go_memcmp", P3(POINTER, POINTER, UINTPTR), R1(INT)) | |
33 | |
34 // Decode a non-ASCII rune from a string. | |
35 DEF_GO_RUNTIME(DECODERUNE, "runtime.decoderune", P2(STRING, INT), | |
36 R2(RUNE, INT)) | |
37 | |
38 // Concatenate strings. | |
39 DEF_GO_RUNTIME(CONCATSTRINGS, "runtime.concatstrings", P2(POINTER, SLICE), | |
40 R1(STRING)) | |
41 DEF_GO_RUNTIME(CONCATSTRING2, "runtime.concatstring2", | |
42 P2(POINTER, ARRAY2STRING), R1(STRING)) | |
43 DEF_GO_RUNTIME(CONCATSTRING3, "runtime.concatstring3", | |
44 P2(POINTER, ARRAY3STRING), R1(STRING)) | |
45 DEF_GO_RUNTIME(CONCATSTRING4, "runtime.concatstring4", | |
46 P2(POINTER, ARRAY4STRING), R1(STRING)) | |
47 DEF_GO_RUNTIME(CONCATSTRING5, "runtime.concatstring5", | |
48 P2(POINTER, ARRAY5STRING), R1(STRING)) | |
49 | |
50 // Compare two strings for equality. | |
51 DEF_GO_RUNTIME(EQSTRING, "runtime.eqstring", P2(STRING, STRING), R1(BOOL)) | |
52 | |
53 // Compare two strings. | |
54 DEF_GO_RUNTIME(CMPSTRING, "runtime.cmpstring", P2(STRING, STRING), R1(INT)) | |
55 | |
56 // Take a slice of a string. | |
57 DEF_GO_RUNTIME(STRING_SLICE, "__go_string_slice", P3(STRING, INT, INT), | |
58 R1(STRING)) | |
59 | |
60 // Convert an integer to a string. | |
61 DEF_GO_RUNTIME(INTSTRING, "runtime.intstring", P2(POINTER, INT64), R1(STRING)) | |
62 | |
63 // Convert a []byte to a string. | |
64 DEF_GO_RUNTIME(SLICEBYTETOSTRING, "runtime.slicebytetostring", | |
65 P2(POINTER, SLICE), R1(STRING)) | |
66 | |
67 // Convert a []rune to a string. | |
68 DEF_GO_RUNTIME(SLICERUNETOSTRING, "runtime.slicerunetostring", | |
69 P2(POINTER, SLICE), R1(STRING)) | |
70 | |
71 // Convert a string to a []byte. | |
72 DEF_GO_RUNTIME(STRINGTOSLICEBYTE, "runtime.stringtoslicebyte", | |
73 P2(POINTER, STRING), R1(SLICE)) | |
74 | |
75 // Convert a string to a []rune. | |
76 DEF_GO_RUNTIME(STRINGTOSLICERUNE, "runtime.stringtoslicerune", | |
77 P2(POINTER, STRING), R1(SLICE)) | |
78 | |
79 | |
80 // Complex division. | |
81 DEF_GO_RUNTIME(COMPLEX64_DIV, "__go_complex64_div", | |
82 P2(COMPLEX64, COMPLEX64), R1(COMPLEX64)) | |
83 DEF_GO_RUNTIME(COMPLEX128_DIV, "__go_complex128_div", | |
84 P2(COMPLEX128, COMPLEX128), R1(COMPLEX128)) | |
85 | |
86 // Make a slice. | |
87 DEF_GO_RUNTIME(MAKESLICE, "runtime.makeslice", P3(TYPE, INT, INT), | |
88 R1(SLICE)) | |
89 | |
90 DEF_GO_RUNTIME(MAKESLICE64, "runtime.makeslice64", P3(TYPE, INT64, INT64), | |
91 R1(SLICE)) | |
92 | |
93 | |
94 // Make a map. | |
95 DEF_GO_RUNTIME(MAKEMAP, "runtime.makemap", P4(TYPE, INT64, POINTER, POINTER), | |
96 R1(MAP)) | |
97 | |
98 // Build a map from a composite literal. | |
99 DEF_GO_RUNTIME(CONSTRUCT_MAP, "__go_construct_map", | |
100 P5(POINTER, UINTPTR, UINTPTR, UINTPTR, POINTER), | |
101 R1(MAP)) | |
102 | |
103 // Look up a key in a map. | |
104 DEF_GO_RUNTIME(MAPACCESS1, "runtime.mapaccess1", P3(TYPE, MAP, POINTER), | |
105 R1(POINTER)) | |
106 | |
107 // Look up a key in a map when the value is large. | |
108 DEF_GO_RUNTIME(MAPACCESS1_FAT, "runtime.mapaccess1_fat", | |
109 P4(TYPE, MAP, POINTER, POINTER), R1(POINTER)) | |
110 | |
111 // Look up a key in a map returning the value and whether it is | |
112 // present. | |
113 DEF_GO_RUNTIME(MAPACCESS2, "runtime.mapaccess2", P3(TYPE, MAP, POINTER), | |
114 R2(POINTER, BOOL)) | |
115 | |
116 // Look up a key in a map, returning the value and whether it is | |
117 // present, when the value is large. | |
118 DEF_GO_RUNTIME(MAPACCESS2_FAT, "runtime.mapaccess2_fat", | |
119 P4(TYPE, MAP, POINTER, POINTER), R2(POINTER, BOOL)) | |
120 | |
121 // Assignment to a key in a map. | |
122 DEF_GO_RUNTIME(MAPASSIGN, "runtime.mapassign", P3(TYPE, MAP, POINTER), | |
123 R1(POINTER)) | |
124 | |
125 // Delete a key from a map. | |
126 DEF_GO_RUNTIME(MAPDELETE, "runtime.mapdelete", P3(TYPE, MAP, POINTER), R0()) | |
127 | |
128 // Begin a range over a map. | |
129 DEF_GO_RUNTIME(MAPITERINIT, "runtime.mapiterinit", P3(TYPE, MAP, POINTER), | |
130 R0()) | |
131 | |
132 // Range over a map, moving to the next map entry. | |
133 DEF_GO_RUNTIME(MAPITERNEXT, "runtime.mapiternext", P1(POINTER), R0()) | |
134 | |
135 | |
136 // Make a channel. | |
137 DEF_GO_RUNTIME(MAKECHAN, "runtime.makechan", P2(TYPE, INT64), R1(CHAN)) | |
138 | |
139 // Send a value on a channel. | |
140 DEF_GO_RUNTIME(CHANSEND, "runtime.chansend1", P2(CHAN, POINTER), R0()) | |
141 | |
142 // Receive a value from a channel. | |
143 DEF_GO_RUNTIME(CHANRECV1, "runtime.chanrecv1", P2(CHAN, POINTER), R0()) | |
144 | |
145 // Receive a value from a channel returning whether it is closed. | |
146 DEF_GO_RUNTIME(CHANRECV2, "runtime.chanrecv2", P2(CHAN, POINTER), R1(BOOL)) | |
147 | |
148 | |
149 // Start building a select statement. | |
150 DEF_GO_RUNTIME(NEWSELECT, "runtime.newselect", P3(POINTER, INT64, INT32), R0()) | |
151 | |
152 // Add a default clause to a select statement. | |
153 DEF_GO_RUNTIME(SELECTDEFAULT, "runtime.selectdefault", P1(POINTER), R0()) | |
154 | |
155 // Add a send clause to a select statement. | |
156 DEF_GO_RUNTIME(SELECTSEND, "runtime.selectsend", P3(POINTER, CHAN, POINTER), | |
157 R0()) | |
158 | |
159 // Add a receive clause to a select statement. | |
160 DEF_GO_RUNTIME(SELECTRECV, "runtime.selectrecv", | |
161 P4(POINTER, CHAN, POINTER, BOOLPTR), R0()) | |
162 | |
163 // Run a select, returning the index of the selected clause. | |
164 DEF_GO_RUNTIME(SELECTGO, "runtime.selectgo", P1(POINTER), R1(INT)) | |
165 | |
166 | |
167 // Panic. | |
168 DEF_GO_RUNTIME(GOPANIC, "runtime.gopanic", P1(EFACE), R0()) | |
169 | |
170 // Recover. | |
171 DEF_GO_RUNTIME(GORECOVER, "runtime.gorecover", P0(), R1(EFACE)) | |
172 | |
173 // Recover when called directly from defer. | |
174 DEF_GO_RUNTIME(DEFERREDRECOVER, "runtime.deferredrecover", P0(), R1(EFACE)) | |
175 | |
176 // Decide whether this function can call recover. | |
177 DEF_GO_RUNTIME(CANRECOVER, "runtime.canrecover", P1(POINTER), R1(BOOL)) | |
178 | |
179 // Set the return address for defer in a defer thunk. | |
180 DEF_GO_RUNTIME(SETDEFERRETADDR, "runtime.setdeferretaddr", P1(POINTER), | |
181 R1(BOOL)) | |
182 | |
183 // Check for a deferred function in an exception handler. | |
184 DEF_GO_RUNTIME(CHECKDEFER, "runtime.checkdefer", P1(BOOLPTR), R0()) | |
185 | |
186 // Run deferred functions. | |
187 DEF_GO_RUNTIME(DEFERRETURN, "runtime.deferreturn", P1(BOOLPTR), R0()) | |
188 | |
189 // Panic with a runtime error. | |
190 DEF_GO_RUNTIME(RUNTIME_ERROR, "__go_runtime_error", P1(INT32), R0()) | |
191 | |
192 | |
193 // Close. | |
194 DEF_GO_RUNTIME(CLOSE, "runtime.closechan", P1(CHAN), R0()) | |
195 | |
196 | |
197 // Copy. | |
198 DEF_GO_RUNTIME(SLICECOPY, "runtime.slicecopy", P3(SLICE, SLICE, UINTPTR), | |
199 R1(INT)) | |
200 | |
201 // Copy from string. | |
202 DEF_GO_RUNTIME(SLICESTRINGCOPY, "runtime.slicestringcopy", P2(SLICE, STRING), | |
203 R1(INT)) | |
204 | |
205 // Copy of value containing pointers. | |
206 DEF_GO_RUNTIME(TYPEDSLICECOPY, "runtime.typedslicecopy", | |
207 P3(TYPE, SLICE, SLICE), R1(INT)) | |
208 | |
209 | |
210 // Grow a slice for append. | |
211 DEF_GO_RUNTIME(GROWSLICE, "runtime.growslice", P3(TYPE, SLICE, INT), R1(SLICE)) | |
212 | |
213 | |
214 // Register roots (global variables) for the garbage collector. | |
215 DEF_GO_RUNTIME(REGISTER_GC_ROOTS, "runtime.registerGCRoots", P1(POINTER), R0()) | |
216 | |
217 | |
218 // Allocate memory. | |
219 DEF_GO_RUNTIME(NEW, "runtime.newobject", P1(TYPE), R1(POINTER)) | |
220 | |
221 // Start a new goroutine. | |
222 DEF_GO_RUNTIME(GO, "__go_go", P2(FUNC_PTR, POINTER), R0()) | |
223 | |
224 // Defer a function. | |
225 DEF_GO_RUNTIME(DEFERPROC, "runtime.deferproc", P3(BOOLPTR, FUNC_PTR, POINTER), | |
226 R0()) | |
227 | |
228 | |
229 // Convert an empty interface to an empty interface, returning ok. | |
230 DEF_GO_RUNTIME(IFACEE2E2, "runtime.ifaceE2E2", P1(EFACE), R2(EFACE, BOOL)) | |
231 | |
232 // Convert a non-empty interface to an empty interface, returning ok. | |
233 DEF_GO_RUNTIME(IFACEI2E2, "runtime.ifaceI2E2", P1(IFACE), R2(EFACE, BOOL)) | |
234 | |
235 // Convert an empty interface to a non-empty interface, returning ok. | |
236 DEF_GO_RUNTIME(IFACEE2I2, "runtime.ifaceE2I2", P2(TYPE, EFACE), | |
237 R2(IFACE, BOOL)) | |
238 | |
239 // Convert a non-empty interface to a non-empty interface, returning ok. | |
240 DEF_GO_RUNTIME(IFACEI2I2, "runtime.ifaceI2I2", P2(TYPE, IFACE), | |
241 R2(IFACE, BOOL)) | |
242 | |
243 // Convert an empty interface to a pointer type, returning ok. | |
244 DEF_GO_RUNTIME(IFACEE2T2P, "runtime.ifaceE2T2P", P2(TYPE, EFACE), | |
245 R2(POINTER, BOOL)) | |
246 | |
247 // Convert a non-empty interface to a pointer type, return ok. | |
248 DEF_GO_RUNTIME(IFACEI2T2P, "runtime.ifaceI2T2P", P2(TYPE, IFACE), | |
249 R2(POINTER, BOOL)) | |
250 | |
251 // Convert an empty interface to a non-pointer type, returning ok. | |
252 DEF_GO_RUNTIME(IFACEE2T2, "runtime.ifaceE2T2", P3(TYPE, EFACE, POINTER), | |
253 R1(BOOL)) | |
254 | |
255 // Convert a non-empty interface to a non-pointer type, returning ok. | |
256 DEF_GO_RUNTIME(IFACEI2T2, "runtime.ifaceI2T2", P3(TYPE, IFACE, POINTER), | |
257 R1(BOOL)) | |
258 | |
259 // Return the interface method table for the second type converted to | |
260 // the first type which is a (possibly empty) interface type. Panics | |
261 // if the second type is nil (indicating a nil interface value) or if | |
262 // the conversion is not possible. Used for type assertions. This is | |
263 // like REQUIREITAB, but for type assertions. | |
264 DEF_GO_RUNTIME(ASSERTITAB, "runtime.assertitab", P2(TYPE, TYPE), R1(POINTER)) | |
265 | |
266 // Return the interface method table for the second type converted to | |
267 // the first type, which is a non-empty interface type. Return nil if | |
268 // the second type is nil, indicating a nil interface value. Panics | |
269 // if the conversion is not possible. Used for assignments. This is | |
270 // like ASSERTITAB, but for assignments. | |
271 DEF_GO_RUNTIME(REQUIREITAB, "runtime.requireitab", P2(TYPE, TYPE), | |
272 R1(POINTER)) | |
273 | |
274 // Check whether an interface type may be converted to a | |
275 // non-interface type. | |
276 DEF_GO_RUNTIME(ASSERTI2T, "runtime.assertI2T", P3(TYPE, TYPE, TYPE), R0()) | |
277 | |
278 // Return whether we can convert a type to an interface type. | |
279 DEF_GO_RUNTIME(IFACET2IP, "runtime.ifaceT2Ip", P2(TYPE, TYPE), R1(BOOL)) | |
280 | |
281 // Get the type descriptor of an empty interface. | |
282 DEF_GO_RUNTIME(EFACETYPE, "runtime.efacetype", P1(EFACE), R1(TYPE)) | |
283 | |
284 // Get the type descriptor of a non-empty interface. | |
285 DEF_GO_RUNTIME(IFACETYPE, "runtime.ifacetype", P1(IFACE), R1(TYPE)) | |
286 | |
287 | |
288 // Compare two type descriptors for equality. | |
289 DEF_GO_RUNTIME(IFACETYPEEQ, "runtime.ifacetypeeq", P2(TYPE, TYPE), R1(BOOL)) | |
290 | |
291 // Compare two empty interface values. | |
292 DEF_GO_RUNTIME(EFACEEQ, "runtime.efaceeq", P2(EFACE, EFACE), R1(BOOL)) | |
293 | |
294 // Compare an empty interface value to a non-interface value. | |
295 DEF_GO_RUNTIME(EFACEVALEQ, "runtime.efacevaleq", P3(EFACE, TYPE, POINTER), | |
296 R1(BOOL)) | |
297 | |
298 // Compare two non-empty interface values. | |
299 DEF_GO_RUNTIME(IFACEEQ, "runtime.ifaceeq", P2(IFACE, IFACE), R1(BOOL)) | |
300 | |
301 // Compare a non-empty interface value to a non-interface value. | |
302 DEF_GO_RUNTIME(IFACEVALEQ, "runtime.ifacevaleq", P3(IFACE, TYPE, POINTER), | |
303 R1(BOOL)) | |
304 | |
305 // Compare a non-empty interface value to an interface value. | |
306 DEF_GO_RUNTIME(IFACEEFACEEQ, "runtime.ifaceefaceeq", P2(IFACE, EFACE), | |
307 R1(BOOL)) | |
308 | |
309 | |
310 // Set *dst = src where dst is a pointer to a pointer and src is a pointer. | |
311 DEF_GO_RUNTIME(WRITEBARRIERPTR, "runtime.writebarrierptr", | |
312 P2(POINTER, POINTER), R0()) | |
313 | |
314 // Set *dst = *src for an arbitrary type. | |
315 DEF_GO_RUNTIME(TYPEDMEMMOVE, "runtime.typedmemmove", | |
316 P3(TYPE, POINTER, POINTER), R0()) | |
317 | |
318 | |
319 // Lock the printer (for print/println). | |
320 DEF_GO_RUNTIME(PRINTLOCK, "runtime.printlock", P0(), R0()) | |
321 | |
322 // Unlock the printer (for print/println). | |
323 DEF_GO_RUNTIME(PRINTUNLOCK, "runtime.printunlock", P0(), R0()) | |
324 | |
325 // Print a string (for print/println). | |
326 DEF_GO_RUNTIME(PRINTSTRING, "runtime.printstring", P1(STRING), R0()) | |
327 | |
328 // Print a uint64 (for print/println). | |
329 DEF_GO_RUNTIME(PRINTUINT, "runtime.printuint", P1(UINT64), R0()) | |
330 | |
331 // Print a int64 (for print/println). | |
332 DEF_GO_RUNTIME(PRINTINT, "runtime.printint", P1(INT64), R0()) | |
333 | |
334 // Print a float64 (for print/println). | |
335 DEF_GO_RUNTIME(PRINTFLOAT, "runtime.printfloat", P1(FLOAT64), R0()) | |
336 | |
337 // Print a complex128 (for print/println). | |
338 DEF_GO_RUNTIME(PRINTCOMPLEX, "runtime.printcomplex", P1(COMPLEX128), R0()) | |
339 | |
340 // Print a bool (for print/println). | |
341 DEF_GO_RUNTIME(PRINTBOOL, "runtime.printbool", P1(BOOL), R0()) | |
342 | |
343 // Print a pointer/map/channel/function (for print/println). | |
344 DEF_GO_RUNTIME(PRINTPOINTER, "runtime.printpointer", P1(POINTER), R0()) | |
345 | |
346 // Print an empty interface (for print/println). | |
347 DEF_GO_RUNTIME(PRINTEFACE, "runtime.printeface", P1(EFACE), R0()) | |
348 | |
349 // Print a non-empty interface (for print/println). | |
350 DEF_GO_RUNTIME(PRINTIFACE, "runtime.printiface", P1(IFACE), R0()) | |
351 | |
352 // Print a slice (for print/println). | |
353 DEF_GO_RUNTIME(PRINTSLICE, "runtime.printslice", P1(SLICE), R0()) | |
354 | |
355 // Print a space (for println). | |
356 DEF_GO_RUNTIME(PRINTSP, "runtime.printsp", P0(), R0()) | |
357 | |
358 // Print a newline (for println). | |
359 DEF_GO_RUNTIME(PRINTNL, "runtime.printnl", P0(), R0()) | |
360 | |
361 | |
362 // Used for field tracking for data analysis. | |
363 DEF_GO_RUNTIME(FIELDTRACK, "__go_fieldtrack", P1(POINTER), R0()) | |
364 | |
365 | |
366 // Remove helper macros. | |
367 #undef ABFT6 | |
368 #undef ABFT2 | |
369 #undef P0 | |
370 #undef P1 | |
371 #undef P2 | |
372 #undef P3 | |
373 #undef P4 | |
374 #undef P5 | |
375 #undef P6 | |
376 #undef R0 | |
377 #undef R1 | |
378 #undef R2 |