github.com/FenixAra/go@v0.0.0-20170127160404-96ea0918e670/src/cmd/compile/internal/ssa/rewritedec.go (about) 1 // autogenerated from gen/dec.rules: do not edit! 2 // generated with: cd gen; go run *.go 3 4 package ssa 5 6 import "math" 7 8 var _ = math.MinInt8 // in case not otherwise used 9 func rewriteValuedec(v *Value, config *Config) bool { 10 switch v.Op { 11 case OpComplexImag: 12 return rewriteValuedec_OpComplexImag(v, config) 13 case OpComplexReal: 14 return rewriteValuedec_OpComplexReal(v, config) 15 case OpIData: 16 return rewriteValuedec_OpIData(v, config) 17 case OpITab: 18 return rewriteValuedec_OpITab(v, config) 19 case OpLoad: 20 return rewriteValuedec_OpLoad(v, config) 21 case OpSliceCap: 22 return rewriteValuedec_OpSliceCap(v, config) 23 case OpSliceLen: 24 return rewriteValuedec_OpSliceLen(v, config) 25 case OpSlicePtr: 26 return rewriteValuedec_OpSlicePtr(v, config) 27 case OpStore: 28 return rewriteValuedec_OpStore(v, config) 29 case OpStringLen: 30 return rewriteValuedec_OpStringLen(v, config) 31 case OpStringPtr: 32 return rewriteValuedec_OpStringPtr(v, config) 33 } 34 return false 35 } 36 func rewriteValuedec_OpComplexImag(v *Value, config *Config) bool { 37 b := v.Block 38 _ = b 39 // match: (ComplexImag (ComplexMake _ imag )) 40 // cond: 41 // result: imag 42 for { 43 v_0 := v.Args[0] 44 if v_0.Op != OpComplexMake { 45 break 46 } 47 imag := v_0.Args[1] 48 v.reset(OpCopy) 49 v.Type = imag.Type 50 v.AddArg(imag) 51 return true 52 } 53 return false 54 } 55 func rewriteValuedec_OpComplexReal(v *Value, config *Config) bool { 56 b := v.Block 57 _ = b 58 // match: (ComplexReal (ComplexMake real _ )) 59 // cond: 60 // result: real 61 for { 62 v_0 := v.Args[0] 63 if v_0.Op != OpComplexMake { 64 break 65 } 66 real := v_0.Args[0] 67 v.reset(OpCopy) 68 v.Type = real.Type 69 v.AddArg(real) 70 return true 71 } 72 return false 73 } 74 func rewriteValuedec_OpIData(v *Value, config *Config) bool { 75 b := v.Block 76 _ = b 77 // match: (IData (IMake _ data)) 78 // cond: 79 // result: data 80 for { 81 v_0 := v.Args[0] 82 if v_0.Op != OpIMake { 83 break 84 } 85 data := v_0.Args[1] 86 v.reset(OpCopy) 87 v.Type = data.Type 88 v.AddArg(data) 89 return true 90 } 91 return false 92 } 93 func rewriteValuedec_OpITab(v *Value, config *Config) bool { 94 b := v.Block 95 _ = b 96 // match: (ITab (IMake itab _)) 97 // cond: 98 // result: itab 99 for { 100 v_0 := v.Args[0] 101 if v_0.Op != OpIMake { 102 break 103 } 104 itab := v_0.Args[0] 105 v.reset(OpCopy) 106 v.Type = itab.Type 107 v.AddArg(itab) 108 return true 109 } 110 return false 111 } 112 func rewriteValuedec_OpLoad(v *Value, config *Config) bool { 113 b := v.Block 114 _ = b 115 // match: (Load <t> ptr mem) 116 // cond: t.IsComplex() && t.Size() == 8 117 // result: (ComplexMake (Load <config.fe.TypeFloat32()> ptr mem) (Load <config.fe.TypeFloat32()> (OffPtr <config.fe.TypeFloat32().PtrTo()> [4] ptr) mem) ) 118 for { 119 t := v.Type 120 ptr := v.Args[0] 121 mem := v.Args[1] 122 if !(t.IsComplex() && t.Size() == 8) { 123 break 124 } 125 v.reset(OpComplexMake) 126 v0 := b.NewValue0(v.Line, OpLoad, config.fe.TypeFloat32()) 127 v0.AddArg(ptr) 128 v0.AddArg(mem) 129 v.AddArg(v0) 130 v1 := b.NewValue0(v.Line, OpLoad, config.fe.TypeFloat32()) 131 v2 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeFloat32().PtrTo()) 132 v2.AuxInt = 4 133 v2.AddArg(ptr) 134 v1.AddArg(v2) 135 v1.AddArg(mem) 136 v.AddArg(v1) 137 return true 138 } 139 // match: (Load <t> ptr mem) 140 // cond: t.IsComplex() && t.Size() == 16 141 // result: (ComplexMake (Load <config.fe.TypeFloat64()> ptr mem) (Load <config.fe.TypeFloat64()> (OffPtr <config.fe.TypeFloat64().PtrTo()> [8] ptr) mem) ) 142 for { 143 t := v.Type 144 ptr := v.Args[0] 145 mem := v.Args[1] 146 if !(t.IsComplex() && t.Size() == 16) { 147 break 148 } 149 v.reset(OpComplexMake) 150 v0 := b.NewValue0(v.Line, OpLoad, config.fe.TypeFloat64()) 151 v0.AddArg(ptr) 152 v0.AddArg(mem) 153 v.AddArg(v0) 154 v1 := b.NewValue0(v.Line, OpLoad, config.fe.TypeFloat64()) 155 v2 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeFloat64().PtrTo()) 156 v2.AuxInt = 8 157 v2.AddArg(ptr) 158 v1.AddArg(v2) 159 v1.AddArg(mem) 160 v.AddArg(v1) 161 return true 162 } 163 // match: (Load <t> ptr mem) 164 // cond: t.IsString() 165 // result: (StringMake (Load <config.fe.TypeBytePtr()> ptr mem) (Load <config.fe.TypeInt()> (OffPtr <config.fe.TypeInt().PtrTo()> [config.PtrSize] ptr) mem)) 166 for { 167 t := v.Type 168 ptr := v.Args[0] 169 mem := v.Args[1] 170 if !(t.IsString()) { 171 break 172 } 173 v.reset(OpStringMake) 174 v0 := b.NewValue0(v.Line, OpLoad, config.fe.TypeBytePtr()) 175 v0.AddArg(ptr) 176 v0.AddArg(mem) 177 v.AddArg(v0) 178 v1 := b.NewValue0(v.Line, OpLoad, config.fe.TypeInt()) 179 v2 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeInt().PtrTo()) 180 v2.AuxInt = config.PtrSize 181 v2.AddArg(ptr) 182 v1.AddArg(v2) 183 v1.AddArg(mem) 184 v.AddArg(v1) 185 return true 186 } 187 // match: (Load <t> ptr mem) 188 // cond: t.IsSlice() 189 // result: (SliceMake (Load <t.ElemType().PtrTo()> ptr mem) (Load <config.fe.TypeInt()> (OffPtr <config.fe.TypeInt().PtrTo()> [config.PtrSize] ptr) mem) (Load <config.fe.TypeInt()> (OffPtr <config.fe.TypeInt().PtrTo()> [2*config.PtrSize] ptr) mem)) 190 for { 191 t := v.Type 192 ptr := v.Args[0] 193 mem := v.Args[1] 194 if !(t.IsSlice()) { 195 break 196 } 197 v.reset(OpSliceMake) 198 v0 := b.NewValue0(v.Line, OpLoad, t.ElemType().PtrTo()) 199 v0.AddArg(ptr) 200 v0.AddArg(mem) 201 v.AddArg(v0) 202 v1 := b.NewValue0(v.Line, OpLoad, config.fe.TypeInt()) 203 v2 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeInt().PtrTo()) 204 v2.AuxInt = config.PtrSize 205 v2.AddArg(ptr) 206 v1.AddArg(v2) 207 v1.AddArg(mem) 208 v.AddArg(v1) 209 v3 := b.NewValue0(v.Line, OpLoad, config.fe.TypeInt()) 210 v4 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeInt().PtrTo()) 211 v4.AuxInt = 2 * config.PtrSize 212 v4.AddArg(ptr) 213 v3.AddArg(v4) 214 v3.AddArg(mem) 215 v.AddArg(v3) 216 return true 217 } 218 // match: (Load <t> ptr mem) 219 // cond: t.IsInterface() 220 // result: (IMake (Load <config.fe.TypeBytePtr()> ptr mem) (Load <config.fe.TypeBytePtr()> (OffPtr <config.fe.TypeBytePtr().PtrTo()> [config.PtrSize] ptr) mem)) 221 for { 222 t := v.Type 223 ptr := v.Args[0] 224 mem := v.Args[1] 225 if !(t.IsInterface()) { 226 break 227 } 228 v.reset(OpIMake) 229 v0 := b.NewValue0(v.Line, OpLoad, config.fe.TypeBytePtr()) 230 v0.AddArg(ptr) 231 v0.AddArg(mem) 232 v.AddArg(v0) 233 v1 := b.NewValue0(v.Line, OpLoad, config.fe.TypeBytePtr()) 234 v2 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeBytePtr().PtrTo()) 235 v2.AuxInt = config.PtrSize 236 v2.AddArg(ptr) 237 v1.AddArg(v2) 238 v1.AddArg(mem) 239 v.AddArg(v1) 240 return true 241 } 242 return false 243 } 244 func rewriteValuedec_OpSliceCap(v *Value, config *Config) bool { 245 b := v.Block 246 _ = b 247 // match: (SliceCap (SliceMake _ _ cap)) 248 // cond: 249 // result: cap 250 for { 251 v_0 := v.Args[0] 252 if v_0.Op != OpSliceMake { 253 break 254 } 255 cap := v_0.Args[2] 256 v.reset(OpCopy) 257 v.Type = cap.Type 258 v.AddArg(cap) 259 return true 260 } 261 return false 262 } 263 func rewriteValuedec_OpSliceLen(v *Value, config *Config) bool { 264 b := v.Block 265 _ = b 266 // match: (SliceLen (SliceMake _ len _)) 267 // cond: 268 // result: len 269 for { 270 v_0 := v.Args[0] 271 if v_0.Op != OpSliceMake { 272 break 273 } 274 len := v_0.Args[1] 275 v.reset(OpCopy) 276 v.Type = len.Type 277 v.AddArg(len) 278 return true 279 } 280 return false 281 } 282 func rewriteValuedec_OpSlicePtr(v *Value, config *Config) bool { 283 b := v.Block 284 _ = b 285 // match: (SlicePtr (SliceMake ptr _ _ )) 286 // cond: 287 // result: ptr 288 for { 289 v_0 := v.Args[0] 290 if v_0.Op != OpSliceMake { 291 break 292 } 293 ptr := v_0.Args[0] 294 v.reset(OpCopy) 295 v.Type = ptr.Type 296 v.AddArg(ptr) 297 return true 298 } 299 return false 300 } 301 func rewriteValuedec_OpStore(v *Value, config *Config) bool { 302 b := v.Block 303 _ = b 304 // match: (Store [8] dst (ComplexMake real imag) mem) 305 // cond: 306 // result: (Store [4] (OffPtr <config.fe.TypeFloat32().PtrTo()> [4] dst) imag (Store [4] dst real mem)) 307 for { 308 if v.AuxInt != 8 { 309 break 310 } 311 dst := v.Args[0] 312 v_1 := v.Args[1] 313 if v_1.Op != OpComplexMake { 314 break 315 } 316 real := v_1.Args[0] 317 imag := v_1.Args[1] 318 mem := v.Args[2] 319 v.reset(OpStore) 320 v.AuxInt = 4 321 v0 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeFloat32().PtrTo()) 322 v0.AuxInt = 4 323 v0.AddArg(dst) 324 v.AddArg(v0) 325 v.AddArg(imag) 326 v1 := b.NewValue0(v.Line, OpStore, TypeMem) 327 v1.AuxInt = 4 328 v1.AddArg(dst) 329 v1.AddArg(real) 330 v1.AddArg(mem) 331 v.AddArg(v1) 332 return true 333 } 334 // match: (Store [16] dst (ComplexMake real imag) mem) 335 // cond: 336 // result: (Store [8] (OffPtr <config.fe.TypeFloat64().PtrTo()> [8] dst) imag (Store [8] dst real mem)) 337 for { 338 if v.AuxInt != 16 { 339 break 340 } 341 dst := v.Args[0] 342 v_1 := v.Args[1] 343 if v_1.Op != OpComplexMake { 344 break 345 } 346 real := v_1.Args[0] 347 imag := v_1.Args[1] 348 mem := v.Args[2] 349 v.reset(OpStore) 350 v.AuxInt = 8 351 v0 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeFloat64().PtrTo()) 352 v0.AuxInt = 8 353 v0.AddArg(dst) 354 v.AddArg(v0) 355 v.AddArg(imag) 356 v1 := b.NewValue0(v.Line, OpStore, TypeMem) 357 v1.AuxInt = 8 358 v1.AddArg(dst) 359 v1.AddArg(real) 360 v1.AddArg(mem) 361 v.AddArg(v1) 362 return true 363 } 364 // match: (Store [2*config.PtrSize] dst (StringMake ptr len) mem) 365 // cond: 366 // result: (Store [config.PtrSize] (OffPtr <config.fe.TypeInt().PtrTo()> [config.PtrSize] dst) len (Store [config.PtrSize] dst ptr mem)) 367 for { 368 if v.AuxInt != 2*config.PtrSize { 369 break 370 } 371 dst := v.Args[0] 372 v_1 := v.Args[1] 373 if v_1.Op != OpStringMake { 374 break 375 } 376 ptr := v_1.Args[0] 377 len := v_1.Args[1] 378 mem := v.Args[2] 379 v.reset(OpStore) 380 v.AuxInt = config.PtrSize 381 v0 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeInt().PtrTo()) 382 v0.AuxInt = config.PtrSize 383 v0.AddArg(dst) 384 v.AddArg(v0) 385 v.AddArg(len) 386 v1 := b.NewValue0(v.Line, OpStore, TypeMem) 387 v1.AuxInt = config.PtrSize 388 v1.AddArg(dst) 389 v1.AddArg(ptr) 390 v1.AddArg(mem) 391 v.AddArg(v1) 392 return true 393 } 394 // match: (Store [3*config.PtrSize] dst (SliceMake ptr len cap) mem) 395 // cond: 396 // result: (Store [config.PtrSize] (OffPtr <config.fe.TypeInt().PtrTo()> [2*config.PtrSize] dst) cap (Store [config.PtrSize] (OffPtr <config.fe.TypeInt().PtrTo()> [config.PtrSize] dst) len (Store [config.PtrSize] dst ptr mem))) 397 for { 398 if v.AuxInt != 3*config.PtrSize { 399 break 400 } 401 dst := v.Args[0] 402 v_1 := v.Args[1] 403 if v_1.Op != OpSliceMake { 404 break 405 } 406 ptr := v_1.Args[0] 407 len := v_1.Args[1] 408 cap := v_1.Args[2] 409 mem := v.Args[2] 410 v.reset(OpStore) 411 v.AuxInt = config.PtrSize 412 v0 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeInt().PtrTo()) 413 v0.AuxInt = 2 * config.PtrSize 414 v0.AddArg(dst) 415 v.AddArg(v0) 416 v.AddArg(cap) 417 v1 := b.NewValue0(v.Line, OpStore, TypeMem) 418 v1.AuxInt = config.PtrSize 419 v2 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeInt().PtrTo()) 420 v2.AuxInt = config.PtrSize 421 v2.AddArg(dst) 422 v1.AddArg(v2) 423 v1.AddArg(len) 424 v3 := b.NewValue0(v.Line, OpStore, TypeMem) 425 v3.AuxInt = config.PtrSize 426 v3.AddArg(dst) 427 v3.AddArg(ptr) 428 v3.AddArg(mem) 429 v1.AddArg(v3) 430 v.AddArg(v1) 431 return true 432 } 433 // match: (Store [2*config.PtrSize] dst (IMake itab data) mem) 434 // cond: 435 // result: (Store [config.PtrSize] (OffPtr <config.fe.TypeBytePtr().PtrTo()> [config.PtrSize] dst) data (Store [config.PtrSize] dst itab mem)) 436 for { 437 if v.AuxInt != 2*config.PtrSize { 438 break 439 } 440 dst := v.Args[0] 441 v_1 := v.Args[1] 442 if v_1.Op != OpIMake { 443 break 444 } 445 itab := v_1.Args[0] 446 data := v_1.Args[1] 447 mem := v.Args[2] 448 v.reset(OpStore) 449 v.AuxInt = config.PtrSize 450 v0 := b.NewValue0(v.Line, OpOffPtr, config.fe.TypeBytePtr().PtrTo()) 451 v0.AuxInt = config.PtrSize 452 v0.AddArg(dst) 453 v.AddArg(v0) 454 v.AddArg(data) 455 v1 := b.NewValue0(v.Line, OpStore, TypeMem) 456 v1.AuxInt = config.PtrSize 457 v1.AddArg(dst) 458 v1.AddArg(itab) 459 v1.AddArg(mem) 460 v.AddArg(v1) 461 return true 462 } 463 return false 464 } 465 func rewriteValuedec_OpStringLen(v *Value, config *Config) bool { 466 b := v.Block 467 _ = b 468 // match: (StringLen (StringMake _ len)) 469 // cond: 470 // result: len 471 for { 472 v_0 := v.Args[0] 473 if v_0.Op != OpStringMake { 474 break 475 } 476 len := v_0.Args[1] 477 v.reset(OpCopy) 478 v.Type = len.Type 479 v.AddArg(len) 480 return true 481 } 482 return false 483 } 484 func rewriteValuedec_OpStringPtr(v *Value, config *Config) bool { 485 b := v.Block 486 _ = b 487 // match: (StringPtr (StringMake ptr _)) 488 // cond: 489 // result: ptr 490 for { 491 v_0 := v.Args[0] 492 if v_0.Op != OpStringMake { 493 break 494 } 495 ptr := v_0.Args[0] 496 v.reset(OpCopy) 497 v.Type = ptr.Type 498 v.AddArg(ptr) 499 return true 500 } 501 return false 502 } 503 func rewriteBlockdec(b *Block, config *Config) bool { 504 switch b.Kind { 505 } 506 return false 507 }