walk

Imports

Imports #

"go/constant"
"internal/abi"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/src"
"fmt"
"go/constant"
"go/token"
"internal/abi"
"internal/buildcfg"
"strings"
"cmd/compile/internal/base"
"cmd/compile/internal/escape"
"cmd/compile/internal/ir"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"encoding/binary"
"fmt"
"go/constant"
"hash/fnv"
"io"
"cmd/compile/internal/base"
"cmd/compile/internal/compare"
"cmd/compile/internal/ir"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/ssagen"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"fmt"
"go/constant"
"internal/abi"
"internal/buildcfg"
"strings"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/objw"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/rttype"
"cmd/compile/internal/staticdata"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/obj"
"cmd/internal/objabi"
"fmt"
"go/constant"
"internal/buildcfg"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/ssa"
"cmd/compile/internal/staticinit"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/objabi"
"cmd/internal/src"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/src"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmp"
"fmt"
"go/constant"
"go/token"
"math/bits"
"slices"
"sort"
"strings"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/objw"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/rttype"
"cmd/compile/internal/ssagen"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/obj"
"cmd/internal/src"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/src"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/ssa"
"cmd/compile/internal/staticdata"
"cmd/compile/internal/staticinit"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/obj"
"encoding/binary"
"go/constant"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/ssagen"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/sys"
"internal/buildcfg"
"unicode/utf8"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/ssagen"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/src"
"cmd/internal/sys"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"fmt"
"internal/abi"
"internal/buildcfg"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/rttype"
"cmd/compile/internal/ssagen"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/src"

Constants & Variables

hooks var #

var hooks = map[string]hookInfo{...}

inInitFunction const #

const inInitFunction initContext = iota

inNonInitFunction const #

const inNonInitFunction

initConst const #

const initConst

initDynamic const #

const initDynamic initGenType = *ast.BinaryExpr

initKindDynamic const #

const initKindDynamic

initKindLocalCode const #

const initKindLocalCode

initKindStatic const #

const initKindStatic initKind = *ast.BinaryExpr

interfaceSwitchGen var #

var interfaceSwitchGen int

itabHashField var #

var itabHashField *types.Field

itabTypeField var #

var itabTypeField *types.Field

mapaccess1 var #

var mapaccess1 = *ast.CallExpr

mapaccess2 var #

var mapaccess2 = *ast.CallExpr

mapassign var #

var mapassign = *ast.CallExpr

mapdelete var #

var mapdelete = *ast.CallExpr

mapfast32 const #

const mapfast32

mapfast32ptr const #

const mapfast32ptr

mapfast64 const #

const mapfast64

mapfast64ptr const #

const mapfast64ptr

mapfaststr const #

const mapfaststr

mapslow const #

const mapslow = iota

math_MulUintptr var #

var math_MulUintptr = *ast.UnaryExpr

maxOpenDefers const #

The max number of defers in a function using open-coded defers. We enforce this limit because the deferBits bitmask is currently a single byte (to minimize code size)

const maxOpenDefers = 8

nmapfast const #

const nmapfast

rtypeHashField var #

var rtypeHashField *types.Field

scase var #

var scase *types.Type

tmpstringbufsize const #

The constant is known to runtime.

const tmpstringbufsize = 32

typeAssertGen var #

var typeAssertGen int

Type Aliases

initContext type #

initContext is the context in which static data is populated. It is either in an init function or in any other function. Static data populated in an init function will be written either zero times (as a readonly, static data symbol) or one time (during init function execution). Either way, there is no opportunity for races or further modification, so the data can be written to a (possibly readonly) data symbol. Static data populated in any other function needs to be local to that function to allow multiple instances of that function to execute concurrently without clobbering each others' data.

type initContext uint8

initGenType type #

initGenType is a bitmap indicating the types of generation that will occur for a static value.

type initGenType uint8

initKind type #

initKind is a kind of static initialization: static, dynamic, or local. Static initialization represents literals and literal components of composite literals. Dynamic initialization represents non-literals and non-literal components of composite literals. LocalCode initialization represents initialization that occurs purely in generated code local to the function of use. Initialization code is sometimes generated in passes, first static then dynamic.

type initKind uint8

mapnames type #

type mapnames [nmapfast]string

ordermarker type #

type ordermarker int

Structs

exprClause struct #

type exprClause struct {
pos src.XPos
lo ir.Node
hi ir.Node
rtype ir.Node
jmp ir.Node
}

exprSwitch struct #

An exprSwitch walks an expression switch.

type exprSwitch struct {
pos src.XPos
exprname ir.Node
done ir.Nodes
clauses []exprClause
}

hookInfo struct #

type hookInfo struct {
paramType types.Kind
argsNum int
runtimeFunc string
}

orderState struct #

orderState holds state during the ordering process.

type orderState struct {
out []ir.Node
temp []*ir.Name
free map[string][]*ir.Name
edit func(ir.Node) ir.Node
}

typeClause struct #

type typeClause struct {
hash uint32
body ir.Nodes
}

typeSwitch struct #

A typeSwitch walks a type switch.

type typeSwitch struct {
srcName ir.Node
hashName ir.Node
okName ir.Node
itabName ir.Node
}

Functions

Add method #

func (s *exprSwitch) Add(pos src.XPos, expr ir.Node, rtype ir.Node, jmp ir.Node)

Emit method #

func (s *exprSwitch) Emit(out *ir.Nodes)

String method #

func (c initContext) String() string

Walk function #

func Walk(fn *ir.Func)

addrTemp method #

addrTemp ensures that n is okay to pass by address to runtime routines. If the original argument n is not okay, addrTemp creates a tmp, emits tmp = n, and then returns tmp. The result of addrTemp MUST be assigned back to n, e.g. n.Left = o.addrTemp(n.Left)

func (o *orderState) addrTemp(n ir.Node) ir.Node

allCaseExprsAreSideEffectFree function #

func allCaseExprsAreSideEffectFree(sw *ir.SwitchStmt) bool

anylit function #

func anylit(n ir.Node, var_ ir.Node, init *ir.Nodes)

append method #

append typechecks stmt and appends it to out.

func (o *orderState) append(stmt ir.Node)

appendSlice function #

expand append(l1, l2...) to init { s := l1 newLen := s.len + l2.len // Compare as uint so growslice can panic on overflow. if uint(newLen) <= uint(s.cap) { s = s[:newLen] } else { s = growslice(s.ptr, s.len, s.cap, l2.len, T) } memmove(&s[s.len-l2.len], &l2[0], l2.len*sizeof(T)) } s l2 is allowed to be a string.

func appendSlice(n *ir.CallExpr, init *ir.Nodes) ir.Node

appendWalkStmt function #

appendWalkStmt typechecks and walks stmt and then appends it to init.

func appendWalkStmt(init *ir.Nodes, stmt ir.Node)

arrayClear function #

arrayClear constructs a call to runtime.memclr for fast zeroing of slices and arrays.

func arrayClear(wbPos src.XPos, a ir.Node, nrange *ir.RangeStmt) ir.Node

arrayRangeClear function #

Lower n into runtime·memclr if possible, for fast zeroing of slices and arrays (issue 5373). Look for instances of for i := range a { a[i] = zero } in which the evaluation of a is side-effect-free. Parameters are as in walkRange: "for v1, v2 = range a".

func arrayRangeClear(loop *ir.RangeStmt, v1 ir.Node, v2 ir.Node, a ir.Node) ir.Node

as2func method #

as2func orders OAS2FUNC nodes. It creates temporaries to ensure left-to-right assignment. The caller should order the right-hand side of the assignment before calling order.as2func. It rewrites, a, b, a = ... as tmp1, tmp2, tmp3 = ... a, b, a = tmp1, tmp2, tmp3 This is necessary to ensure left to right assignment order.

func (o *orderState) as2func(n *ir.AssignListStmt)

as2ok method #

as2ok orders OAS2XXX with ok. Just like as2func, this also adds temporaries to ensure left-to-right assignment.

func (o *orderState) as2ok(n *ir.AssignListStmt)

ascompatee function #

check assign expression list to an expression list. called in expr-list = expr-list

func ascompatee(op ir.Op, nl []ir.Node, nr []ir.Node) []ir.Node

ascompatet function #

check assign type list to an expression list. called in expr-list = func()

func ascompatet(nl ir.Nodes, nr *types.Type) []ir.Node

backingArrayPtrLen function #

backingArrayPtrLen extracts the pointer and length from a slice or string. This constructs two nodes referring to n, so n must be a cheapExpr.

func backingArrayPtrLen(n ir.Node) (ptr ir.Node, length ir.Node)

badtype function #

func badtype(op ir.Op, tl *types.Type, tr *types.Type)

binarySearch function #

binarySearch constructs a binary search tree for handling n cases, and appends it to out. It's used for efficiently implementing switch statements. less(i) should return a boolean expression. If it evaluates true, then cases before i will be tested; otherwise, cases i and later. leaf(i, nif) should setup nif (an OIF node) to test case i. In particular, it should set nif.Cond and nif.Body.

func binarySearch(n int, out *ir.Nodes, less func(i int) ir.Node, leaf func(i int, nif *ir.IfStmt))

bounded function #

return 1 if integer n must be in range [0, max), 0 otherwise.

func bounded(n ir.Node, max int64) bool

boundedDotPtr function #

boundedDotPtr returns a selector expression representing ptr.field and omits nil-pointer checks for ptr.

func boundedDotPtr(pos src.XPos, ptr ir.Node, field *types.Field) *ir.SelectorExpr

brcom function #

brcom returns !(op). For example, brcom(==) is !=.

func brcom(op ir.Op) ir.Op

brrev function #

brrev returns reverse(op). For example, Brrev(<) is >.

func brrev(op ir.Op) ir.Op

bytePtrToIndex function #

bytePtrToIndex returns a Node representing "(*byte)(&n[i])".

func bytePtrToIndex(n ir.Node, i int64) ir.Node

byteindex function #

byteindex converts n, which is byte-sized, to an int used to index into an array. We cannot use conv, because we allow converting bool to int here, which is forbidden in user code.

func byteindex(n ir.Node) ir.Node

call method #

call orders the call expression n. n.Op is OCALLFUNC/OCALLINTER or a builtin like OCOPY.

func (o *orderState) call(nn ir.Node)

chanfn function #

func chanfn(name string, n int, t *types.Type) ir.Node

cheapComputableIndex function #

func cheapComputableIndex(width int64) bool

cheapExpr method #

cheapExpr returns a cheap version of n. The definition of cheap is that n is a variable or constant. If not, cheapExpr allocates a new tmp, emits tmp = n, and then returns tmp.

func (o *orderState) cheapExpr(n ir.Node) ir.Node

cheapExpr function #

return side-effect free and cheap n, appending side effects to init. result may not be assignable.

func cheapExpr(n ir.Node, init *ir.Nodes) ir.Node

closureArgs function #

closureArgs returns a slice of expressions that can be used to initialize the given closure's free variables. These correspond one-to-one with the variables in clo.Func.ClosureVars, and will be either an ONAME node (if the variable is captured by value) or an OADDR-of-ONAME node (if not).

func closureArgs(clo *ir.ClosureExpr) []ir.Node

convas function #

func convas(n *ir.AssignStmt, init *ir.Nodes) *ir.AssignStmt

copyExpr method #

copyExpr behaves like newTemp but also emits code to initialize the temporary to the value n.

func (o *orderState) copyExpr(n ir.Node) *ir.Name

copyExpr function #

func copyExpr(n ir.Node, t *types.Type, init *ir.Nodes) ir.Node

copyExpr1 method #

func (o *orderState) copyExpr1(n ir.Node, clear bool) *ir.Name

copyExprClear method #

copyExprClear is like copyExpr but clears the temp before assignment. It is provided for use when the evaluation of tmp = n turns into a function call that is passed a pointer to the temporary as the output space. If the call blocks before tmp has been written, the garbage collector will still treat the temporary as live, so we must zero it before entering that call. Today, this only happens for channel receive operations. (The other candidate would be map access, but map access returns a pointer to the result data instead of taking a pointer to be filled in.)

func (o *orderState) copyExprClear(n ir.Node) *ir.Name

dataWord function #

Returns the data word (the second word) used to represent conv.X in an interface.

func dataWord(conv *ir.ConvExpr, init *ir.Nodes) ir.Node

dataWordFuncName function #

dataWordFuncName returns the name of the function used to convert a value of type "from" to the data word of an interface. argType is the type the argument needs to be coerced to. needsaddr reports whether the value should be passed (needaddr==false) or its address (needsaddr==true).

func dataWordFuncName(from *types.Type) (fnname string, argType *types.Type, needsaddr bool)

directClosureCall function #

directClosureCall rewrites a direct call of a function literal into a normal function call with closure variables passed as arguments. This avoids allocation of a closure object. For illustration, the following call: func(a int) { println(byval) byref++ }(42) becomes: func(byval int, &byref *int, a int) { println(byval) (*&byref)++ }(byval, &byref, 42)

func directClosureCall(n *ir.CallExpr)

edge method #

edge inserts coverage instrumentation for libfuzzer.

func (o *orderState) edge()

endsInFallthrough function #

endsInFallthrough reports whether stmts ends with a "fallthrough" statement.

func endsInFallthrough(stmts []ir.Node) (bool, src.XPos)

expr method #

expr orders a single expression, appending side effects to o.out as needed. If this is part of an assignment lhs = *np, lhs is given. Otherwise lhs == nil. (When lhs != nil it may be possible to avoid copying the result of the expression to a temporary.) The result of expr MUST be assigned back to n, e.g. n.Left = o.expr(n.Left, lhs)

func (o *orderState) expr(n ir.Node, lhs ir.Node) ir.Node

expr1 method #

func (o *orderState) expr1(n ir.Node, lhs ir.Node) ir.Node

exprInPlace method #

exprInPlace orders the side effects in *np and leaves them as the init list of the final *np. The result of exprInPlace MUST be assigned back to n, e.g. n.Left = o.exprInPlace(n.Left)

func (o *orderState) exprInPlace(n ir.Node) ir.Node

exprList method #

exprList orders the expression list l into o.

func (o *orderState) exprList(l ir.Nodes)

exprListInPlace method #

exprListInPlace orders the expression list l but saves the side effects on the individual expression ninit lists.

func (o *orderState) exprListInPlace(l ir.Nodes)

exprNoLHS method #

func (o *orderState) exprNoLHS(n ir.Node) ir.Node

extendSlice function #

func extendSlice(n *ir.CallExpr, init *ir.Nodes) ir.Node

fakePC function #

func fakePC(n ir.Node) ir.Node

finishCompare function #

The result of finishCompare MUST be assigned back to n, e.g. n.Left = finishCompare(n.Left, x, r, init)

func finishCompare(n *ir.BinaryExpr, r ir.Node, init *ir.Nodes) ir.Node

fixedlit function #

fixedlit handles struct, array, and slice literals. TODO: expand documentation.

func fixedlit(ctxt initContext, kind initKind, n *ir.CompLitExpr, var_ ir.Node, init *ir.Nodes)

flush method #

func (s *typeSwitch) flush(cc []typeClause, compiled *ir.Nodes)

flush method #

func (s *exprSwitch) flush()

genAsStatic function #

func genAsStatic(as *ir.AssignStmt)

getdyn function #

getdyn calculates the initGenType for n. If top is false, getdyn is recursing.

func getdyn(n ir.Node, top bool) initGenType

hasDefaultCase function #

func hasDefaultCase(n *ir.SwitchStmt) bool

ifaceData function #

ifaceData loads the data field from an interface. The concrete type must be known to have type t. It follows the pointer if !IsDirectIface(t).

func ifaceData(pos src.XPos, n ir.Node, t *types.Type) ir.Node

init method #

init moves n's init list to o.out.

func (o *orderState) init(n ir.Node)

initStackTemp function #

initStackTemp appends statements to init to initialize the given temporary variable to val, and then returns the expression &tmp.

func initStackTemp(init *ir.Nodes, tmp *ir.Name, val ir.Node) *ir.AddrExpr

isAppendOfMake function #

isAppendOfMake reports whether n is of the form append(x, make([]T, y)...). isAppendOfMake assumes n has already been typechecked.

func isAppendOfMake(n ir.Node) bool

isByteCount function #

isByteCount reports whether n is of the form len(string([]byte)).

func isByteCount(n ir.Node) bool

isChanLenCap function #

isChanLenCap reports whether n is of the form len(c) or cap(c) for a channel c. Note that this does not check for -n or instrumenting because this is a correctness rewrite, not an optimization.

func isChanLenCap(n ir.Node) bool

isMapClear function #

isMapClear checks if n is of the form: for k := range m { delete(m, k) } where == for keys of map m is reflexive.

func isMapClear(n *ir.RangeStmt) bool

isRuneCount function #

isRuneCount reports whether n is of the form len([]rune(string)). These are optimized into a call to runtime.countrunes.

func isRuneCount(n ir.Node) bool

isSimpleName function #

func isSimpleName(nn ir.Node) bool

isSmallSliceLit function #

func isSmallSliceLit(n *ir.CompLitExpr) bool

isStaticCompositeLiteral function #

isStaticCompositeLiteral reports whether n is a compile-time constant.

func isStaticCompositeLiteral(n ir.Node) bool

itabType function #

itabType loads the _type field from a runtime.itab struct.

func itabType(itab ir.Node) ir.Node

makeTypeAssertDescriptor function #

func makeTypeAssertDescriptor(target *types.Type, canFail bool) *obj.LSym

mapAssign method #

mapAssign appends n to o.out.

func (o *orderState) mapAssign(n ir.Node)

mapClear function #

mapClear constructs a call to runtime.mapclear for the map m.

func mapClear(m ir.Node, rtyp ir.Node) ir.Node

mapKeyArg function #

mapKeyArg returns an expression for key that is suitable to be passed as the key argument for runtime map* functions. n is the map indexing or delete Node (to provide Pos).

func mapKeyArg(fast int, n ir.Node, key ir.Node, assigned bool) ir.Node

mapKeyReplaceStrConv function #

mapKeyReplaceStrConv replaces OBYTES2STR by OBYTES2STRTMP in n to avoid string allocations for keys in map lookups. Returns a bool that signals if a modification was made. For: x = m[string(k)] x = m[T1{... Tn{..., string(k), ...}}] where k is []byte, T1 to Tn is a nesting of struct and array literals, the allocation of backing bytes for the string can be avoided by reusing the []byte backing array. These are special cases for avoiding allocations when converting byte slices to strings. It would be nice to handle these generally, but because []byte keys are not allowed in maps, the use of string(k) comes up in important cases in practice. See issue 3512.

func mapKeyReplaceStrConv(n ir.Node) bool

mapKeyTemp method #

mapKeyTemp prepares n to be a key in a map runtime call and returns n. The first parameter is the position of n's containing node, for use in case that n's position is not unique (e.g., if n is an ONAME).

func (o *orderState) mapKeyTemp(outerPos src.XPos, t *types.Type, n ir.Node) ir.Node

mapRangeClear function #

mapRangeClear constructs a call to runtime.mapclear for the map range idiom.

func mapRangeClear(nrange *ir.RangeStmt) ir.Node

mapfast function #

func mapfast(t *types.Type) int

mapfastOld function #

func mapfastOld(t *types.Type) int

mapfastSwiss function #

func mapfastSwiss(t *types.Type) int

mapfn function #

func mapfn(name string, t *types.Type, isfat bool) ir.Node

mapfndel function #

func mapfndel(name string, t *types.Type) ir.Node

maplit function #

func maplit(n *ir.CompLitExpr, m ir.Node, init *ir.Nodes)

markTemp method #

markTemp returns the top of the temporary variable stack.

func (o *orderState) markTemp() ordermarker

mayCall function #

mayCall reports whether evaluating expression n may require function calls, which could clobber function call arguments/results currently on the stack.

func mayCall(n ir.Node) bool

methodValueWrapper function #

methodValueWrapper returns the ONAME node representing the wrapper function (*-fm) needed for the given method value. If the wrapper function hasn't already been created yet, it's created and added to typecheck.Target.Decls.

func methodValueWrapper(dot *ir.SelectorExpr) *ir.Name

mkcall function #

func mkcall(name string, t *types.Type, init *ir.Nodes, args ...ir.Node) *ir.CallExpr

mkcall1 function #

func mkcall1(fn ir.Node, t *types.Type, init *ir.Nodes, args ...ir.Node) *ir.CallExpr

mkcallstmt function #

func mkcallstmt(name string, args ...ir.Node) ir.Node

mkcallstmt1 function #

func mkcallstmt1(fn ir.Node, args ...ir.Node) ir.Node

mkmapnames function #

func mkmapnames(base string, ptr string) mapnames

newTemp method #

newTemp allocates a new temporary with the given type, pushes it onto the temp stack, and returns it. If clear is true, newTemp emits code to zero the temporary.

func (o *orderState) newTemp(t *types.Type, clear bool) *ir.Name

oaslit function #

oaslit handles special composite literal assignments. It returns true if n's effects have been added to init, in which case n should be dropped from the program by the caller.

func oaslit(n *ir.AssignStmt, init *ir.Nodes) bool

order function #

order rewrites fn.Nbody to apply the ordering constraints described in the comment at the top of the file.

func order(fn *ir.Func)

orderBlock function #

orderBlock orders the block of statements in n into a new slice, and then replaces the old slice in n with the new slice. free is a map that can be used to obtain temporary variables by type.

func orderBlock(n *ir.Nodes, free map[string][]*ir.Name)

orderMakeSliceCopy function #

orderMakeSliceCopy matches the pattern: m = OMAKESLICE([]T, x); OCOPY(m, s) and rewrites it to: m = OMAKESLICECOPY([]T, x, s); nil

func orderMakeSliceCopy(s []ir.Node)

orderStmtInPlace function #

orderStmtInPlace orders the side effects of the single statement *np and replaces it with the resulting statement list. The result of orderStmtInPlace MUST be assigned back to n, e.g. n.Left = orderStmtInPlace(n.Left) free is a map that can be used to obtain temporary variables by type.

func orderStmtInPlace(n ir.Node, free map[string][]*ir.Name) ir.Node

popTemp method #

popTemp pops temporaries off the stack until reaching the mark, which must have been returned by markTemp.

func (o *orderState) popTemp(mark ordermarker)

rangeAssign function #

rangeAssign returns "n.Key = key".

func rangeAssign(n *ir.RangeStmt, key ir.Node) ir.Node

rangeAssign2 function #

rangeAssign2 returns "n.Key, n.Value = key, value".

func rangeAssign2(n *ir.RangeStmt, key ir.Node, value ir.Node) ir.Node

rangeConvert function #

rangeConvert returns src, converted to dst if necessary. If a conversion is necessary, then typeWord and srcRType are copied to their respective ConvExpr fields.

func rangeConvert(nrange *ir.RangeStmt, dst *types.Type, src ir.Node, typeWord ir.Node, srcRType ir.Node) ir.Node

readonlystaticname function #

readonlystaticname returns a name backed by a read-only static data symbol.

func readonlystaticname(t *types.Type) *ir.Name

readsMemory function #

readsMemory reports whether the evaluation n directly reads from memory that might be written to indirectly.

func readsMemory(n ir.Node) bool

rtconvfn function #

rtconvfn returns the parameter and result types that will be used by a runtime function to convert from type src to type dst. The runtime function name can be derived from the names of the returned types. If no such function is necessary, it returns (Txxx, Txxx).

func rtconvfn(src *types.Type, dst *types.Type) (param types.Kind, result types.Kind)

runtimeField function #

func runtimeField(name string, offset int64, typ *types.Type) *types.Field

safeExpr method #

safeExpr returns a safe version of n. The definition of safe is that n can appear multiple times without violating the semantics of the original program, and that assigning to the safe version has the same effect as assigning to the original n. The intended use is to apply to x when rewriting x += y into x = x + y.

func (o *orderState) safeExpr(n ir.Node) ir.Node

safeExpr function #

return side effect-free n, appending side effects to init. result is assignable if n is.

func safeExpr(n ir.Node, init *ir.Nodes) ir.Node

safeMapRHS method #

func (o *orderState) safeMapRHS(r ir.Node) ir.Node

scasetype function #

Keep in sync with src/runtime/select.go.

func scasetype() *types.Type

slicelit function #

func slicelit(ctxt initContext, n *ir.CompLitExpr, var_ ir.Node, init *ir.Nodes)

soleComponent function #

func soleComponent(init *ir.Nodes, n ir.Node) ir.Node

stackBufAddr function #

stackBufAddr returns the expression &tmp, where tmp is a newly allocated temporary variable of type [len]elem. This variable is initialized, and elem must not contain pointers.

func stackBufAddr(len int64, elem *types.Type) *ir.AddrExpr

stackTempAddr function #

stackTempAddr returns the expression &tmp, where tmp is a newly allocated temporary variable of the given type. Statements to zero-initialize tmp are appended to init.

func stackTempAddr(init *ir.Nodes, typ *types.Type) *ir.AddrExpr

stmt method #

stmt orders the statement n, appending to o.out.

func (o *orderState) stmt(n ir.Node)

stmtList method #

stmtList orders each of the statements in the list.

func (o *orderState) stmtList(l ir.Nodes)

stringSearch function #

func stringSearch(expr ir.Node, cc []exprClause, out *ir.Nodes)

test method #

func (c *exprClause) test(exprname ir.Node) ir.Node

tracecmpArg function #

func tracecmpArg(n ir.Node, t *types.Type, init *ir.Nodes) ir.Node

tryJumpTable method #

Try to implement the clauses with a jump table. Returns true if successful.

func (s *typeSwitch) tryJumpTable(cc []typeClause, out *ir.Nodes) bool

tryJumpTable method #

Try to implement the clauses with a jump table. Returns true if successful.

func (s *exprSwitch) tryJumpTable(cc []exprClause, out *ir.Nodes) bool

typeHashFieldOf function #

typeHashFieldOf returns an expression to select the type hash field from an interface's descriptor word (whether a *runtime._type or *runtime.itab pointer).

func typeHashFieldOf(pos src.XPos, itab *ir.UnaryExpr) *ir.SelectorExpr

usefield function #

func usefield(n *ir.SelectorExpr)

usemethod function #

usemethod checks calls for uses of Method and MethodByName of reflect.Value, reflect.Type, reflect.(*rtype), and reflect.(*interfaceType).

func usemethod(n *ir.CallExpr)

validGoDeferCall function #

validGoDeferCall reports whether call is a valid call to appear in a go or defer statement; that is, whether it's a regular function call without arguments or results.

func validGoDeferCall(call ir.Node) bool

vmkcall function #

func vmkcall(fn ir.Node, t *types.Type, init *ir.Nodes, va []ir.Node) *ir.CallExpr

walkAddString function #

func walkAddString(typ *types.Type, n *ir.AddStringExpr, init *ir.Nodes) ir.Node

walkAppend function #

Rewrite append(src, x, y, z) so that any side effects in x, y, z (including runtime panics) are evaluated in initialization statements before the append. For normal code generation, stop there and leave the rest to ssagen. For race detector, expand append(src, a [, b]* ) to init { s := src const argc = len(args) - 1 newLen := s.len + argc if uint(newLen) <= uint(s.cap) { s = s[:newLen] } else { s = growslice(s.ptr, newLen, s.cap, argc, elemType) } s[s.len - argc] = a s[s.len - argc + 1] = b ... } s

func walkAppend(n *ir.CallExpr, init *ir.Nodes, dst ir.Node) ir.Node

walkAppendArgs function #

func walkAppendArgs(n *ir.CallExpr, init *ir.Nodes)

walkAssign function #

walkAssign walks an OAS (AssignExpr) or OASOP (AssignOpExpr) node.

func walkAssign(init *ir.Nodes, n ir.Node) ir.Node

walkAssignDotType function #

walkAssignDotType walks an OAS2DOTTYPE node.

func walkAssignDotType(n *ir.AssignListStmt, init *ir.Nodes) ir.Node

walkAssignFunc function #

walkAssignFunc walks an OAS2FUNC node.

func walkAssignFunc(init *ir.Nodes, n *ir.AssignListStmt) ir.Node

walkAssignList function #

walkAssignList walks an OAS2 node.

func walkAssignList(init *ir.Nodes, n *ir.AssignListStmt) ir.Node

walkAssignMapRead function #

walkAssignMapRead walks an OAS2MAPR node.

func walkAssignMapRead(init *ir.Nodes, n *ir.AssignListStmt) ir.Node

walkAssignRecv function #

walkAssignRecv walks an OAS2RECV node.

func walkAssignRecv(init *ir.Nodes, n *ir.AssignListStmt) ir.Node

walkBytesRunesToString function #

walkBytesRunesToString walks an OBYTES2STR or ORUNES2STR node.

func walkBytesRunesToString(n *ir.ConvExpr, init *ir.Nodes) ir.Node

walkBytesToStringTemp function #

walkBytesToStringTemp walks an OBYTES2STRTMP node.

func walkBytesToStringTemp(n *ir.ConvExpr, init *ir.Nodes) ir.Node

walkCall function #

walkCall walks an OCALLFUNC or OCALLINTER node.

func walkCall(n *ir.CallExpr, init *ir.Nodes) ir.Node

walkCall1 function #

func walkCall1(n *ir.CallExpr, init *ir.Nodes)

walkCheckPtrArithmetic function #

func walkCheckPtrArithmetic(n *ir.ConvExpr, init *ir.Nodes) ir.Node

walkClear function #

walkClear walks an OCLEAR node.

func walkClear(n *ir.UnaryExpr) ir.Node

walkClose function #

walkClose walks an OCLOSE node.

func walkClose(n *ir.UnaryExpr, init *ir.Nodes) ir.Node

walkClosure function #

func walkClosure(clo *ir.ClosureExpr, init *ir.Nodes) ir.Node

walkCompLit function #

walkCompLit walks a composite literal node: OARRAYLIT, OSLICELIT, OMAPLIT, OSTRUCTLIT (all CompLitExpr), or OPTRLIT (AddrExpr).

func walkCompLit(n ir.Node, init *ir.Nodes) ir.Node

walkCompare function #

The result of walkCompare MUST be assigned back to n, e.g. n.Left = walkCompare(n.Left, init)

func walkCompare(n *ir.BinaryExpr, init *ir.Nodes) ir.Node

walkCompareInterface function #

func walkCompareInterface(n *ir.BinaryExpr, init *ir.Nodes) ir.Node

walkCompareString function #

func walkCompareString(n *ir.BinaryExpr, init *ir.Nodes) ir.Node

walkConv function #

walkConv walks an OCONV or OCONVNOP (but not OCONVIFACE) node.

func walkConv(n *ir.ConvExpr, init *ir.Nodes) ir.Node

walkConvInterface function #

walkConvInterface walks an OCONVIFACE node.

func walkConvInterface(n *ir.ConvExpr, init *ir.Nodes) ir.Node

walkCopy function #

Lower copy(a, b) to a memmove call or a runtime call. init { n := len(a) if n > len(b) { n = len(b) } if a.ptr != b.ptr { memmove(a.ptr, b.ptr, n*sizeof(elem(a))) } } n; Also works if b is a string.

func walkCopy(n *ir.BinaryExpr, init *ir.Nodes, runtimecall bool) ir.Node

walkDelete function #

walkDelete walks an ODELETE node.

func walkDelete(init *ir.Nodes, n *ir.CallExpr) ir.Node

walkDivMod function #

walkDivMod walks an ODIV or OMOD node.

func walkDivMod(n *ir.BinaryExpr, init *ir.Nodes) ir.Node

walkDot function #

walkDot walks an ODOT or ODOTPTR node.

func walkDot(n *ir.SelectorExpr, init *ir.Nodes) ir.Node

walkDotType function #

walkDotType walks an ODOTTYPE or ODOTTYPE2 node.

func walkDotType(n *ir.TypeAssertExpr, init *ir.Nodes) ir.Node

walkDynamicDotType function #

walkDynamicDotType walks an ODYNAMICDOTTYPE or ODYNAMICDOTTYPE2 node.

func walkDynamicDotType(n *ir.DynamicTypeAssertExpr, init *ir.Nodes) ir.Node

walkExpr function #

The result of walkExpr MUST be assigned back to n, e.g. n.Left = walkExpr(n.Left, init)

func walkExpr(n ir.Node, init *ir.Nodes) ir.Node

walkExpr1 function #

func walkExpr1(n ir.Node, init *ir.Nodes) ir.Node

walkExprList function #

walk the whole tree of the body of an expression or simple statement. the types expressions are calculated. compile-time constants are evaluated. complex side effects like statements are appended to init.

func walkExprList(s []ir.Node, init *ir.Nodes)

walkExprListCheap function #

func walkExprListCheap(s []ir.Node, init *ir.Nodes)

walkExprListSafe function #

func walkExprListSafe(s []ir.Node, init *ir.Nodes)

walkFor function #

walkFor walks an OFOR node.

func walkFor(n *ir.ForStmt) ir.Node

walkGoDefer function #

walkGoDefer walks an OGO or ODEFER node.

func walkGoDefer(n *ir.GoDeferStmt) ir.Node

walkGrowslice function #

growslice(ptr *T, newLen, oldCap, num int, ) (ret []T)

func walkGrowslice(slice *ir.Name, init *ir.Nodes, oldPtr ir.Node, newLen ir.Node, oldCap ir.Node, num ir.Node) *ir.CallExpr

walkIf function #

walkIf walks an OIF node.

func walkIf(n *ir.IfStmt) ir.Node

walkIndex function #

walkIndex walks an OINDEX node.

func walkIndex(n *ir.IndexExpr, init *ir.Nodes) ir.Node

walkIndexMap function #

walkIndexMap walks an OINDEXMAP node. It replaces m[k] with *map{access1,assign}(maptype, m, &k)

func walkIndexMap(n *ir.IndexExpr, init *ir.Nodes) ir.Node

walkLenCap function #

walkLenCap walks an OLEN or OCAP node.

func walkLenCap(n *ir.UnaryExpr, init *ir.Nodes) ir.Node

walkLogical function #

walkLogical walks an OANDAND or OOROR node.

func walkLogical(n *ir.LogicalExpr, init *ir.Nodes) ir.Node

walkMakeChan function #

walkMakeChan walks an OMAKECHAN node.

func walkMakeChan(n *ir.MakeExpr, init *ir.Nodes) ir.Node

walkMakeMap function #

walkMakeMap walks an OMAKEMAP node.

func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node

walkMakeOldMap function #

func walkMakeOldMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node

walkMakeSlice function #

walkMakeSlice walks an OMAKESLICE node.

func walkMakeSlice(n *ir.MakeExpr, init *ir.Nodes) ir.Node

walkMakeSliceCopy function #

walkMakeSliceCopy walks an OMAKESLICECOPY node.

func walkMakeSliceCopy(n *ir.MakeExpr, init *ir.Nodes) ir.Node

walkMakeSwissMap function #

func walkMakeSwissMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node

walkMethodValue function #

func walkMethodValue(n *ir.SelectorExpr, init *ir.Nodes) ir.Node

walkMinMax function #

func walkMinMax(n *ir.CallExpr, init *ir.Nodes) ir.Node

walkNew function #

walkNew walks an ONEW node.

func walkNew(n *ir.UnaryExpr, init *ir.Nodes) ir.Node

walkPrint function #

generate code for print.

func walkPrint(nn *ir.CallExpr, init *ir.Nodes) ir.Node

walkRange function #

walkRange transforms various forms of ORANGE into simpler forms. The result must be assigned back to n. Node n may also be modified in place, and may also be the returned node.

func walkRange(nrange *ir.RangeStmt) ir.Node

walkRecoverFP function #

walkRecoverFP walks an ORECOVERFP node.

func walkRecoverFP(nn *ir.CallExpr, init *ir.Nodes) ir.Node

walkRecv function #

walkRecv walks an ORECV node.

func walkRecv(n *ir.UnaryExpr) ir.Node

walkReturn function #

walkReturn walks an ORETURN node.

func walkReturn(n *ir.ReturnStmt) ir.Node

walkRuneToString function #

walkRuneToString walks an ORUNESTR node.

func walkRuneToString(n *ir.ConvExpr, init *ir.Nodes) ir.Node

walkSelect function #

func walkSelect(sel *ir.SelectStmt)

walkSelectCases function #

func walkSelectCases(cases []*ir.CommClause) []ir.Node

walkSend function #

walkSend walks an OSEND node.

func walkSend(n *ir.SendStmt, init *ir.Nodes) ir.Node

walkSlice function #

walkSlice walks an OSLICE, OSLICEARR, OSLICESTR, OSLICE3, or OSLICE3ARR node.

func walkSlice(n *ir.SliceExpr, init *ir.Nodes) ir.Node

walkSliceHeader function #

walkSliceHeader walks an OSLICEHEADER node.

func walkSliceHeader(n *ir.SliceHeaderExpr, init *ir.Nodes) ir.Node

walkSliceToArray function #

walkSliceToArray walks an OSLICE2ARR expression.

func walkSliceToArray(n *ir.ConvExpr, init *ir.Nodes) ir.Node

walkStmt function #

The result of walkStmt MUST be assigned back to n, e.g. n.Left = walkStmt(n.Left)

func walkStmt(n ir.Node) ir.Node

walkStmtList function #

func walkStmtList(s []ir.Node)

walkStringHeader function #

walkStringHeader walks an OSTRINGHEADER node.

func walkStringHeader(n *ir.StringHeaderExpr, init *ir.Nodes) ir.Node

walkStringToBytes function #

walkStringToBytes walks an OSTR2BYTES node.

func walkStringToBytes(n *ir.ConvExpr, init *ir.Nodes) ir.Node

walkStringToBytesTemp function #

walkStringToBytesTemp walks an OSTR2BYTESTMP node.

func walkStringToBytesTemp(n *ir.ConvExpr, init *ir.Nodes) ir.Node

walkStringToRunes function #

walkStringToRunes walks an OSTR2RUNES node.

func walkStringToRunes(n *ir.ConvExpr, init *ir.Nodes) ir.Node

walkSwitch function #

walkSwitch walks a switch statement.

func walkSwitch(sw *ir.SwitchStmt)

walkSwitchExpr function #

walkSwitchExpr generates an AST implementing sw. sw is an expression switch.

func walkSwitchExpr(sw *ir.SwitchStmt)

walkSwitchType function #

walkSwitchType generates an AST that implements sw, where sw is a type switch.

func walkSwitchType(sw *ir.SwitchStmt)

walkUnsafeData function #

walkUnsafeData walks an OUNSAFESLICEDATA or OUNSAFESTRINGDATA expression.

func walkUnsafeData(n *ir.UnaryExpr, init *ir.Nodes) ir.Node

walkUnsafeSlice function #

func walkUnsafeSlice(n *ir.BinaryExpr, init *ir.Nodes) ir.Node

walkUnsafeString function #

func walkUnsafeString(n *ir.BinaryExpr, init *ir.Nodes) ir.Node

writebarrierfn function #

func writebarrierfn(name string, l *types.Type, r *types.Type) ir.Node

Generated with Arrow