1 // Copyright 2013 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.
7 // This package defines a high-level intermediate representation for
8 // Go programs using static single-assignment (SSA) form.
18 "golang.org/x/tools/go/types/typeutil"
21 // A Program is a partial or complete Go program converted to SSA form.
23 Fset *token.FileSet // position information for the files of this Program
24 imported map[string]*Package // all importable Packages, keyed by import path
25 packages map[*types.Package]*Package // all loaded Packages, keyed by object
26 mode BuilderMode // set of mode bits for SSA construction
27 MethodSets typeutil.MethodSetCache // cache of type-checker's method-sets
29 methodsMu sync.Mutex // guards the following maps:
30 methodSets typeutil.Map // maps type to its concrete methodSet
31 runtimeTypes typeutil.Map // types for which rtypes are needed
32 canon typeutil.Map // type canonicalization map
33 bounds map[*types.Func]*Function // bounds for curried x.Method closures
34 thunks map[selectionKey]*Function // thunks for T.Method expressions
37 // A Package is a single analyzed Go package containing Members for
38 // all package-level functions, variables, constants and types it
39 // declares. These may be accessed directly via Members, or via the
40 // type-specific accessor methods Func, Type, Var and Const.
42 // Members also contains entries for "init" (the synthetic package
43 // initializer) and "init#%d", the nth declared init function,
44 // and unspecified other things too.
47 Prog *Program // the owning program
48 Pkg *types.Package // the corresponding go/types.Package
49 Members map[string]Member // all package members keyed by name (incl. init and init#%d)
50 values map[types.Object]Value // package members (incl. types and methods), keyed by object
51 init *Function // Func("init"); the package's init function
52 debug bool // include full debug info in this package
54 // The following fields are set transiently, then cleared
56 buildOnce sync.Once // ensures package building occurs once
57 ninit int32 // number of init functions
58 info *types.Info // package type information
59 files []*ast.File // package ASTs
62 // A Member is a member of a Go package, implemented by *NamedConst,
63 // *Global, *Function, or *Type; they are created by package-level
64 // const, var, func and type declarations respectively.
66 type Member interface {
67 Name() string // declared name of the package member
68 String() string // package-qualified name of the package member
69 RelString(*types.Package) string // like String, but relative refs are unqualified
70 Object() types.Object // typechecker's object for this member, if any
71 Pos() token.Pos // position of member's declaration, if known
72 Type() types.Type // type of the package member
73 Token() token.Token // token.{VAR,FUNC,CONST,TYPE}
74 Package() *Package // the containing package
77 // A Type is a Member of a Package representing a package-level named type.
79 object *types.TypeName
83 // A NamedConst is a Member of a Package representing a package-level
86 // Pos() returns the position of the declaring ast.ValueSpec.Names[*]
89 // NB: a NamedConst is not a Value; it contains a constant Value, which
90 // it augments with the name and position of its 'const' declaration.
92 type NamedConst struct {
98 // A Value is an SSA value that can be referenced by an instruction.
99 type Value interface {
100 // Name returns the name of this value, and determines how
101 // this Value appears when used as an operand of an
104 // This is the same as the source name for Parameters,
105 // Builtins, Functions, FreeVars, Globals.
106 // For constants, it is a representation of the constant's value
107 // and type. For all other Values this is the name of the
108 // virtual register defined by the instruction.
110 // The name of an SSA Value is not semantically significant,
111 // and may not even be unique within a function.
114 // If this value is an Instruction, String returns its
115 // disassembled form; otherwise it returns unspecified
116 // human-readable information about the Value, such as its
117 // kind, name and type.
120 // Type returns the type of this value. Many instructions
121 // (e.g. IndexAddr) change their behaviour depending on the
122 // types of their operands.
125 // Parent returns the function to which this Value belongs.
126 // It returns nil for named Functions, Builtin, Const and Global.
129 // Referrers returns the list of instructions that have this
130 // value as one of their operands; it may contain duplicates
131 // if an instruction has a repeated operand.
133 // Referrers actually returns a pointer through which the
134 // caller may perform mutations to the object's state.
136 // Referrers is currently only defined if Parent()!=nil,
137 // i.e. for the function-local values FreeVar, Parameter,
138 // Functions (iff anonymous) and all value-defining instructions.
139 // It returns nil for named Functions, Builtin, Const and Global.
141 // Instruction.Operands contains the inverse of this relation.
142 Referrers() *[]Instruction
144 // Pos returns the location of the AST token most closely
145 // associated with the operation that gave rise to this value,
146 // or token.NoPos if it was not explicit in the source.
148 // For each ast.Node type, a particular token is designated as
149 // the closest location for the expression, e.g. the Lparen
150 // for an *ast.CallExpr. This permits a compact but
151 // approximate mapping from Values to source positions for use
152 // in diagnostic messages, for example.
154 // (Do not use this position to determine which Value
155 // corresponds to an ast.Expr; use Function.ValueForExpr
156 // instead. NB: it requires that the function was built with
157 // debug information.)
161 // An Instruction is an SSA instruction that computes a new Value or
164 // An Instruction that defines a value (e.g. BinOp) also implements
165 // the Value interface; an Instruction that only has an effect (e.g. Store)
168 type Instruction interface {
169 // String returns the disassembled form of this value.
171 // Examples of Instructions that are Values:
174 // Note that the name of the Value is not printed.
176 // Examples of Instructions that are not Values:
177 // "return x" (Return)
180 // (The separation Value.Name() from Value.String() is useful
181 // for some analyses which distinguish the operation from the
182 // value it defines, e.g., 'y = local int' is both an allocation
183 // of memory 'local int' and a definition of a pointer y.)
186 // Parent returns the function to which this instruction
190 // Block returns the basic block to which this instruction
194 // setBlock sets the basic block to which this instruction belongs.
195 setBlock(*BasicBlock)
197 // Operands returns the operands of this instruction: the
198 // set of Values it references.
200 // Specifically, it appends their addresses to rands, a
201 // user-provided slice, and returns the resulting slice,
202 // permitting avoidance of memory allocation.
204 // The operands are appended in undefined order, but the order
205 // is consistent for a given Instruction; the addresses are
206 // always non-nil but may point to a nil Value. Clients may
207 // store through the pointers, e.g. to effect a value
210 // Value.Referrers is a subset of the inverse of this
211 // relation. (Referrers are not tracked for all types of
213 Operands(rands []*Value) []*Value
215 // Pos returns the location of the AST token most closely
216 // associated with the operation that gave rise to this
217 // instruction, or token.NoPos if it was not explicit in the
220 // For each ast.Node type, a particular token is designated as
221 // the closest location for the expression, e.g. the Go token
222 // for an *ast.GoStmt. This permits a compact but approximate
223 // mapping from Instructions to source positions for use in
224 // diagnostic messages, for example.
226 // (Do not use this position to determine which Instruction
227 // corresponds to an ast.Expr; see the notes for Value.Pos.
228 // This position may be used to determine which non-Value
229 // Instruction corresponds to some ast.Stmts, but not all: If
230 // and Jump instructions have no Pos(), for example.)
234 // A Node is a node in the SSA value graph. Every concrete type that
235 // implements Node is also either a Value, an Instruction, or both.
237 // Node contains the methods common to Value and Instruction, plus the
238 // Operands and Referrers methods generalized to return nil for
239 // non-Instructions and non-Values, respectively.
241 // Node is provided to simplify SSA graph algorithms. Clients should
242 // use the more specific and informative Value or Instruction
243 // interfaces where appropriate.
245 type Node interface {
252 Operands(rands []*Value) []*Value // nil for non-Instructions
253 Referrers() *[]Instruction // nil for non-Values
256 // Function represents the parameters, results, and code of a function
259 // If Blocks is nil, this indicates an external function for which no
260 // Go source code is available. In this case, FreeVars and Locals
261 // are nil too. Clients performing whole-program analysis must
262 // handle external functions specially.
264 // Blocks contains the function's control-flow graph (CFG).
265 // Blocks[0] is the function entry point; block order is not otherwise
266 // semantically significant, though it may affect the readability of
268 // To iterate over the blocks in dominance order, use DomPreorder().
270 // Recover is an optional second entry point to which control resumes
271 // after a recovered panic. The Recover block may contain only a return
272 // statement, preceded by a load of the function's named return
273 // parameters, if any.
275 // A nested function (Parent()!=nil) that refers to one or more
276 // lexically enclosing local variables ("free variables") has FreeVars.
277 // Such functions cannot be called directly but require a
278 // value created by MakeClosure which, via its Bindings, supplies
279 // values for these parameters.
281 // If the function is a method (Signature.Recv() != nil) then the first
282 // element of Params is the receiver parameter.
284 // A Go package may declare many functions called "init".
285 // For each one, Object().Name() returns "init" but Name() returns
286 // "init#1", etc, in declaration order.
288 // Pos() returns the declaring ast.FuncLit.Type.Func or the position
289 // of the ast.FuncDecl.Name, if the function was explicit in the
290 // source. Synthetic wrappers, for which Synthetic != "", may share
291 // the same position as the function they wrap.
292 // Syntax.Pos() always returns the position of the declaring "func" token.
294 // Type() returns the function's Signature.
296 type Function struct {
298 object types.Object // a declared *types.Func or one of its wrappers
299 method *types.Selection // info about provenance of synthetic methods
300 Signature *types.Signature
303 Synthetic string // provenance of synthetic function; "" for true source functions
304 syntax ast.Node // *ast.Func{Decl,Lit}; replaced with simple ast.Node after build, unless debug mode
305 parent *Function // enclosing function if anon; nil if global
306 Pkg *Package // enclosing package; nil for shared funcs (wrappers and error.Error)
307 Prog *Program // enclosing program
308 Params []*Parameter // function parameters; for methods, includes receiver
309 FreeVars []*FreeVar // free variables whose values must be supplied by closure
310 Locals []*Alloc // local variables of this function
311 Blocks []*BasicBlock // basic blocks of the function; nil => external
312 Recover *BasicBlock // optional; control transfers here after recovered panic
313 AnonFuncs []*Function // anonymous functions directly beneath this one
314 referrers []Instruction // referring instructions (iff Parent() != nil)
316 // The following fields are set transiently during building,
318 currentBlock *BasicBlock // where to emit code
319 objects map[types.Object]Value // addresses of local variables
320 namedResults []*Alloc // tuple of named results
321 targets *targets // linked stack of branch targets
322 lblocks map[*ast.Object]*lblock // labelled blocks
325 // BasicBlock represents an SSA basic block.
327 // The final element of Instrs is always an explicit transfer of
328 // control (If, Jump, Return, or Panic).
330 // A block may contain no Instructions only if it is unreachable,
331 // i.e., Preds is nil. Empty blocks are typically pruned.
333 // BasicBlocks and their Preds/Succs relation form a (possibly cyclic)
334 // graph independent of the SSA Value graph: the control-flow graph or
335 // CFG. It is illegal for multiple edges to exist between the same
338 // Each BasicBlock is also a node in the dominator tree of the CFG.
339 // The tree may be navigated using Idom()/Dominees() and queried using
342 // The order of Preds and Succs is significant (to Phi and If
343 // instructions, respectively).
345 type BasicBlock struct {
346 Index int // index of this block within Parent().Blocks
347 Comment string // optional label; no semantic significance
348 parent *Function // parent function
349 Instrs []Instruction // instructions in order
350 Preds, Succs []*BasicBlock // predecessors and successors
351 succs2 [2]*BasicBlock // initial space for Succs
352 dom domInfo // dominator tree info
353 gaps int // number of nil Instrs (transient)
354 rundefers int // number of rundefers (transient)
357 // Pure values ----------------------------------------
359 // A FreeVar represents a free variable of the function to which it
362 // FreeVars are used to implement anonymous functions, whose free
363 // variables are lexically captured in a closure formed by
364 // MakeClosure. The value of such a free var is an Alloc or another
365 // FreeVar and is considered a potentially escaping heap address, with
368 // FreeVars are also used to implement bound method closures. Such a
369 // free var represents the receiver value and may be of any type that
370 // has concrete methods.
372 // Pos() returns the position of the value that was captured, which
373 // belongs to an enclosing function.
375 type FreeVar struct {
380 referrers []Instruction
382 // Transiently needed during building.
383 outer Value // the Value captured from the enclosing context.
386 // A Parameter represents an input parameter of a function.
388 type Parameter struct {
390 object types.Object // a *types.Var; nil for non-source locals
394 referrers []Instruction
397 // A Const represents the value of a constant expression.
399 // The underlying type of a constant may be any boolean, numeric, or
400 // string type. In addition, a Const may represent the nil value of
401 // any reference type---interface, map, channel, pointer, slice, or
402 // function---but not "untyped nil".
404 // All source-level constant expressions are represented by a Const
405 // of the same type and value.
407 // Value holds the value of the constant, independent of its Type(),
408 // using go/constant representation, or nil for a typed nil value.
410 // Pos() returns token.NoPos.
412 // Example printed form:
414 // "hello":untyped string
422 // A Global is a named Value holding the address of a package-level
425 // Pos() returns the position of the ast.ValueSpec.Names[*]
430 object types.Object // a *types.Var; may be nil for synthetics e.g. init$guard
437 // A Builtin represents a specific use of a built-in function, e.g. len.
439 // Builtins are immutable values. Builtins do not have addresses.
440 // Builtins can only appear in CallCommon.Func.
442 // Name() indicates the function: one of the built-in functions from the
443 // Go spec (excluding "make" and "new") or one of these ssa-defined
446 // // wrapnilchk returns ptr if non-nil, panics otherwise.
447 // // (For use in indirection wrappers.)
448 // func ssa:wrapnilchk(ptr *T, recvType, methodName string) *T
450 // Object() returns a *types.Builtin for built-ins defined by the spec,
453 // Type() returns a *types.Signature representing the effective
454 // signature of the built-in for this call.
456 type Builtin struct {
461 // Value-defining instructions ----------------------------------------
463 // The Alloc instruction reserves space for a variable of the given type,
464 // zero-initializes it, and yields its address.
466 // Alloc values are always addresses, and have pointer types, so the
467 // type of the allocated variable is actually
468 // Type().Underlying().(*types.Pointer).Elem().
470 // If Heap is false, Alloc allocates space in the function's
471 // activation record (frame); we refer to an Alloc(Heap=false) as a
472 // "local" alloc. Each local Alloc returns the same address each time
473 // it is executed within the same activation; the space is
474 // re-initialized to zero.
476 // If Heap is true, Alloc allocates space in the heap; we
477 // refer to an Alloc(Heap=true) as a "new" alloc. Each new Alloc
478 // returns a different address each time it is executed.
480 // When Alloc is applied to a channel, map or slice type, it returns
481 // the address of an uninitialized (nil) reference of that kind; store
482 // the result of MakeSlice, MakeMap or MakeChan in that location to
483 // instantiate these types.
485 // Pos() returns the ast.CompositeLit.Lbrace for a composite literal,
486 // or the ast.CallExpr.Rparen for a call to new() or for a call that
487 // allocates a varargs slice.
489 // Example printed form:
497 index int // dense numbering; for lifting
500 // The Phi instruction represents an SSA φ-node, which combines values
501 // that differ across incoming control-flow edges and yields a new
502 // value. Within a block, all φ-nodes must appear before all non-φ
505 // Pos() returns the position of the && or || for short-circuit
506 // control-flow joins, or that of the *Alloc for φ-nodes inserted
507 // during SSA renaming.
509 // Example printed form:
510 // t2 = phi [0: t0, 1: t1]
514 Comment string // a hint as to its purpose
515 Edges []Value // Edges[i] is value for Block().Preds[i]
518 // The Call instruction represents a function or method call.
520 // The Call instruction yields the function result if there is exactly
521 // one. Otherwise it returns a tuple, the components of which are
522 // accessed via Extract.
524 // See CallCommon for generic function call documentation.
526 // Pos() returns the ast.CallExpr.Lparen, if explicit in the source.
528 // Example printed form:
529 // t2 = println(t0, t1)
531 // t7 = invoke t5.Println(...t6)
538 // The BinOp instruction yields the result of binary operation X Op Y.
540 // Pos() returns the ast.BinaryExpr.OpPos, if explicit in the source.
542 // Example printed form:
548 // ADD SUB MUL QUO REM + - * / %
549 // AND OR XOR SHL SHR AND_NOT & | ^ << >> &^
550 // EQL NEQ LSS LEQ GTR GEQ == != < <= < >=
555 // The UnOp instruction yields the result of Op X.
556 // ARROW is channel receive.
557 // MUL is pointer indirection (load).
558 // XOR is bitwise complement.
560 // NOT is logical negation.
562 // If CommaOk and Op=ARROW, the result is a 2-tuple of the value above
563 // and a boolean indicating the success of the receive. The
564 // components of the tuple are accessed using Extract.
566 // Pos() returns the ast.UnaryExpr.OpPos, if explicit in the source.
567 // For receive operations (ARROW) implicit in ranging over a channel,
568 // Pos() returns the ast.RangeStmt.For.
569 // For implicit memory loads (STAR), Pos() returns the position of the
570 // most closely associated source-level construct; the details are not
573 // Example printed form:
579 Op token.Token // One of: NOT SUB ARROW MUL XOR ! - <- * ^
584 // The ChangeType instruction applies to X a value-preserving type
587 // Type changes are permitted:
588 // - between a named type and its underlying type.
589 // - between two named types of the same underlying type.
590 // - between (possibly named) pointers to identical base types.
591 // - from a bidirectional channel to a read- or write-channel,
592 // optionally adding/removing a name.
594 // This operation cannot fail dynamically.
596 // Pos() returns the ast.CallExpr.Lparen, if the instruction arose
597 // from an explicit conversion in the source.
599 // Example printed form:
600 // t1 = changetype *int <- IntPtr (t0)
602 type ChangeType struct {
607 // The Convert instruction yields the conversion of value X to type
608 // Type(). One or both of those types is basic (but possibly named).
610 // A conversion may change the value and representation of its operand.
611 // Conversions are permitted:
612 // - between real numeric types.
613 // - between complex numeric types.
614 // - between string and []byte or []rune.
615 // - between pointers and unsafe.Pointer.
616 // - between unsafe.Pointer and uintptr.
617 // - from (Unicode) integer to (UTF-8) string.
618 // A conversion may imply a type name change also.
620 // This operation cannot fail dynamically.
622 // Conversions of untyped string/number/bool constants to a specific
623 // representation are eliminated during SSA construction.
625 // Pos() returns the ast.CallExpr.Lparen, if the instruction arose
626 // from an explicit conversion in the source.
628 // Example printed form:
629 // t1 = convert []byte <- string (t0)
631 type Convert struct {
636 // ChangeInterface constructs a value of one interface type from a
637 // value of another interface type known to be assignable to it.
638 // This operation cannot fail.
640 // Pos() returns the ast.CallExpr.Lparen if the instruction arose from
641 // an explicit T(e) conversion; the ast.TypeAssertExpr.Lparen if the
642 // instruction arose from an explicit e.(T) operation; or token.NoPos
645 // Example printed form:
646 // t1 = change interface interface{} <- I (t0)
648 type ChangeInterface struct {
653 // MakeInterface constructs an instance of an interface type from a
654 // value of a concrete type.
656 // Use Program.MethodSets.MethodSet(X.Type()) to find the method-set
657 // of X, and Program.MethodValue(m) to find the implementation of a method.
659 // To construct the zero value of an interface type T, use:
660 // NewConst(constant.MakeNil(), T, pos)
662 // Pos() returns the ast.CallExpr.Lparen, if the instruction arose
663 // from an explicit conversion in the source.
665 // Example printed form:
666 // t1 = make interface{} <- int (42:int)
667 // t2 = make Stringer <- t0
669 type MakeInterface struct {
674 // The MakeClosure instruction yields a closure value whose code is
675 // Fn and whose free variables' values are supplied by Bindings.
677 // Type() returns a (possibly named) *types.Signature.
679 // Pos() returns the ast.FuncLit.Type.Func for a function literal
680 // closure or the ast.SelectorExpr.Sel for a bound method closure.
682 // Example printed form:
683 // t0 = make closure anon@1.2 [x y z]
684 // t1 = make closure bound$(main.I).add [i]
686 type MakeClosure struct {
688 Fn Value // always a *Function
689 Bindings []Value // values for each free variable in Fn.FreeVars
692 // The MakeMap instruction creates a new hash-table-based map object
693 // and yields a value of kind map.
695 // Type() returns a (possibly named) *types.Map.
697 // Pos() returns the ast.CallExpr.Lparen, if created by make(map), or
698 // the ast.CompositeLit.Lbrack if created by a literal.
700 // Example printed form:
701 // t1 = make map[string]int t0
702 // t1 = make StringIntMap t0
704 type MakeMap struct {
706 Reserve Value // initial space reservation; nil => default
709 // The MakeChan instruction creates a new channel object and yields a
710 // value of kind chan.
712 // Type() returns a (possibly named) *types.Chan.
714 // Pos() returns the ast.CallExpr.Lparen for the make(chan) that
717 // Example printed form:
718 // t0 = make chan int 0
719 // t0 = make IntChan 0
721 type MakeChan struct {
723 Size Value // int; size of buffer; zero => synchronous.
726 // The MakeSlice instruction yields a slice of length Len backed by a
727 // newly allocated array of length Cap.
729 // Both Len and Cap must be non-nil Values of integer type.
731 // (Alloc(types.Array) followed by Slice will not suffice because
732 // Alloc can only create arrays of constant length.)
734 // Type() returns a (possibly named) *types.Slice.
736 // Pos() returns the ast.CallExpr.Lparen for the make([]T) that
739 // Example printed form:
740 // t1 = make []string 1:int t0
741 // t1 = make StringSlice 1:int t0
743 type MakeSlice struct {
749 // The Slice instruction yields a slice of an existing string, slice
750 // or *array X between optional integer bounds Low and High.
752 // Dynamically, this instruction panics if X evaluates to a nil *array
755 // Type() returns string if the type of X was string, otherwise a
756 // *types.Slice with the same element type as X.
758 // Pos() returns the ast.SliceExpr.Lbrack if created by a x[:] slice
759 // operation, the ast.CompositeLit.Lbrace if created by a literal, or
760 // NoPos if not explicit in the source (e.g. a variadic argument slice).
762 // Example printed form:
767 X Value // slice, string, or *array
768 Low, High, Max Value // each may be nil
771 // The FieldAddr instruction yields the address of Field of *struct X.
773 // The field is identified by its index within the field list of the
776 // Dynamically, this instruction panics if X evaluates to a nil
779 // Type() returns a (possibly named) *types.Pointer.
781 // Pos() returns the position of the ast.SelectorExpr.Sel for the
782 // field, if explicit in the source.
784 // Example printed form:
785 // t1 = &t0.name [#1]
787 type FieldAddr struct {
790 Field int // field is X.Type().Underlying().(*types.Pointer).Elem().Underlying().(*types.Struct).Field(Field)
793 // The Field instruction yields the Field of struct X.
795 // The field is identified by its index within the field list of the
796 // struct type of X; by using numeric indices we avoid ambiguity of
797 // package-local identifiers and permit compact representations.
799 // Pos() returns the position of the ast.SelectorExpr.Sel for the
800 // field, if explicit in the source.
802 // Example printed form:
808 Field int // index into X.Type().(*types.Struct).Fields
811 // The IndexAddr instruction yields the address of the element at
812 // index Index of collection X. Index is an integer expression.
814 // The elements of maps and strings are not addressable; use Lookup or
815 // MapUpdate instead.
817 // Dynamically, this instruction panics if X evaluates to a nil *array
820 // Type() returns a (possibly named) *types.Pointer.
822 // Pos() returns the ast.IndexExpr.Lbrack for the index operation, if
823 // explicit in the source.
825 // Example printed form:
828 type IndexAddr struct {
830 X Value // slice or *array,
831 Index Value // numeric index
834 // The Index instruction yields element Index of array X.
836 // Pos() returns the ast.IndexExpr.Lbrack for the index operation, if
837 // explicit in the source.
839 // Example printed form:
845 Index Value // integer index
848 // The Lookup instruction yields element Index of collection X, a map
849 // or string. Index is an integer expression if X is a string or the
850 // appropriate key type if X is a map.
852 // If CommaOk, the result is a 2-tuple of the value above and a
853 // boolean indicating the result of a map membership test for the key.
854 // The components of the tuple are accessed using Extract.
856 // Pos() returns the ast.IndexExpr.Lbrack, if explicit in the source.
858 // Example printed form:
864 X Value // string or map
865 Index Value // numeric or key-typed index
866 CommaOk bool // return a value,ok pair
869 // SelectState is a helper for Select.
870 // It represents one goal state and its corresponding communication.
872 type SelectState struct {
873 Dir types.ChanDir // direction of case (SendOnly or RecvOnly)
874 Chan Value // channel to use (for send or receive)
875 Send Value // value to send (for send)
876 Pos token.Pos // position of token.ARROW
877 DebugNode ast.Node // ast.SendStmt or ast.UnaryExpr(<-) [debug mode]
880 // The Select instruction tests whether (or blocks until) one
881 // of the specified sent or received states is entered.
883 // Let n be the number of States for which Dir==RECV and T_i (0<=i<n)
884 // be the element type of each such state's Chan.
885 // Select returns an n+2-tuple
886 // (index int, recvOk bool, r_0 T_0, ... r_n-1 T_n-1)
887 // The tuple's components, described below, must be accessed via the
888 // Extract instruction.
890 // If Blocking, select waits until exactly one state holds, i.e. a
891 // channel becomes ready for the designated operation of sending or
892 // receiving; select chooses one among the ready states
893 // pseudorandomly, performs the send or receive operation, and sets
894 // 'index' to the index of the chosen channel.
896 // If !Blocking, select doesn't block if no states hold; instead it
897 // returns immediately with index equal to -1.
899 // If the chosen channel was used for a receive, the r_i component is
900 // set to the received value, where i is the index of that state among
901 // all n receive states; otherwise r_i has the zero value of type T_i.
902 // Note that the receive index i is not the same as the state
905 // The second component of the triple, recvOk, is a boolean whose value
906 // is true iff the selected operation was a receive and the receive
907 // successfully yielded a value.
909 // Pos() returns the ast.SelectStmt.Select.
911 // Example printed form:
912 // t3 = select nonblocking [<-t0, t1<-t2]
913 // t4 = select blocking []
917 States []*SelectState
921 // The Range instruction yields an iterator over the domain and range
922 // of X, which must be a string or map.
924 // Elements are accessed via Next.
926 // Type() returns an opaque and degenerate "rangeIter" type.
928 // Pos() returns the ast.RangeStmt.For.
930 // Example printed form:
931 // t0 = range "hello":string
935 X Value // string or map
938 // The Next instruction reads and advances the (map or string)
939 // iterator Iter and returns a 3-tuple value (ok, k, v). If the
940 // iterator is not exhausted, ok is true and k and v are the next
941 // elements of the domain and range, respectively. Otherwise ok is
942 // false and k and v are undefined.
944 // Components of the tuple are accessed using Extract.
946 // The IsString field distinguishes iterators over strings from those
947 // over maps, as the Type() alone is insufficient: consider
950 // Type() returns a *types.Tuple for the triple (ok, k, v).
951 // The types of k and/or v may be types.Invalid.
953 // Example printed form:
959 IsString bool // true => string iterator; false => map iterator.
962 // The TypeAssert instruction tests whether interface value X has type
965 // If !CommaOk, on success it returns v, the result of the conversion
966 // (defined below); on failure it panics.
968 // If CommaOk: on success it returns a pair (v, true) where v is the
969 // result of the conversion; on failure it returns (z, false) where z
970 // is AssertedType's zero value. The components of the pair must be
971 // accessed using the Extract instruction.
973 // If AssertedType is a concrete type, TypeAssert checks whether the
974 // dynamic type in interface X is equal to it, and if so, the result
975 // of the conversion is a copy of the value in the interface.
977 // If AssertedType is an interface, TypeAssert checks whether the
978 // dynamic type of the interface is assignable to it, and if so, the
979 // result of the conversion is a copy of the interface value X.
980 // If AssertedType is a superinterface of X.Type(), the operation will
981 // fail iff the operand is nil. (Contrast with ChangeInterface, which
982 // performs no nil-check.)
984 // Type() reflects the actual type of the result, possibly a
985 // 2-types.Tuple; AssertedType is the asserted type.
987 // Pos() returns the ast.CallExpr.Lparen if the instruction arose from
988 // an explicit T(e) conversion; the ast.TypeAssertExpr.Lparen if the
989 // instruction arose from an explicit e.(T) operation; or the
990 // ast.CaseClause.Case if the instruction arose from a case of a
991 // type-switch statement.
993 // Example printed form:
994 // t1 = typeassert t0.(int)
995 // t3 = typeassert,ok t2.(T)
997 type TypeAssert struct {
1000 AssertedType types.Type
1004 // The Extract instruction yields component Index of Tuple.
1006 // This is used to access the results of instructions with multiple
1007 // return values, such as Call, TypeAssert, Next, UnOp(ARROW) and
1010 // Example printed form:
1011 // t1 = extract t0 #1
1013 type Extract struct {
1019 // Instructions executed for effect. They do not yield a value. --------------------
1021 // The Jump instruction transfers control to the sole successor of its
1024 // A Jump must be the last instruction of its containing BasicBlock.
1026 // Pos() returns NoPos.
1028 // Example printed form:
1035 // The If instruction transfers control to one of the two successors
1036 // of its owning block, depending on the boolean Cond: the first if
1037 // true, the second if false.
1039 // An If instruction must be the last instruction of its containing
1042 // Pos() returns NoPos.
1044 // Example printed form:
1045 // if t0 goto done else body
1052 // The Return instruction returns values and control back to the calling
1055 // len(Results) is always equal to the number of results in the
1056 // function's signature.
1058 // If len(Results) > 1, Return returns a tuple value with the specified
1059 // components which the caller must access using Extract instructions.
1061 // There is no instruction to return a ready-made tuple like those
1062 // returned by a "value,ok"-mode TypeAssert, Lookup or UnOp(ARROW) or
1063 // a tail-call to a function with multiple result parameters.
1065 // Return must be the last instruction of its containing BasicBlock.
1066 // Such a block has no successors.
1068 // Pos() returns the ast.ReturnStmt.Return, if explicit in the source.
1070 // Example printed form:
1072 // return nil:I, 2:int
1074 type Return struct {
1080 // The RunDefers instruction pops and invokes the entire stack of
1081 // procedure calls pushed by Defer instructions in this function.
1083 // It is legal to encounter multiple 'rundefers' instructions in a
1084 // single control-flow path through a function; this is useful in
1085 // the combined init() function, for example.
1087 // Pos() returns NoPos.
1089 // Example printed form:
1092 type RunDefers struct {
1096 // The Panic instruction initiates a panic with value X.
1098 // A Panic instruction must be the last instruction of its containing
1099 // BasicBlock, which must have no successors.
1101 // NB: 'go panic(x)' and 'defer panic(x)' do not use this instruction;
1102 // they are treated as calls to a built-in function.
1104 // Pos() returns the ast.CallExpr.Lparen if this panic was explicit
1107 // Example printed form:
1112 X Value // an interface{}
1116 // The Go instruction creates a new goroutine and calls the specified
1117 // function within it.
1119 // See CallCommon for generic function call documentation.
1121 // Pos() returns the ast.GoStmt.Go.
1123 // Example printed form:
1124 // go println(t0, t1)
1126 // go invoke t5.Println(...t6)
1134 // The Defer instruction pushes the specified call onto a stack of
1135 // functions to be called by a RunDefers instruction or by a panic.
1137 // See CallCommon for generic function call documentation.
1139 // Pos() returns the ast.DeferStmt.Defer.
1141 // Example printed form:
1142 // defer println(t0, t1)
1144 // defer invoke t5.Println(...t6)
1152 // The Send instruction sends X on channel Chan.
1154 // Pos() returns the ast.SendStmt.Arrow, if explicit in the source.
1156 // Example printed form:
1165 // The Store instruction stores Val at address Addr.
1166 // Stores can be of arbitrary types.
1168 // Pos() returns the position of the source-level construct most closely
1169 // associated with the memory store operation.
1170 // Since implicit memory stores are numerous and varied and depend upon
1171 // implementation choices, the details are not specified.
1173 // Example printed form:
1183 // The MapUpdate instruction updates the association of Map[Key] to
1186 // Pos() returns the ast.KeyValueExpr.Colon or ast.IndexExpr.Lbrack,
1187 // if explicit in the source.
1189 // Example printed form:
1192 type MapUpdate struct {
1200 // A DebugRef instruction maps a source-level expression Expr to the
1201 // SSA value X that represents the value (!IsAddr) or address (IsAddr)
1202 // of that expression.
1204 // DebugRef is a pseudo-instruction: it has no dynamic effect.
1206 // Pos() returns Expr.Pos(), the start position of the source-level
1207 // expression. This is not the same as the "designated" token as
1208 // documented at Value.Pos(). e.g. CallExpr.Pos() does not return the
1209 // position of the ("designated") Lparen token.
1211 // If Expr is an *ast.Ident denoting a var or func, Object() returns
1212 // the object; though this information can be obtained from the type
1213 // checker, including it here greatly facilitates debugging.
1214 // For non-Ident expressions, Object() returns nil.
1216 // DebugRefs are generated only for functions built with debugging
1217 // enabled; see Package.SetDebugMode() and the GlobalDebug builder
1220 // DebugRefs are not emitted for ast.Idents referring to constants or
1221 // predeclared identifiers, since they are trivial and numerous.
1222 // Nor are they emitted for ast.ParenExprs.
1224 // (By representing these as instructions, rather than out-of-band,
1225 // consistency is maintained during transformation passes by the
1226 // ordinary SSA renaming machinery.)
1228 // Example printed form:
1229 // ; *ast.CallExpr @ 102:9 is t5
1230 // ; var x float64 @ 109:72 is x
1231 // ; address of *ast.CompositeLit @ 216:10 is t0
1233 type DebugRef struct {
1235 Expr ast.Expr // the referring expression (never *ast.ParenExpr)
1236 object types.Object // the identity of the source var/func
1237 IsAddr bool // Expr is addressable and X is the address it denotes
1238 X Value // the value or address of Expr
1241 // Embeddable mix-ins and helpers for common parts of other structs. -----------
1243 // register is a mix-in embedded by all SSA values that are also
1244 // instructions, i.e. virtual registers, and provides a uniform
1245 // implementation of most of the Value interface: Value.Name() is a
1246 // numbered register (e.g. "t0"); the other methods are field accessors.
1248 // Temporary names are automatically assigned to each register on
1249 // completion of building a function in SSA form.
1251 // Clients must not assume that the 'id' value (and the Name() derived
1252 // from it) is unique within a function. As always in this API,
1253 // semantics are determined only by identity; names exist only to
1254 // facilitate debugging.
1256 type register struct {
1258 num int // "name" of virtual register, e.g. "t0". Not guaranteed unique.
1259 typ types.Type // type of virtual register
1260 pos token.Pos // position of source expression, or NoPos
1261 referrers []Instruction
1264 // anInstruction is a mix-in embedded by all Instructions.
1265 // It provides the implementations of the Block and setBlock methods.
1266 type anInstruction struct {
1267 block *BasicBlock // the basic block of this instruction
1270 // CallCommon is contained by Go, Defer and Call to hold the
1271 // common parts of a function or method call.
1273 // Each CallCommon exists in one of two modes, function call and
1274 // interface method invocation, or "call" and "invoke" for short.
1276 // 1. "call" mode: when Method is nil (!IsInvoke), a CallCommon
1277 // represents an ordinary function call of the value in Value,
1278 // which may be a *Builtin, a *Function or any other value of kind
1281 // Value may be one of:
1282 // (a) a *Function, indicating a statically dispatched call
1283 // to a package-level function, an anonymous function, or
1284 // a method of a named type.
1285 // (b) a *MakeClosure, indicating an immediately applied
1286 // function literal with free variables.
1287 // (c) a *Builtin, indicating a statically dispatched call
1288 // to a built-in function.
1289 // (d) any other value, indicating a dynamically dispatched
1291 // StaticCallee returns the identity of the callee in cases
1292 // (a) and (b), nil otherwise.
1294 // Args contains the arguments to the call. If Value is a method,
1295 // Args[0] contains the receiver parameter.
1297 // Example printed form:
1298 // t2 = println(t0, t1)
1302 // 2. "invoke" mode: when Method is non-nil (IsInvoke), a CallCommon
1303 // represents a dynamically dispatched call to an interface method.
1304 // In this mode, Value is the interface value and Method is the
1305 // interface's abstract method. Note: an abstract method may be
1306 // shared by multiple interfaces due to embedding; Value.Type()
1307 // provides the specific interface used for this call.
1309 // Value is implicitly supplied to the concrete method implementation
1310 // as the receiver parameter; in other words, Args[0] holds not the
1311 // receiver but the first true argument.
1313 // Example printed form:
1314 // t1 = invoke t0.String()
1315 // go invoke t3.Run(t2)
1316 // defer invoke t4.Handle(...t5)
1318 // For all calls to variadic functions (Signature().Variadic()),
1319 // the last element of Args is a slice.
1321 type CallCommon struct {
1322 Value Value // receiver (invoke mode) or func value (call mode)
1323 Method *types.Func // abstract method (invoke mode)
1324 Args []Value // actual parameters (in static method call, includes receiver)
1325 pos token.Pos // position of CallExpr.Lparen, iff explicit in source
1328 // IsInvoke returns true if this call has "invoke" (not "call") mode.
1329 func (c *CallCommon) IsInvoke() bool {
1330 return c.Method != nil
1333 func (c *CallCommon) Pos() token.Pos { return c.pos }
1335 // Signature returns the signature of the called function.
1337 // For an "invoke"-mode call, the signature of the interface method is
1340 // In either "call" or "invoke" mode, if the callee is a method, its
1341 // receiver is represented by sig.Recv, not sig.Params().At(0).
1343 func (c *CallCommon) Signature() *types.Signature {
1344 if c.Method != nil {
1345 return c.Method.Type().(*types.Signature)
1347 return c.Value.Type().Underlying().(*types.Signature)
1350 // StaticCallee returns the callee if this is a trivially static
1351 // "call"-mode call to a function.
1352 func (c *CallCommon) StaticCallee() *Function {
1353 switch fn := c.Value.(type) {
1357 return fn.Fn.(*Function)
1362 // Description returns a description of the mode of this call suitable
1363 // for a user interface, e.g., "static method call".
1364 func (c *CallCommon) Description() string {
1365 switch fn := c.Value.(type) {
1367 return "built-in function call"
1369 return "static function closure call"
1371 if fn.Signature.Recv() != nil {
1372 return "static method call"
1374 return "static function call"
1377 return "dynamic method call" // ("invoke" mode)
1379 return "dynamic function call"
1382 // The CallInstruction interface, implemented by *Go, *Defer and *Call,
1383 // exposes the common parts of function-calling instructions,
1384 // yet provides a way back to the Value defined by *Call alone.
1386 type CallInstruction interface {
1388 Common() *CallCommon // returns the common parts of the call
1389 Value() *Call // returns the result value of the call (*Call) or nil (*Go, *Defer)
1392 func (s *Call) Common() *CallCommon { return &s.Call }
1393 func (s *Defer) Common() *CallCommon { return &s.Call }
1394 func (s *Go) Common() *CallCommon { return &s.Call }
1396 func (s *Call) Value() *Call { return s }
1397 func (s *Defer) Value() *Call { return nil }
1398 func (s *Go) Value() *Call { return nil }
1400 func (v *Builtin) Type() types.Type { return v.sig }
1401 func (v *Builtin) Name() string { return v.name }
1402 func (*Builtin) Referrers() *[]Instruction { return nil }
1403 func (v *Builtin) Pos() token.Pos { return token.NoPos }
1404 func (v *Builtin) Object() types.Object { return types.Universe.Lookup(v.name) }
1405 func (v *Builtin) Parent() *Function { return nil }
1407 func (v *FreeVar) Type() types.Type { return v.typ }
1408 func (v *FreeVar) Name() string { return v.name }
1409 func (v *FreeVar) Referrers() *[]Instruction { return &v.referrers }
1410 func (v *FreeVar) Pos() token.Pos { return v.pos }
1411 func (v *FreeVar) Parent() *Function { return v.parent }
1413 func (v *Global) Type() types.Type { return v.typ }
1414 func (v *Global) Name() string { return v.name }
1415 func (v *Global) Parent() *Function { return nil }
1416 func (v *Global) Pos() token.Pos { return v.pos }
1417 func (v *Global) Referrers() *[]Instruction { return nil }
1418 func (v *Global) Token() token.Token { return token.VAR }
1419 func (v *Global) Object() types.Object { return v.object }
1420 func (v *Global) String() string { return v.RelString(nil) }
1421 func (v *Global) Package() *Package { return v.Pkg }
1422 func (v *Global) RelString(from *types.Package) string { return relString(v, from) }
1424 func (v *Function) Name() string { return v.name }
1425 func (v *Function) Type() types.Type { return v.Signature }
1426 func (v *Function) Pos() token.Pos { return v.pos }
1427 func (v *Function) Token() token.Token { return token.FUNC }
1428 func (v *Function) Object() types.Object { return v.object }
1429 func (v *Function) String() string { return v.RelString(nil) }
1430 func (v *Function) Package() *Package { return v.Pkg }
1431 func (v *Function) Parent() *Function { return v.parent }
1432 func (v *Function) Referrers() *[]Instruction {
1433 if v.parent != nil {
1439 func (v *Parameter) Type() types.Type { return v.typ }
1440 func (v *Parameter) Name() string { return v.name }
1441 func (v *Parameter) Object() types.Object { return v.object }
1442 func (v *Parameter) Referrers() *[]Instruction { return &v.referrers }
1443 func (v *Parameter) Pos() token.Pos { return v.pos }
1444 func (v *Parameter) Parent() *Function { return v.parent }
1446 func (v *Alloc) Type() types.Type { return v.typ }
1447 func (v *Alloc) Referrers() *[]Instruction { return &v.referrers }
1448 func (v *Alloc) Pos() token.Pos { return v.pos }
1450 func (v *register) Type() types.Type { return v.typ }
1451 func (v *register) setType(typ types.Type) { v.typ = typ }
1452 func (v *register) Name() string { return fmt.Sprintf("t%d", v.num) }
1453 func (v *register) setNum(num int) { v.num = num }
1454 func (v *register) Referrers() *[]Instruction { return &v.referrers }
1455 func (v *register) Pos() token.Pos { return v.pos }
1456 func (v *register) setPos(pos token.Pos) { v.pos = pos }
1458 func (v *anInstruction) Parent() *Function { return v.block.parent }
1459 func (v *anInstruction) Block() *BasicBlock { return v.block }
1460 func (v *anInstruction) setBlock(block *BasicBlock) { v.block = block }
1461 func (v *anInstruction) Referrers() *[]Instruction { return nil }
1463 func (t *Type) Name() string { return t.object.Name() }
1464 func (t *Type) Pos() token.Pos { return t.object.Pos() }
1465 func (t *Type) Type() types.Type { return t.object.Type() }
1466 func (t *Type) Token() token.Token { return token.TYPE }
1467 func (t *Type) Object() types.Object { return t.object }
1468 func (t *Type) String() string { return t.RelString(nil) }
1469 func (t *Type) Package() *Package { return t.pkg }
1470 func (t *Type) RelString(from *types.Package) string { return relString(t, from) }
1472 func (c *NamedConst) Name() string { return c.object.Name() }
1473 func (c *NamedConst) Pos() token.Pos { return c.object.Pos() }
1474 func (c *NamedConst) String() string { return c.RelString(nil) }
1475 func (c *NamedConst) Type() types.Type { return c.object.Type() }
1476 func (c *NamedConst) Token() token.Token { return token.CONST }
1477 func (c *NamedConst) Object() types.Object { return c.object }
1478 func (c *NamedConst) Package() *Package { return c.pkg }
1479 func (c *NamedConst) RelString(from *types.Package) string { return relString(c, from) }
1481 func (d *DebugRef) Object() types.Object { return d.object }
1483 // Func returns the package-level function of the specified name,
1484 // or nil if not found.
1486 func (p *Package) Func(name string) (f *Function) {
1487 f, _ = p.Members[name].(*Function)
1491 // Var returns the package-level variable of the specified name,
1492 // or nil if not found.
1494 func (p *Package) Var(name string) (g *Global) {
1495 g, _ = p.Members[name].(*Global)
1499 // Const returns the package-level constant of the specified name,
1500 // or nil if not found.
1502 func (p *Package) Const(name string) (c *NamedConst) {
1503 c, _ = p.Members[name].(*NamedConst)
1507 // Type returns the package-level type of the specified name,
1508 // or nil if not found.
1510 func (p *Package) Type(name string) (t *Type) {
1511 t, _ = p.Members[name].(*Type)
1515 func (v *Call) Pos() token.Pos { return v.Call.pos }
1516 func (s *Defer) Pos() token.Pos { return s.pos }
1517 func (s *Go) Pos() token.Pos { return s.pos }
1518 func (s *MapUpdate) Pos() token.Pos { return s.pos }
1519 func (s *Panic) Pos() token.Pos { return s.pos }
1520 func (s *Return) Pos() token.Pos { return s.pos }
1521 func (s *Send) Pos() token.Pos { return s.pos }
1522 func (s *Store) Pos() token.Pos { return s.pos }
1523 func (s *If) Pos() token.Pos { return token.NoPos }
1524 func (s *Jump) Pos() token.Pos { return token.NoPos }
1525 func (s *RunDefers) Pos() token.Pos { return token.NoPos }
1526 func (s *DebugRef) Pos() token.Pos { return s.Expr.Pos() }
1530 func (v *Alloc) Operands(rands []*Value) []*Value {
1534 func (v *BinOp) Operands(rands []*Value) []*Value {
1535 return append(rands, &v.X, &v.Y)
1538 func (c *CallCommon) Operands(rands []*Value) []*Value {
1539 rands = append(rands, &c.Value)
1540 for i := range c.Args {
1541 rands = append(rands, &c.Args[i])
1546 func (s *Go) Operands(rands []*Value) []*Value {
1547 return s.Call.Operands(rands)
1550 func (s *Call) Operands(rands []*Value) []*Value {
1551 return s.Call.Operands(rands)
1554 func (s *Defer) Operands(rands []*Value) []*Value {
1555 return s.Call.Operands(rands)
1558 func (v *ChangeInterface) Operands(rands []*Value) []*Value {
1559 return append(rands, &v.X)
1562 func (v *ChangeType) Operands(rands []*Value) []*Value {
1563 return append(rands, &v.X)
1566 func (v *Convert) Operands(rands []*Value) []*Value {
1567 return append(rands, &v.X)
1570 func (s *DebugRef) Operands(rands []*Value) []*Value {
1571 return append(rands, &s.X)
1574 func (v *Extract) Operands(rands []*Value) []*Value {
1575 return append(rands, &v.Tuple)
1578 func (v *Field) Operands(rands []*Value) []*Value {
1579 return append(rands, &v.X)
1582 func (v *FieldAddr) Operands(rands []*Value) []*Value {
1583 return append(rands, &v.X)
1586 func (s *If) Operands(rands []*Value) []*Value {
1587 return append(rands, &s.Cond)
1590 func (v *Index) Operands(rands []*Value) []*Value {
1591 return append(rands, &v.X, &v.Index)
1594 func (v *IndexAddr) Operands(rands []*Value) []*Value {
1595 return append(rands, &v.X, &v.Index)
1598 func (*Jump) Operands(rands []*Value) []*Value {
1602 func (v *Lookup) Operands(rands []*Value) []*Value {
1603 return append(rands, &v.X, &v.Index)
1606 func (v *MakeChan) Operands(rands []*Value) []*Value {
1607 return append(rands, &v.Size)
1610 func (v *MakeClosure) Operands(rands []*Value) []*Value {
1611 rands = append(rands, &v.Fn)
1612 for i := range v.Bindings {
1613 rands = append(rands, &v.Bindings[i])
1618 func (v *MakeInterface) Operands(rands []*Value) []*Value {
1619 return append(rands, &v.X)
1622 func (v *MakeMap) Operands(rands []*Value) []*Value {
1623 return append(rands, &v.Reserve)
1626 func (v *MakeSlice) Operands(rands []*Value) []*Value {
1627 return append(rands, &v.Len, &v.Cap)
1630 func (v *MapUpdate) Operands(rands []*Value) []*Value {
1631 return append(rands, &v.Map, &v.Key, &v.Value)
1634 func (v *Next) Operands(rands []*Value) []*Value {
1635 return append(rands, &v.Iter)
1638 func (s *Panic) Operands(rands []*Value) []*Value {
1639 return append(rands, &s.X)
1642 func (v *Phi) Operands(rands []*Value) []*Value {
1643 for i := range v.Edges {
1644 rands = append(rands, &v.Edges[i])
1649 func (v *Range) Operands(rands []*Value) []*Value {
1650 return append(rands, &v.X)
1653 func (s *Return) Operands(rands []*Value) []*Value {
1654 for i := range s.Results {
1655 rands = append(rands, &s.Results[i])
1660 func (*RunDefers) Operands(rands []*Value) []*Value {
1664 func (v *Select) Operands(rands []*Value) []*Value {
1665 for i := range v.States {
1666 rands = append(rands, &v.States[i].Chan, &v.States[i].Send)
1671 func (s *Send) Operands(rands []*Value) []*Value {
1672 return append(rands, &s.Chan, &s.X)
1675 func (v *Slice) Operands(rands []*Value) []*Value {
1676 return append(rands, &v.X, &v.Low, &v.High, &v.Max)
1679 func (s *Store) Operands(rands []*Value) []*Value {
1680 return append(rands, &s.Addr, &s.Val)
1683 func (v *TypeAssert) Operands(rands []*Value) []*Value {
1684 return append(rands, &v.X)
1687 func (v *UnOp) Operands(rands []*Value) []*Value {
1688 return append(rands, &v.X)
1691 // Non-Instruction Values:
1692 func (v *Builtin) Operands(rands []*Value) []*Value { return rands }
1693 func (v *FreeVar) Operands(rands []*Value) []*Value { return rands }
1694 func (v *Const) Operands(rands []*Value) []*Value { return rands }
1695 func (v *Function) Operands(rands []*Value) []*Value { return rands }
1696 func (v *Global) Operands(rands []*Value) []*Value { return rands }
1697 func (v *Parameter) Operands(rands []*Value) []*Value { return rands }