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  	// cond: data.Op != OpStructMake && data.Op != OpArrayMake1
   246  	// result: data
   247  	for {
   248  		if v_0.Op != OpIMake {
   249  			break
   250  		}
   251  		data := v_0.Args[1]
   252  		if !(data.Op != OpStructMake && data.Op != OpArrayMake1) {
   253  			break
   254  		}
   255  		v.copyOf(data)
   256  		return true
   257  	}
   258  	// match: (IData x:(Load <t> ptr mem))
   259  	// cond: t.IsInterface()
   260  	// result: @x.Block (Load <typ.BytePtr> (OffPtr <typ.BytePtrPtr> [config.PtrSize] ptr) mem)
   261  	for {
   262  		x := v_0
   263  		if x.Op != OpLoad {
   264  			break
   265  		}
   266  		t := x.Type
   267  		mem := x.Args[1]
   268  		ptr := x.Args[0]
   269  		if !(t.IsInterface()) {
   270  			break
   271  		}
   272  		b = x.Block
   273  		v0 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr)
   274  		v.copyOf(v0)
   275  		v1 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr)
   276  		v1.AuxInt = int64ToAuxInt(config.PtrSize)
   277  		v1.AddArg(ptr)
   278  		v0.AddArg2(v1, mem)
   279  		return true
   280  	}
   281  	return false
   282  }
   283  func rewriteValuedec_OpIMake(v *Value) bool {
   284  	v_1 := v.Args[1]
   285  	v_0 := v.Args[0]
   286  	// match: (IMake _typ (StructMake ___))
   287  	// result: imakeOfStructMake(v)
   288  	for {
   289  		if v_1.Op != OpStructMake {
   290  			break
   291  		}
   292  		v.copyOf(imakeOfStructMake(v))
   293  		return true
   294  	}
   295  	// match: (IMake _typ (ArrayMake1 val))
   296  	// result: (IMake _typ val)
   297  	for {
   298  		_typ := v_0
   299  		if v_1.Op != OpArrayMake1 {
   300  			break
   301  		}
   302  		val := v_1.Args[0]
   303  		v.reset(OpIMake)
   304  		v.AddArg2(_typ, val)
   305  		return true
   306  	}
   307  	return false
   308  }
   309  func rewriteValuedec_OpITab(v *Value) bool {
   310  	v_0 := v.Args[0]
   311  	b := v.Block
   312  	typ := &b.Func.Config.Types
   313  	// match: (ITab (IMake itab _))
   314  	// result: itab
   315  	for {
   316  		if v_0.Op != OpIMake {
   317  			break
   318  		}
   319  		itab := v_0.Args[0]
   320  		v.copyOf(itab)
   321  		return true
   322  	}
   323  	// match: (ITab x:(Load <t> ptr mem))
   324  	// cond: t.IsInterface()
   325  	// result: @x.Block (Load <typ.Uintptr> ptr mem)
   326  	for {
   327  		x := v_0
   328  		if x.Op != OpLoad {
   329  			break
   330  		}
   331  		t := x.Type
   332  		mem := x.Args[1]
   333  		ptr := x.Args[0]
   334  		if !(t.IsInterface()) {
   335  			break
   336  		}
   337  		b = x.Block
   338  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Uintptr)
   339  		v.copyOf(v0)
   340  		v0.AddArg2(ptr, mem)
   341  		return true
   342  	}
   343  	return false
   344  }
   345  func rewriteValuedec_OpLoad(v *Value) bool {
   346  	v_1 := v.Args[1]
   347  	v_0 := v.Args[0]
   348  	b := v.Block
   349  	config := b.Func.Config
   350  	typ := &b.Func.Config.Types
   351  	// match: (Load <t> ptr mem)
   352  	// cond: t.IsComplex() && t.Size() == 8
   353  	// result: (ComplexMake (Load <typ.Float32> ptr mem) (Load <typ.Float32> (OffPtr <typ.Float32Ptr> [4] ptr) mem) )
   354  	for {
   355  		t := v.Type
   356  		ptr := v_0
   357  		mem := v_1
   358  		if !(t.IsComplex() && t.Size() == 8) {
   359  			break
   360  		}
   361  		v.reset(OpComplexMake)
   362  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Float32)
   363  		v0.AddArg2(ptr, mem)
   364  		v1 := b.NewValue0(v.Pos, OpLoad, typ.Float32)
   365  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.Float32Ptr)
   366  		v2.AuxInt = int64ToAuxInt(4)
   367  		v2.AddArg(ptr)
   368  		v1.AddArg2(v2, mem)
   369  		v.AddArg2(v0, v1)
   370  		return true
   371  	}
   372  	// match: (Load <t> ptr mem)
   373  	// cond: t.IsComplex() && t.Size() == 16
   374  	// result: (ComplexMake (Load <typ.Float64> ptr mem) (Load <typ.Float64> (OffPtr <typ.Float64Ptr> [8] ptr) mem) )
   375  	for {
   376  		t := v.Type
   377  		ptr := v_0
   378  		mem := v_1
   379  		if !(t.IsComplex() && t.Size() == 16) {
   380  			break
   381  		}
   382  		v.reset(OpComplexMake)
   383  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Float64)
   384  		v0.AddArg2(ptr, mem)
   385  		v1 := b.NewValue0(v.Pos, OpLoad, typ.Float64)
   386  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.Float64Ptr)
   387  		v2.AuxInt = int64ToAuxInt(8)
   388  		v2.AddArg(ptr)
   389  		v1.AddArg2(v2, mem)
   390  		v.AddArg2(v0, v1)
   391  		return true
   392  	}
   393  	// match: (Load <t> ptr mem)
   394  	// cond: t.IsString()
   395  	// result: (StringMake (Load <typ.BytePtr> ptr mem) (Load <typ.Int> (OffPtr <typ.IntPtr> [config.PtrSize] ptr) mem))
   396  	for {
   397  		t := v.Type
   398  		ptr := v_0
   399  		mem := v_1
   400  		if !(t.IsString()) {
   401  			break
   402  		}
   403  		v.reset(OpStringMake)
   404  		v0 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr)
   405  		v0.AddArg2(ptr, mem)
   406  		v1 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   407  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   408  		v2.AuxInt = int64ToAuxInt(config.PtrSize)
   409  		v2.AddArg(ptr)
   410  		v1.AddArg2(v2, mem)
   411  		v.AddArg2(v0, v1)
   412  		return true
   413  	}
   414  	// match: (Load <t> ptr mem)
   415  	// cond: t.IsSlice()
   416  	// 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))
   417  	for {
   418  		t := v.Type
   419  		ptr := v_0
   420  		mem := v_1
   421  		if !(t.IsSlice()) {
   422  			break
   423  		}
   424  		v.reset(OpSliceMake)
   425  		v0 := b.NewValue0(v.Pos, OpLoad, t.Elem().PtrTo())
   426  		v0.AddArg2(ptr, mem)
   427  		v1 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   428  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   429  		v2.AuxInt = int64ToAuxInt(config.PtrSize)
   430  		v2.AddArg(ptr)
   431  		v1.AddArg2(v2, mem)
   432  		v3 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   433  		v4 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   434  		v4.AuxInt = int64ToAuxInt(2 * config.PtrSize)
   435  		v4.AddArg(ptr)
   436  		v3.AddArg2(v4, mem)
   437  		v.AddArg3(v0, v1, v3)
   438  		return true
   439  	}
   440  	// match: (Load <t> ptr mem)
   441  	// cond: t.IsInterface()
   442  	// result: (IMake (Load <typ.Uintptr> ptr mem) (Load <typ.BytePtr> (OffPtr <typ.BytePtrPtr> [config.PtrSize] ptr) mem))
   443  	for {
   444  		t := v.Type
   445  		ptr := v_0
   446  		mem := v_1
   447  		if !(t.IsInterface()) {
   448  			break
   449  		}
   450  		v.reset(OpIMake)
   451  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Uintptr)
   452  		v0.AddArg2(ptr, mem)
   453  		v1 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr)
   454  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr)
   455  		v2.AuxInt = int64ToAuxInt(config.PtrSize)
   456  		v2.AddArg(ptr)
   457  		v1.AddArg2(v2, mem)
   458  		v.AddArg2(v0, v1)
   459  		return true
   460  	}
   461  	return false
   462  }
   463  func rewriteValuedec_OpSliceCap(v *Value) bool {
   464  	v_0 := v.Args[0]
   465  	b := v.Block
   466  	config := b.Func.Config
   467  	typ := &b.Func.Config.Types
   468  	// match: (SliceCap (SliceMake _ _ cap))
   469  	// result: cap
   470  	for {
   471  		if v_0.Op != OpSliceMake {
   472  			break
   473  		}
   474  		cap := v_0.Args[2]
   475  		v.copyOf(cap)
   476  		return true
   477  	}
   478  	// match: (SliceCap x:(Load <t> ptr mem))
   479  	// cond: t.IsSlice()
   480  	// result: @x.Block (Load <typ.Int> (OffPtr <typ.IntPtr> [2*config.PtrSize] ptr) mem)
   481  	for {
   482  		x := v_0
   483  		if x.Op != OpLoad {
   484  			break
   485  		}
   486  		t := x.Type
   487  		mem := x.Args[1]
   488  		ptr := x.Args[0]
   489  		if !(t.IsSlice()) {
   490  			break
   491  		}
   492  		b = x.Block
   493  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   494  		v.copyOf(v0)
   495  		v1 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   496  		v1.AuxInt = int64ToAuxInt(2 * config.PtrSize)
   497  		v1.AddArg(ptr)
   498  		v0.AddArg2(v1, mem)
   499  		return true
   500  	}
   501  	return false
   502  }
   503  func rewriteValuedec_OpSliceLen(v *Value) bool {
   504  	v_0 := v.Args[0]
   505  	b := v.Block
   506  	config := b.Func.Config
   507  	typ := &b.Func.Config.Types
   508  	// match: (SliceLen (SliceMake _ len _))
   509  	// result: len
   510  	for {
   511  		if v_0.Op != OpSliceMake {
   512  			break
   513  		}
   514  		len := v_0.Args[1]
   515  		v.copyOf(len)
   516  		return true
   517  	}
   518  	// match: (SliceLen x:(Load <t> ptr mem))
   519  	// cond: t.IsSlice()
   520  	// result: @x.Block (Load <typ.Int> (OffPtr <typ.IntPtr> [config.PtrSize] ptr) mem)
   521  	for {
   522  		x := v_0
   523  		if x.Op != OpLoad {
   524  			break
   525  		}
   526  		t := x.Type
   527  		mem := x.Args[1]
   528  		ptr := x.Args[0]
   529  		if !(t.IsSlice()) {
   530  			break
   531  		}
   532  		b = x.Block
   533  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   534  		v.copyOf(v0)
   535  		v1 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   536  		v1.AuxInt = int64ToAuxInt(config.PtrSize)
   537  		v1.AddArg(ptr)
   538  		v0.AddArg2(v1, mem)
   539  		return true
   540  	}
   541  	return false
   542  }
   543  func rewriteValuedec_OpSlicePtr(v *Value) bool {
   544  	v_0 := v.Args[0]
   545  	b := v.Block
   546  	// match: (SlicePtr (SliceMake ptr _ _ ))
   547  	// result: ptr
   548  	for {
   549  		if v_0.Op != OpSliceMake {
   550  			break
   551  		}
   552  		ptr := v_0.Args[0]
   553  		v.copyOf(ptr)
   554  		return true
   555  	}
   556  	// match: (SlicePtr x:(Load <t> ptr mem))
   557  	// cond: t.IsSlice()
   558  	// result: @x.Block (Load <t.Elem().PtrTo()> ptr mem)
   559  	for {
   560  		x := v_0
   561  		if x.Op != OpLoad {
   562  			break
   563  		}
   564  		t := x.Type
   565  		mem := x.Args[1]
   566  		ptr := x.Args[0]
   567  		if !(t.IsSlice()) {
   568  			break
   569  		}
   570  		b = x.Block
   571  		v0 := b.NewValue0(v.Pos, OpLoad, t.Elem().PtrTo())
   572  		v.copyOf(v0)
   573  		v0.AddArg2(ptr, mem)
   574  		return true
   575  	}
   576  	return false
   577  }
   578  func rewriteValuedec_OpSlicePtrUnchecked(v *Value) bool {
   579  	v_0 := v.Args[0]
   580  	// match: (SlicePtrUnchecked (SliceMake ptr _ _ ))
   581  	// result: ptr
   582  	for {
   583  		if v_0.Op != OpSliceMake {
   584  			break
   585  		}
   586  		ptr := v_0.Args[0]
   587  		v.copyOf(ptr)
   588  		return true
   589  	}
   590  	return false
   591  }
   592  func rewriteValuedec_OpStore(v *Value) bool {
   593  	v_2 := v.Args[2]
   594  	v_1 := v.Args[1]
   595  	v_0 := v.Args[0]
   596  	b := v.Block
   597  	config := b.Func.Config
   598  	typ := &b.Func.Config.Types
   599  	// match: (Store {t} _ _ mem)
   600  	// cond: t.Size() == 0
   601  	// result: mem
   602  	for {
   603  		t := auxToType(v.Aux)
   604  		mem := v_2
   605  		if !(t.Size() == 0) {
   606  			break
   607  		}
   608  		v.copyOf(mem)
   609  		return true
   610  	}
   611  	// match: (Store {t} dst (ComplexMake real imag) mem)
   612  	// cond: t.Size() == 8
   613  	// result: (Store {typ.Float32} (OffPtr <typ.Float32Ptr> [4] dst) imag (Store {typ.Float32} dst real mem))
   614  	for {
   615  		t := auxToType(v.Aux)
   616  		dst := v_0
   617  		if v_1.Op != OpComplexMake {
   618  			break
   619  		}
   620  		imag := v_1.Args[1]
   621  		real := v_1.Args[0]
   622  		mem := v_2
   623  		if !(t.Size() == 8) {
   624  			break
   625  		}
   626  		v.reset(OpStore)
   627  		v.Aux = typeToAux(typ.Float32)
   628  		v0 := b.NewValue0(v.Pos, OpOffPtr, typ.Float32Ptr)
   629  		v0.AuxInt = int64ToAuxInt(4)
   630  		v0.AddArg(dst)
   631  		v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   632  		v1.Aux = typeToAux(typ.Float32)
   633  		v1.AddArg3(dst, real, mem)
   634  		v.AddArg3(v0, imag, v1)
   635  		return true
   636  	}
   637  	// match: (Store {t} dst (ComplexMake real imag) mem)
   638  	// cond: t.Size() == 16
   639  	// result: (Store {typ.Float64} (OffPtr <typ.Float64Ptr> [8] dst) imag (Store {typ.Float64} dst real mem))
   640  	for {
   641  		t := auxToType(v.Aux)
   642  		dst := v_0
   643  		if v_1.Op != OpComplexMake {
   644  			break
   645  		}
   646  		imag := v_1.Args[1]
   647  		real := v_1.Args[0]
   648  		mem := v_2
   649  		if !(t.Size() == 16) {
   650  			break
   651  		}
   652  		v.reset(OpStore)
   653  		v.Aux = typeToAux(typ.Float64)
   654  		v0 := b.NewValue0(v.Pos, OpOffPtr, typ.Float64Ptr)
   655  		v0.AuxInt = int64ToAuxInt(8)
   656  		v0.AddArg(dst)
   657  		v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   658  		v1.Aux = typeToAux(typ.Float64)
   659  		v1.AddArg3(dst, real, mem)
   660  		v.AddArg3(v0, imag, v1)
   661  		return true
   662  	}
   663  	// match: (Store dst (StringMake ptr len) mem)
   664  	// result: (Store {typ.Int} (OffPtr <typ.IntPtr> [config.PtrSize] dst) len (Store {typ.BytePtr} dst ptr mem))
   665  	for {
   666  		dst := v_0
   667  		if v_1.Op != OpStringMake {
   668  			break
   669  		}
   670  		len := v_1.Args[1]
   671  		ptr := v_1.Args[0]
   672  		mem := v_2
   673  		v.reset(OpStore)
   674  		v.Aux = typeToAux(typ.Int)
   675  		v0 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   676  		v0.AuxInt = int64ToAuxInt(config.PtrSize)
   677  		v0.AddArg(dst)
   678  		v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   679  		v1.Aux = typeToAux(typ.BytePtr)
   680  		v1.AddArg3(dst, ptr, mem)
   681  		v.AddArg3(v0, len, v1)
   682  		return true
   683  	}
   684  	// match: (Store {t} dst (SliceMake ptr len cap) mem)
   685  	// 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)))
   686  	for {
   687  		t := auxToType(v.Aux)
   688  		dst := v_0
   689  		if v_1.Op != OpSliceMake {
   690  			break
   691  		}
   692  		cap := v_1.Args[2]
   693  		ptr := v_1.Args[0]
   694  		len := v_1.Args[1]
   695  		mem := v_2
   696  		v.reset(OpStore)
   697  		v.Aux = typeToAux(typ.Int)
   698  		v0 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   699  		v0.AuxInt = int64ToAuxInt(2 * config.PtrSize)
   700  		v0.AddArg(dst)
   701  		v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   702  		v1.Aux = typeToAux(typ.Int)
   703  		v2 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   704  		v2.AuxInt = int64ToAuxInt(config.PtrSize)
   705  		v2.AddArg(dst)
   706  		v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   707  		v3.Aux = typeToAux(t.Elem().PtrTo())
   708  		v3.AddArg3(dst, ptr, mem)
   709  		v1.AddArg3(v2, len, v3)
   710  		v.AddArg3(v0, cap, v1)
   711  		return true
   712  	}
   713  	// match: (Store dst (IMake itab data) mem)
   714  	// result: (Store {typ.BytePtr} (OffPtr <typ.BytePtrPtr> [config.PtrSize] dst) data (Store {typ.Uintptr} dst itab mem))
   715  	for {
   716  		dst := v_0
   717  		if v_1.Op != OpIMake {
   718  			break
   719  		}
   720  		data := v_1.Args[1]
   721  		itab := v_1.Args[0]
   722  		mem := v_2
   723  		v.reset(OpStore)
   724  		v.Aux = typeToAux(typ.BytePtr)
   725  		v0 := b.NewValue0(v.Pos, OpOffPtr, typ.BytePtrPtr)
   726  		v0.AuxInt = int64ToAuxInt(config.PtrSize)
   727  		v0.AddArg(dst)
   728  		v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem)
   729  		v1.Aux = typeToAux(typ.Uintptr)
   730  		v1.AddArg3(dst, itab, mem)
   731  		v.AddArg3(v0, data, v1)
   732  		return true
   733  	}
   734  	// match: (Store _ (StructMake ___) _)
   735  	// result: rewriteStructStore(v)
   736  	for {
   737  		if v_1.Op != OpStructMake {
   738  			break
   739  		}
   740  		v.copyOf(rewriteStructStore(v))
   741  		return true
   742  	}
   743  	// match: (Store dst (ArrayMake1 e) mem)
   744  	// result: (Store {e.Type} dst e mem)
   745  	for {
   746  		dst := v_0
   747  		if v_1.Op != OpArrayMake1 {
   748  			break
   749  		}
   750  		e := v_1.Args[0]
   751  		mem := v_2
   752  		v.reset(OpStore)
   753  		v.Aux = typeToAux(e.Type)
   754  		v.AddArg3(dst, e, mem)
   755  		return true
   756  	}
   757  	return false
   758  }
   759  func rewriteValuedec_OpStringLen(v *Value) bool {
   760  	v_0 := v.Args[0]
   761  	b := v.Block
   762  	config := b.Func.Config
   763  	typ := &b.Func.Config.Types
   764  	// match: (StringLen (StringMake _ len))
   765  	// result: len
   766  	for {
   767  		if v_0.Op != OpStringMake {
   768  			break
   769  		}
   770  		len := v_0.Args[1]
   771  		v.copyOf(len)
   772  		return true
   773  	}
   774  	// match: (StringLen x:(Load <t> ptr mem))
   775  	// cond: t.IsString()
   776  	// result: @x.Block (Load <typ.Int> (OffPtr <typ.IntPtr> [config.PtrSize] ptr) mem)
   777  	for {
   778  		x := v_0
   779  		if x.Op != OpLoad {
   780  			break
   781  		}
   782  		t := x.Type
   783  		mem := x.Args[1]
   784  		ptr := x.Args[0]
   785  		if !(t.IsString()) {
   786  			break
   787  		}
   788  		b = x.Block
   789  		v0 := b.NewValue0(v.Pos, OpLoad, typ.Int)
   790  		v.copyOf(v0)
   791  		v1 := b.NewValue0(v.Pos, OpOffPtr, typ.IntPtr)
   792  		v1.AuxInt = int64ToAuxInt(config.PtrSize)
   793  		v1.AddArg(ptr)
   794  		v0.AddArg2(v1, mem)
   795  		return true
   796  	}
   797  	return false
   798  }
   799  func rewriteValuedec_OpStringPtr(v *Value) bool {
   800  	v_0 := v.Args[0]
   801  	b := v.Block
   802  	typ := &b.Func.Config.Types
   803  	// match: (StringPtr (StringMake ptr _))
   804  	// result: ptr
   805  	for {
   806  		if v_0.Op != OpStringMake {
   807  			break
   808  		}
   809  		ptr := v_0.Args[0]
   810  		v.copyOf(ptr)
   811  		return true
   812  	}
   813  	// match: (StringPtr x:(Load <t> ptr mem))
   814  	// cond: t.IsString()
   815  	// result: @x.Block (Load <typ.BytePtr> ptr mem)
   816  	for {
   817  		x := v_0
   818  		if x.Op != OpLoad {
   819  			break
   820  		}
   821  		t := x.Type
   822  		mem := x.Args[1]
   823  		ptr := x.Args[0]
   824  		if !(t.IsString()) {
   825  			break
   826  		}
   827  		b = x.Block
   828  		v0 := b.NewValue0(v.Pos, OpLoad, typ.BytePtr)
   829  		v.copyOf(v0)
   830  		v0.AddArg2(ptr, mem)
   831  		return true
   832  	}
   833  	return false
   834  }
   835  func rewriteValuedec_OpStructMake(v *Value) bool {
   836  	// match: (StructMake x)
   837  	// cond: x.Type.IsPtrShaped()
   838  	// result: x
   839  	for {
   840  		if len(v.Args) != 1 {
   841  			break
   842  		}
   843  		x := v.Args[0]
   844  		if !(x.Type.IsPtrShaped()) {
   845  			break
   846  		}
   847  		v.copyOf(x)
   848  		return true
   849  	}
   850  	return false
   851  }
   852  func rewriteValuedec_OpStructSelect(v *Value) bool {
   853  	v_0 := v.Args[0]
   854  	b := v.Block
   855  	// match: (StructSelect (IData x))
   856  	// cond: v.Type.Size() > 0
   857  	// result: (IData x)
   858  	for {
   859  		if v_0.Op != OpIData {
   860  			break
   861  		}
   862  		x := v_0.Args[0]
   863  		if !(v.Type.Size() > 0) {
   864  			break
   865  		}
   866  		v.reset(OpIData)
   867  		v.AddArg(x)
   868  		return true
   869  	}
   870  	// match: (StructSelect (IData x))
   871  	// cond: v.Type.Size() == 0 && v.Type.IsStruct()
   872  	// result: (StructMake)
   873  	for {
   874  		if v_0.Op != OpIData {
   875  			break
   876  		}
   877  		if !(v.Type.Size() == 0 && v.Type.IsStruct()) {
   878  			break
   879  		}
   880  		v.reset(OpStructMake)
   881  		return true
   882  	}
   883  	// match: (StructSelect (IData x))
   884  	// cond: v.Type.Size() == 0 && v.Type.IsArray()
   885  	// result: (ArrayMake0)
   886  	for {
   887  		if v_0.Op != OpIData {
   888  			break
   889  		}
   890  		if !(v.Type.Size() == 0 && v.Type.IsArray()) {
   891  			break
   892  		}
   893  		v.reset(OpArrayMake0)
   894  		return true
   895  	}
   896  	// match: (StructSelect [i] x:(StructMake ___))
   897  	// result: x.Args[i]
   898  	for {
   899  		i := auxIntToInt64(v.AuxInt)
   900  		x := v_0
   901  		if x.Op != OpStructMake {
   902  			break
   903  		}
   904  		v.copyOf(x.Args[i])
   905  		return true
   906  	}
   907  	// match: (StructSelect x)
   908  	// cond: x.Type.IsPtrShaped()
   909  	// result: x
   910  	for {
   911  		x := v_0
   912  		if !(x.Type.IsPtrShaped()) {
   913  			break
   914  		}
   915  		v.copyOf(x)
   916  		return true
   917  	}
   918  	// match: (StructSelect [i] x:(Load <t> ptr mem))
   919  	// result: @x.Block (Load <v.Type> (OffPtr <v.Type.PtrTo()> [t.FieldOff(int(i))] ptr) mem)
   920  	for {
   921  		i := auxIntToInt64(v.AuxInt)
   922  		x := v_0
   923  		if x.Op != OpLoad {
   924  			break
   925  		}
   926  		t := x.Type
   927  		mem := x.Args[1]
   928  		ptr := x.Args[0]
   929  		b = x.Block
   930  		v0 := b.NewValue0(v.Pos, OpLoad, v.Type)
   931  		v.copyOf(v0)
   932  		v1 := b.NewValue0(v.Pos, OpOffPtr, v.Type.PtrTo())
   933  		v1.AuxInt = int64ToAuxInt(t.FieldOff(int(i)))
   934  		v1.AddArg(ptr)
   935  		v0.AddArg2(v1, mem)
   936  		return true
   937  	}
   938  	return false
   939  }
   940  func rewriteBlockdec(b *Block) bool {
   941  	return false
   942  }
   943  

View as plain text