1
0
mirror of https://github.com/golang/go synced 2024-11-22 20:24:47 -07:00

cmd/compile: update ir.Node ops comments

After Russquake, all the Node ops now have different structure, update
comment to reflect that.

Change-Id: I43f859783cda457528ae4d2da9857f2cc0438b62
Reviewed-on: https://go-review.googlesource.com/c/go/+/311949
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Cuong Manh Le 2021-04-21 01:59:51 +07:00
parent f53c2fac46
commit acf1b46de5

View File

@ -123,167 +123,166 @@ const (
ONIL // nil ONIL // nil
// expressions // expressions
OADD // Left + Right OADD // X + Y
OSUB // Left - Right OSUB // X - Y
OOR // Left | Right OOR // X | Y
OXOR // Left ^ Right OXOR // X ^ Y
OADDSTR // +{List} (string addition, list elements are strings) OADDSTR // +{List} (string addition, list elements are strings)
OADDR // &Left OADDR // &X
OANDAND // Left && Right OANDAND // X && Y
OAPPEND // append(List); after walk, Left may contain elem type descriptor OAPPEND // append(Args); after walk, X may contain elem type descriptor
OBYTES2STR // Type(Left) (Type is string, Left is a []byte) OBYTES2STR // Type(X) (Type is string, X is a []byte)
OBYTES2STRTMP // Type(Left) (Type is string, Left is a []byte, ephemeral) OBYTES2STRTMP // Type(X) (Type is string, X is a []byte, ephemeral)
ORUNES2STR // Type(Left) (Type is string, Left is a []rune) ORUNES2STR // Type(X) (Type is string, X is a []rune)
OSTR2BYTES // Type(Left) (Type is []byte, Left is a string) OSTR2BYTES // Type(X) (Type is []byte, X is a string)
OSTR2BYTESTMP // Type(Left) (Type is []byte, Left is a string, ephemeral) OSTR2BYTESTMP // Type(X) (Type is []byte, X is a string, ephemeral)
OSTR2RUNES // Type(Left) (Type is []rune, Left is a string) OSTR2RUNES // Type(X) (Type is []rune, X is a string)
OSLICE2ARRPTR // Type(Left) (Type is *[N]T, Left is a []T) OSLICE2ARRPTR // Type(X) (Type is *[N]T, X is a []T)
// Left = Right or (if Colas=true) Left := Right // X = Y or (if Def=true) X := Y
// If Colas, then Ninit includes a DCL node for Left. // If Def, then Init includes a DCL node for X.
OAS OAS
// List = Rlist (x, y, z = a, b, c) or (if Colas=true) List := Rlist // Lhs = Rhs (x, y, z = a, b, c) or (if Def=true) Lhs := Rhs
// If Colas, then Ninit includes DCL nodes for List // If Def, then Init includes DCL nodes for Lhs
OAS2 OAS2
OAS2DOTTYPE // List = Right (x, ok = I.(int)) OAS2DOTTYPE // Lhs = Rhs (x, ok = I.(int))
OAS2FUNC // List = Right (x, y = f()) OAS2FUNC // Lhs = Rhs (x, y = f())
OAS2MAPR // List = Right (x, ok = m["foo"]) OAS2MAPR // Lhs = Rhs (x, ok = m["foo"])
OAS2RECV // List = Right (x, ok = <-c) OAS2RECV // Lhs = Rhs (x, ok = <-c)
OASOP // Left Etype= Right (x += y) OASOP // X AsOp= Y (x += y)
OCALL // Left(List) (function call, method call or type conversion) OCALL // X(Args) (function call, method call or type conversion)
// OCALLFUNC, OCALLMETH, and OCALLINTER have the same structure. // OCALLFUNC, OCALLMETH, and OCALLINTER have the same structure.
// Prior to walk, they are: Left(List), where List is all regular arguments. // Prior to walk, they are: X(Args), where Args is all regular arguments.
// After walk, List is a series of assignments to temporaries, // After walk, if any argument whose evaluation might requires temporary variable,
// and Rlist is an updated set of arguments. // that temporary variable will be pushed to Init, Args will contains an updated
// Nbody is all OVARLIVE nodes that are attached to OCALLxxx. // set of arguments. KeepAlive is all OVARLIVE nodes that are attached to OCALLxxx.
// TODO(josharian/khr): Use Ninit instead of List for the assignments to temporaries. See CL 114797. OCALLFUNC // X(Args) (function call f(args))
OCALLFUNC // Left(List/Rlist) (function call f(args)) OCALLMETH // X(Args) (direct method call x.Method(args))
OCALLMETH // Left(List/Rlist) (direct method call x.Method(args)) OCALLINTER // X(Args) (interface method call x.Method(args))
OCALLINTER // Left(List/Rlist) (interface method call x.Method(args)) OCALLPART // X.Sel (method expression x.Method, not called)
OCALLPART // Left.Right (method expression x.Method, not called) OCAP // cap(X)
OCAP // cap(Left) OCLOSE // close(X)
OCLOSE // close(Left) OCLOSURE // func Type { Func.Closure.Body } (func literal)
OCLOSURE // func Type { Func.Closure.Nbody } (func literal) OCOMPLIT // Type{List} (composite literal, not yet lowered to specific form)
OCOMPLIT // Right{List} (composite literal, not yet lowered to specific form)
OMAPLIT // Type{List} (composite literal, Type is map) OMAPLIT // Type{List} (composite literal, Type is map)
OSTRUCTLIT // Type{List} (composite literal, Type is struct) OSTRUCTLIT // Type{List} (composite literal, Type is struct)
OARRAYLIT // Type{List} (composite literal, Type is array) OARRAYLIT // Type{List} (composite literal, Type is array)
OSLICELIT // Type{List} (composite literal, Type is slice) Right.Int64() = slice length. OSLICELIT // Type{List} (composite literal, Type is slice), Len is slice length.
OPTRLIT // &Left (left is composite literal) OPTRLIT // &X (X is composite literal)
OCONV // Type(Left) (type conversion) OCONV // Type(X) (type conversion)
OCONVIFACE // Type(Left) (type conversion, to interface) OCONVIFACE // Type(X) (type conversion, to interface)
OCONVNOP // Type(Left) (type conversion, no effect) OCONVNOP // Type(X) (type conversion, no effect)
OCOPY // copy(Left, Right) OCOPY // copy(X, Y)
ODCL // var Left (declares Left of type Left.Type) ODCL // var X (declares X of type X.Type)
// Used during parsing but don't last. // Used during parsing but don't last.
ODCLFUNC // func f() or func (r) f() ODCLFUNC // func f() or func (r) f()
ODCLCONST // const pi = 3.14 ODCLCONST // const pi = 3.14
ODCLTYPE // type Int int or type Int = int ODCLTYPE // type Int int or type Int = int
ODELETE // delete(List) ODELETE // delete(Args)
ODOT // Left.Sym (Left is of struct type) ODOT // X.Sel (X is of struct type)
ODOTPTR // Left.Sym (Left is of pointer to struct type) ODOTPTR // X.Sel (X is of pointer to struct type)
ODOTMETH // Left.Sym (Left is non-interface, Right is method name) ODOTMETH // X.Sel (X is non-interface, Sel is method name)
ODOTINTER // Left.Sym (Left is interface, Right is method name) ODOTINTER // X.Sel (X is interface, Sel is method name)
OXDOT // Left.Sym (before rewrite to one of the preceding) OXDOT // X.Sel (before rewrite to one of the preceding)
ODOTTYPE // Left.Right or Left.Type (.Right during parsing, .Type once resolved); after walk, .Right contains address of interface type descriptor and .Right.Right contains address of concrete type descriptor ODOTTYPE // X.Ntype or X.Type (.Ntype during parsing, .Type once resolved); after walk, Itab contains address of interface type descriptor and Itab.X contains address of concrete type descriptor
ODOTTYPE2 // Left.Right or Left.Type (.Right during parsing, .Type once resolved; on rhs of OAS2DOTTYPE); after walk, .Right contains address of interface type descriptor ODOTTYPE2 // X.Ntype or X.Type (.Ntype during parsing, .Type once resolved; on rhs of OAS2DOTTYPE); after walk, Itab contains address of interface type descriptor
OEQ // Left == Right OEQ // X == Y
ONE // Left != Right ONE // X != Y
OLT // Left < Right OLT // X < Y
OLE // Left <= Right OLE // X <= Y
OGE // Left >= Right OGE // X >= Y
OGT // Left > Right OGT // X > Y
ODEREF // *Left ODEREF // *X
OINDEX // Left[Right] (index of array or slice) OINDEX // X[Index] (index of array or slice)
OINDEXMAP // Left[Right] (index of map) OINDEXMAP // X[Index] (index of map)
OKEY // Left:Right (key:value in struct/array/map literal) OKEY // Key:Value (key:value in struct/array/map literal)
OSTRUCTKEY // Sym:Left (key:value in struct literal, after type checking) OSTRUCTKEY // Field:Value (key:value in struct literal, after type checking)
OLEN // len(Left) OLEN // len(X)
OMAKE // make(List) (before type checking converts to one of the following) OMAKE // make(Args) (before type checking converts to one of the following)
OMAKECHAN // make(Type, Left) (type is chan) OMAKECHAN // make(Type[, Len]) (type is chan)
OMAKEMAP // make(Type, Left) (type is map) OMAKEMAP // make(Type[, Len]) (type is map)
OMAKESLICE // make(Type, Left, Right) (type is slice) OMAKESLICE // make(Type[, Len[, Cap]]) (type is slice)
OMAKESLICECOPY // makeslicecopy(Type, Left, Right) (type is slice; Left is length and Right is the copied from slice) OMAKESLICECOPY // makeslicecopy(Type, Len, Cap) (type is slice; Len is length and Cap is the copied from slice)
// OMAKESLICECOPY is created by the order pass and corresponds to: // OMAKESLICECOPY is created by the order pass and corresponds to:
// s = make(Type, Left); copy(s, Right) // s = make(Type, Len); copy(s, Cap)
// //
// Bounded can be set on the node when Left == len(Right) is known at compile time. // Bounded can be set on the node when Len == len(Cap) is known at compile time.
// //
// This node is created so the walk pass can optimize this pattern which would // This node is created so the walk pass can optimize this pattern which would
// otherwise be hard to detect after the order pass. // otherwise be hard to detect after the order pass.
OMUL // Left * Right OMUL // X * Y
ODIV // Left / Right ODIV // X / Y
OMOD // Left % Right OMOD // X % Y
OLSH // Left << Right OLSH // X << Y
ORSH // Left >> Right ORSH // X >> Y
OAND // Left & Right OAND // X & Y
OANDNOT // Left &^ Right OANDNOT // X &^ Y
ONEW // new(Left); corresponds to calls to new in source code ONEW // new(X); corresponds to calls to new in source code
ONOT // !Left ONOT // !X
OBITNOT // ^Left OBITNOT // ^X
OPLUS // +Left OPLUS // +X
ONEG // -Left ONEG // -X
OOROR // Left || Right OOROR // X || Y
OPANIC // panic(Left) OPANIC // panic(X)
OPRINT // print(List) OPRINT // print(List)
OPRINTN // println(List) OPRINTN // println(List)
OPAREN // (Left) OPAREN // (X)
OSEND // Left <- Right OSEND // Chan <- Value
OSLICE // Left[List[0] : List[1]] (Left is untypechecked or slice) OSLICE // X[Low : High] (X is untypechecked or slice)
OSLICEARR // Left[List[0] : List[1]] (Left is pointer to array) OSLICEARR // X[Low : High] (X is pointer to array)
OSLICESTR // Left[List[0] : List[1]] (Left is string) OSLICESTR // X[Low : High] (X is string)
OSLICE3 // Left[List[0] : List[1] : List[2]] (Left is untypedchecked or slice) OSLICE3 // X[Low : High : Max] (X is untypedchecked or slice)
OSLICE3ARR // Left[List[0] : List[1] : List[2]] (Left is pointer to array) OSLICE3ARR // X[Low : High : Max] (X is pointer to array)
OSLICEHEADER // sliceheader{Left, List[0], List[1]} (Left is unsafe.Pointer, List[0] is length, List[1] is capacity) OSLICEHEADER // sliceheader{Ptr, Len, Cap} (Ptr is unsafe.Pointer, Len is length, Cap is capacity)
ORECOVER // recover() ORECOVER // recover()
ORECV // <-Left ORECV // <-X
ORUNESTR // Type(Left) (Type is string, Left is rune) ORUNESTR // Type(X) (Type is string, X is rune)
OSELRECV2 // like OAS2: List = Rlist where len(List)=2, len(Rlist)=1, Rlist[0].Op = ORECV (appears as .Left of OCASE) OSELRECV2 // like OAS2: Lhs = Rhs where len(Lhs)=2, len(Rhs)=1, Rhs[0].Op = ORECV (appears as .Var of OCASE)
OIOTA // iota OIOTA // iota
OREAL // real(Left) OREAL // real(X)
OIMAG // imag(Left) OIMAG // imag(X)
OCOMPLEX // complex(Left, Right) or complex(List[0]) where List[0] is a 2-result function call OCOMPLEX // complex(X, Y)
OALIGNOF // unsafe.Alignof(Left) OALIGNOF // unsafe.Alignof(X)
OOFFSETOF // unsafe.Offsetof(Left) OOFFSETOF // unsafe.Offsetof(X)
OSIZEOF // unsafe.Sizeof(Left) OSIZEOF // unsafe.Sizeof(X)
OMETHEXPR // method expression OMETHEXPR // method expression
OSTMTEXPR // statement expression (Init; Left) OSTMTEXPR // statement expression (Init; X)
// statements // statements
OBLOCK // { List } (block of code) OBLOCK // { List } (block of code)
OBREAK // break [Sym] OBREAK // break [Label]
// OCASE: case List: Nbody (List==nil means default) // OCASE: case List: Body (List==nil means default)
// For OTYPESW, List is a OTYPE node for the specified type (or OLITERAL // For OTYPESW, List is a OTYPE node for the specified type (or OLITERAL
// for nil), and, if a type-switch variable is specified, Rlist is an // for nil), and, if a type-switch variable is specified, Rlist is an
// ONAME for the version of the type-switch variable with the specified // ONAME for the version of the type-switch variable with the specified
// type. // type.
OCASE OCASE
OCONTINUE // continue [Sym] OCONTINUE // continue [Label]
ODEFER // defer Left (Left must be call) ODEFER // defer Call
OFALL // fallthrough OFALL // fallthrough
OFOR // for Ninit; Left; Right { Nbody } OFOR // for Init; Cond; Post { Body }
// OFORUNTIL is like OFOR, but the test (Left) is applied after the body: // OFORUNTIL is like OFOR, but the test (Cond) is applied after the body:
// Ninit // Init
// top: { Nbody } // Execute the body at least once // top: { Body } // Execute the body at least once
// cont: Right // cont: Post
// if Left { // And then test the loop condition // if Cond { // And then test the loop condition
// List // Before looping to top, execute List // List // Before looping to top, execute List
// goto top // goto top
// } // }
// OFORUNTIL is created by walk. There's no way to write this in Go code. // OFORUNTIL is created by walk. There's no way to write this in Go code.
OFORUNTIL OFORUNTIL
OGOTO // goto Sym OGOTO // goto Label
OIF // if Ninit; Left { Nbody } else { Rlist } OIF // if Init; Cond { Then } else { Else }
OLABEL // Sym: OLABEL // Label:
OGO // go Left (Left must be call) OGO // go Call
ORANGE // for List = range Right { Nbody } ORANGE // for Key, Value = range X { Body }
ORETURN // return List ORETURN // return Results
OSELECT // select { List } (List is list of OCASE) OSELECT // select { Cases }
OSWITCH // switch Ninit; Left { List } (List is a list of OCASE) OSWITCH // switch Init; Expr { Cases }
// OTYPESW: Left := Right.(type) (appears as .Left of OSWITCH) // OTYPESW: X := Y.(type) (appears as .Tag of OSWITCH)
// Left is nil if there is no type-switch variable // X is nil if there is no type-switch variable
OTYPESW OTYPESW
OFUNCINST // instantiation of a generic function OFUNCINST // instantiation of a generic function
@ -292,7 +291,7 @@ const (
OTMAP // map[string]int OTMAP // map[string]int
OTSTRUCT // struct{} OTSTRUCT // struct{}
OTINTER // interface{} OTINTER // interface{}
// OTFUNC: func() - Left is receiver field, List is list of param fields, Rlist is // OTFUNC: func() - Recv is receiver field, Params is list of param fields, Results is
// list of result fields. // list of result fields.
OTFUNC OTFUNC
OTARRAY // [8]int or [...]int OTARRAY // [8]int or [...]int
@ -306,7 +305,7 @@ const (
OINLCALL // intermediary representation of an inlined call. OINLCALL // intermediary representation of an inlined call.
OEFACE // itable and data words of an empty-interface value. OEFACE // itable and data words of an empty-interface value.
OITAB // itable word of an interface value. OITAB // itable word of an interface value.
OIDATA // data word of an interface value in Left OIDATA // data word of an interface value in X
OSPTR // base pointer of a slice or string. OSPTR // base pointer of a slice or string.
OCFUNC // reference to c function pointer (not go func value) OCFUNC // reference to c function pointer (not go func value)
OCHECKNIL // emit code to ensure pointer/interface not nil OCHECKNIL // emit code to ensure pointer/interface not nil
@ -539,7 +538,7 @@ func SetPos(n Node) src.XPos {
} }
// The result of InitExpr MUST be assigned back to n, e.g. // The result of InitExpr MUST be assigned back to n, e.g.
// n.Left = InitExpr(init, n.Left) // n.X = InitExpr(init, n.X)
func InitExpr(init []Node, expr Node) Node { func InitExpr(init []Node, expr Node) Node {
if len(init) == 0 { if len(init) == 0 {
return expr return expr