...

Text file src/pkg/cmd/compile/internal/ssa/gen/dec.rules

     1	// Copyright 2016 The Go Authors. All rights reserved.
     2	// Use of this source code is governed by a BSD-style
     3	// license that can be found in the LICENSE file.
     4	
     5	// This file contains rules to decompose builtin compound types
     6	// (complex,string,slice,interface) into their constituent
     7	// types.  These rules work together with the decomposeBuiltIn
     8	// pass which handles phis of these types.
     9	
    10	// complex ops
    11	(ComplexReal (ComplexMake real _  )) -> real
    12	(ComplexImag (ComplexMake _ imag )) -> imag
    13	
    14	(Load <t> ptr mem) && t.IsComplex() && t.Size() == 8 ->
    15	  (ComplexMake
    16	    (Load <typ.Float32> ptr mem)
    17	    (Load <typ.Float32>
    18	      (OffPtr <typ.Float32Ptr> [4] ptr)
    19	      mem)
    20	    )
    21	(Store {t} dst (ComplexMake real imag) mem) && t.(*types.Type).Size() == 8 ->
    22	  (Store {typ.Float32}
    23	    (OffPtr <typ.Float32Ptr> [4] dst)
    24	    imag
    25	    (Store {typ.Float32} dst real mem))
    26	(Load <t> ptr mem) && t.IsComplex() && t.Size() == 16 ->
    27	  (ComplexMake
    28	    (Load <typ.Float64> ptr mem)
    29	    (Load <typ.Float64>
    30	      (OffPtr <typ.Float64Ptr> [8] ptr)
    31	      mem)
    32	    )
    33	(Store {t} dst (ComplexMake real imag) mem) && t.(*types.Type).Size() == 16 ->
    34	  (Store {typ.Float64}
    35	    (OffPtr <typ.Float64Ptr> [8] dst)
    36	    imag
    37	    (Store {typ.Float64} dst real mem))
    38	
    39	// string ops
    40	(StringPtr (StringMake ptr _)) -> ptr
    41	(StringLen (StringMake _ len)) -> len
    42	
    43	(Load <t> ptr mem) && t.IsString() ->
    44	  (StringMake
    45	    (Load <typ.BytePtr> ptr mem)
    46	    (Load <typ.Int>
    47	      (OffPtr <typ.IntPtr> [config.PtrSize] ptr)
    48	      mem))
    49	(Store dst (StringMake ptr len) mem) ->
    50	  (Store {typ.Int}
    51	    (OffPtr <typ.IntPtr> [config.PtrSize] dst)
    52	    len
    53	    (Store {typ.BytePtr} dst ptr mem))
    54	
    55	// slice ops
    56	(SlicePtr (SliceMake ptr _ _ )) -> ptr
    57	(SliceLen (SliceMake _ len _)) -> len
    58	(SliceCap (SliceMake _ _ cap)) -> cap
    59	
    60	(Load <t> ptr mem) && t.IsSlice() ->
    61	  (SliceMake
    62	    (Load <t.Elem().PtrTo()> ptr mem)
    63	    (Load <typ.Int>
    64	      (OffPtr <typ.IntPtr> [config.PtrSize] ptr)
    65	      mem)
    66	    (Load <typ.Int>
    67	      (OffPtr <typ.IntPtr> [2*config.PtrSize] ptr)
    68	      mem))
    69	(Store dst (SliceMake ptr len cap) mem) ->
    70	  (Store {typ.Int}
    71	    (OffPtr <typ.IntPtr> [2*config.PtrSize] dst)
    72	    cap
    73	    (Store {typ.Int}
    74	      (OffPtr <typ.IntPtr> [config.PtrSize] dst)
    75	      len
    76	      (Store {typ.BytePtr} dst ptr mem)))
    77	
    78	// interface ops
    79	(ITab (IMake itab _)) -> itab
    80	(IData (IMake _ data)) -> data
    81	
    82	(Load <t> ptr mem) && t.IsInterface() ->
    83	  (IMake
    84	    (Load <typ.Uintptr> ptr mem)
    85	    (Load <typ.BytePtr>
    86	      (OffPtr <typ.BytePtrPtr> [config.PtrSize] ptr)
    87	      mem))
    88	(Store dst (IMake itab data) mem) ->
    89	  (Store {typ.BytePtr}
    90	    (OffPtr <typ.BytePtrPtr> [config.PtrSize] dst)
    91	    data
    92	    (Store {typ.Uintptr} dst itab mem))

View as plain text