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

cmd/gc: add commentary to the OXXX constants.

R=rsc, daniel.morsing
CC=golang-dev
https://golang.org/cl/6495074
This commit is contained in:
Nigel Tao 2012-09-05 09:34:52 +10:00
parent ee911c4265
commit 1c675ac89d

View File

@ -399,104 +399,172 @@ struct Hist
}; };
#define H ((Hist*)0) #define H ((Hist*)0)
// Node ops.
enum enum
{ {
OXXX, OXXX,
// names // names
ONAME, ONAME, // var, const or func name
ONONAME, ONONAME, // unnamed arg or return value: f(int, string) (int, error) { etc }
OTYPE, OTYPE, // type name
OPACK, OPACK, // import
OLITERAL, OLITERAL, // literal
// exprs // expressions
OADD, OSUB, OOR, OXOR, OADDSTR, OADD, // x + y
OADDR, OSUB, // x - y
OANDAND, OOR, // x | y
OAPPEND, OXOR, // x ^ y
OARRAYBYTESTR, OARRAYRUNESTR, OADDSTR, // s + "foo"
OSTRARRAYBYTE, OSTRARRAYRUNE, OADDR, // &x
OAS, OAS2, OAS2FUNC, OAS2RECV, OAS2MAPR, OAS2DOTTYPE, OANDAND, // b0 && b1
OASOP, OAPPEND, // append
OBAD, OARRAYBYTESTR, // string(bytes)
OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, OARRAYRUNESTR, // string(runes)
OCAP, OSTRARRAYBYTE, // []byte(s)
OCLOSE, OSTRARRAYRUNE, // []rune(s)
OCLOSURE, OAS, // x = y or x := y
OCMPIFACE, OCMPSTR, OAS2, // x, y, z = xx, yy, zz
OCOMPLIT, OMAPLIT, OSTRUCTLIT, OARRAYLIT, OPTRLIT, OAS2FUNC, // x, y = f()
OCONV, OCONVIFACE, OCONVNOP, OAS2RECV, // x, ok = <-c
OCOPY, OAS2MAPR, // x, ok = m["foo"]
ODCL, ODCLFUNC, ODCLFIELD, ODCLCONST, ODCLTYPE, OAS2DOTTYPE, // x, ok = I.(int)
ODELETE, OASOP, // x += y
ODOT, ODOTPTR, ODOTMETH, ODOTINTER, OXDOT, OBAD, // unused.
ODOTTYPE, OCALL, // function call, method call or type conversion, possibly preceded by defer or go.
ODOTTYPE2, OCALLFUNC, // f()
OEQ, ONE, OLT, OLE, OGE, OGT, OCALLMETH, // t.Method()
OIND, OCALLINTER, // err.Error()
OINDEX, OINDEXMAP, OCAP, // cap
OKEY, OPARAM, OCLOSE, // close
OLEN, OCLOSURE, // f = func() { etc }
OMAKE, OMAKECHAN, OMAKEMAP, OMAKESLICE, OCMPIFACE, // err1 == err2
OHMUL, ORRC, OLRC, // high-mul and rotate-carry OCMPSTR, // s1 == s2
OMUL, ODIV, OMOD, OLSH, ORSH, OAND, OANDNOT, OCOMPLIT, // composite literal, typechecking may convert to a more specific OXXXLIT.
ONEW, OMAPLIT, // M{"foo":3, "bar":4}
ONOT, OCOM, OPLUS, OMINUS, OSTRUCTLIT, // T{x:3, y:4}
OOROR, OARRAYLIT, // [2]int{3, 4}
OPANIC, OPRINT, OPRINTN, OPTRLIT, // &T{x:3, y:4}
OPAREN, OCONV, // var i int; var u uint; i = int(u)
OSEND, OCONVIFACE, // I(t)
OSLICE, OSLICEARR, OSLICESTR, OCONVNOP, // type Int int; var i int; var j Int; i = int(j)
ORECOVER, OCOPY, // copy
ORECV, ODCL, // var x int
ORUNESTR, ODCLFUNC, // func f() or func (r) f()
OSELRECV, ODCLFIELD, // struct field, interface field, or func/method argument/return value.
OSELRECV2, ODCLCONST, // const pi = 3.14
OIOTA, ODCLTYPE, // type Int int
OREAL, OIMAG, OCOMPLEX, ODELETE, // delete
ODOT, // t.x
ODOTPTR, // p.x that is implicitly (*p).x
ODOTMETH, // t.Method
ODOTINTER, // err.Error
OXDOT, // t.x, typechecking may convert to a more specific ODOTXXX.
ODOTTYPE, // e = err.(MyErr)
ODOTTYPE2, // e, ok = err.(MyErr)
OEQ, // x == y
ONE, // x != y
OLT, // x < y
OLE, // x <= y
OGE, // x >= y
OGT, // x > y
OIND, // *p
OINDEX, // a[i]
OINDEXMAP, // m[s]
OKEY, // The x:3 in t{x:3, y:4}, the 1:2 in a[1:2], the 2:20 in [3]int{2:20}, etc.
OPARAM, // The on-stack copy of a parameter or return value that escapes.
OLEN, // len
OMAKE, // make, typechecking may convert to a more specfic OMAKEXXX.
OMAKECHAN, // make(chan int)
OMAKEMAP, // make(map[string]int)
OMAKESLICE, // make([]int, 0)
// stmts // TODO: move these to the "for back ends" section, like OLROT.
OBLOCK, OHMUL, // high-mul. 386/amd64: AMUL/AIMUL for unsigned/signed (OMUL uses AIMUL for both).
OBREAK, ORRC, // right rotate-carry. 386/amd64: ARCR.
OCASE, OXCASE, OLRC, // unused.
OCONTINUE,
ODEFER, OMUL, // x * y
OEMPTY, ODIV, // x / y
OFALL, OXFALL, OMOD, // x % y
OFOR, OLSH, // x << u
OGOTO, ORSH, // x >> u
OIF, OAND, // x & y
OLABEL, OANDNOT, // x &^ y
OPROC, ONEW, // new
ORANGE, ONOT, // !b
ORETURN, OCOM, // ^x
OSELECT, OPLUS, // +x
OSWITCH, OMINUS, // -y
OTYPESW, // l = r.(type) OOROR, // b1 || b2
OPANIC, // panic
OPRINT, // print
OPRINTN, // println
OPAREN, // (x)
OSEND, // c <- x
OSLICE, // v[1:2], typechecking may convert to a more specfic OSLICEXXX.
OSLICEARR, // a[1:2]
OSLICESTR, // s[1:2]
ORECOVER, // recover
ORECV, // <-c
ORUNESTR, // string(i)
OSELRECV, // case x = <-c:
OSELRECV2, // case x, ok = <-c:
OIOTA, // iota
OREAL, // real
OIMAG, // imag
OCOMPLEX, // complex
// statements
OBLOCK, // block of code
OBREAK, // break
OCASE, // case, after being verified by swt.c's casebody.
OXCASE, // case, before verification.
OCONTINUE, // continue
ODEFER, // defer
OEMPTY, // no-op
OFALL, // fallthrough, after being verified by swt.c's casebody.
OXFALL, // fallthrough, before verification.
OFOR, // for
OGOTO, // goto
OIF, // if
OLABEL, // label:
OPROC, // go
ORANGE, // range
ORETURN, // return
OSELECT, // select
OSWITCH, // switch x
OTYPESW, // switch err.(type)
// types // types
OTCHAN, OTCHAN, // chan int
OTMAP, OTMAP, // map[string]int
OTSTRUCT, OTSTRUCT, // struct{}
OTINTER, OTINTER, // interface{}
OTFUNC, OTFUNC, // func()
OTARRAY, OTARRAY, // []int, [8]int, [N]int or [...]int
OTPAREN, OTPAREN, // (T)
// misc // misc
ODDD, ODDD, // func f(args ...int) or f(l...) or var a = [...]int{0, 1, 2}.
ODDDARG, ODDDARG, // func f(args ...int), introduced by escape analysis.
OINLCALL, // intermediary representation of an inlined call OINLCALL, // intermediary representation of an inlined call.
OEFACE, // itable and data words of empty-interface value OEFACE, // itable and data words of an empty-interface value.
OITAB, // itable word of interface value OITAB, // itable word of an interface value.
// for back ends // for back ends
OCMP, ODEC, OEXTEND, OINC, OREGISTER, OINDREG, OCMP, // compare. 386/amd64: ACMP.
OLROT, ODEC, // decrement. 386/amd64: ADEC.
OEXTEND, // extend. 386/amd64: ACWD/ACDQ/ACQO.
OINC, // increment. 386/amd64: AINC.
OREGISTER, // an arch-specific register.
OINDREG, // offset plus indirect of a register, such as 8(SP).
OLROT, // rotate left. 386/amd64: AROL.
OEND, OEND,
}; };
enum enum
{ {
Txxx, // 0 Txxx, // 0
@ -542,6 +610,7 @@ enum
NTYPE, NTYPE,
}; };
enum enum
{ {
CTxxx, CTxxx,