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

Documentation: cmd/compile/internal/ssa

     1  // Code generated from gen/decArgs.rules; DO NOT EDIT.
     2  // generated with: cd gen; go run *.go
     3  
     4  package ssa
     5  
     6  import "fmt"
     7  import "math"
     8  import "cmd/internal/obj"
     9  import "cmd/internal/objabi"
    10  import "cmd/compile/internal/types"
    11  
    12  var _ = fmt.Println   // in case not otherwise used
    13  var _ = math.MinInt8  // in case not otherwise used
    14  var _ = obj.ANOP      // in case not otherwise used
    15  var _ = objabi.GOROOT // in case not otherwise used
    16  var _ = types.TypeMem // in case not otherwise used
    17  
    18  func rewriteValuedecArgs(v *Value) bool {
    19  	switch v.Op {
    20  	case OpArg:
    21  		return rewriteValuedecArgs_OpArg_0(v) || rewriteValuedecArgs_OpArg_10(v)
    22  	}
    23  	return false
    24  }
    25  func rewriteValuedecArgs_OpArg_0(v *Value) bool {
    26  	b := v.Block
    27  	config := b.Func.Config
    28  	fe := b.Func.fe
    29  	typ := &b.Func.Config.Types
    30  	// match: (Arg {n} [off])
    31  	// cond: v.Type.IsString()
    32  	// result: (StringMake (Arg <typ.BytePtr> {n} [off]) (Arg <typ.Int> {n} [off+config.PtrSize]))
    33  	for {
    34  		off := v.AuxInt
    35  		n := v.Aux
    36  		if !(v.Type.IsString()) {
    37  			break
    38  		}
    39  		v.reset(OpStringMake)
    40  		v0 := b.NewValue0(v.Pos, OpArg, typ.BytePtr)
    41  		v0.AuxInt = off
    42  		v0.Aux = n
    43  		v.AddArg(v0)
    44  		v1 := b.NewValue0(v.Pos, OpArg, typ.Int)
    45  		v1.AuxInt = off + config.PtrSize
    46  		v1.Aux = n
    47  		v.AddArg(v1)
    48  		return true
    49  	}
    50  	// match: (Arg {n} [off])
    51  	// cond: v.Type.IsSlice()
    52  	// result: (SliceMake (Arg <v.Type.Elem().PtrTo()> {n} [off]) (Arg <typ.Int> {n} [off+config.PtrSize]) (Arg <typ.Int> {n} [off+2*config.PtrSize]))
    53  	for {
    54  		off := v.AuxInt
    55  		n := v.Aux
    56  		if !(v.Type.IsSlice()) {
    57  			break
    58  		}
    59  		v.reset(OpSliceMake)
    60  		v0 := b.NewValue0(v.Pos, OpArg, v.Type.Elem().PtrTo())
    61  		v0.AuxInt = off
    62  		v0.Aux = n
    63  		v.AddArg(v0)
    64  		v1 := b.NewValue0(v.Pos, OpArg, typ.Int)
    65  		v1.AuxInt = off + config.PtrSize
    66  		v1.Aux = n
    67  		v.AddArg(v1)
    68  		v2 := b.NewValue0(v.Pos, OpArg, typ.Int)
    69  		v2.AuxInt = off + 2*config.PtrSize
    70  		v2.Aux = n
    71  		v.AddArg(v2)
    72  		return true
    73  	}
    74  	// match: (Arg {n} [off])
    75  	// cond: v.Type.IsInterface()
    76  	// result: (IMake (Arg <typ.Uintptr> {n} [off]) (Arg <typ.BytePtr> {n} [off+config.PtrSize]))
    77  	for {
    78  		off := v.AuxInt
    79  		n := v.Aux
    80  		if !(v.Type.IsInterface()) {
    81  			break
    82  		}
    83  		v.reset(OpIMake)
    84  		v0 := b.NewValue0(v.Pos, OpArg, typ.Uintptr)
    85  		v0.AuxInt = off
    86  		v0.Aux = n
    87  		v.AddArg(v0)
    88  		v1 := b.NewValue0(v.Pos, OpArg, typ.BytePtr)
    89  		v1.AuxInt = off + config.PtrSize
    90  		v1.Aux = n
    91  		v.AddArg(v1)
    92  		return true
    93  	}
    94  	// match: (Arg {n} [off])
    95  	// cond: v.Type.IsComplex() && v.Type.Size() == 16
    96  	// result: (ComplexMake (Arg <typ.Float64> {n} [off]) (Arg <typ.Float64> {n} [off+8]))
    97  	for {
    98  		off := v.AuxInt
    99  		n := v.Aux
   100  		if !(v.Type.IsComplex() && v.Type.Size() == 16) {
   101  			break
   102  		}
   103  		v.reset(OpComplexMake)
   104  		v0 := b.NewValue0(v.Pos, OpArg, typ.Float64)
   105  		v0.AuxInt = off
   106  		v0.Aux = n
   107  		v.AddArg(v0)
   108  		v1 := b.NewValue0(v.Pos, OpArg, typ.Float64)
   109  		v1.AuxInt = off + 8
   110  		v1.Aux = n
   111  		v.AddArg(v1)
   112  		return true
   113  	}
   114  	// match: (Arg {n} [off])
   115  	// cond: v.Type.IsComplex() && v.Type.Size() == 8
   116  	// result: (ComplexMake (Arg <typ.Float32> {n} [off]) (Arg <typ.Float32> {n} [off+4]))
   117  	for {
   118  		off := v.AuxInt
   119  		n := v.Aux
   120  		if !(v.Type.IsComplex() && v.Type.Size() == 8) {
   121  			break
   122  		}
   123  		v.reset(OpComplexMake)
   124  		v0 := b.NewValue0(v.Pos, OpArg, typ.Float32)
   125  		v0.AuxInt = off
   126  		v0.Aux = n
   127  		v.AddArg(v0)
   128  		v1 := b.NewValue0(v.Pos, OpArg, typ.Float32)
   129  		v1.AuxInt = off + 4
   130  		v1.Aux = n
   131  		v.AddArg(v1)
   132  		return true
   133  	}
   134  	// match: (Arg <t>)
   135  	// cond: t.IsStruct() && t.NumFields() == 0 && fe.CanSSA(t)
   136  	// result: (StructMake0)
   137  	for {
   138  		t := v.Type
   139  		if !(t.IsStruct() && t.NumFields() == 0 && fe.CanSSA(t)) {
   140  			break
   141  		}
   142  		v.reset(OpStructMake0)
   143  		return true
   144  	}
   145  	// match: (Arg <t> {n} [off])
   146  	// cond: t.IsStruct() && t.NumFields() == 1 && fe.CanSSA(t)
   147  	// result: (StructMake1 (Arg <t.FieldType(0)> {n} [off+t.FieldOff(0)]))
   148  	for {
   149  		t := v.Type
   150  		off := v.AuxInt
   151  		n := v.Aux
   152  		if !(t.IsStruct() && t.NumFields() == 1 && fe.CanSSA(t)) {
   153  			break
   154  		}
   155  		v.reset(OpStructMake1)
   156  		v0 := b.NewValue0(v.Pos, OpArg, t.FieldType(0))
   157  		v0.AuxInt = off + t.FieldOff(0)
   158  		v0.Aux = n
   159  		v.AddArg(v0)
   160  		return true
   161  	}
   162  	// match: (Arg <t> {n} [off])
   163  	// cond: t.IsStruct() && t.NumFields() == 2 && fe.CanSSA(t)
   164  	// result: (StructMake2 (Arg <t.FieldType(0)> {n} [off+t.FieldOff(0)]) (Arg <t.FieldType(1)> {n} [off+t.FieldOff(1)]))
   165  	for {
   166  		t := v.Type
   167  		off := v.AuxInt
   168  		n := v.Aux
   169  		if !(t.IsStruct() && t.NumFields() == 2 && fe.CanSSA(t)) {
   170  			break
   171  		}
   172  		v.reset(OpStructMake2)
   173  		v0 := b.NewValue0(v.Pos, OpArg, t.FieldType(0))
   174  		v0.AuxInt = off + t.FieldOff(0)
   175  		v0.Aux = n
   176  		v.AddArg(v0)
   177  		v1 := b.NewValue0(v.Pos, OpArg, t.FieldType(1))
   178  		v1.AuxInt = off + t.FieldOff(1)
   179  		v1.Aux = n
   180  		v.AddArg(v1)
   181  		return true
   182  	}
   183  	// match: (Arg <t> {n} [off])
   184  	// cond: t.IsStruct() && t.NumFields() == 3 && fe.CanSSA(t)
   185  	// result: (StructMake3 (Arg <t.FieldType(0)> {n} [off+t.FieldOff(0)]) (Arg <t.FieldType(1)> {n} [off+t.FieldOff(1)]) (Arg <t.FieldType(2)> {n} [off+t.FieldOff(2)]))
   186  	for {
   187  		t := v.Type
   188  		off := v.AuxInt
   189  		n := v.Aux
   190  		if !(t.IsStruct() && t.NumFields() == 3 && fe.CanSSA(t)) {
   191  			break
   192  		}
   193  		v.reset(OpStructMake3)
   194  		v0 := b.NewValue0(v.Pos, OpArg, t.FieldType(0))
   195  		v0.AuxInt = off + t.FieldOff(0)
   196  		v0.Aux = n
   197  		v.AddArg(v0)
   198  		v1 := b.NewValue0(v.Pos, OpArg, t.FieldType(1))
   199  		v1.AuxInt = off + t.FieldOff(1)
   200  		v1.Aux = n
   201  		v.AddArg(v1)
   202  		v2 := b.NewValue0(v.Pos, OpArg, t.FieldType(2))
   203  		v2.AuxInt = off + t.FieldOff(2)
   204  		v2.Aux = n
   205  		v.AddArg(v2)
   206  		return true
   207  	}
   208  	// match: (Arg <t> {n} [off])
   209  	// cond: t.IsStruct() && t.NumFields() == 4 && fe.CanSSA(t)
   210  	// result: (StructMake4 (Arg <t.FieldType(0)> {n} [off+t.FieldOff(0)]) (Arg <t.FieldType(1)> {n} [off+t.FieldOff(1)]) (Arg <t.FieldType(2)> {n} [off+t.FieldOff(2)]) (Arg <t.FieldType(3)> {n} [off+t.FieldOff(3)]))
   211  	for {
   212  		t := v.Type
   213  		off := v.AuxInt
   214  		n := v.Aux
   215  		if !(t.IsStruct() && t.NumFields() == 4 && fe.CanSSA(t)) {
   216  			break
   217  		}
   218  		v.reset(OpStructMake4)
   219  		v0 := b.NewValue0(v.Pos, OpArg, t.FieldType(0))
   220  		v0.AuxInt = off + t.FieldOff(0)
   221  		v0.Aux = n
   222  		v.AddArg(v0)
   223  		v1 := b.NewValue0(v.Pos, OpArg, t.FieldType(1))
   224  		v1.AuxInt = off + t.FieldOff(1)
   225  		v1.Aux = n
   226  		v.AddArg(v1)
   227  		v2 := b.NewValue0(v.Pos, OpArg, t.FieldType(2))
   228  		v2.AuxInt = off + t.FieldOff(2)
   229  		v2.Aux = n
   230  		v.AddArg(v2)
   231  		v3 := b.NewValue0(v.Pos, OpArg, t.FieldType(3))
   232  		v3.AuxInt = off + t.FieldOff(3)
   233  		v3.Aux = n
   234  		v.AddArg(v3)
   235  		return true
   236  	}
   237  	return false
   238  }
   239  func rewriteValuedecArgs_OpArg_10(v *Value) bool {
   240  	b := v.Block
   241  	fe := b.Func.fe
   242  	// match: (Arg <t>)
   243  	// cond: t.IsArray() && t.NumElem() == 0
   244  	// result: (ArrayMake0)
   245  	for {
   246  		t := v.Type
   247  		if !(t.IsArray() && t.NumElem() == 0) {
   248  			break
   249  		}
   250  		v.reset(OpArrayMake0)
   251  		return true
   252  	}
   253  	// match: (Arg <t> {n} [off])
   254  	// cond: t.IsArray() && t.NumElem() == 1 && fe.CanSSA(t)
   255  	// result: (ArrayMake1 (Arg <t.Elem()> {n} [off]))
   256  	for {
   257  		t := v.Type
   258  		off := v.AuxInt
   259  		n := v.Aux
   260  		if !(t.IsArray() && t.NumElem() == 1 && fe.CanSSA(t)) {
   261  			break
   262  		}
   263  		v.reset(OpArrayMake1)
   264  		v0 := b.NewValue0(v.Pos, OpArg, t.Elem())
   265  		v0.AuxInt = off
   266  		v0.Aux = n
   267  		v.AddArg(v0)
   268  		return true
   269  	}
   270  	return false
   271  }
   272  func rewriteBlockdecArgs(b *Block) bool {
   273  	config := b.Func.Config
   274  	typ := &config.Types
   275  	_ = typ
   276  	v := b.Control
   277  	_ = v
   278  	switch b.Kind {
   279  	}
   280  	return false
   281  }
   282  

View as plain text