Skip to content

Commit 527a189

Browse files
committed
[dev.regabi] cmd/compile: move helpers into package ir [generated]
[git-generate] cd src/cmd/compile/internal/gc sed -i '' 's/TestBuiltin.*/& t.Skip("mkbuiltin needs fixing")/' builtin_test.go gofmt -w builtin_test.go rf ' # Inline a few little-used constructors to avoid bringing them. ex { import "cmd/compile/internal/base" import "cmd/compile/internal/ir" import "cmd/compile/internal/types" import "cmd/internal/src" var typ *types.Type var sym *types.Sym var str string symfield(sym, typ) -> ir.NewField(base.Pos, sym, nil, typ) anonfield(typ) -> ir.NewField(base.Pos, nil, nil, typ) namedfield(str, typ) -> ir.NewField(base.Pos, lookup(str), nil, typ) var cp *ir.CallPartExpr callpartMethod(cp) -> cp.Method var n ir.Node callpartMethod(n) -> n.(*ir.CallPartExpr).Method var ns []ir.Node liststmt(ns) -> ir.NewBlockStmt(src.NoXPos, ns) } rm symfield anonfield namedfield liststmt callpartMethod mv maxStackVarSize MaxStackVarSize mv maxImplicitStackVarSize MaxImplicitStackVarSize mv smallArrayBytes MaxSmallArraySize mv MaxStackVarSize cfg.go mv nodbool NewBool mv nodintconst NewInt mv nodstr NewString mv NewBool NewInt NewString const.go mv Mpprec ConstPrec mv bigFloatVal BigFloat mv doesoverflow ConstOverflow mv isGoConst IsConstNode mv smallintconst IsSmallIntConst mv isZero IsZero mv islvalue IsAssignable mv staticValue StaticValue mv samesafeexpr SameSafeExpr mv checkPtr ShouldCheckPtr mv isReflectHeaderDataField IsReflectHeaderDataField mv paramNnames ParamNames mv methodSym MethodSym mv methodSymSuffix MethodSymSuffix mv methodExprFunc MethodExprFunc mv methodExprName MethodExprName mv IsZero IsAssignable StaticValue staticValue1 reassigned \ IsIntrinsicCall \ SameSafeExpr ShouldCheckPtr IsReflectHeaderDataField \ ParamNames MethodSym MethodSymSuffix \ MethodExprName MethodExprFunc \ expr.go mv Curfn CurFunc mv funcsymname FuncSymName mv newFuncNameAt NewFuncNameAt mv setNodeNameFunc MarkFunc mv CurFunc FuncSymName NewFuncNameAt MarkFunc func.go mv isParamStackCopy IsParamStackCopy mv isParamHeapCopy IsParamHeapCopy mv nodfp RegFP mv IsParamStackCopy IsParamHeapCopy RegFP name.go mv hasUniquePos HasUniquePos mv setlineno SetPos mv initExpr InitExpr mv hasNamedResults HasNamedResults mv outervalue OuterValue mv HasNamedResults HasUniquePos SetPos InitExpr OuterValue EscNever node.go mv visitBottomUp VisitFuncsBottomUp # scc.go mv cfg.go \ NewBool NewInt NewString \ # parts of const.go ConstPrec BigFloat ConstOverflow IsConstNode IsSmallIntConst \ expr.go func.go name.go node.go scc.go \ cmd/compile/internal/ir ' Change-Id: I13402c5a2cedbf78d993a1eae2940718f23ac166 Reviewed-on: https://go-review.googlesource.com/c/go/+/279421 Trust: Russ Cox <[email protected]> Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 65c4c6d commit 527a189

38 files changed

+1255
-1261
lines changed

src/cmd/compile/internal/gc/alg.go

+26-26
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ func genhash(t *types.Type) *obj.LSym {
147147

148148
// func sym(p *T, h uintptr) uintptr
149149
args := []*ir.Field{
150-
namedfield("p", types.NewPtr(t)),
151-
namedfield("h", types.Types[types.TUINTPTR]),
150+
ir.NewField(base.Pos, lookup("p"), nil, types.NewPtr(t)),
151+
ir.NewField(base.Pos, lookup("h"), nil, types.Types[types.TUINTPTR]),
152152
}
153-
results := []*ir.Field{anonfield(types.Types[types.TUINTPTR])}
153+
results := []*ir.Field{ir.NewField(base.Pos, nil, nil, types.Types[types.TUINTPTR])}
154154
tfn := ir.NewFuncType(base.Pos, nil, args, results)
155155

156156
fn := dclfunc(sym, tfn)
@@ -166,9 +166,9 @@ func genhash(t *types.Type) *obj.LSym {
166166

167167
// for i := 0; i < nelem; i++
168168
ni := temp(types.Types[types.TINT])
169-
init := ir.NewAssignStmt(base.Pos, ni, nodintconst(0))
170-
cond := ir.NewBinaryExpr(base.Pos, ir.OLT, ni, nodintconst(t.NumElem()))
171-
post := ir.NewAssignStmt(base.Pos, ni, ir.NewBinaryExpr(base.Pos, ir.OADD, ni, nodintconst(1)))
169+
init := ir.NewAssignStmt(base.Pos, ni, ir.NewInt(0))
170+
cond := ir.NewBinaryExpr(base.Pos, ir.OLT, ni, ir.NewInt(t.NumElem()))
171+
post := ir.NewAssignStmt(base.Pos, ni, ir.NewBinaryExpr(base.Pos, ir.OADD, ni, ir.NewInt(1)))
172172
loop := ir.NewForStmt(base.Pos, nil, cond, post, nil)
173173
loop.PtrInit().Append(init)
174174

@@ -219,7 +219,7 @@ func genhash(t *types.Type) *obj.LSym {
219219
na := nodAddr(nx)
220220
call.Args.Append(na)
221221
call.Args.Append(nh)
222-
call.Args.Append(nodintconst(size))
222+
call.Args.Append(ir.NewInt(size))
223223
fn.Body.Append(ir.NewAssignStmt(base.Pos, nh, call))
224224

225225
i = next
@@ -239,9 +239,9 @@ func genhash(t *types.Type) *obj.LSym {
239239
fn.SetDupok(true)
240240
typecheckFunc(fn)
241241

242-
Curfn = fn
242+
ir.CurFunc = fn
243243
typecheckslice(fn.Body, ctxStmt)
244-
Curfn = nil
244+
ir.CurFunc = nil
245245

246246
if base.Debug.DclStack != 0 {
247247
types.CheckDclstack()
@@ -285,12 +285,12 @@ func hashfor(t *types.Type) ir.Node {
285285
}
286286

287287
n := NewName(sym)
288-
setNodeNameFunc(n)
288+
ir.MarkFunc(n)
289289
n.SetType(functype(nil, []*ir.Field{
290-
anonfield(types.NewPtr(t)),
291-
anonfield(types.Types[types.TUINTPTR]),
290+
ir.NewField(base.Pos, nil, nil, types.NewPtr(t)),
291+
ir.NewField(base.Pos, nil, nil, types.Types[types.TUINTPTR]),
292292
}, []*ir.Field{
293-
anonfield(types.Types[types.TUINTPTR]),
293+
ir.NewField(base.Pos, nil, nil, types.Types[types.TUINTPTR]),
294294
}))
295295
return n
296296
}
@@ -376,8 +376,8 @@ func geneq(t *types.Type) *obj.LSym {
376376

377377
// func sym(p, q *T) bool
378378
tfn := ir.NewFuncType(base.Pos, nil,
379-
[]*ir.Field{namedfield("p", types.NewPtr(t)), namedfield("q", types.NewPtr(t))},
380-
[]*ir.Field{namedfield("r", types.Types[types.TBOOL])})
379+
[]*ir.Field{ir.NewField(base.Pos, lookup("p"), nil, types.NewPtr(t)), ir.NewField(base.Pos, lookup("q"), nil, types.NewPtr(t))},
380+
[]*ir.Field{ir.NewField(base.Pos, lookup("r"), nil, types.Types[types.TBOOL])})
381381

382382
fn := dclfunc(sym, tfn)
383383
np := ir.AsNode(tfn.Type().Params().Field(0).Nname)
@@ -440,20 +440,20 @@ func geneq(t *types.Type) *obj.LSym {
440440
// Generate a series of checks.
441441
for i := int64(0); i < nelem; i++ {
442442
// if check {} else { goto neq }
443-
nif := ir.NewIfStmt(base.Pos, checkIdx(nodintconst(i)), nil, nil)
443+
nif := ir.NewIfStmt(base.Pos, checkIdx(ir.NewInt(i)), nil, nil)
444444
nif.Else.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, neq))
445445
fn.Body.Append(nif)
446446
}
447447
if last {
448-
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, checkIdx(nodintconst(nelem))))
448+
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, checkIdx(ir.NewInt(nelem))))
449449
}
450450
} else {
451451
// Generate a for loop.
452452
// for i := 0; i < nelem; i++
453453
i := temp(types.Types[types.TINT])
454-
init := ir.NewAssignStmt(base.Pos, i, nodintconst(0))
455-
cond := ir.NewBinaryExpr(base.Pos, ir.OLT, i, nodintconst(nelem))
456-
post := ir.NewAssignStmt(base.Pos, i, ir.NewBinaryExpr(base.Pos, ir.OADD, i, nodintconst(1)))
454+
init := ir.NewAssignStmt(base.Pos, i, ir.NewInt(0))
455+
cond := ir.NewBinaryExpr(base.Pos, ir.OLT, i, ir.NewInt(nelem))
456+
post := ir.NewAssignStmt(base.Pos, i, ir.NewBinaryExpr(base.Pos, ir.OADD, i, ir.NewInt(1)))
457457
loop := ir.NewForStmt(base.Pos, nil, cond, post, nil)
458458
loop.PtrInit().Append(init)
459459
// if eq(pi, qi) {} else { goto neq }
@@ -462,7 +462,7 @@ func geneq(t *types.Type) *obj.LSym {
462462
loop.Body.Append(nif)
463463
fn.Body.Append(loop)
464464
if last {
465-
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, nodbool(true)))
465+
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(true)))
466466
}
467467
}
468468
}
@@ -572,7 +572,7 @@ func geneq(t *types.Type) *obj.LSym {
572572
}
573573

574574
if len(flatConds) == 0 {
575-
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, nodbool(true)))
575+
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(true)))
576576
} else {
577577
for _, c := range flatConds[:len(flatConds)-1] {
578578
// if cond {} else { goto neq }
@@ -594,7 +594,7 @@ func geneq(t *types.Type) *obj.LSym {
594594
// r = false
595595
// return (or goto ret)
596596
fn.Body.Append(ir.NewLabelStmt(base.Pos, neq))
597-
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, nodbool(false)))
597+
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(false)))
598598
if EqCanPanic(t) || anyCall(fn) {
599599
// Epilogue is large, so share it with the equal case.
600600
fn.Body.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, ret))
@@ -615,9 +615,9 @@ func geneq(t *types.Type) *obj.LSym {
615615
fn.SetDupok(true)
616616
typecheckFunc(fn)
617617

618-
Curfn = fn
618+
ir.CurFunc = fn
619619
typecheckslice(fn.Body, ctxStmt)
620-
Curfn = nil
620+
ir.CurFunc = nil
621621

622622
if base.Debug.DclStack != 0 {
623623
types.CheckDclstack()
@@ -726,7 +726,7 @@ func eqmem(p ir.Node, q ir.Node, field *types.Sym, size int64) ir.Node {
726726
call.Args.Append(nx)
727727
call.Args.Append(ny)
728728
if needsize {
729-
call.Args.Append(nodintconst(size))
729+
call.Args.Append(ir.NewInt(size))
730730
}
731731

732732
return call

0 commit comments

Comments
 (0)