1
2
3 package typecheck
4
5 import (
6 "cmd/compile/internal/types"
7 "cmd/internal/src"
8 )
9
10
11
12
13 func newSig(params, results []*types.Field) *types.Type {
14 return types.NewSignature(nil, params, results)
15 }
16
17 func params(tlist ...*types.Type) []*types.Field {
18 flist := make([]*types.Field, len(tlist))
19 for i, typ := range tlist {
20 flist[i] = types.NewField(src.NoXPos, nil, typ)
21 }
22 return flist
23 }
24
25 var runtimeDecls = [...]struct {
26 name string
27 tag int
28 typ int
29 }{
30 {"newobject", funcTag, 4},
31 {"mallocgc", funcTag, 8},
32 {"panicdivide", funcTag, 9},
33 {"panicshift", funcTag, 9},
34 {"panicmakeslicelen", funcTag, 9},
35 {"panicmakeslicecap", funcTag, 9},
36 {"throwinit", funcTag, 9},
37 {"panicwrap", funcTag, 9},
38 {"gopanic", funcTag, 11},
39 {"gorecover", funcTag, 14},
40 {"goschedguarded", funcTag, 9},
41 {"goPanicIndex", funcTag, 16},
42 {"goPanicIndexU", funcTag, 18},
43 {"goPanicSliceAlen", funcTag, 16},
44 {"goPanicSliceAlenU", funcTag, 18},
45 {"goPanicSliceAcap", funcTag, 16},
46 {"goPanicSliceAcapU", funcTag, 18},
47 {"goPanicSliceB", funcTag, 16},
48 {"goPanicSliceBU", funcTag, 18},
49 {"goPanicSlice3Alen", funcTag, 16},
50 {"goPanicSlice3AlenU", funcTag, 18},
51 {"goPanicSlice3Acap", funcTag, 16},
52 {"goPanicSlice3AcapU", funcTag, 18},
53 {"goPanicSlice3B", funcTag, 16},
54 {"goPanicSlice3BU", funcTag, 18},
55 {"goPanicSlice3C", funcTag, 16},
56 {"goPanicSlice3CU", funcTag, 18},
57 {"goPanicSliceConvert", funcTag, 16},
58 {"printbool", funcTag, 19},
59 {"printfloat", funcTag, 21},
60 {"printint", funcTag, 23},
61 {"printhex", funcTag, 25},
62 {"printuint", funcTag, 25},
63 {"printcomplex", funcTag, 27},
64 {"printstring", funcTag, 29},
65 {"printpointer", funcTag, 30},
66 {"printuintptr", funcTag, 31},
67 {"printiface", funcTag, 30},
68 {"printeface", funcTag, 30},
69 {"printslice", funcTag, 30},
70 {"printnl", funcTag, 9},
71 {"printsp", funcTag, 9},
72 {"printlock", funcTag, 9},
73 {"printunlock", funcTag, 9},
74 {"concatstring2", funcTag, 34},
75 {"concatstring3", funcTag, 35},
76 {"concatstring4", funcTag, 36},
77 {"concatstring5", funcTag, 37},
78 {"concatstrings", funcTag, 39},
79 {"concatbyte2", funcTag, 41},
80 {"concatbyte3", funcTag, 42},
81 {"concatbyte4", funcTag, 43},
82 {"concatbyte5", funcTag, 44},
83 {"concatbytes", funcTag, 45},
84 {"cmpstring", funcTag, 46},
85 {"intstring", funcTag, 49},
86 {"slicebytetostring", funcTag, 50},
87 {"slicebytetostringtmp", funcTag, 51},
88 {"slicerunetostring", funcTag, 54},
89 {"stringtoslicebyte", funcTag, 55},
90 {"stringtoslicerune", funcTag, 58},
91 {"slicecopy", funcTag, 59},
92 {"decoderune", funcTag, 60},
93 {"countrunes", funcTag, 61},
94 {"convT", funcTag, 62},
95 {"convTnoptr", funcTag, 62},
96 {"convT16", funcTag, 64},
97 {"convT32", funcTag, 66},
98 {"convT64", funcTag, 67},
99 {"convTstring", funcTag, 68},
100 {"convTslice", funcTag, 71},
101 {"assertE2I", funcTag, 72},
102 {"assertE2I2", funcTag, 72},
103 {"panicdottypeE", funcTag, 73},
104 {"panicdottypeI", funcTag, 73},
105 {"panicnildottype", funcTag, 74},
106 {"typeAssert", funcTag, 72},
107 {"interfaceSwitch", funcTag, 75},
108 {"ifaceeq", funcTag, 77},
109 {"efaceeq", funcTag, 77},
110 {"panicrangestate", funcTag, 78},
111 {"deferrangefunc", funcTag, 79},
112 {"rand", funcTag, 80},
113 {"rand32", funcTag, 81},
114 {"makemap64", funcTag, 83},
115 {"makemap", funcTag, 84},
116 {"makemap_small", funcTag, 85},
117 {"mapaccess1", funcTag, 86},
118 {"mapaccess1_fast32", funcTag, 87},
119 {"mapaccess1_fast64", funcTag, 88},
120 {"mapaccess1_faststr", funcTag, 89},
121 {"mapaccess1_fat", funcTag, 90},
122 {"mapaccess2", funcTag, 91},
123 {"mapaccess2_fast32", funcTag, 92},
124 {"mapaccess2_fast64", funcTag, 93},
125 {"mapaccess2_faststr", funcTag, 94},
126 {"mapaccess2_fat", funcTag, 95},
127 {"mapassign", funcTag, 86},
128 {"mapassign_fast32", funcTag, 87},
129 {"mapassign_fast32ptr", funcTag, 96},
130 {"mapassign_fast64", funcTag, 88},
131 {"mapassign_fast64ptr", funcTag, 96},
132 {"mapassign_faststr", funcTag, 89},
133 {"mapiterinit", funcTag, 97},
134 {"mapdelete", funcTag, 97},
135 {"mapdelete_fast32", funcTag, 98},
136 {"mapdelete_fast64", funcTag, 99},
137 {"mapdelete_faststr", funcTag, 100},
138 {"mapiternext", funcTag, 101},
139 {"mapclear", funcTag, 102},
140 {"makechan64", funcTag, 104},
141 {"makechan", funcTag, 105},
142 {"chanrecv1", funcTag, 107},
143 {"chanrecv2", funcTag, 108},
144 {"chansend1", funcTag, 110},
145 {"closechan", funcTag, 111},
146 {"chanlen", funcTag, 112},
147 {"chancap", funcTag, 112},
148 {"writeBarrier", varTag, 114},
149 {"typedmemmove", funcTag, 115},
150 {"typedmemclr", funcTag, 116},
151 {"typedslicecopy", funcTag, 117},
152 {"selectnbsend", funcTag, 118},
153 {"selectnbrecv", funcTag, 119},
154 {"selectsetpc", funcTag, 120},
155 {"selectgo", funcTag, 121},
156 {"block", funcTag, 9},
157 {"makeslice", funcTag, 122},
158 {"makeslice64", funcTag, 123},
159 {"makeslicecopy", funcTag, 124},
160 {"growslice", funcTag, 126},
161 {"unsafeslicecheckptr", funcTag, 127},
162 {"panicunsafeslicelen", funcTag, 9},
163 {"panicunsafeslicenilptr", funcTag, 9},
164 {"unsafestringcheckptr", funcTag, 128},
165 {"panicunsafestringlen", funcTag, 9},
166 {"panicunsafestringnilptr", funcTag, 9},
167 {"memmove", funcTag, 129},
168 {"memclrNoHeapPointers", funcTag, 130},
169 {"memclrHasPointers", funcTag, 130},
170 {"memequal", funcTag, 131},
171 {"memequal0", funcTag, 132},
172 {"memequal8", funcTag, 132},
173 {"memequal16", funcTag, 132},
174 {"memequal32", funcTag, 132},
175 {"memequal64", funcTag, 132},
176 {"memequal128", funcTag, 132},
177 {"f32equal", funcTag, 133},
178 {"f64equal", funcTag, 133},
179 {"c64equal", funcTag, 133},
180 {"c128equal", funcTag, 133},
181 {"strequal", funcTag, 133},
182 {"interequal", funcTag, 133},
183 {"nilinterequal", funcTag, 133},
184 {"memhash", funcTag, 134},
185 {"memhash0", funcTag, 135},
186 {"memhash8", funcTag, 135},
187 {"memhash16", funcTag, 135},
188 {"memhash32", funcTag, 135},
189 {"memhash64", funcTag, 135},
190 {"memhash128", funcTag, 135},
191 {"f32hash", funcTag, 136},
192 {"f64hash", funcTag, 136},
193 {"c64hash", funcTag, 136},
194 {"c128hash", funcTag, 136},
195 {"strhash", funcTag, 136},
196 {"interhash", funcTag, 136},
197 {"nilinterhash", funcTag, 136},
198 {"int64div", funcTag, 137},
199 {"uint64div", funcTag, 138},
200 {"int64mod", funcTag, 137},
201 {"uint64mod", funcTag, 138},
202 {"float64toint64", funcTag, 139},
203 {"float64touint64", funcTag, 140},
204 {"float64touint32", funcTag, 141},
205 {"int64tofloat64", funcTag, 142},
206 {"int64tofloat32", funcTag, 144},
207 {"uint64tofloat64", funcTag, 145},
208 {"uint64tofloat32", funcTag, 146},
209 {"uint32tofloat64", funcTag, 147},
210 {"complex128div", funcTag, 148},
211 {"racefuncenter", funcTag, 31},
212 {"racefuncexit", funcTag, 9},
213 {"raceread", funcTag, 31},
214 {"racewrite", funcTag, 31},
215 {"racereadrange", funcTag, 149},
216 {"racewriterange", funcTag, 149},
217 {"msanread", funcTag, 149},
218 {"msanwrite", funcTag, 149},
219 {"msanmove", funcTag, 150},
220 {"asanread", funcTag, 149},
221 {"asanwrite", funcTag, 149},
222 {"checkptrAlignment", funcTag, 151},
223 {"checkptrArithmetic", funcTag, 153},
224 {"libfuzzerTraceCmp1", funcTag, 154},
225 {"libfuzzerTraceCmp2", funcTag, 155},
226 {"libfuzzerTraceCmp4", funcTag, 156},
227 {"libfuzzerTraceCmp8", funcTag, 157},
228 {"libfuzzerTraceConstCmp1", funcTag, 154},
229 {"libfuzzerTraceConstCmp2", funcTag, 155},
230 {"libfuzzerTraceConstCmp4", funcTag, 156},
231 {"libfuzzerTraceConstCmp8", funcTag, 157},
232 {"libfuzzerHookStrCmp", funcTag, 158},
233 {"libfuzzerHookEqualFold", funcTag, 158},
234 {"addCovMeta", funcTag, 160},
235 {"x86HasPOPCNT", varTag, 6},
236 {"x86HasSSE41", varTag, 6},
237 {"x86HasFMA", varTag, 6},
238 {"armHasVFPv4", varTag, 6},
239 {"arm64HasATOMICS", varTag, 6},
240 {"loong64HasLAM_BH", varTag, 6},
241 {"loong64HasLSX", varTag, 6},
242 {"asanregisterglobals", funcTag, 130},
243 }
244
245 func runtimeTypes() []*types.Type {
246 var typs [161]*types.Type
247 typs[0] = types.ByteType
248 typs[1] = types.NewPtr(typs[0])
249 typs[2] = types.Types[types.TANY]
250 typs[3] = types.NewPtr(typs[2])
251 typs[4] = newSig(params(typs[1]), params(typs[3]))
252 typs[5] = types.Types[types.TUINTPTR]
253 typs[6] = types.Types[types.TBOOL]
254 typs[7] = types.Types[types.TUNSAFEPTR]
255 typs[8] = newSig(params(typs[5], typs[1], typs[6]), params(typs[7]))
256 typs[9] = newSig(nil, nil)
257 typs[10] = types.Types[types.TINTER]
258 typs[11] = newSig(params(typs[10]), nil)
259 typs[12] = types.Types[types.TINT32]
260 typs[13] = types.NewPtr(typs[12])
261 typs[14] = newSig(params(typs[13]), params(typs[10]))
262 typs[15] = types.Types[types.TINT]
263 typs[16] = newSig(params(typs[15], typs[15]), nil)
264 typs[17] = types.Types[types.TUINT]
265 typs[18] = newSig(params(typs[17], typs[15]), nil)
266 typs[19] = newSig(params(typs[6]), nil)
267 typs[20] = types.Types[types.TFLOAT64]
268 typs[21] = newSig(params(typs[20]), nil)
269 typs[22] = types.Types[types.TINT64]
270 typs[23] = newSig(params(typs[22]), nil)
271 typs[24] = types.Types[types.TUINT64]
272 typs[25] = newSig(params(typs[24]), nil)
273 typs[26] = types.Types[types.TCOMPLEX128]
274 typs[27] = newSig(params(typs[26]), nil)
275 typs[28] = types.Types[types.TSTRING]
276 typs[29] = newSig(params(typs[28]), nil)
277 typs[30] = newSig(params(typs[2]), nil)
278 typs[31] = newSig(params(typs[5]), nil)
279 typs[32] = types.NewArray(typs[0], 32)
280 typs[33] = types.NewPtr(typs[32])
281 typs[34] = newSig(params(typs[33], typs[28], typs[28]), params(typs[28]))
282 typs[35] = newSig(params(typs[33], typs[28], typs[28], typs[28]), params(typs[28]))
283 typs[36] = newSig(params(typs[33], typs[28], typs[28], typs[28], typs[28]), params(typs[28]))
284 typs[37] = newSig(params(typs[33], typs[28], typs[28], typs[28], typs[28], typs[28]), params(typs[28]))
285 typs[38] = types.NewSlice(typs[28])
286 typs[39] = newSig(params(typs[33], typs[38]), params(typs[28]))
287 typs[40] = types.NewSlice(typs[0])
288 typs[41] = newSig(params(typs[28], typs[28]), params(typs[40]))
289 typs[42] = newSig(params(typs[28], typs[28], typs[28]), params(typs[40]))
290 typs[43] = newSig(params(typs[28], typs[28], typs[28], typs[28]), params(typs[40]))
291 typs[44] = newSig(params(typs[28], typs[28], typs[28], typs[28], typs[28]), params(typs[40]))
292 typs[45] = newSig(params(typs[38]), params(typs[40]))
293 typs[46] = newSig(params(typs[28], typs[28]), params(typs[15]))
294 typs[47] = types.NewArray(typs[0], 4)
295 typs[48] = types.NewPtr(typs[47])
296 typs[49] = newSig(params(typs[48], typs[22]), params(typs[28]))
297 typs[50] = newSig(params(typs[33], typs[1], typs[15]), params(typs[28]))
298 typs[51] = newSig(params(typs[1], typs[15]), params(typs[28]))
299 typs[52] = types.RuneType
300 typs[53] = types.NewSlice(typs[52])
301 typs[54] = newSig(params(typs[33], typs[53]), params(typs[28]))
302 typs[55] = newSig(params(typs[33], typs[28]), params(typs[40]))
303 typs[56] = types.NewArray(typs[52], 32)
304 typs[57] = types.NewPtr(typs[56])
305 typs[58] = newSig(params(typs[57], typs[28]), params(typs[53]))
306 typs[59] = newSig(params(typs[3], typs[15], typs[3], typs[15], typs[5]), params(typs[15]))
307 typs[60] = newSig(params(typs[28], typs[15]), params(typs[52], typs[15]))
308 typs[61] = newSig(params(typs[28]), params(typs[15]))
309 typs[62] = newSig(params(typs[1], typs[3]), params(typs[7]))
310 typs[63] = types.Types[types.TUINT16]
311 typs[64] = newSig(params(typs[63]), params(typs[7]))
312 typs[65] = types.Types[types.TUINT32]
313 typs[66] = newSig(params(typs[65]), params(typs[7]))
314 typs[67] = newSig(params(typs[24]), params(typs[7]))
315 typs[68] = newSig(params(typs[28]), params(typs[7]))
316 typs[69] = types.Types[types.TUINT8]
317 typs[70] = types.NewSlice(typs[69])
318 typs[71] = newSig(params(typs[70]), params(typs[7]))
319 typs[72] = newSig(params(typs[1], typs[1]), params(typs[1]))
320 typs[73] = newSig(params(typs[1], typs[1], typs[1]), nil)
321 typs[74] = newSig(params(typs[1]), nil)
322 typs[75] = newSig(params(typs[1], typs[1]), params(typs[15], typs[1]))
323 typs[76] = types.NewPtr(typs[5])
324 typs[77] = newSig(params(typs[76], typs[7], typs[7]), params(typs[6]))
325 typs[78] = newSig(params(typs[15]), nil)
326 typs[79] = newSig(nil, params(typs[10]))
327 typs[80] = newSig(nil, params(typs[24]))
328 typs[81] = newSig(nil, params(typs[65]))
329 typs[82] = types.NewMap(typs[2], typs[2])
330 typs[83] = newSig(params(typs[1], typs[22], typs[3]), params(typs[82]))
331 typs[84] = newSig(params(typs[1], typs[15], typs[3]), params(typs[82]))
332 typs[85] = newSig(nil, params(typs[82]))
333 typs[86] = newSig(params(typs[1], typs[82], typs[3]), params(typs[3]))
334 typs[87] = newSig(params(typs[1], typs[82], typs[65]), params(typs[3]))
335 typs[88] = newSig(params(typs[1], typs[82], typs[24]), params(typs[3]))
336 typs[89] = newSig(params(typs[1], typs[82], typs[28]), params(typs[3]))
337 typs[90] = newSig(params(typs[1], typs[82], typs[3], typs[1]), params(typs[3]))
338 typs[91] = newSig(params(typs[1], typs[82], typs[3]), params(typs[3], typs[6]))
339 typs[92] = newSig(params(typs[1], typs[82], typs[65]), params(typs[3], typs[6]))
340 typs[93] = newSig(params(typs[1], typs[82], typs[24]), params(typs[3], typs[6]))
341 typs[94] = newSig(params(typs[1], typs[82], typs[28]), params(typs[3], typs[6]))
342 typs[95] = newSig(params(typs[1], typs[82], typs[3], typs[1]), params(typs[3], typs[6]))
343 typs[96] = newSig(params(typs[1], typs[82], typs[7]), params(typs[3]))
344 typs[97] = newSig(params(typs[1], typs[82], typs[3]), nil)
345 typs[98] = newSig(params(typs[1], typs[82], typs[65]), nil)
346 typs[99] = newSig(params(typs[1], typs[82], typs[24]), nil)
347 typs[100] = newSig(params(typs[1], typs[82], typs[28]), nil)
348 typs[101] = newSig(params(typs[3]), nil)
349 typs[102] = newSig(params(typs[1], typs[82]), nil)
350 typs[103] = types.NewChan(typs[2], types.Cboth)
351 typs[104] = newSig(params(typs[1], typs[22]), params(typs[103]))
352 typs[105] = newSig(params(typs[1], typs[15]), params(typs[103]))
353 typs[106] = types.NewChan(typs[2], types.Crecv)
354 typs[107] = newSig(params(typs[106], typs[3]), nil)
355 typs[108] = newSig(params(typs[106], typs[3]), params(typs[6]))
356 typs[109] = types.NewChan(typs[2], types.Csend)
357 typs[110] = newSig(params(typs[109], typs[3]), nil)
358 typs[111] = newSig(params(typs[109]), nil)
359 typs[112] = newSig(params(typs[2]), params(typs[15]))
360 typs[113] = types.NewArray(typs[0], 3)
361 typs[114] = types.NewStruct([]*types.Field{types.NewField(src.NoXPos, Lookup("enabled"), typs[6]), types.NewField(src.NoXPos, Lookup("pad"), typs[113]), types.NewField(src.NoXPos, Lookup("cgo"), typs[6]), types.NewField(src.NoXPos, Lookup("alignme"), typs[24])})
362 typs[115] = newSig(params(typs[1], typs[3], typs[3]), nil)
363 typs[116] = newSig(params(typs[1], typs[3]), nil)
364 typs[117] = newSig(params(typs[1], typs[3], typs[15], typs[3], typs[15]), params(typs[15]))
365 typs[118] = newSig(params(typs[109], typs[3]), params(typs[6]))
366 typs[119] = newSig(params(typs[3], typs[106]), params(typs[6], typs[6]))
367 typs[120] = newSig(params(typs[76]), nil)
368 typs[121] = newSig(params(typs[1], typs[1], typs[76], typs[15], typs[15], typs[6]), params(typs[15], typs[6]))
369 typs[122] = newSig(params(typs[1], typs[15], typs[15]), params(typs[7]))
370 typs[123] = newSig(params(typs[1], typs[22], typs[22]), params(typs[7]))
371 typs[124] = newSig(params(typs[1], typs[15], typs[15], typs[7]), params(typs[7]))
372 typs[125] = types.NewSlice(typs[2])
373 typs[126] = newSig(params(typs[3], typs[15], typs[15], typs[15], typs[1]), params(typs[125]))
374 typs[127] = newSig(params(typs[1], typs[7], typs[22]), nil)
375 typs[128] = newSig(params(typs[7], typs[22]), nil)
376 typs[129] = newSig(params(typs[3], typs[3], typs[5]), nil)
377 typs[130] = newSig(params(typs[7], typs[5]), nil)
378 typs[131] = newSig(params(typs[3], typs[3], typs[5]), params(typs[6]))
379 typs[132] = newSig(params(typs[3], typs[3]), params(typs[6]))
380 typs[133] = newSig(params(typs[7], typs[7]), params(typs[6]))
381 typs[134] = newSig(params(typs[3], typs[5], typs[5]), params(typs[5]))
382 typs[135] = newSig(params(typs[7], typs[5]), params(typs[5]))
383 typs[136] = newSig(params(typs[3], typs[5]), params(typs[5]))
384 typs[137] = newSig(params(typs[22], typs[22]), params(typs[22]))
385 typs[138] = newSig(params(typs[24], typs[24]), params(typs[24]))
386 typs[139] = newSig(params(typs[20]), params(typs[22]))
387 typs[140] = newSig(params(typs[20]), params(typs[24]))
388 typs[141] = newSig(params(typs[20]), params(typs[65]))
389 typs[142] = newSig(params(typs[22]), params(typs[20]))
390 typs[143] = types.Types[types.TFLOAT32]
391 typs[144] = newSig(params(typs[22]), params(typs[143]))
392 typs[145] = newSig(params(typs[24]), params(typs[20]))
393 typs[146] = newSig(params(typs[24]), params(typs[143]))
394 typs[147] = newSig(params(typs[65]), params(typs[20]))
395 typs[148] = newSig(params(typs[26], typs[26]), params(typs[26]))
396 typs[149] = newSig(params(typs[5], typs[5]), nil)
397 typs[150] = newSig(params(typs[5], typs[5], typs[5]), nil)
398 typs[151] = newSig(params(typs[7], typs[1], typs[5]), nil)
399 typs[152] = types.NewSlice(typs[7])
400 typs[153] = newSig(params(typs[7], typs[152]), nil)
401 typs[154] = newSig(params(typs[69], typs[69], typs[17]), nil)
402 typs[155] = newSig(params(typs[63], typs[63], typs[17]), nil)
403 typs[156] = newSig(params(typs[65], typs[65], typs[17]), nil)
404 typs[157] = newSig(params(typs[24], typs[24], typs[17]), nil)
405 typs[158] = newSig(params(typs[28], typs[28], typs[17]), nil)
406 typs[159] = types.NewArray(typs[0], 16)
407 typs[160] = newSig(params(typs[7], typs[65], typs[159], typs[28], typs[15], typs[69], typs[69]), params(typs[65]))
408 return typs[:]
409 }
410
411 var coverageDecls = [...]struct {
412 name string
413 tag int
414 typ int
415 }{
416 {"initHook", funcTag, 1},
417 }
418
419 func coverageTypes() []*types.Type {
420 var typs [2]*types.Type
421 typs[0] = types.Types[types.TBOOL]
422 typs[1] = newSig(params(typs[0]), nil)
423 return typs[:]
424 }
425
View as plain text