1
2
3
4 package ssa
5
6 import "cmd/compile/internal/types"
7
8 func rewriteValuedec(v *Value) bool {
9 switch v.Op {
10 case OpComplexImag:
11 return rewriteValuedec_OpComplexImag(v)
12 case OpComplexReal:
13 return rewriteValuedec_OpComplexReal(v)
14 case OpIData:
15 return rewriteValuedec_OpIData(v)
16 case OpITab:
17 return rewriteValuedec_OpITab(v)
18 case OpLoad:
19 return rewriteValuedec_OpLoad(v)
20 case OpSliceCap:
21 return rewriteValuedec_OpSliceCap(v)
22 case OpSliceLen:
23 return rewriteValuedec_OpSliceLen(v)
24 case OpSlicePtr:
25 return rewriteValuedec_OpSlicePtr(v)
26 case OpSlicePtrUnchecked:
27 return rewriteValuedec_OpSlicePtrUnchecked(v)
28 case OpStore:
29 return rewriteValuedec_OpStore(v)
30 case OpStringLen:
31 return rewriteValuedec_OpStringLen(v)
32 case OpStringPtr:
33 return rewriteValuedec_OpStringPtr(v)
34 }
35 return false
36 }
37 func rewriteValuedec_OpComplexImag(v *Value) bool {
38 v_0 := v.Args[0]
39
40
41 for {
42 if v_0.Op != OpComplexMake {
43 break
44 }
45 imag := v_0.Args[1]
46 v.copyOf(imag)
47 return true
48 }
49 return false
50 }
51 func rewriteValuedec_OpComplexReal(v *Value) bool {
52 v_0 := v.Args[0]
53
54
55 for {
56 if v_0.Op != OpComplexMake {
57 break
58 }
59 real := v_0.Args[0]
60 v.copyOf(real)
61 return true
62 }
63 return false
64 }
65 func rewriteValuedec_OpIData(v *Value) bool {
66 v_0 := v.Args[0]
67
68
69 for {
70 if v_0.Op != OpIMake {
71 break
72 }
73 data := v_0.Args[1]
74 v.copyOf(data)
75 return true
76 }
77 return false
78 }
79 func rewriteValuedec_OpITab(v *Value) bool {
80 v_0 := v.Args[0]
81
82
83 for {
84 if v_0.Op != OpIMake {
85 break
86 }
87 itab := v_0.Args[0]
88 v.copyOf(itab)
89 return true
90 }
91 return false
92 }
93 func rewriteValuedec_OpLoad(v *Value) bool {
94 v_1 := v.Args[1]
95 v_0 := v.Args[0]
96 b := v.Block
97 config := b.Func.Config
98 typ := &b.Func.Config.Types
99
100
101
102 for {
103 t := v.Type
104 ptr := v_0
105 mem := v_1
106 if !(t.IsComplex() && t.Size() == 8) {
107 break
108 }
109 v.reset(OpComplexMake)
110 v0 := b.NewValue0(v.Pos, OpLoad, typ.Float32)
111 v0.AddArg2(ptr, mem)
112 v1 := b.NewValue0(v.Pos, OpLoad, typ.Float32)
113 v2 := b.NewValue0(v.Pos, OpOffPtr, typ.Float32Ptr)
114 v2.AuxInt = int64ToAuxInt(4)
115 v2.AddArg(ptr)
116 v1.AddArg2(v2, mem)
117 v.AddArg2(v0, v1)
118 return true
119 }
120
121
122
123 for {
124 t := v.Type
125 ptr := v_0
126 mem := v_1
127 if !(t.IsComplex() && t.Size() == 16) {
128 break
129 }
130 v.reset(OpComplexMake)
131 v0 := b.NewValue0(v.Pos, OpLoad, typ.Float64)
132 v0.AddArg2(ptr, mem)
133 v1 := b.NewValue0(v.Pos, OpLoad, typ.Float64)
134 v2 := b.NewValue0(v.Pos, OpOffPtr, typ.Float64Ptr)
135 v2.AuxInt = int64ToAuxInt(8)
136 v2.AddArg(ptr)
137 v1.AddArg2(v2, mem)
138 v.AddArg2(v0, v1)
139 return true
140 }
141
142
143
144 for {
145 t := v.Type
146 ptr := v_0
147 mem := v_1
148 if !(t.IsString()) {
149 break
150 }
151 v.reset(OpStringMake)
152 v0 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr)
153 v0.AddArg2(ptr, mem)
154 v1 := b.NewValue0(v.Pos, OpLoad, typ.Int)
155 v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
156 v2.AuxInt = int64ToAuxInt(config.PtrSize)
157 v2.AddArg(ptr)
158 v1.AddArg2(v2, mem)
159 v.AddArg2(v0, v1)
160 return true
161 }
162
163
164
165 for {
166 t := v.Type
167 ptr := v_0
168 mem := v_1
169 if !(t.IsSlice()) {
170 break
171 }
172 v.reset(OpSliceMake)
173 v0 := b.NewValue0(v.Pos, OpLoad, t.Elem().PtrTo())
174 v0.AddArg2(ptr, mem)
175 v1 := b.NewValue0(v.Pos, OpLoad, typ.Int)
176 v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
177 v2.AuxInt = int64ToAuxInt(config.PtrSize)
178 v2.AddArg(ptr)
179 v1.AddArg2(v2, mem)
180 v3 := b.NewValue0(v.Pos, OpLoad, typ.Int)
181 v4 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
182 v4.AuxInt = int64ToAuxInt(2 * config.PtrSize)
183 v4.AddArg(ptr)
184 v3.AddArg2(v4, mem)
185 v.AddArg3(v0, v1, v3)
186 return true
187 }
188
189
190
191 for {
192 t := v.Type
193 ptr := v_0
194 mem := v_1
195 if !(t.IsInterface()) {
196 break
197 }
198 v.reset(OpIMake)
199 v0 := b.NewValue0(v.Pos, OpLoad, typ.Uintptr)
200 v0.AddArg2(ptr, mem)
201 v1 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr)
202 v2 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr)
203 v2.AuxInt = int64ToAuxInt(config.PtrSize)
204 v2.AddArg(ptr)
205 v1.AddArg2(v2, mem)
206 v.AddArg2(v0, v1)
207 return true
208 }
209 return false
210 }
211 func rewriteValuedec_OpSliceCap(v *Value) bool {
212 v_0 := v.Args[0]
213
214
215 for {
216 if v_0.Op != OpSliceMake {
217 break
218 }
219 cap := v_0.Args[2]
220 v.copyOf(cap)
221 return true
222 }
223 return false
224 }
225 func rewriteValuedec_OpSliceLen(v *Value) bool {
226 v_0 := v.Args[0]
227
228
229 for {
230 if v_0.Op != OpSliceMake {
231 break
232 }
233 len := v_0.Args[1]
234 v.copyOf(len)
235 return true
236 }
237 return false
238 }
239 func rewriteValuedec_OpSlicePtr(v *Value) bool {
240 v_0 := v.Args[0]
241
242
243 for {
244 if v_0.Op != OpSliceMake {
245 break
246 }
247 ptr := v_0.Args[0]
248 v.copyOf(ptr)
249 return true
250 }
251 return false
252 }
253 func rewriteValuedec_OpSlicePtrUnchecked(v *Value) bool {
254 v_0 := v.Args[0]
255
256
257 for {
258 if v_0.Op != OpSliceMake {
259 break
260 }
261 ptr := v_0.Args[0]
262 v.copyOf(ptr)
263 return true
264 }
265 return false
266 }
267 func rewriteValuedec_OpStore(v *Value) bool {
268 v_2 := v.Args[2]
269 v_1 := v.Args[1]
270 v_0 := v.Args[0]
271 b := v.Block
272 config := b.Func.Config
273 typ := &b.Func.Config.Types
274
275
276
277 for {
278 t := auxToType(v.Aux)
279 dst := v_0
280 if v_1.Op != OpComplexMake {
281 break
282 }
283 imag := v_1.Args[1]
284 real := v_1.Args[0]
285 mem := v_2
286 if !(t.Size() == 8) {
287 break
288 }
289 v.reset(OpStore)
290 v.Aux = typeToAux(typ.Float32)
291 v0 := b.NewValue0(v.Pos, OpOffPtr, typ.Float32Ptr)
292 v0.AuxInt = int64ToAuxInt(4)
293 v0.AddArg(dst)
294 v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
295 v1.Aux = typeToAux(typ.Float32)
296 v1.AddArg3(dst, real, mem)
297 v.AddArg3(v0, imag, v1)
298 return true
299 }
300
301
302
303 for {
304 t := auxToType(v.Aux)
305 dst := v_0
306 if v_1.Op != OpComplexMake {
307 break
308 }
309 imag := v_1.Args[1]
310 real := v_1.Args[0]
311 mem := v_2
312 if !(t.Size() == 16) {
313 break
314 }
315 v.reset(OpStore)
316 v.Aux = typeToAux(typ.Float64)
317 v0 := b.NewValue0(v.Pos, OpOffPtr, typ.Float64Ptr)
318 v0.AuxInt = int64ToAuxInt(8)
319 v0.AddArg(dst)
320 v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
321 v1.Aux = typeToAux(typ.Float64)
322 v1.AddArg3(dst, real, mem)
323 v.AddArg3(v0, imag, v1)
324 return true
325 }
326
327
328 for {
329 dst := v_0
330 if v_1.Op != OpStringMake {
331 break
332 }
333 len := v_1.Args[1]
334 ptr := v_1.Args[0]
335 mem := v_2
336 v.reset(OpStore)
337 v.Aux = typeToAux(typ.Int)
338 v0 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
339 v0.AuxInt = int64ToAuxInt(config.PtrSize)
340 v0.AddArg(dst)
341 v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
342 v1.Aux = typeToAux(typ.BytePtr)
343 v1.AddArg3(dst, ptr, mem)
344 v.AddArg3(v0, len, v1)
345 return true
346 }
347
348
349 for {
350 t := auxToType(v.Aux)
351 dst := v_0
352 if v_1.Op != OpSliceMake {
353 break
354 }
355 cap := v_1.Args[2]
356 ptr := v_1.Args[0]
357 len := v_1.Args[1]
358 mem := v_2
359 v.reset(OpStore)
360 v.Aux = typeToAux(typ.Int)
361 v0 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
362 v0.AuxInt = int64ToAuxInt(2 * config.PtrSize)
363 v0.AddArg(dst)
364 v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
365 v1.Aux = typeToAux(typ.Int)
366 v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
367 v2.AuxInt = int64ToAuxInt(config.PtrSize)
368 v2.AddArg(dst)
369 v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
370 v3.Aux = typeToAux(t.Elem().PtrTo())
371 v3.AddArg3(dst, ptr, mem)
372 v1.AddArg3(v2, len, v3)
373 v.AddArg3(v0, cap, v1)
374 return true
375 }
376
377
378 for {
379 dst := v_0
380 if v_1.Op != OpIMake {
381 break
382 }
383 data := v_1.Args[1]
384 itab := v_1.Args[0]
385 mem := v_2
386 v.reset(OpStore)
387 v.Aux = typeToAux(typ.BytePtr)
388 v0 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr)
389 v0.AuxInt = int64ToAuxInt(config.PtrSize)
390 v0.AddArg(dst)
391 v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
392 v1.Aux = typeToAux(typ.Uintptr)
393 v1.AddArg3(dst, itab, mem)
394 v.AddArg3(v0, data, v1)
395 return true
396 }
397 return false
398 }
399 func rewriteValuedec_OpStringLen(v *Value) bool {
400 v_0 := v.Args[0]
401
402
403 for {
404 if v_0.Op != OpStringMake {
405 break
406 }
407 len := v_0.Args[1]
408 v.copyOf(len)
409 return true
410 }
411 return false
412 }
413 func rewriteValuedec_OpStringPtr(v *Value) bool {
414 v_0 := v.Args[0]
415
416
417 for {
418 if v_0.Op != OpStringMake {
419 break
420 }
421 ptr := v_0.Args[0]
422 v.copyOf(ptr)
423 return true
424 }
425 return false
426 }
427 func rewriteBlockdec(b *Block) bool {
428 return false
429 }
430
View as plain text