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.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.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 (SlicePtrUnchecked (SliceMake ptr _ _ )) => ptr
60
61 (Load <t> ptr mem) && t.IsSlice() =>
62 (SliceMake
63 (Load <t.Elem().PtrTo()> ptr mem)
64 (Load <typ.Int>
65 (OffPtr <typ.IntPtr> [config.PtrSize] ptr)
66 mem)
67 (Load <typ.Int>
68 (OffPtr <typ.IntPtr> [2*config.PtrSize] ptr)
69 mem))
70 (Store {t} dst (SliceMake ptr len cap) mem) =>
71 (Store {typ.Int}
72 (OffPtr <typ.IntPtr> [2*config.PtrSize] dst)
73 cap
74 (Store {typ.Int}
75 (OffPtr <typ.IntPtr> [config.PtrSize] dst)
76 len
77 (Store {t.Elem().PtrTo()} dst ptr mem)))
78
79 // interface ops
80 (ITab (IMake itab _)) => itab
81 (IData (IMake _ data)) => data
82
83 (Load <t> ptr mem) && t.IsInterface() =>
84 (IMake
85 (Load <typ.Uintptr> ptr mem)
86 (Load <typ.BytePtr>
87 (OffPtr <typ.BytePtrPtr> [config.PtrSize] ptr)
88 mem))
89 (Store dst (IMake itab data) mem) =>
90 (Store {typ.BytePtr}
91 (OffPtr <typ.BytePtrPtr> [config.PtrSize] dst)
92 data
93 (Store {typ.Uintptr} dst itab mem))
94
View as plain text