aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/runtime.def
blob: 9a3c68091308fd499988f3a99a08f61e543442e6 (plain)
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
// runtime.def -- runtime functions called by generated code.  -*- C++ -*-

// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Definitions for the Go runtime functions.

// Parameter type helper macros.
#define ABFT6(T1, T2, T3, T4, T5, T6) \
  { RFT_ ## T1, RFT_ ## T2, RFT_ ## T3, RFT_ ## T4, RFT_ ## T5, RFT_ ## T6 }
#define P0()			ABFT6(VOID, VOID, VOID, VOID, VOID, VOID)
#define P1(T)			ABFT6(T, VOID, VOID, VOID, VOID, VOID)
#define P2(T1, T2)		ABFT6(T1, T2, VOID, VOID, VOID, VOID)
#define P3(T1, T2, T3)		ABFT6(T1, T2, T3, VOID, VOID, VOID)
#define P4(T1, T2, T3, T4)	ABFT6(T1, T2, T3, T4, VOID, VOID)
#define P5(T1, T2, T3, T4, T5)	ABFT6(T1, T2, T3, T4, T5, VOID)
#define P6(T1,T2,T3,T4,T5,T6)	ABFT6(T1, T2, T3, T4, T5, T6)

// Result type helper macros.
#define ABFT2(T1, T2) { RFT_ ## T1, RFT_ ## T2 }
#define R0()			ABFT2(VOID, VOID)
#define R1(T)			ABFT2(T, VOID)
#define R2(T1, T2)		ABFT2(T1, T2)

// Define all the Go runtime functions.  The first parameter is the
// enum code used to refer to the function.  The second parameter is
// the name.  The third is the parameter types and the fourth is the
// result types.

// The standard C memcmp function, used for struct comparisons.
DEF_GO_RUNTIME(MEMCMP, "__builtin_memcmp", P3(POINTER, POINTER, UINTPTR), R1(INT32))

// Decode a non-ASCII rune from a string.
DEF_GO_RUNTIME(DECODERUNE, "runtime.decoderune", P2(STRING, INT),
	       R2(RUNE, INT))

// Concatenate strings.
DEF_GO_RUNTIME(CONCATSTRINGS, "runtime.concatstrings",
               P3(POINTER, POINTER, INT), R1(STRING))

// Compare two strings.
DEF_GO_RUNTIME(CMPSTRING, "runtime.cmpstring", P2(STRING, STRING), R1(INT))

// Convert an integer to a string.
DEF_GO_RUNTIME(INTSTRING, "runtime.intstring", P2(POINTER, INT64), R1(STRING))

// Convert a []byte to a string.
DEF_GO_RUNTIME(SLICEBYTETOSTRING, "runtime.slicebytetostring",
	       P3(POINTER, POINTER, INT), R1(STRING))

// Convert a []rune to a string.
DEF_GO_RUNTIME(SLICERUNETOSTRING, "runtime.slicerunetostring",
	       P2(POINTER, SLICE), R1(STRING))

// Convert a string to a []byte.
DEF_GO_RUNTIME(STRINGTOSLICEBYTE, "runtime.stringtoslicebyte",
	       P2(POINTER, STRING), R1(SLICE))

// Convert a string to a []rune.
DEF_GO_RUNTIME(STRINGTOSLICERUNE, "runtime.stringtoslicerune",
	       P2(POINTER, STRING), R1(SLICE))


// Complex division.
DEF_GO_RUNTIME(COMPLEX64_DIV, "__go_complex64_div",
	       P2(COMPLEX64, COMPLEX64), R1(COMPLEX64))
DEF_GO_RUNTIME(COMPLEX128_DIV, "__go_complex128_div",
	       P2(COMPLEX128, COMPLEX128), R1(COMPLEX128))

// Make a slice.
DEF_GO_RUNTIME(MAKESLICE, "runtime.makeslice", P3(TYPE, INT, INT),
	       R1(POINTER))

DEF_GO_RUNTIME(MAKESLICE64, "runtime.makeslice64", P3(TYPE, INT64, INT64),
	       R1(POINTER))


// Make a map with a hint and an (optional, unused) map structure.
DEF_GO_RUNTIME(MAKEMAP, "runtime.makemap", P3(TYPE, INT, POINTER),
		R1(MAP))
DEF_GO_RUNTIME(MAKEMAP64, "runtime.makemap64", P3(TYPE, INT64, POINTER),
		R1(MAP))

// Make a map with no hint, or a small constant hint.
DEF_GO_RUNTIME(MAKEMAP_SMALL, "runtime.makemap__small", P0(), R1(MAP))

// Build a map from a composite literal.
DEF_GO_RUNTIME(CONSTRUCT_MAP, "__go_construct_map",
	       P5(POINTER, UINTPTR, UINTPTR, UINTPTR, POINTER),
	       R1(MAP))

// Look up a key in a map.
DEF_GO_RUNTIME(MAPACCESS1, "runtime.mapaccess1", P3(TYPE, MAP, POINTER),
	       R1(POINTER))

// Look up a uint32 key in a map.
DEF_GO_RUNTIME(MAPACCESS1_FAST32, "runtime.mapaccess1__fast32",
               P3(TYPE, MAP, UINT32), R1(POINTER))

// Look up a uint64 key in a map.
DEF_GO_RUNTIME(MAPACCESS1_FAST64, "runtime.mapaccess1__fast64",
               P3(TYPE, MAP, UINT64), R1(POINTER))

// Look up a string key in a map.
DEF_GO_RUNTIME(MAPACCESS1_FASTSTR, "runtime.mapaccess1__faststr",
               P3(TYPE, MAP, STRING), R1(POINTER))

// Look up a key in a map when the value is large.
DEF_GO_RUNTIME(MAPACCESS1_FAT, "runtime.mapaccess1__fat",
	       P4(TYPE, MAP, POINTER, POINTER), R1(POINTER))

// Look up a key in a map returning the value and whether it is
// present.
DEF_GO_RUNTIME(MAPACCESS2, "runtime.mapaccess2", P3(TYPE, MAP, POINTER),
	       R2(POINTER, BOOL))

// Look up a uint32 key in a map returning the value and whether
// it is present.
DEF_GO_RUNTIME(MAPACCESS2_FAST32, "runtime.mapaccess2__fast32",
               P3(TYPE, MAP, UINT32), R2(POINTER, BOOL))

// Look up a uint64 key in a map returning the value and whether
// it is present.
DEF_GO_RUNTIME(MAPACCESS2_FAST64, "runtime.mapaccess2__fast64",
               P3(TYPE, MAP, UINT64), R2(POINTER, BOOL))

// Look up a string key in a map returning the value and whether
// it is present.
DEF_GO_RUNTIME(MAPACCESS2_FASTSTR, "runtime.mapaccess2__faststr",
               P3(TYPE, MAP, STRING), R2(POINTER, BOOL))

// Look up a key in a map, returning the value and whether it is
// present, when the value is large.
DEF_GO_RUNTIME(MAPACCESS2_FAT, "runtime.mapaccess2__fat",
	       P4(TYPE, MAP, POINTER, POINTER), R2(POINTER, BOOL))

// Assignment to a key in a map.
DEF_GO_RUNTIME(MAPASSIGN, "runtime.mapassign", P3(TYPE, MAP, POINTER),
	       R1(POINTER))

// Assignment to a uint32 key in a map.
DEF_GO_RUNTIME(MAPASSIGN_FAST32, "runtime.mapassign__fast32",
               P3(TYPE, MAP, UINT32), R1(POINTER))

// Assignment to a uint64 key in a map.
DEF_GO_RUNTIME(MAPASSIGN_FAST64, "runtime.mapassign__fast64",
               P3(TYPE, MAP, UINT64), R1(POINTER))

// Assignment to a 32-bit pointer key in a map.
DEF_GO_RUNTIME(MAPASSIGN_FAST32PTR, "runtime.mapassign__fast32ptr",
               P3(TYPE, MAP, POINTER), R1(POINTER))

// Assignment to a 64-bit pointer key in a map.
DEF_GO_RUNTIME(MAPASSIGN_FAST64PTR, "runtime.mapassign__fast64ptr",
               P3(TYPE, MAP, POINTER), R1(POINTER))

// Assignment to a string key in a map.
DEF_GO_RUNTIME(MAPASSIGN_FASTSTR, "runtime.mapassign__faststr",
               P3(TYPE, MAP, STRING), R1(POINTER))

// Delete a key from a map.
DEF_GO_RUNTIME(MAPDELETE, "runtime.mapdelete", P3(TYPE, MAP, POINTER), R0())

// Delete a uint32 key from a map.
DEF_GO_RUNTIME(MAPDELETE_FAST32, "runtime.mapdelete__fast32",
               P3(TYPE, MAP, UINT32), R0())

// Delete a uint64 key from a map.
DEF_GO_RUNTIME(MAPDELETE_FAST64, "runtime.mapdelete__fast64",
               P3(TYPE, MAP, UINT64), R0())

// Delete a string key from a map.
DEF_GO_RUNTIME(MAPDELETE_FASTSTR, "runtime.mapdelete__faststr",
               P3(TYPE, MAP, STRING), R0())

// Begin a range over a map.
DEF_GO_RUNTIME(MAPITERINIT, "runtime.mapiterinit", P3(TYPE, MAP, POINTER),
	       R0())

// Range over a map, moving to the next map entry.
DEF_GO_RUNTIME(MAPITERNEXT, "runtime.mapiternext", P1(POINTER), R0())

// Clear a map.
DEF_GO_RUNTIME(MAPCLEAR, "runtime.mapclear", P2(TYPE, MAP), R0())


// Make a channel.
DEF_GO_RUNTIME(MAKECHAN, "runtime.makechan", P2(TYPE, INT), R1(CHAN))
DEF_GO_RUNTIME(MAKECHAN64, "runtime.makechan64", P2(TYPE, INT64), R1(CHAN))

// Send a value on a channel.
DEF_GO_RUNTIME(CHANSEND, "runtime.chansend1", P2(CHAN, POINTER), R0())

// Receive a value from a channel.
DEF_GO_RUNTIME(CHANRECV1, "runtime.chanrecv1", P2(CHAN, POINTER), R0())

// Receive a value from a channel returning whether it is closed.
DEF_GO_RUNTIME(CHANRECV2, "runtime.chanrecv2", P2(CHAN, POINTER), R1(BOOL))


// Run a select, returning the index of the selected clause and
// whether that channel received a value.
DEF_GO_RUNTIME(SELECTGO, "runtime.selectgo", P3(POINTER, POINTER, INT),
	       R2(INT, BOOL))

// Non-blocking send a value on a channel, used for two-case select
// statement with a default case.
DEF_GO_RUNTIME(SELECTNBSEND, "runtime.selectnbsend", P2(CHAN, POINTER), R1(BOOL))

// Non-blocking receive a value from a channel, used for two-case select
// statement with a default case.
DEF_GO_RUNTIME(SELECTNBRECV, "runtime.selectnbrecv", P2(POINTER, CHAN), R1(BOOL))

// Non-blocking tuple receive from a channel, used for two-case select
// statement with a default case.
DEF_GO_RUNTIME(SELECTNBRECV2, "runtime.selectnbrecv2", P3(POINTER, POINTER, CHAN),
               R1(BOOL))

// Block execution.  Used for zero-case select.
DEF_GO_RUNTIME(BLOCK, "runtime.block", P0(), R0())


// Panic.
DEF_GO_RUNTIME(GOPANIC, "runtime.gopanic", P1(EFACE), R0())

// Recover.
DEF_GO_RUNTIME(GORECOVER, "runtime.gorecover", P0(), R1(EFACE))

// Recover when called directly from defer.
DEF_GO_RUNTIME(DEFERREDRECOVER, "runtime.deferredrecover", P0(), R1(EFACE))

// Decide whether this function can call recover.
DEF_GO_RUNTIME(CANRECOVER, "runtime.canrecover", P1(UINTPTR), R1(BOOL))

// Set the return address for defer in a defer thunk.
DEF_GO_RUNTIME(SETDEFERRETADDR, "runtime.setdeferretaddr", P1(UINTPTR),
	       R1(BOOL))

// Check for a deferred function in an exception handler.
DEF_GO_RUNTIME(CHECKDEFER, "runtime.checkdefer", P1(BOOLPTR), R0())

// Run deferred functions.
DEF_GO_RUNTIME(DEFERRETURN, "runtime.deferreturn", P1(BOOLPTR), R0())


// Close.
DEF_GO_RUNTIME(CLOSE, "runtime.closechan", P1(CHAN), R0())


// Copy.
DEF_GO_RUNTIME(SLICECOPY, "runtime.slicecopy",
	       P5(POINTER, INT, POINTER, INT, UINTPTR), R1(INT))

// Copy from string.
DEF_GO_RUNTIME(SLICESTRINGCOPY, "runtime.slicestringcopy",
	       P3(POINTER, INT, STRING), R1(INT))

// Copy of value containing pointers.
DEF_GO_RUNTIME(TYPEDSLICECOPY, "runtime.typedslicecopy",
	       P5(TYPE, POINTER, INT, POINTER, INT), R1(INT))

// Grow a slice for append.
DEF_GO_RUNTIME(GROWSLICE, "runtime.growslice",
               P5(TYPE, POINTER, INT, INT, INT), R1(SLICE))


// Check the length and cap passed to make, without making a slice.
// This is used for apend(s, make([]T, len)...).
DEF_GO_RUNTIME(CHECK_MAKE_SLICE, "runtime.checkMakeSlice", P3(TYPE, INT, INT),
	       R1(UINTPTR))

// Register roots (global variables) for the garbage collector.
DEF_GO_RUNTIME(REGISTER_GC_ROOTS, "runtime.registerGCRoots", P1(POINTER), R0())

// Register type descriptors.
DEF_GO_RUNTIME(REGISTER_TYPE_DESCRIPTORS, "runtime.registerTypeDescriptors",
               P2(INT, POINTER), R0())


// Allocate memory.
DEF_GO_RUNTIME(NEW, "runtime.newobject", P1(TYPE), R1(POINTER))

// Start a new goroutine.
DEF_GO_RUNTIME(GO, "__go_go", P2(UINTPTR, POINTER), R1(POINTER))

// Defer a function.
DEF_GO_RUNTIME(DEFERPROC, "runtime.deferproc", P3(BOOLPTR, UINTPTR, POINTER),
	       R0())

// Defer a function, with stack-allocated defer structure.
DEF_GO_RUNTIME(DEFERPROCSTACK, "runtime.deferprocStack",
               P4(POINTER, BOOLPTR, UINTPTR, POINTER), R0())


// Convert an empty interface to an empty interface, returning ok.
DEF_GO_RUNTIME(IFACEE2E2, "runtime.ifaceE2E2", P1(EFACE), R2(EFACE, BOOL))

// Convert a non-empty interface to an empty interface, returning ok.
DEF_GO_RUNTIME(IFACEI2E2, "runtime.ifaceI2E2", P1(IFACE), R2(EFACE, BOOL))

// Convert an empty interface to a non-empty interface, returning ok.
DEF_GO_RUNTIME(IFACEE2I2, "runtime.ifaceE2I2", P2(TYPE, EFACE),
	       R2(IFACE, BOOL))

// Convert a non-empty interface to a non-empty interface, returning ok.
DEF_GO_RUNTIME(IFACEI2I2, "runtime.ifaceI2I2", P2(TYPE, IFACE),
	       R2(IFACE, BOOL))

// Convert an empty interface to a pointer type, returning ok.
DEF_GO_RUNTIME(IFACEE2T2P, "runtime.ifaceE2T2P", P2(TYPE, EFACE),
	       R2(POINTER, BOOL))

// Convert a non-empty interface to a pointer type, return ok.
DEF_GO_RUNTIME(IFACEI2T2P, "runtime.ifaceI2T2P", P2(TYPE, IFACE),
	       R2(POINTER, BOOL))

// Convert an empty interface to a non-pointer type, returning ok.
DEF_GO_RUNTIME(IFACEE2T2, "runtime.ifaceE2T2", P3(TYPE, EFACE, POINTER),
	       R1(BOOL))

// Convert a non-empty interface to a non-pointer type, returning ok.
DEF_GO_RUNTIME(IFACEI2T2, "runtime.ifaceI2T2", P3(TYPE, IFACE, POINTER),
	       R1(BOOL))

// Return the interface method table for the second type converted to
// the first type which is a (possibly empty) interface type.  Panics
// if the second type is nil (indicating a nil interface value) or if
// the conversion is not possible.  Used for type assertions.  This is
// like REQUIREITAB, but for type assertions.
DEF_GO_RUNTIME(ASSERTITAB, "runtime.assertitab", P2(TYPE, TYPE), R1(POINTER))

// Return the interface method table for the second type converted to
// the first type, which is a non-empty interface type.  Return nil if
// the second type is nil, indicating a nil interface value.  Panics
// if the conversion is not possible.  Used for assignments.  This is
// like ASSERTITAB, but for assignments.
DEF_GO_RUNTIME(REQUIREITAB, "runtime.requireitab", P2(TYPE, TYPE),
	       R1(POINTER))

// Panic when an interface type to non-interface type conversion fails.
DEF_GO_RUNTIME(PANICDOTTYPE, "runtime.panicdottype", P3(TYPE, TYPE, TYPE),
               R0())

// Return whether we can convert a type to an interface type.
DEF_GO_RUNTIME(IFACET2IP, "runtime.ifaceT2Ip", P2(TYPE, TYPE), R1(BOOL))

// Compare two type descriptors for equality.
DEF_GO_RUNTIME(EQTYPE, "runtime.eqtype", P2(TYPE, TYPE), R1(BOOL))

// Compare two empty interface values.
DEF_GO_RUNTIME(EFACEEQ, "runtime.efaceeq", P2(EFACE, EFACE), R1(BOOL))

// Compare an empty interface value to a non-interface value.
DEF_GO_RUNTIME(EFACEVALEQ, "runtime.efacevaleq", P3(EFACE, TYPE, POINTER),
	       R1(BOOL))

// Compare two non-empty interface values.
DEF_GO_RUNTIME(IFACEEQ, "runtime.ifaceeq", P2(IFACE, IFACE), R1(BOOL))

// Compare a non-empty interface value to a non-interface value.
DEF_GO_RUNTIME(IFACEVALEQ, "runtime.ifacevaleq", P3(IFACE, TYPE, POINTER),
	       R1(BOOL))

// Compare a non-empty interface value to an interface value.
DEF_GO_RUNTIME(IFACEEFACEEQ, "runtime.ifaceefaceeq", P2(IFACE, EFACE),
	       R1(BOOL))


// Set *dst = src where dst is a pointer to a pointer and src is a pointer.
DEF_GO_RUNTIME(GCWRITEBARRIER, "runtime.gcWriteBarrier",
	       P2(POINTER, UINTPTR), R0())

// Set *dst = *src for an arbitrary type.
DEF_GO_RUNTIME(TYPEDMEMMOVE, "runtime.typedmemmove",
	       P3(TYPE, POINTER, POINTER), R0())

// Clear memory that contains pointer.
DEF_GO_RUNTIME(MEMCLRHASPTR, "runtime.memclrHasPointers",
               P2(POINTER, UINTPTR), R0())


// Lock the printer (for print/println).
DEF_GO_RUNTIME(PRINTLOCK, "runtime.printlock", P0(), R0())

// Unlock the printer (for print/println).
DEF_GO_RUNTIME(PRINTUNLOCK, "runtime.printunlock", P0(), R0())

// Print a string (for print/println).
DEF_GO_RUNTIME(PRINTSTRING, "runtime.printstring", P1(STRING), R0())

// Print a uint64 (for print/println).
DEF_GO_RUNTIME(PRINTUINT, "runtime.printuint", P1(UINT64), R0())

// Print a uint64 in hex (for print/println, used for runtime.hex type).
DEF_GO_RUNTIME(PRINTHEX, "runtime.printhex", P1(UINT64), R0())

// Print a int64 (for print/println).
DEF_GO_RUNTIME(PRINTINT, "runtime.printint", P1(INT64), R0())

// Print a float64 (for print/println).
DEF_GO_RUNTIME(PRINTFLOAT, "runtime.printfloat", P1(FLOAT64), R0())

// Print a complex128 (for print/println).
DEF_GO_RUNTIME(PRINTCOMPLEX, "runtime.printcomplex", P1(COMPLEX128), R0())

// Print a bool (for print/println).
DEF_GO_RUNTIME(PRINTBOOL, "runtime.printbool", P1(BOOL), R0())

// Print a pointer/map/channel/function (for print/println).
DEF_GO_RUNTIME(PRINTPOINTER, "runtime.printpointer", P1(POINTER), R0())

// Print an empty interface (for print/println).
DEF_GO_RUNTIME(PRINTEFACE, "runtime.printeface", P1(EFACE), R0())

// Print a non-empty interface (for print/println).
DEF_GO_RUNTIME(PRINTIFACE, "runtime.printiface", P1(IFACE), R0())

// Print a slice (for print/println).
DEF_GO_RUNTIME(PRINTSLICE, "runtime.printslice", P1(SLICE), R0())

// Print a space (for println).
DEF_GO_RUNTIME(PRINTSP, "runtime.printsp", P0(), R0())

// Print a newline (for println).
DEF_GO_RUNTIME(PRINTNL, "runtime.printnl", P0(), R0())


// Used for field tracking for data analysis.
DEF_GO_RUNTIME(FIELDTRACK, "__go_fieldtrack", P1(POINTER), R0())


// Unreachable code.
DEF_GO_RUNTIME(UNREACHABLE, "__builtin_unreachable", P0(), R0())

// Memmove.
DEF_GO_RUNTIME(BUILTIN_MEMMOVE, "__builtin_memmove",
               P3(POINTER, POINTER, UINTPTR), R0())

// Memset, used for zeroing memory.
DEF_GO_RUNTIME(BUILTIN_MEMSET, "__builtin_memset",
               P3(POINTER, INT32, UINTPTR), R0())

// Various intrinsics.

// Get the caller's PC, used for runtime.getcallerpc.
DEF_GO_RUNTIME(BUILTIN_RETURN_ADDRESS, "__builtin_return_address",
               P1(UINT32), R1(POINTER))

// Get the caller's SP, used for runtime.getcallersp.
DEF_GO_RUNTIME(BUILTIN_DWARF_CFA, "__builtin_dwarf_cfa", P0(),
               R1(POINTER))

// Swap bytes.
DEF_GO_RUNTIME(BUILTIN_BSWAP16, "__builtin_bswap16", P1(UINT16),
               R1(UINT16))
DEF_GO_RUNTIME(BUILTIN_BSWAP32, "__builtin_bswap32", P1(UINT32),
               R1(UINT32))
DEF_GO_RUNTIME(BUILTIN_BSWAP64, "__builtin_bswap64", P1(UINT64),
               R1(UINT64))

// Count trailing zeros.
DEF_GO_RUNTIME(BUILTIN_CTZ, "__builtin_ctz", P1(UINT32), R1(INT32))
DEF_GO_RUNTIME(BUILTIN_CTZLL, "__builtin_ctzll", P1(UINT64), R1(INT32))

// Count leading zeros.
DEF_GO_RUNTIME(BUILTIN_CLZ, "__builtin_clz", P1(UINT32), R1(INT32))
DEF_GO_RUNTIME(BUILTIN_CLZLL, "__builtin_clzll", P1(UINT64), R1(INT32))

// Count one bits.
DEF_GO_RUNTIME(BUILTIN_POPCOUNT, "__builtin_popcount", P1(UINT32), R1(INT32))
DEF_GO_RUNTIME(BUILTIN_POPCOUNTLL, "__builtin_popcountll", P1(UINT64), R1(INT32))

// Atomics.
DEF_GO_RUNTIME(ATOMIC_LOAD_4, "__atomic_load_4", P2(POINTER, INT32),
               R1(UINT32))
DEF_GO_RUNTIME(ATOMIC_LOAD_8, "__atomic_load_8", P2(POINTER, INT32),
               R1(UINT64))
DEF_GO_RUNTIME(ATOMIC_STORE_4, "__atomic_store_4", P3(POINTER, UINT32, INT32),
               R0())
DEF_GO_RUNTIME(ATOMIC_STORE_8, "__atomic_store_8", P3(POINTER, UINT64, INT32),
               R0())
DEF_GO_RUNTIME(ATOMIC_EXCHANGE_4, "__atomic_exchange_4", P3(POINTER, UINT32, INT32),
               R1(UINT32))
DEF_GO_RUNTIME(ATOMIC_EXCHANGE_8, "__atomic_exchange_8", P3(POINTER, UINT64, INT32),
               R1(UINT64))
DEF_GO_RUNTIME(ATOMIC_COMPARE_EXCHANGE_4, "__atomic_compare_exchange_4",
               P6(POINTER, POINTER, UINT32, BOOL, INT32, INT32),
               R1(BOOL))
DEF_GO_RUNTIME(ATOMIC_COMPARE_EXCHANGE_8, "__atomic_compare_exchange_8",
               P6(POINTER, POINTER, UINT64, BOOL, INT32, INT32),
               R1(BOOL))
DEF_GO_RUNTIME(ATOMIC_ADD_FETCH_4, "__atomic_add_fetch_4",
               P3(POINTER, UINT32, INT32),
               R1(UINT32))
DEF_GO_RUNTIME(ATOMIC_ADD_FETCH_8, "__atomic_add_fetch_8",
               P3(POINTER, UINT64, INT32),
               R1(UINT64))
DEF_GO_RUNTIME(ATOMIC_AND_FETCH_1, "__atomic_and_fetch_1",
               P3(POINTER, UINT8, INT32),
               R1(UINT8))
DEF_GO_RUNTIME(ATOMIC_OR_FETCH_1, "__atomic_or_fetch_1",
               P3(POINTER, UINT8, INT32),
               R1(UINT8))

// Panic reporting a division by zero.
DEF_GO_RUNTIME(PANIC_DIVIDE, "runtime.panicdivide", P0(), R0())

// Panic reporting a shift by negative count.
DEF_GO_RUNTIME(PANIC_SHIFT, "runtime.panicshift", P0(), R0())

// Panic reporting a nil dereference.
DEF_GO_RUNTIME(PANIC_MEM, "runtime.panicmem", P0(), R0())

// Panic reporting that make's slice len argument is out of range.
DEF_GO_RUNTIME(PANIC_MAKE_SLICE_LEN, "runtime.panicmakeslicelen", P0(), R0())

// Panic reporting that make's slice cap argument is out of range.
DEF_GO_RUNTIME(PANIC_MAKE_SLICE_CAP, "runtime.panicmakeslicecap", P0(), R0())

// Panic reporting using go with a nil function.
DEF_GO_RUNTIME(PANIC_GO_NIL, "runtime.panicgonil", P0(), R0())

// Panics reporting an index or slice out of bounds error.
DEF_GO_RUNTIME(PANIC_INDEX, "runtime.goPanicIndex",
	       P2(INT, INT), R0())
DEF_GO_RUNTIME(PANIC_INDEX_U, "runtime.goPanicIndexU",
	       P2(UINT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE_ALEN, "runtime.goPanicSliceAlen",
	       P2(INT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE_ALEN_U, "runtime.goPanicSliceAlenU",
	       P2(UINT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE_ACAP, "runtime.goPanicSliceAcap",
	       P2(INT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE_ACAP_U, "runtime.goPanicSliceAcapU",
	       P2(UINT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE_B, "runtime.goPanicSliceB",
	       P2(INT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE_B_U, "runtime.goPanicSliceBU",
	       P2(UINT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE3_ALEN, "runtime.goPanicSlice3Alen",
	       P2(INT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE3_ALEN_U, "runtime.goPanicSlice3AlenU",
	       P2(UINT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE3_ACAP, "runtime.goPanicSlice3Acap",
	       P2(INT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE3_ACAP_U, "runtime.goPanicSlice3AcapU",
	       P2(UINT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE3_B, "runtime.goPanicSlice3B",
	       P2(INT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE3_B_U, "runtime.goPanicSlice3BU",
	       P2(UINT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE3_C, "runtime.goPanicSlice3C",
	       P2(INT, INT), R0())
DEF_GO_RUNTIME(PANIC_SLICE3_C_U, "runtime.goPanicSlice3CU",
	       P2(UINT, INT), R0())

// Panics reporting an index or slice out of bounds error with a
// 64-bit index type.  These are only used by 32-bit targets.
DEF_GO_RUNTIME(PANIC_EXTEND_INDEX, "runtime.goPanicExtendIndex",
	       P2(INT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_INDEX_U, "runtime.goPanicExtendIndexU",
	       P2(UINT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_ALEN, "runtime.goPanicExtendSliceAlen",
	       P2(INT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_ALEN_U, "runtime.goPanicExtendSliceAlenU",
	       P2(UINT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_ACAP, "runtime.goPanicExtendSliceAcap",
	       P2(INT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_ACAP_U, "runtime.goPanicExtendSliceAcapU",
	       P2(UINT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_B, "runtime.goPanicExtendSliceB",
	       P2(INT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE_B_U, "runtime.goPanicExtendSliceBU",
	       P2(UINT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_ALEN, "runtime.goPanicExtendSlice3Alen",
	       P2(INT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_ALEN_U, "runtime.goPanicExtendSlice3AlenU",
	       P2(UINT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_ACAP, "runtime.goPanicExtendSlice3Acap",
	       P2(INT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_ACAP_U, "runtime.goPanicExtendSlice3AcapU",
	       P2(UINT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_B, "runtime.goPanicExtendSlice3B",
	       P2(INT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_B_U, "runtime.goPanicExtendSlice3BU",
	       P2(UINT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_C, "runtime.goPanicExtendSlice3C",
	       P2(INT64, INT), R0())
DEF_GO_RUNTIME(PANIC_EXTEND_SLICE3_C_U, "runtime.goPanicExtendSlice3CU",
	       P2(UINT64, INT), R0())

// Remove helper macros.
#undef ABFT6
#undef ABFT2
#undef P0
#undef P1
#undef P2
#undef P3
#undef P4
#undef P5
#undef P6
#undef R0
#undef R1
#undef R2