// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This file contains rules to decompose builtin compound types // (complex,string,slice,interface) into their constituent // types. These rules work together with the decomposeBuiltIn // pass which handles phis of these types. // complex ops (ComplexReal (ComplexMake real _ )) => real (ComplexImag (ComplexMake _ imag )) => imag (Load ptr mem) && t.IsComplex() && t.Size() == 8 => (ComplexMake (Load ptr mem) (Load (OffPtr [4] ptr) mem) ) (Store {t} dst (ComplexMake real imag) mem) && t.Size() == 8 => (Store {typ.Float32} (OffPtr [4] dst) imag (Store {typ.Float32} dst real mem)) (Load ptr mem) && t.IsComplex() && t.Size() == 16 => (ComplexMake (Load ptr mem) (Load (OffPtr [8] ptr) mem) ) (Store {t} dst (ComplexMake real imag) mem) && t.Size() == 16 => (Store {typ.Float64} (OffPtr [8] dst) imag (Store {typ.Float64} dst real mem)) // string ops (StringPtr (StringMake ptr _)) => ptr (StringLen (StringMake _ len)) => len (Load ptr mem) && t.IsString() => (StringMake (Load ptr mem) (Load (OffPtr [config.PtrSize] ptr) mem)) (Store dst (StringMake ptr len) mem) => (Store {typ.Int} (OffPtr [config.PtrSize] dst) len (Store {typ.BytePtr} dst ptr mem)) // slice ops (SlicePtr (SliceMake ptr _ _ )) => ptr (SliceLen (SliceMake _ len _)) => len (SliceCap (SliceMake _ _ cap)) => cap (Load ptr mem) && t.IsSlice() => (SliceMake (Load ptr mem) (Load (OffPtr [config.PtrSize] ptr) mem) (Load (OffPtr [2*config.PtrSize] ptr) mem)) (Store {t} dst (SliceMake ptr len cap) mem) => (Store {typ.Int} (OffPtr [2*config.PtrSize] dst) cap (Store {typ.Int} (OffPtr [config.PtrSize] dst) len (Store {t.Elem().PtrTo()} dst ptr mem))) // interface ops (ITab (IMake itab _)) => itab (IData (IMake _ data)) => data (Load ptr mem) && t.IsInterface() => (IMake (Load ptr mem) (Load (OffPtr [config.PtrSize] ptr) mem)) (Store dst (IMake itab data) mem) => (Store {typ.BytePtr} (OffPtr [config.PtrSize] dst) data (Store {typ.Uintptr} dst itab mem))