1
2
3
4
5 package walk
6
7 import (
8 "cmd/compile/internal/base"
9 "cmd/compile/internal/ir"
10 "cmd/compile/internal/typecheck"
11 "cmd/compile/internal/types"
12 )
13
14
15
16 func initStackTemp(init *ir.Nodes, tmp *ir.Name, val ir.Node) *ir.AddrExpr {
17 if val != nil && !types.Identical(tmp.Type(), val.Type()) {
18 base.Fatalf("bad initial value for %L: %L", tmp, val)
19 }
20 appendWalkStmt(init, ir.NewAssignStmt(base.Pos, tmp, val))
21 return typecheck.Expr(typecheck.NodAddr(tmp)).(*ir.AddrExpr)
22 }
23
24
25
26
27 func stackTempAddr(init *ir.Nodes, typ *types.Type) *ir.AddrExpr {
28 n := typecheck.TempAt(base.Pos, ir.CurFunc, typ)
29 n.SetNonMergeable(true)
30 return initStackTemp(init, n, nil)
31 }
32
33
34
35
36 func stackBufAddr(len int64, elem *types.Type) *ir.AddrExpr {
37 if elem.HasPointers() {
38 base.FatalfAt(base.Pos, "%v has pointers", elem)
39 }
40 tmp := typecheck.TempAt(base.Pos, ir.CurFunc, types.NewArray(elem, len))
41 return typecheck.Expr(typecheck.NodAddr(tmp)).(*ir.AddrExpr)
42 }
43
View as plain text