Source file src/cmd/compile/internal/ssa/rewritedec.go

     1  // Code generated from _gen/dec.rules using 'go generate'; DO NOT EDIT.
     2  
     3  package ssa
     4  
     5  import "cmd/compile/internal/types"
     6  
     7  func rewriteValuedec(v *Value) bool {
     8  	switch v.Op {
     9  	case OpArrayMake1:
    10  		return rewriteValuedec_OpArrayMake1(v)
    11  	case OpArraySelect:
    12  		return rewriteValuedec_OpArraySelect(v)
    13  	case OpComplexImag:
    14  		return rewriteValuedec_OpComplexImag(v)
    15  	case OpComplexReal:
    16  		return rewriteValuedec_OpComplexReal(v)
    17  	case OpIData:
    18  		return rewriteValuedec_OpIData(v)
    19  	case OpIMake:
    20  		return rewriteValuedec_OpIMake(v)
    21  	case OpITab:
    22  		return rewriteValuedec_OpITab(v)
    23  	case OpLoad:
    24  		return rewriteValuedec_OpLoad(v)
    25  	case OpSliceCap:
    26  		return rewriteValuedec_OpSliceCap(v)
    27  	case OpSliceLen:
    28  		return rewriteValuedec_OpSliceLen(v)
    29  	case OpSlicePtr:
    30  		return rewriteValuedec_OpSlicePtr(v)
    31  	case OpSlicePtrUnchecked:
    32  		return rewriteValuedec_OpSlicePtrUnchecked(v)
    33  	case OpStore:
    34  		return rewriteValuedec_OpStore(v)
    35  	case OpStringLen:
    36  		return rewriteValuedec_OpStringLen(v)
    37  	case OpStringPtr:
    38  		return rewriteValuedec_OpStringPtr(v)
    39  	case OpStructMake:
    40  		return rewriteValuedec_OpStructMake(v)
    41  	case OpStructSelect:
    42  		return rewriteValuedec_OpStructSelect(v)
    43  	}
    44  	return false
    45  }
    46  func rewriteValuedec_OpArrayMake1(v *Value) bool {
    47  	v_0 := v.Args[0]
    48  	// match: (ArrayMake1 x)
    49  	// cond: x.Type.IsPtrShaped()
    50  	// result: x
    51  	for {
    52  		x := v_0
    53  		if !(x.Type.IsPtrShaped()) {
    54  			break
    55  		}
    56  		v.copyOf(x)
    57  		return true
    58  	}
    59  	return false
    60  }
    61  func rewriteValuedec_OpArraySelect(v *Value) bool {
    62  	v_0 := v.Args[0]
    63  	b := v.Block
    64  	// match: (ArraySelect [0] x)
    65  	// cond: x.Type.IsPtrShaped()
    66  	// result: x
    67  	for {
    68  		if auxIntToInt64(v.AuxInt) != 0 {
    69  			break
    70  		}
    71  		x := v_0
    72  		if !(x.Type.IsPtrShaped()) {
    73  			break
    74  		}
    75  		v.copyOf(x)
    76  		return true
    77  	}
    78  	// match: (ArraySelect (ArrayMake1 x))
    79  	// result: x
    80  	for {
    81  		if v_0.Op != OpArrayMake1 {
    82  			break
    83  		}
    84  		x := v_0.Args[0]
    85  		v.copyOf(x)
    86  		return true
    87  	}
    88  	// match: (ArraySelect [0] (IData x))
    89  	// result: (IData x)
    90  	for {
    91  		if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpIData {
    92  			break
    93  		}
    94  		x := v_0.Args[0]
    95  		v.reset(OpIData)
    96  		v.AddArg(x)
    97  		return true
    98  	}
    99  	// match: (ArraySelect [i] x:(Load <t> ptr mem))
   100  	// result: @x.Block (Load <v.Type> (OffPtr <v.Type.PtrTo()> [t.Elem().Size()*i] ptr) mem)
   101  	for {
   102  		i := auxIntToInt64(v.AuxInt)
   103  		x := v_0
   104  		if x.Op != OpLoad {
   105  			break
   106  		}
   107  		t := x.Type
   108  		mem := x.Args[1]
   109  		ptr := x.Args[0]
   110  		b = x.Block
   111  		v0 := b.NewValue0(v.Pos, OpLoad, v.Type)
   112  		v.copyOf(v0)
   113  		v1 := b.NewValue0(v.Pos, OpOffPtr, v.Type.PtrTo())
   114  		v1.AuxInt = int64ToAuxInt(t.Elem().Size() * i)
   115  		v1.AddArg(ptr)
   116  		v0.AddArg2(v1, mem)
   117  		return true
   118  	}
   119  	return false
   120  }
   121  func rewriteValuedec_OpComplexImag(v *Value) bool {
   122  	v_0 := v.Args[0]
   123  	b := v.Block
   124  	typ := &b.Func.Config.Types
   125  	// match: (ComplexImag (ComplexMake _ imag ))
   126  	// result: imag
   127  	for {
   128  		if v_0.Op != OpComplexMake {
   129  			break
   130  		}
   131  		imag := v_0.Args[1]
   132  		v.copyOf(imag)
   133  		return true
   134  	}
   135  	// match: (ComplexImag x:(Load <t> ptr mem))
   136  	// cond: t.IsComplex() && t.Size() == 8
   137  	// result: @x.Block (Load <typ.Float32> (OffPtr <typ.Float32Ptr> [4] ptr) mem)
   138  	for {
   139  		x := v_0
   140  		if x.Op != OpLoad {
   141  			break
   142  		}
   143  		t := x.Type
   144  		mem := x.Args[1]
   145  		ptr := x.Args[0]
   146  		if !(t.IsComplex() && t.Size() == 8) {
   147  			break
   148  		}
   149  		b = x.Block
   150  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Float32)
   151  		v.copyOf(v0)
   152  		v1 := b.NewValue0(v.Pos, OpOffPtr, typ.Float32Ptr)
   153  		v1.AuxInt = int64ToAuxInt(4)
   154  		v1.AddArg(ptr)
   155  		v0.AddArg2(v1, mem)
   156  		return true
   157  	}
   158  	// match: (ComplexImag x:(Load <t> ptr mem))
   159  	// cond: t.IsComplex() && t.Size() == 16
   160  	// result: @x.Block (Load <typ.Float64> (OffPtr <typ.Float64Ptr> [8] ptr) mem)
   161  	for {
   162  		x := v_0
   163  		if x.Op != OpLoad {
   164  			break
   165  		}
   166  		t := x.Type
   167  		mem := x.Args[1]
   168  		ptr := x.Args[0]
   169  		if !(t.IsComplex() && t.Size() == 16) {
   170  			break
   171  		}
   172  		b = x.Block
   173  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Float64)
   174  		v.copyOf(v0)
   175  		v1 := b.NewValue0(v.Pos, OpOffPtr, typ.Float64Ptr)
   176  		v1.AuxInt = int64ToAuxInt(8)
   177  		v1.AddArg(ptr)
   178  		v0.AddArg2(v1, mem)
   179  		return true
   180  	}
   181  	return false
   182  }
   183  func rewriteValuedec_OpComplexReal(v *Value) bool {
   184  	v_0 := v.Args[0]
   185  	b := v.Block
   186  	typ := &b.Func.Config.Types
   187  	// match: (ComplexReal (ComplexMake real _ ))
   188  	// result: real
   189  	for {
   190  		if v_0.Op != OpComplexMake {
   191  			break
   192  		}
   193  		real := v_0.Args[0]
   194  		v.copyOf(real)
   195  		return true
   196  	}
   197  	// match: (ComplexReal x:(Load <t> ptr mem))
   198  	// cond: t.IsComplex() && t.Size() == 8
   199  	// result: @x.Block (Load <typ.Float32> ptr mem)
   200  	for {
   201  		x := v_0
   202  		if x.Op != OpLoad {
   203  			break
   204  		}
   205  		t := x.Type
   206  		mem := x.Args[1]
   207  		ptr := x.Args[0]
   208  		if !(t.IsComplex() && t.Size() == 8) {
   209  			break
   210  		}
   211  		b = x.Block
   212  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Float32)
   213  		v.copyOf(v0)
   214  		v0.AddArg2(ptr, mem)
   215  		return true
   216  	}
   217  	// match: (ComplexReal x:(Load <t> ptr mem))
   218  	// cond: t.IsComplex() && t.Size() == 16
   219  	// result: @x.Block (Load <typ.Float64> ptr mem)
   220  	for {
   221  		x := v_0
   222  		if x.Op != OpLoad {
   223  			break
   224  		}
   225  		t := x.Type
   226  		mem := x.Args[1]
   227  		ptr := x.Args[0]
   228  		if !(t.IsComplex() && t.Size() == 16) {
   229  			break
   230  		}
   231  		b = x.Block
   232  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Float64)
   233  		v.copyOf(v0)
   234  		v0.AddArg2(ptr, mem)
   235  		return true
   236  	}
   237  	return false
   238  }
   239  func rewriteValuedec_OpIData(v *Value) bool {
   240  	v_0 := v.Args[0]
   241  	b := v.Block
   242  	config := b.Func.Config
   243  	typ := &b.Func.Config.Types
   244  	// match: (IData (IMake _ data))
   245  	// result: data
   246  	for {
   247  		if v_0.Op != OpIMake {
   248  			break
   249  		}
   250  		data := v_0.Args[1]
   251  		v.copyOf(data)
   252  		return true
   253  	}
   254  	// match: (IData x:(Load <t> ptr mem))
   255  	// cond: t.IsInterface()
   256  	// result: @x.Block (Load <typ.BytePtr> (OffPtr <typ.BytePtrPtr> [config.PtrSize] ptr) mem)
   257  	for {
   258  		x := v_0
   259  		if x.Op != OpLoad {
   260  			break
   261  		}
   262  		t := x.Type
   263  		mem := x.Args[1]
   264  		ptr := x.Args[0]
   265  		if !(t.IsInterface()) {
   266  			break
   267  		}
   268  		b = x.Block
   269  		v0 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr)
   270  		v.copyOf(v0)
   271  		v1 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr)
   272  		v1.AuxInt = int64ToAuxInt(config.PtrSize)
   273  		v1.AddArg(ptr)
   274  		v0.AddArg2(v1, mem)
   275  		return true
   276  	}
   277  	return false
   278  }
   279  func rewriteValuedec_OpIMake(v *Value) bool {
   280  	v_1 := v.Args[1]
   281  	v_0 := v.Args[0]
   282  	// match: (IMake _typ (StructMake ___))
   283  	// result: imakeOfStructMake(v)
   284  	for {
   285  		if v_1.Op != OpStructMake {
   286  			break
   287  		}
   288  		v.copyOf(imakeOfStructMake(v))
   289  		return true
   290  	}
   291  	// match: (IMake _typ (ArrayMake1 val))
   292  	// result: (IMake _typ val)
   293  	for {
   294  		_typ := v_0
   295  		if v_1.Op != OpArrayMake1 {
   296  			break
   297  		}
   298  		val := v_1.Args[0]
   299  		v.reset(OpIMake)
   300  		v.AddArg2(_typ, val)
   301  		return true
   302  	}
   303  	return false
   304  }
   305  func rewriteValuedec_OpITab(v *Value) bool {
   306  	v_0 := v.Args[0]
   307  	b := v.Block
   308  	typ := &b.Func.Config.Types
   309  	// match: (ITab (IMake itab _))
   310  	// result: itab
   311  	for {
   312  		if v_0.Op != OpIMake {
   313  			break
   314  		}
   315  		itab := v_0.Args[0]
   316  		v.copyOf(itab)
   317  		return true
   318  	}
   319  	// match: (ITab x:(Load <t> ptr mem))
   320  	// cond: t.IsInterface()
   321  	// result: @x.Block (Load <typ.Uintptr> ptr mem)
   322  	for {
   323  		x := v_0
   324  		if x.Op != OpLoad {
   325  			break
   326  		}
   327  		t := x.Type
   328  		mem := x.Args[1]
   329  		ptr := x.Args[0]
   330  		if !(t.IsInterface()) {
   331  			break
   332  		}
   333  		b = x.Block
   334  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Uintptr)
   335  		v.copyOf(v0)
   336  		v0.AddArg2(ptr, mem)
   337  		return true
   338  	}
   339  	return false
   340  }
   341  func rewriteValuedec_OpLoad(v *Value) bool {
   342  	v_1 := v.Args[1]
   343  	v_0 := v.Args[0]
   344  	b := v.Block
   345  	config := b.Func.Config
   346  	typ := &b.Func.Config.Types
   347  	// match: (Load <t> ptr mem)
   348  	// cond: t.IsComplex() && t.Size() == 8
   349  	// result: (ComplexMake (Load <typ.Float32> ptr mem) (Load <typ.Float32> (OffPtr <typ.Float32Ptr> [4] ptr) mem) )
   350  	for {
   351  		t := v.Type
   352  		ptr := v_0
   353  		mem := v_1
   354  		if !(t.IsComplex() && t.Size() == 8) {
   355  			break
   356  		}
   357  		v.reset(OpComplexMake)
   358  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Float32)
   359  		v0.AddArg2(ptr, mem)
   360  		v1 := b.NewValue0(v.Pos, OpLoad, typ.Float32)
   361  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.Float32Ptr)
   362  		v2.AuxInt = int64ToAuxInt(4)
   363  		v2.AddArg(ptr)
   364  		v1.AddArg2(v2, mem)
   365  		v.AddArg2(v0, v1)
   366  		return true
   367  	}
   368  	// match: (Load <t> ptr mem)
   369  	// cond: t.IsComplex() && t.Size() == 16
   370  	// result: (ComplexMake (Load <typ.Float64> ptr mem) (Load <typ.Float64> (OffPtr <typ.Float64Ptr> [8] ptr) mem) )
   371  	for {
   372  		t := v.Type
   373  		ptr := v_0
   374  		mem := v_1
   375  		if !(t.IsComplex() && t.Size() == 16) {
   376  			break
   377  		}
   378  		v.reset(OpComplexMake)
   379  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Float64)
   380  		v0.AddArg2(ptr, mem)
   381  		v1 := b.NewValue0(v.Pos, OpLoad, typ.Float64)
   382  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.Float64Ptr)
   383  		v2.AuxInt = int64ToAuxInt(8)
   384  		v2.AddArg(ptr)
   385  		v1.AddArg2(v2, mem)
   386  		v.AddArg2(v0, v1)
   387  		return true
   388  	}
   389  	// match: (Load <t> ptr mem)
   390  	// cond: t.IsString()
   391  	// result: (StringMake (Load <typ.BytePtr> ptr mem) (Load <typ.Int> (OffPtr <typ.IntPtr> [config.PtrSize] ptr) mem))
   392  	for {
   393  		t := v.Type
   394  		ptr := v_0
   395  		mem := v_1
   396  		if !(t.IsString()) {
   397  			break
   398  		}
   399  		v.reset(OpStringMake)
   400  		v0 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr)
   401  		v0.AddArg2(ptr, mem)
   402  		v1 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   403  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   404  		v2.AuxInt = int64ToAuxInt(config.PtrSize)
   405  		v2.AddArg(ptr)
   406  		v1.AddArg2(v2, mem)
   407  		v.AddArg2(v0, v1)
   408  		return true
   409  	}
   410  	// match: (Load <t> ptr mem)
   411  	// cond: t.IsSlice()
   412  	// result: (SliceMake (Load <t.Elem().PtrTo()> ptr mem) (Load <typ.Int> (OffPtr <typ.IntPtr> [config.PtrSize] ptr) mem) (Load <typ.Int> (OffPtr <typ.IntPtr> [2*config.PtrSize] ptr) mem))
   413  	for {
   414  		t := v.Type
   415  		ptr := v_0
   416  		mem := v_1
   417  		if !(t.IsSlice()) {
   418  			break
   419  		}
   420  		v.reset(OpSliceMake)
   421  		v0 := b.NewValue0(v.Pos, OpLoad, t.Elem().PtrTo())
   422  		v0.AddArg2(ptr, mem)
   423  		v1 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   424  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   425  		v2.AuxInt = int64ToAuxInt(config.PtrSize)
   426  		v2.AddArg(ptr)
   427  		v1.AddArg2(v2, mem)
   428  		v3 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   429  		v4 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   430  		v4.AuxInt = int64ToAuxInt(2 * config.PtrSize)
   431  		v4.AddArg(ptr)
   432  		v3.AddArg2(v4, mem)
   433  		v.AddArg3(v0, v1, v3)
   434  		return true
   435  	}
   436  	// match: (Load <t> ptr mem)
   437  	// cond: t.IsInterface()
   438  	// result: (IMake (Load <typ.Uintptr> ptr mem) (Load <typ.BytePtr> (OffPtr <typ.BytePtrPtr> [config.PtrSize] ptr) mem))
   439  	for {
   440  		t := v.Type
   441  		ptr := v_0
   442  		mem := v_1
   443  		if !(t.IsInterface()) {
   444  			break
   445  		}
   446  		v.reset(OpIMake)
   447  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Uintptr)
   448  		v0.AddArg2(ptr, mem)
   449  		v1 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr)
   450  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr)
   451  		v2.AuxInt = int64ToAuxInt(config.PtrSize)
   452  		v2.AddArg(ptr)
   453  		v1.AddArg2(v2, mem)
   454  		v.AddArg2(v0, v1)
   455  		return true
   456  	}
   457  	return false
   458  }
   459  func rewriteValuedec_OpSliceCap(v *Value) bool {
   460  	v_0 := v.Args[0]
   461  	b := v.Block
   462  	config := b.Func.Config
   463  	typ := &b.Func.Config.Types
   464  	// match: (SliceCap (SliceMake _ _ cap))
   465  	// result: cap
   466  	for {
   467  		if v_0.Op != OpSliceMake {
   468  			break
   469  		}
   470  		cap := v_0.Args[2]
   471  		v.copyOf(cap)
   472  		return true
   473  	}
   474  	// match: (SliceCap x:(Load <t> ptr mem))
   475  	// cond: t.IsSlice()
   476  	// result: @x.Block (Load <typ.Int> (OffPtr <typ.IntPtr> [2*config.PtrSize] ptr) mem)
   477  	for {
   478  		x := v_0
   479  		if x.Op != OpLoad {
   480  			break
   481  		}
   482  		t := x.Type
   483  		mem := x.Args[1]
   484  		ptr := x.Args[0]
   485  		if !(t.IsSlice()) {
   486  			break
   487  		}
   488  		b = x.Block
   489  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   490  		v.copyOf(v0)
   491  		v1 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   492  		v1.AuxInt = int64ToAuxInt(2 * config.PtrSize)
   493  		v1.AddArg(ptr)
   494  		v0.AddArg2(v1, mem)
   495  		return true
   496  	}
   497  	return false
   498  }
   499  func rewriteValuedec_OpSliceLen(v *Value) bool {
   500  	v_0 := v.Args[0]
   501  	b := v.Block
   502  	config := b.Func.Config
   503  	typ := &b.Func.Config.Types
   504  	// match: (SliceLen (SliceMake _ len _))
   505  	// result: len
   506  	for {
   507  		if v_0.Op != OpSliceMake {
   508  			break
   509  		}
   510  		len := v_0.Args[1]
   511  		v.copyOf(len)
   512  		return true
   513  	}
   514  	// match: (SliceLen x:(Load <t> ptr mem))
   515  	// cond: t.IsSlice()
   516  	// result: @x.Block (Load <typ.Int> (OffPtr <typ.IntPtr> [config.PtrSize] ptr) mem)
   517  	for {
   518  		x := v_0
   519  		if x.Op != OpLoad {
   520  			break
   521  		}
   522  		t := x.Type
   523  		mem := x.Args[1]
   524  		ptr := x.Args[0]
   525  		if !(t.IsSlice()) {
   526  			break
   527  		}
   528  		b = x.Block
   529  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   530  		v.copyOf(v0)
   531  		v1 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   532  		v1.AuxInt = int64ToAuxInt(config.PtrSize)
   533  		v1.AddArg(ptr)
   534  		v0.AddArg2(v1, mem)
   535  		return true
   536  	}
   537  	return false
   538  }
   539  func rewriteValuedec_OpSlicePtr(v *Value) bool {
   540  	v_0 := v.Args[0]
   541  	b := v.Block
   542  	// match: (SlicePtr (SliceMake ptr _ _ ))
   543  	// result: ptr
   544  	for {
   545  		if v_0.Op != OpSliceMake {
   546  			break
   547  		}
   548  		ptr := v_0.Args[0]
   549  		v.copyOf(ptr)
   550  		return true
   551  	}
   552  	// match: (SlicePtr x:(Load <t> ptr mem))
   553  	// cond: t.IsSlice()
   554  	// result: @x.Block (Load <t.Elem().PtrTo()> ptr mem)
   555  	for {
   556  		x := v_0
   557  		if x.Op != OpLoad {
   558  			break
   559  		}
   560  		t := x.Type
   561  		mem := x.Args[1]
   562  		ptr := x.Args[0]
   563  		if !(t.IsSlice()) {
   564  			break
   565  		}
   566  		b = x.Block
   567  		v0 := b.NewValue0(v.Pos, OpLoad, t.Elem().PtrTo())
   568  		v.copyOf(v0)
   569  		v0.AddArg2(ptr, mem)
   570  		return true
   571  	}
   572  	return false
   573  }
   574  func rewriteValuedec_OpSlicePtrUnchecked(v *Value) bool {
   575  	v_0 := v.Args[0]
   576  	// match: (SlicePtrUnchecked (SliceMake ptr _ _ ))
   577  	// result: ptr
   578  	for {
   579  		if v_0.Op != OpSliceMake {
   580  			break
   581  		}
   582  		ptr := v_0.Args[0]
   583  		v.copyOf(ptr)
   584  		return true
   585  	}
   586  	return false
   587  }
   588  func rewriteValuedec_OpStore(v *Value) bool {
   589  	v_2 := v.Args[2]
   590  	v_1 := v.Args[1]
   591  	v_0 := v.Args[0]
   592  	b := v.Block
   593  	config := b.Func.Config
   594  	typ := &b.Func.Config.Types
   595  	// match: (Store {t} _ _ mem)
   596  	// cond: t.Size() == 0
   597  	// result: mem
   598  	for {
   599  		t := auxToType(v.Aux)
   600  		mem := v_2
   601  		if !(t.Size() == 0) {
   602  			break
   603  		}
   604  		v.copyOf(mem)
   605  		return true
   606  	}
   607  	// match: (Store {t} dst (ComplexMake real imag) mem)
   608  	// cond: t.Size() == 8
   609  	// result: (Store {typ.Float32} (OffPtr <typ.Float32Ptr> [4] dst) imag (Store {typ.Float32} dst real mem))
   610  	for {
   611  		t := auxToType(v.Aux)
   612  		dst := v_0
   613  		if v_1.Op != OpComplexMake {
   614  			break
   615  		}
   616  		imag := v_1.Args[1]
   617  		real := v_1.Args[0]
   618  		mem := v_2
   619  		if !(t.Size() == 8) {
   620  			break
   621  		}
   622  		v.reset(OpStore)
   623  		v.Aux = typeToAux(typ.Float32)
   624  		v0 := b.NewValue0(v.Pos, OpOffPtr, typ.Float32Ptr)
   625  		v0.AuxInt = int64ToAuxInt(4)
   626  		v0.AddArg(dst)
   627  		v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   628  		v1.Aux = typeToAux(typ.Float32)
   629  		v1.AddArg3(dst, real, mem)
   630  		v.AddArg3(v0, imag, v1)
   631  		return true
   632  	}
   633  	// match: (Store {t} dst (ComplexMake real imag) mem)
   634  	// cond: t.Size() == 16
   635  	// result: (Store {typ.Float64} (OffPtr <typ.Float64Ptr> [8] dst) imag (Store {typ.Float64} dst real mem))
   636  	for {
   637  		t := auxToType(v.Aux)
   638  		dst := v_0
   639  		if v_1.Op != OpComplexMake {
   640  			break
   641  		}
   642  		imag := v_1.Args[1]
   643  		real := v_1.Args[0]
   644  		mem := v_2
   645  		if !(t.Size() == 16) {
   646  			break
   647  		}
   648  		v.reset(OpStore)
   649  		v.Aux = typeToAux(typ.Float64)
   650  		v0 := b.NewValue0(v.Pos, OpOffPtr, typ.Float64Ptr)
   651  		v0.AuxInt = int64ToAuxInt(8)
   652  		v0.AddArg(dst)
   653  		v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   654  		v1.Aux = typeToAux(typ.Float64)
   655  		v1.AddArg3(dst, real, mem)
   656  		v.AddArg3(v0, imag, v1)
   657  		return true
   658  	}
   659  	// match: (Store dst (StringMake ptr len) mem)
   660  	// result: (Store {typ.Int} (OffPtr <typ.IntPtr> [config.PtrSize] dst) len (Store {typ.BytePtr} dst ptr mem))
   661  	for {
   662  		dst := v_0
   663  		if v_1.Op != OpStringMake {
   664  			break
   665  		}
   666  		len := v_1.Args[1]
   667  		ptr := v_1.Args[0]
   668  		mem := v_2
   669  		v.reset(OpStore)
   670  		v.Aux = typeToAux(typ.Int)
   671  		v0 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   672  		v0.AuxInt = int64ToAuxInt(config.PtrSize)
   673  		v0.AddArg(dst)
   674  		v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   675  		v1.Aux = typeToAux(typ.BytePtr)
   676  		v1.AddArg3(dst, ptr, mem)
   677  		v.AddArg3(v0, len, v1)
   678  		return true
   679  	}
   680  	// match: (Store {t} dst (SliceMake ptr len cap) mem)
   681  	// result: (Store {typ.Int} (OffPtr <typ.IntPtr> [2*config.PtrSize] dst) cap (Store {typ.Int} (OffPtr <typ.IntPtr> [config.PtrSize] dst) len (Store {t.Elem().PtrTo()} dst ptr mem)))
   682  	for {
   683  		t := auxToType(v.Aux)
   684  		dst := v_0
   685  		if v_1.Op != OpSliceMake {
   686  			break
   687  		}
   688  		cap := v_1.Args[2]
   689  		ptr := v_1.Args[0]
   690  		len := v_1.Args[1]
   691  		mem := v_2
   692  		v.reset(OpStore)
   693  		v.Aux = typeToAux(typ.Int)
   694  		v0 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   695  		v0.AuxInt = int64ToAuxInt(2 * config.PtrSize)
   696  		v0.AddArg(dst)
   697  		v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   698  		v1.Aux = typeToAux(typ.Int)
   699  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   700  		v2.AuxInt = int64ToAuxInt(config.PtrSize)
   701  		v2.AddArg(dst)
   702  		v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   703  		v3.Aux = typeToAux(t.Elem().PtrTo())
   704  		v3.AddArg3(dst, ptr, mem)
   705  		v1.AddArg3(v2, len, v3)
   706  		v.AddArg3(v0, cap, v1)
   707  		return true
   708  	}
   709  	// match: (Store dst (IMake itab data) mem)
   710  	// result: (Store {typ.BytePtr} (OffPtr <typ.BytePtrPtr> [config.PtrSize] dst) data (Store {typ.Uintptr} dst itab mem))
   711  	for {
   712  		dst := v_0
   713  		if v_1.Op != OpIMake {
   714  			break
   715  		}
   716  		data := v_1.Args[1]
   717  		itab := v_1.Args[0]
   718  		mem := v_2
   719  		v.reset(OpStore)
   720  		v.Aux = typeToAux(typ.BytePtr)
   721  		v0 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr)
   722  		v0.AuxInt = int64ToAuxInt(config.PtrSize)
   723  		v0.AddArg(dst)
   724  		v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   725  		v1.Aux = typeToAux(typ.Uintptr)
   726  		v1.AddArg3(dst, itab, mem)
   727  		v.AddArg3(v0, data, v1)
   728  		return true
   729  	}
   730  	// match: (Store _ (StructMake ___) _)
   731  	// result: rewriteStructStore(v)
   732  	for {
   733  		if v_1.Op != OpStructMake {
   734  			break
   735  		}
   736  		v.copyOf(rewriteStructStore(v))
   737  		return true
   738  	}
   739  	// match: (Store dst (ArrayMake1 e) mem)
   740  	// result: (Store {e.Type} dst e mem)
   741  	for {
   742  		dst := v_0
   743  		if v_1.Op != OpArrayMake1 {
   744  			break
   745  		}
   746  		e := v_1.Args[0]
   747  		mem := v_2
   748  		v.reset(OpStore)
   749  		v.Aux = typeToAux(e.Type)
   750  		v.AddArg3(dst, e, mem)
   751  		return true
   752  	}
   753  	return false
   754  }
   755  func rewriteValuedec_OpStringLen(v *Value) bool {
   756  	v_0 := v.Args[0]
   757  	b := v.Block
   758  	config := b.Func.Config
   759  	typ := &b.Func.Config.Types
   760  	// match: (StringLen (StringMake _ len))
   761  	// result: len
   762  	for {
   763  		if v_0.Op != OpStringMake {
   764  			break
   765  		}
   766  		len := v_0.Args[1]
   767  		v.copyOf(len)
   768  		return true
   769  	}
   770  	// match: (StringLen x:(Load <t> ptr mem))
   771  	// cond: t.IsString()
   772  	// result: @x.Block (Load <typ.Int> (OffPtr <typ.IntPtr> [config.PtrSize] ptr) mem)
   773  	for {
   774  		x := v_0
   775  		if x.Op != OpLoad {
   776  			break
   777  		}
   778  		t := x.Type
   779  		mem := x.Args[1]
   780  		ptr := x.Args[0]
   781  		if !(t.IsString()) {
   782  			break
   783  		}
   784  		b = x.Block
   785  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   786  		v.copyOf(v0)
   787  		v1 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   788  		v1.AuxInt = int64ToAuxInt(config.PtrSize)
   789  		v1.AddArg(ptr)
   790  		v0.AddArg2(v1, mem)
   791  		return true
   792  	}
   793  	return false
   794  }
   795  func rewriteValuedec_OpStringPtr(v *Value) bool {
   796  	v_0 := v.Args[0]
   797  	b := v.Block
   798  	typ := &b.Func.Config.Types
   799  	// match: (StringPtr (StringMake ptr _))
   800  	// result: ptr
   801  	for {
   802  		if v_0.Op != OpStringMake {
   803  			break
   804  		}
   805  		ptr := v_0.Args[0]
   806  		v.copyOf(ptr)
   807  		return true
   808  	}
   809  	// match: (StringPtr x:(Load <t> ptr mem))
   810  	// cond: t.IsString()
   811  	// result: @x.Block (Load <typ.BytePtr> ptr mem)
   812  	for {
   813  		x := v_0
   814  		if x.Op != OpLoad {
   815  			break
   816  		}
   817  		t := x.Type
   818  		mem := x.Args[1]
   819  		ptr := x.Args[0]
   820  		if !(t.IsString()) {
   821  			break
   822  		}
   823  		b = x.Block
   824  		v0 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr)
   825  		v.copyOf(v0)
   826  		v0.AddArg2(ptr, mem)
   827  		return true
   828  	}
   829  	return false
   830  }
   831  func rewriteValuedec_OpStructMake(v *Value) bool {
   832  	// match: (StructMake x)
   833  	// cond: x.Type.IsPtrShaped()
   834  	// result: x
   835  	for {
   836  		if len(v.Args) != 1 {
   837  			break
   838  		}
   839  		x := v.Args[0]
   840  		if !(x.Type.IsPtrShaped()) {
   841  			break
   842  		}
   843  		v.copyOf(x)
   844  		return true
   845  	}
   846  	return false
   847  }
   848  func rewriteValuedec_OpStructSelect(v *Value) bool {
   849  	v_0 := v.Args[0]
   850  	b := v.Block
   851  	// match: (StructSelect (IData x))
   852  	// cond: v.Type.Size() > 0
   853  	// result: (IData x)
   854  	for {
   855  		if v_0.Op != OpIData {
   856  			break
   857  		}
   858  		x := v_0.Args[0]
   859  		if !(v.Type.Size() > 0) {
   860  			break
   861  		}
   862  		v.reset(OpIData)
   863  		v.AddArg(x)
   864  		return true
   865  	}
   866  	// match: (StructSelect (IData x))
   867  	// cond: v.Type.Size() == 0 && v.Type.IsStruct()
   868  	// result: (StructMake)
   869  	for {
   870  		if v_0.Op != OpIData {
   871  			break
   872  		}
   873  		if !(v.Type.Size() == 0 && v.Type.IsStruct()) {
   874  			break
   875  		}
   876  		v.reset(OpStructMake)
   877  		return true
   878  	}
   879  	// match: (StructSelect (IData x))
   880  	// cond: v.Type.Size() == 0 && v.Type.IsArray()
   881  	// result: (ArrayMake0)
   882  	for {
   883  		if v_0.Op != OpIData {
   884  			break
   885  		}
   886  		if !(v.Type.Size() == 0 && v.Type.IsArray()) {
   887  			break
   888  		}
   889  		v.reset(OpArrayMake0)
   890  		return true
   891  	}
   892  	// match: (StructSelect [i] x:(StructMake ___))
   893  	// result: x.Args[i]
   894  	for {
   895  		i := auxIntToInt64(v.AuxInt)
   896  		x := v_0
   897  		if x.Op != OpStructMake {
   898  			break
   899  		}
   900  		v.copyOf(x.Args[i])
   901  		return true
   902  	}
   903  	// match: (StructSelect x)
   904  	// cond: x.Type.IsPtrShaped()
   905  	// result: x
   906  	for {
   907  		x := v_0
   908  		if !(x.Type.IsPtrShaped()) {
   909  			break
   910  		}
   911  		v.copyOf(x)
   912  		return true
   913  	}
   914  	// match: (StructSelect [i] x:(Load <t> ptr mem))
   915  	// result: @x.Block (Load <v.Type> (OffPtr <v.Type.PtrTo()> [t.FieldOff(int(i))] ptr) mem)
   916  	for {
   917  		i := auxIntToInt64(v.AuxInt)
   918  		x := v_0
   919  		if x.Op != OpLoad {
   920  			break
   921  		}
   922  		t := x.Type
   923  		mem := x.Args[1]
   924  		ptr := x.Args[0]
   925  		b = x.Block
   926  		v0 := b.NewValue0(v.Pos, OpLoad, v.Type)
   927  		v.copyOf(v0)
   928  		v1 := b.NewValue0(v.Pos, OpOffPtr, v.Type.PtrTo())
   929  		v1.AuxInt = int64ToAuxInt(t.FieldOff(int(i)))
   930  		v1.AddArg(ptr)
   931  		v0.AddArg2(v1, mem)
   932  		return true
   933  	}
   934  	return false
   935  }
   936  func rewriteBlockdec(b *Block) bool {
   937  	return false
   938  }
   939  

View as plain text