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.
32DEF_GO_RUNTIME(MEMCMP, "__builtin_memcmp", P3(POINTER, POINTER, UINTPTR), R1(INT32))
33
34// Decode a non-ASCII rune from a string.
35DEF_GO_RUNTIME(DECODERUNE, "runtime.decoderune", P2(STRING, INT),
36	       R2(RUNE, INT))
37
38// Concatenate strings.
39DEF_GO_RUNTIME(CONCATSTRINGS, "runtime.concatstrings",
40               P3(POINTER, POINTER, INT), R1(STRING))
41
42// Compare two strings.
43DEF_GO_RUNTIME(CMPSTRING, "runtime.cmpstring", P2(STRING, STRING), R1(INT))
44
45// Convert an integer to a string.
46DEF_GO_RUNTIME(INTSTRING, "runtime.intstring", P2(POINTER, INT64), R1(STRING))
47
48// Convert a []byte to a string.
49DEF_GO_RUNTIME(SLICEBYTETOSTRING, "runtime.slicebytetostring",
50	       P2(POINTER, SLICE), R1(STRING))
51
52// Convert a []rune to a string.
53DEF_GO_RUNTIME(SLICERUNETOSTRING, "runtime.slicerunetostring",
54	       P2(POINTER, SLICE), R1(STRING))
55
56// Convert a string to a []byte.
57DEF_GO_RUNTIME(STRINGTOSLICEBYTE, "runtime.stringtoslicebyte",
58	       P2(POINTER, STRING), R1(SLICE))
59
60// Convert a string to a []rune.
61DEF_GO_RUNTIME(STRINGTOSLICERUNE, "runtime.stringtoslicerune",
62	       P2(POINTER, STRING), R1(SLICE))
63
64
65// Complex division.
66DEF_GO_RUNTIME(COMPLEX64_DIV, "__go_complex64_div",
67	       P2(COMPLEX64, COMPLEX64), R1(COMPLEX64))
68DEF_GO_RUNTIME(COMPLEX128_DIV, "__go_complex128_div",
69	       P2(COMPLEX128, COMPLEX128), R1(COMPLEX128))
70
71// Make a slice.
72DEF_GO_RUNTIME(MAKESLICE, "runtime.makeslice", P3(TYPE, INT, INT),
73	       R1(POINTER))
74
75DEF_GO_RUNTIME(MAKESLICE64, "runtime.makeslice64", P3(TYPE, INT64, INT64),
76	       R1(POINTER))
77
78
79// Make a map with a hint and an (optional, unused) map structure.
80DEF_GO_RUNTIME(MAKEMAP, "runtime.makemap", P3(TYPE, INT, POINTER),
81		R1(MAP))
82DEF_GO_RUNTIME(MAKEMAP64, "runtime.makemap64", P3(TYPE, INT64, POINTER),
83		R1(MAP))
84
85// Make a map with no hint, or a small constant hint.
86DEF_GO_RUNTIME(MAKEMAP_SMALL, "runtime.makemap_small", P0(), R1(MAP))
87
88// Build a map from a composite literal.
89DEF_GO_RUNTIME(CONSTRUCT_MAP, "__go_construct_map",
90	       P5(POINTER, UINTPTR, UINTPTR, UINTPTR, POINTER),
91	       R1(MAP))
92
93// Look up a key in a map.
94DEF_GO_RUNTIME(MAPACCESS1, "runtime.mapaccess1", P3(TYPE, MAP, POINTER),
95	       R1(POINTER))
96
97// Look up a uint32 key in a map.
98DEF_GO_RUNTIME(MAPACCESS1_FAST32, "runtime.mapaccess1_fast32",
99               P3(TYPE, MAP, UINT32), R1(POINTER))
100
101// Look up a uint64 key in a map.
102DEF_GO_RUNTIME(MAPACCESS1_FAST64, "runtime.mapaccess1_fast64",
103               P3(TYPE, MAP, UINT64), R1(POINTER))
104
105// Look up a string key in a map.
106DEF_GO_RUNTIME(MAPACCESS1_FASTSTR, "runtime.mapaccess1_faststr",
107               P3(TYPE, MAP, STRING), R1(POINTER))
108
109// Look up a key in a map when the value is large.
110DEF_GO_RUNTIME(MAPACCESS1_FAT, "runtime.mapaccess1_fat",
111	       P4(TYPE, MAP, POINTER, POINTER), R1(POINTER))
112
113// Look up a key in a map returning the value and whether it is
114// present.
115DEF_GO_RUNTIME(MAPACCESS2, "runtime.mapaccess2", P3(TYPE, MAP, POINTER),
116	       R2(POINTER, BOOL))
117
118// Look up a uint32 key in a map returning the value and whether
119// it is present.
120DEF_GO_RUNTIME(MAPACCESS2_FAST32, "runtime.mapaccess2_fast32",
121               P3(TYPE, MAP, UINT32), R2(POINTER, BOOL))
122
123// Look up a uint64 key in a map returning the value and whether
124// it is present.
125DEF_GO_RUNTIME(MAPACCESS2_FAST64, "runtime.mapaccess2_fast64",
126               P3(TYPE, MAP, UINT64), R2(POINTER, BOOL))
127
128// Look up a string key in a map returning the value and whether
129// it is present.
130DEF_GO_RUNTIME(MAPACCESS2_FASTSTR, "runtime.mapaccess2_faststr",
131               P3(TYPE, MAP, STRING), R2(POINTER, BOOL))
132
133// Look up a key in a map, returning the value and whether it is
134// present, when the value is large.
135DEF_GO_RUNTIME(MAPACCESS2_FAT, "runtime.mapaccess2_fat",
136	       P4(TYPE, MAP, POINTER, POINTER), R2(POINTER, BOOL))
137
138// Assignment to a key in a map.
139DEF_GO_RUNTIME(MAPASSIGN, "runtime.mapassign", P3(TYPE, MAP, POINTER),
140	       R1(POINTER))
141
142// Assignment to a uint32 key in a map.
143DEF_GO_RUNTIME(MAPASSIGN_FAST32, "runtime.mapassign_fast32",
144               P3(TYPE, MAP, UINT32), R1(POINTER))
145
146// Assignment to a uint64 key in a map.
147DEF_GO_RUNTIME(MAPASSIGN_FAST64, "runtime.mapassign_fast64",
148               P3(TYPE, MAP, UINT64), R1(POINTER))
149
150// Assignment to a 32-bit pointer key in a map.
151DEF_GO_RUNTIME(MAPASSIGN_FAST32PTR, "runtime.mapassign_fast32ptr",
152               P3(TYPE, MAP, POINTER), R1(POINTER))
153
154// Assignment to a 64-bit pointer key in a map.
155DEF_GO_RUNTIME(MAPASSIGN_FAST64PTR, "runtime.mapassign_fast64ptr",
156               P3(TYPE, MAP, POINTER), R1(POINTER))
157
158// Assignment to a string key in a map.
159DEF_GO_RUNTIME(MAPASSIGN_FASTSTR, "runtime.mapassign_faststr",
160               P3(TYPE, MAP, STRING), R1(POINTER))
161
162// Delete a key from a map.
163DEF_GO_RUNTIME(MAPDELETE, "runtime.mapdelete", P3(TYPE, MAP, POINTER), R0())
164
165// Delete a uint32 key from a map.
166DEF_GO_RUNTIME(MAPDELETE_FAST32, "runtime.mapdelete_fast32",
167               P3(TYPE, MAP, UINT32), R0())
168
169// Delete a uint64 key from a map.
170DEF_GO_RUNTIME(MAPDELETE_FAST64, "runtime.mapdelete_fast64",
171               P3(TYPE, MAP, UINT64), R0())
172
173// Delete a string key from a map.
174DEF_GO_RUNTIME(MAPDELETE_FASTSTR, "runtime.mapdelete_faststr",
175               P3(TYPE, MAP, STRING), R0())
176
177// Begin a range over a map.
178DEF_GO_RUNTIME(MAPITERINIT, "runtime.mapiterinit", P3(TYPE, MAP, POINTER),
179	       R0())
180
181// Range over a map, moving to the next map entry.
182DEF_GO_RUNTIME(MAPITERNEXT, "runtime.mapiternext", P1(POINTER), R0())
183
184// Clear a map.
185DEF_GO_RUNTIME(MAPCLEAR, "runtime.mapclear", P2(TYPE, MAP), R0())
186
187
188// Make a channel.
189DEF_GO_RUNTIME(MAKECHAN, "runtime.makechan", P2(TYPE, INT), R1(CHAN))
190DEF_GO_RUNTIME(MAKECHAN64, "runtime.makechan64", P2(TYPE, INT64), R1(CHAN))
191
192// Send a value on a channel.
193DEF_GO_RUNTIME(CHANSEND, "runtime.chansend1", P2(CHAN, POINTER), R0())
194
195// Receive a value from a channel.
196DEF_GO_RUNTIME(CHANRECV1, "runtime.chanrecv1", P2(CHAN, POINTER), R0())
197
198// Receive a value from a channel returning whether it is closed.
199DEF_GO_RUNTIME(CHANRECV2, "runtime.chanrecv2", P2(CHAN, POINTER), R1(BOOL))
200
201
202// Run a select, returning the index of the selected clause and
203// whether that channel received a value.
204DEF_GO_RUNTIME(SELECTGO, "runtime.selectgo", P3(POINTER, POINTER, INT),
205	       R2(INT, BOOL))
206
207// Non-blocking send a value on a channel, used for two-case select
208// statement with a default case.
209DEF_GO_RUNTIME(SELECTNBSEND, "runtime.selectnbsend", P2(CHAN, POINTER), R1(BOOL))
210
211// Non-blocking receive a value from a channel, used for two-case select
212// statement with a default case.
213DEF_GO_RUNTIME(SELECTNBRECV, "runtime.selectnbrecv", P2(POINTER, CHAN), R1(BOOL))
214
215// Non-blocking tuple receive from a channel, used for two-case select
216// statement with a default case.
217DEF_GO_RUNTIME(SELECTNBRECV2, "runtime.selectnbrecv2", P3(POINTER, POINTER, CHAN),
218               R1(BOOL))
219
220// Block execution.  Used for zero-case select.
221DEF_GO_RUNTIME(BLOCK, "runtime.block", P0(), R0())
222
223
224// Panic.
225DEF_GO_RUNTIME(GOPANIC, "runtime.gopanic", P1(EFACE), R0())
226
227// Recover.
228DEF_GO_RUNTIME(GORECOVER, "runtime.gorecover", P0(), R1(EFACE))
229
230// Recover when called directly from defer.
231DEF_GO_RUNTIME(DEFERREDRECOVER, "runtime.deferredrecover", P0(), R1(EFACE))
232
233// Decide whether this function can call recover.
234DEF_GO_RUNTIME(CANRECOVER, "runtime.canrecover", P1(UINTPTR), R1(BOOL))
235
236// Set the return address for defer in a defer thunk.
237DEF_GO_RUNTIME(SETDEFERRETADDR, "runtime.setdeferretaddr", P1(UINTPTR),
238	       R1(BOOL))
239
240// Check for a deferred function in an exception handler.
241DEF_GO_RUNTIME(CHECKDEFER, "runtime.checkdefer", P1(BOOLPTR), R0())
242
243// Run deferred functions.
244DEF_GO_RUNTIME(DEFERRETURN, "runtime.deferreturn", P1(BOOLPTR), R0())
245
246
247// Close.
248DEF_GO_RUNTIME(CLOSE, "runtime.closechan", P1(CHAN), R0())
249
250
251// Copy.
252DEF_GO_RUNTIME(SLICECOPY, "runtime.slicecopy", P3(SLICE, SLICE, UINTPTR),
253	       R1(INT))
254
255// Copy from string.
256DEF_GO_RUNTIME(SLICESTRINGCOPY, "runtime.slicestringcopy", P2(SLICE, STRING),
257	       R1(INT))
258
259// Copy of value containing pointers.
260DEF_GO_RUNTIME(TYPEDSLICECOPY, "runtime.typedslicecopy",
261	       P3(TYPE, SLICE, SLICE), R1(INT))
262
263
264// Grow a slice for append.
265DEF_GO_RUNTIME(GROWSLICE, "runtime.growslice",
266               P5(TYPE, POINTER, INT, INT, INT), R1(SLICE))
267
268
269// Register roots (global variables) for the garbage collector.
270DEF_GO_RUNTIME(REGISTER_GC_ROOTS, "runtime.registerGCRoots", P1(POINTER), R0())
271
272// Register type descriptors.
273DEF_GO_RUNTIME(REGISTER_TYPE_DESCRIPTORS, "runtime.registerTypeDescriptors",
274               P2(INT, POINTER), R0())
275
276
277// Allocate memory.
278DEF_GO_RUNTIME(NEW, "runtime.newobject", P1(TYPE), R1(POINTER))
279
280// Start a new goroutine.
281DEF_GO_RUNTIME(GO, "__go_go", P2(UINTPTR, POINTER), R1(POINTER))
282
283// Defer a function.
284DEF_GO_RUNTIME(DEFERPROC, "runtime.deferproc", P3(BOOLPTR, UINTPTR, POINTER),
285	       R0())
286
287// Defer a function, with stack-allocated defer structure.
288DEF_GO_RUNTIME(DEFERPROCSTACK, "runtime.deferprocStack",
289               P4(POINTER, BOOLPTR, UINTPTR, POINTER), R0())
290
291
292// Convert an empty interface to an empty interface, returning ok.
293DEF_GO_RUNTIME(IFACEE2E2, "runtime.ifaceE2E2", P1(EFACE), R2(EFACE, BOOL))
294
295// Convert a non-empty interface to an empty interface, returning ok.
296DEF_GO_RUNTIME(IFACEI2E2, "runtime.ifaceI2E2", P1(IFACE), R2(EFACE, BOOL))
297
298// Convert an empty interface to a non-empty interface, returning ok.
299DEF_GO_RUNTIME(IFACEE2I2, "runtime.ifaceE2I2", P2(TYPE, EFACE),
300	       R2(IFACE, BOOL))
301
302// Convert a non-empty interface to a non-empty interface, returning ok.
303DEF_GO_RUNTIME(IFACEI2I2, "runtime.ifaceI2I2", P2(TYPE, IFACE),
304	       R2(IFACE, BOOL))
305
306// Convert an empty interface to a pointer type, returning ok.
307DEF_GO_RUNTIME(IFACEE2T2P, "runtime.ifaceE2T2P", P2(TYPE, EFACE),
308	       R2(POINTER, BOOL))
309
310// Convert a non-empty interface to a pointer type, return ok.
311DEF_GO_RUNTIME(IFACEI2T2P, "runtime.ifaceI2T2P", P2(TYPE, IFACE),
312	       R2(POINTER, BOOL))
313
314// Convert an empty interface to a non-pointer type, returning ok.
315DEF_GO_RUNTIME(IFACEE2T2, "runtime.ifaceE2T2", P3(TYPE, EFACE, POINTER),
316	       R1(BOOL))
317
318// Convert a non-empty interface to a non-pointer type, returning ok.
319DEF_GO_RUNTIME(IFACEI2T2, "runtime.ifaceI2T2", P3(TYPE, IFACE, POINTER),
320	       R1(BOOL))
321
322// Return the interface method table for the second type converted to
323// the first type which is a (possibly empty) interface type.  Panics
324// if the second type is nil (indicating a nil interface value) or if
325// the conversion is not possible.  Used for type assertions.  This is
326// like REQUIREITAB, but for type assertions.
327DEF_GO_RUNTIME(ASSERTITAB, "runtime.assertitab", P2(TYPE, TYPE), R1(POINTER))
328
329// Return the interface method table for the second type converted to
330// the first type, which is a non-empty interface type.  Return nil if
331// the second type is nil, indicating a nil interface value.  Panics
332// if the conversion is not possible.  Used for assignments.  This is
333// like ASSERTITAB, but for assignments.
334DEF_GO_RUNTIME(REQUIREITAB, "runtime.requireitab", P2(TYPE, TYPE),
335	       R1(POINTER))
336
337// Panic when an interface type to non-interface type conversion fails.
338DEF_GO_RUNTIME(PANICDOTTYPE, "runtime.panicdottype", P3(TYPE, TYPE, TYPE),
339               R0())
340
341// Return whether we can convert a type to an interface type.
342DEF_GO_RUNTIME(IFACET2IP, "runtime.ifaceT2Ip", P2(TYPE, TYPE), R1(BOOL))
343
344// Compare two empty interface values.
345DEF_GO_RUNTIME(EFACEEQ, "runtime.efaceeq", P2(EFACE, EFACE), R1(BOOL))
346
347// Compare an empty interface value to a non-interface value.
348DEF_GO_RUNTIME(EFACEVALEQ, "runtime.efacevaleq", P3(EFACE, TYPE, POINTER),
349	       R1(BOOL))
350
351// Compare two non-empty interface values.
352DEF_GO_RUNTIME(IFACEEQ, "runtime.ifaceeq", P2(IFACE, IFACE), R1(BOOL))
353
354// Compare a non-empty interface value to a non-interface value.
355DEF_GO_RUNTIME(IFACEVALEQ, "runtime.ifacevaleq", P3(IFACE, TYPE, POINTER),
356	       R1(BOOL))
357
358// Compare a non-empty interface value to an interface value.
359DEF_GO_RUNTIME(IFACEEFACEEQ, "runtime.ifaceefaceeq", P2(IFACE, EFACE),
360	       R1(BOOL))
361
362
363// Set *dst = src where dst is a pointer to a pointer and src is a pointer.
364DEF_GO_RUNTIME(GCWRITEBARRIER, "runtime.gcWriteBarrier",
365	       P2(POINTER, UINTPTR), R0())
366
367// Set *dst = *src for an arbitrary type.
368DEF_GO_RUNTIME(TYPEDMEMMOVE, "runtime.typedmemmove",
369	       P3(TYPE, POINTER, POINTER), R0())
370
371// Clear memory that contains pointer.
372DEF_GO_RUNTIME(MEMCLRHASPTR, "runtime.memclrHasPointers",
373               P2(POINTER, UINTPTR), R0())
374
375
376// Lock the printer (for print/println).
377DEF_GO_RUNTIME(PRINTLOCK, "runtime.printlock", P0(), R0())
378
379// Unlock the printer (for print/println).
380DEF_GO_RUNTIME(PRINTUNLOCK, "runtime.printunlock", P0(), R0())
381
382// Print a string (for print/println).
383DEF_GO_RUNTIME(PRINTSTRING, "runtime.printstring", P1(STRING), R0())
384
385// Print a uint64 (for print/println).
386DEF_GO_RUNTIME(PRINTUINT, "runtime.printuint", P1(UINT64), R0())
387
388// Print a uint64 in hex (for print/println, used for runtime.hex type).
389DEF_GO_RUNTIME(PRINTHEX, "runtime.printhex", P1(UINT64), R0())
390
391// Print a int64 (for print/println).
392DEF_GO_RUNTIME(PRINTINT, "runtime.printint", P1(INT64), R0())
393
394// Print a float64 (for print/println).
395DEF_GO_RUNTIME(PRINTFLOAT, "runtime.printfloat", P1(FLOAT64), R0())
396
397// Print a complex128 (for print/println).
398DEF_GO_RUNTIME(PRINTCOMPLEX, "runtime.printcomplex", P1(COMPLEX128), R0())
399
400// Print a bool (for print/println).
401DEF_GO_RUNTIME(PRINTBOOL, "runtime.printbool", P1(BOOL), R0())
402
403// Print a pointer/map/channel/function (for print/println).
404DEF_GO_RUNTIME(PRINTPOINTER, "runtime.printpointer", P1(POINTER), R0())
405
406// Print an empty interface (for print/println).
407DEF_GO_RUNTIME(PRINTEFACE, "runtime.printeface", P1(EFACE), R0())
408
409// Print a non-empty interface (for print/println).
410DEF_GO_RUNTIME(PRINTIFACE, "runtime.printiface", P1(IFACE), R0())
411
412// Print a slice (for print/println).
413DEF_GO_RUNTIME(PRINTSLICE, "runtime.printslice", P1(SLICE), R0())
414
415// Print a space (for println).
416DEF_GO_RUNTIME(PRINTSP, "runtime.printsp", P0(), R0())
417
418// Print a newline (for println).
419DEF_GO_RUNTIME(PRINTNL, "runtime.printnl", P0(), R0())
420
421
422// Used for field tracking for data analysis.
423DEF_GO_RUNTIME(FIELDTRACK, "__go_fieldtrack", P1(POINTER), R0())
424
425
426// Unreachable code.
427DEF_GO_RUNTIME(UNREACHABLE, "__builtin_unreachable", P0(), R0())
428
429// Memmove.
430DEF_GO_RUNTIME(BUILTIN_MEMMOVE, "__builtin_memmove",
431               P3(POINTER, POINTER, UINTPTR), R0())
432
433// Memset, used for zeroing memory.
434DEF_GO_RUNTIME(BUILTIN_MEMSET, "__builtin_memset",
435               P3(POINTER, INT32, UINTPTR), R0())
436
437// Various intrinsics.
438
439// Get the caller's PC, used for runtime.getcallerpc.
440DEF_GO_RUNTIME(BUILTIN_RETURN_ADDRESS, "__builtin_return_address",
441               P1(UINT32), R1(POINTER))
442
443// Get the caller's SP, used for runtime.getcallersp.
444DEF_GO_RUNTIME(BUILTIN_DWARF_CFA, "__builtin_dwarf_cfa", P0(),
445               R1(POINTER))
446
447// Swap bytes.
448DEF_GO_RUNTIME(BUILTIN_BSWAP16, "__builtin_bswap16", P1(UINT16),
449               R1(UINT16))
450DEF_GO_RUNTIME(BUILTIN_BSWAP32, "__builtin_bswap32", P1(UINT32),
451               R1(UINT32))
452DEF_GO_RUNTIME(BUILTIN_BSWAP64, "__builtin_bswap64", P1(UINT64),
453               R1(UINT64))
454
455// Count trailing zeros.
456DEF_GO_RUNTIME(BUILTIN_CTZ, "__builtin_ctz", P1(UINT32), R1(INT32))
457DEF_GO_RUNTIME(BUILTIN_CTZLL, "__builtin_ctzll", P1(UINT64), R1(INT32))
458
459// Count leading zeros.
460DEF_GO_RUNTIME(BUILTIN_CLZ, "__builtin_clz", P1(UINT32), R1(INT32))
461DEF_GO_RUNTIME(BUILTIN_CLZLL, "__builtin_clzll", P1(UINT64), R1(INT32))
462
463// Count one bits.
464DEF_GO_RUNTIME(BUILTIN_POPCOUNT, "__builtin_popcount", P1(UINT32), R1(INT32))
465DEF_GO_RUNTIME(BUILTIN_POPCOUNTLL, "__builtin_popcountll", P1(UINT64), R1(INT32))
466
467// Atomics.
468DEF_GO_RUNTIME(ATOMIC_LOAD_4, "__atomic_load_4", P2(POINTER, INT32),
469               R1(UINT32))
470DEF_GO_RUNTIME(ATOMIC_LOAD_8, "__atomic_load_8", P2(POINTER, INT32),
471               R1(UINT64))
472DEF_GO_RUNTIME(ATOMIC_STORE_4, "__atomic_store_4", P3(POINTER, UINT32, INT32),
473               R0())
474DEF_GO_RUNTIME(ATOMIC_STORE_8, "__atomic_store_8", P3(POINTER, UINT64, INT32),
475               R0())
476DEF_GO_RUNTIME(ATOMIC_EXCHANGE_4, "__atomic_exchange_4", P3(POINTER, UINT32, INT32),
477               R1(UINT32))
478DEF_GO_RUNTIME(ATOMIC_EXCHANGE_8, "__atomic_exchange_8", P3(POINTER, UINT64, INT32),
479               R1(UINT64))
480DEF_GO_RUNTIME(ATOMIC_COMPARE_EXCHANGE_4, "__atomic_compare_exchange_4",
481               P6(POINTER, POINTER, UINT32, BOOL, INT32, INT32),
482               R1(BOOL))
483DEF_GO_RUNTIME(ATOMIC_COMPARE_EXCHANGE_8, "__atomic_compare_exchange_8",
484               P6(POINTER, POINTER, UINT64, BOOL, INT32, INT32),
485               R1(BOOL))
486DEF_GO_RUNTIME(ATOMIC_ADD_FETCH_4, "__atomic_add_fetch_4",
487               P3(POINTER, UINT32, INT32),
488               R1(UINT32))
489DEF_GO_RUNTIME(ATOMIC_ADD_FETCH_8, "__atomic_add_fetch_8",
490               P3(POINTER, UINT64, INT32),
491               R1(UINT64))
492DEF_GO_RUNTIME(ATOMIC_AND_FETCH_1, "__atomic_and_fetch_1",
493               P3(POINTER, UINT8, INT32),
494               R1(UINT8))
495DEF_GO_RUNTIME(ATOMIC_OR_FETCH_1, "__atomic_or_fetch_1",
496               P3(POINTER, UINT8, INT32),
497               R1(UINT8))
498
499// Panic reporting a division by zero.
500DEF_GO_RUNTIME(PANIC_DIVIDE, "runtime.panicdivide", P0(), R0())
501
502// Panic reporting a shift by negative count.
503DEF_GO_RUNTIME(PANIC_SHIFT, "runtime.panicshift", P0(), R0())
504
505// Panic reporting a nil dereference.
506DEF_GO_RUNTIME(PANIC_MEM, "runtime.panicmem", P0(), R0())
507
508// Panic reporting that make's slice len argument is out of range.
509DEF_GO_RUNTIME(PANIC_MAKE_SLICE_LEN, "runtime.panicmakeslicelen", P0(), R0())
510
511// Panic reporting that make's slice cap argument is out of range.
512DEF_GO_RUNTIME(PANIC_MAKE_SLICE_CAP, "runtime.panicmakeslicecap", P0(), R0())
513
514// Panic reporting using go with a nil function.
515DEF_GO_RUNTIME(PANIC_GO_NIL, "runtime.panicgonil", P0(), R0())
516
517// Panics reporting an index or slice out of bounds error.
518DEF_GO_RUNTIME(PANIC_INDEX, "runtime.goPanicIndex",
519	       P2(INT, INT), R0())
520DEF_GO_RUNTIME(PANIC_INDEX_U, "runtime.goPanicIndexU",
521	       P2(UINT, INT), R0())
522DEF_GO_RUNTIME(PANIC_SLICE_ALEN, "runtime.goPanicSliceAlen",
523	       P2(INT, INT), R0())
524DEF_GO_RUNTIME(PANIC_SLICE_ALEN_U, "runtime.goPanicSliceAlenU",
525	       P2(UINT, INT), R0())
526DEF_GO_RUNTIME(PANIC_SLICE_ACAP, "runtime.goPanicSliceAcap",
527	       P2(INT, INT), R0())
528DEF_GO_RUNTIME(PANIC_SLICE_ACAP_U, "runtime.goPanicSliceAcapU",
529	       P2(UINT, INT), R0())
530DEF_GO_RUNTIME(PANIC_SLICE_B, "runtime.goPanicSliceB",
531	       P2(INT, INT), R0())
532DEF_GO_RUNTIME(PANIC_SLICE_B_U, "runtime.goPanicSliceBU",
533	       P2(UINT, INT), R0())
534DEF_GO_RUNTIME(PANIC_SLICE3_ALEN, "runtime.goPanicSlice3Alen",
535	       P2(INT, INT), R0())
536DEF_GO_RUNTIME(PANIC_SLICE3_ALEN_U, "runtime.goPanicSlice3AlenU",
537	       P2(UINT, INT), R0())
538DEF_GO_RUNTIME(PANIC_SLICE3_ACAP, "runtime.goPanicSlice3Acap",
539	       P2(INT, INT), R0())
540DEF_GO_RUNTIME(PANIC_SLICE3_ACAP_U, "runtime.goPanicSlice3AcapU",
541	       P2(UINT, INT), R0())
542DEF_GO_RUNTIME(PANIC_SLICE3_B, "runtime.goPanicSlice3B",
543	       P2(INT, INT), R0())
544DEF_GO_RUNTIME(PANIC_SLICE3_B_U, "runtime.goPanicSlice3BU",
545	       P2(UINT, INT), R0())
546DEF_GO_RUNTIME(PANIC_SLICE3_C, "runtime.goPanicSlice3C",
547	       P2(INT, INT), R0())
548DEF_GO_RUNTIME(PANIC_SLICE3_C_U, "runtime.goPanicSlice3CU",
549	       P2(UINT, INT), R0())
550
551// Panics reporting an index or slice out of bounds error with a
552// 64-bit index type.  These are only used by 32-bit targets.
553DEF_GO_RUNTIME(PANIC_EXTEND_INDEX, "runtime.goPanicExtendIndex",
554	       P2(INT64, INT), R0())
555DEF_GO_RUNTIME(PANIC_EXTEND_INDEX_U, "runtime.goPanicExtendIndexU",
556	       P2(UINT64, INT), R0())
557DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_ALEN, "runtime.goPanicExtendSliceAlen",
558	       P2(INT64, INT), R0())
559DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_ALEN_U, "runtime.goPanicExtendSliceAlenU",
560	       P2(UINT64, INT), R0())
561DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_ACAP, "runtime.goPanicExtendSliceAcap",
562	       P2(INT64, INT), R0())
563DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_ACAP_U, "runtime.goPanicExtendSliceAcapU",
564	       P2(UINT64, INT), R0())
565DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_B, "runtime.goPanicExtendSliceB",
566	       P2(INT64, INT), R0())
567DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_B_U, "runtime.goPanicExtendSliceBU",
568	       P2(UINT64, INT), R0())
569DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_ALEN, "runtime.goPanicExtendSlice3Alen",
570	       P2(INT64, INT), R0())
571DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_ALEN_U, "runtime.goPanicExtendSlice3AlenU",
572	       P2(UINT64, INT), R0())
573DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_ACAP, "runtime.goPanicExtendSlice3Acap",
574	       P2(INT64, INT), R0())
575DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_ACAP_U, "runtime.goPanicExtendSlice3AcapU",
576	       P2(UINT64, INT), R0())
577DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_B, "runtime.goPanicExtendSlice3B",
578	       P2(INT64, INT), R0())
579DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_B_U, "runtime.goPanicExtendSlice3BU",
580	       P2(UINT64, INT), R0())
581DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_C, "runtime.goPanicExtendSlice3C",
582	       P2(INT64, INT), R0())
583DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_C_U, "runtime.goPanicExtendSlice3CU",
584	       P2(UINT64, INT), R0())
585
586// Remove helper macros.
587#undef ABFT6
588#undef ABFT2
589#undef P0
590#undef P1
591#undef P2
592#undef P3
593#undef P4
594#undef P5
595#undef P6
596#undef R0
597#undef R1
598#undef R2
599