...
Source file src/pkg/cmd/compile/internal/gc/gen.go
1
2
3
4
5 package gc
6
7 import (
8 "cmd/compile/internal/types"
9 "cmd/internal/obj"
10 "cmd/internal/src"
11 "strconv"
12 )
13
14
15
16 func sysfunc(name string) *obj.LSym {
17 s := Runtimepkg.Lookup(name)
18 s.SetFunc(true)
19 return s.Linksym()
20 }
21
22
23
24
25 func sysvar(name string) *obj.LSym {
26 return Runtimepkg.Lookup(name).Linksym()
27 }
28
29
30
31 func (n *Node) isParamStackCopy() bool {
32 return n.Op == ONAME && (n.Class() == PPARAM || n.Class() == PPARAMOUT) && n.Name.Param.Heapaddr != nil
33 }
34
35
36
37 func (n *Node) isParamHeapCopy() bool {
38 return n.Op == ONAME && n.Class() == PAUTOHEAP && n.Name.Param.Stackcopy != nil
39 }
40
41
42 func autotmpname(n int) string {
43
44
45 const prefix = ".autotmp_"
46
47 b := []byte(prefix + " ")[:len(prefix)]
48 b = strconv.AppendInt(b, int64(n), 10)
49 return types.InternString(b)
50 }
51
52
53 func tempAt(pos src.XPos, curfn *Node, t *types.Type) *Node {
54 if curfn == nil {
55 Fatalf("no curfn for tempname")
56 }
57 if curfn.Func.Closure != nil && curfn.Op == OCLOSURE {
58 Dump("tempname", curfn)
59 Fatalf("adding tempname to wrong closure function")
60 }
61 if t == nil {
62 Fatalf("tempname called with nil type")
63 }
64
65 s := &types.Sym{
66 Name: autotmpname(len(curfn.Func.Dcl)),
67 Pkg: localpkg,
68 }
69 n := newnamel(pos, s)
70 s.Def = asTypesNode(n)
71 n.Type = t
72 n.SetClass(PAUTO)
73 n.Esc = EscNever
74 n.Name.Curfn = curfn
75 n.Name.SetUsed(true)
76 n.Name.SetAutoTemp(true)
77 curfn.Func.Dcl = append(curfn.Func.Dcl, n)
78
79 dowidth(t)
80
81 return n.Orig
82 }
83
84 func temp(t *types.Type) *Node {
85 return tempAt(lineno, Curfn, t)
86 }
87
View as plain text