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