1
0
mirror of https://github.com/golang/go synced 2024-11-23 20:30:04 -07:00

cmd/compile/internal/ir: explicit Pos for New{Bool,Int,String}

Stop depending on base.Pos for these.

Change-Id: I58dea44f8141eb37b59a6e9f7db0c6baa516ad93
Reviewed-on: https://go-review.googlesource.com/c/go/+/472296
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2023-02-28 13:27:51 -08:00 committed by Gopher Robot
parent ce2a609909
commit b94dc384ca
19 changed files with 115 additions and 119 deletions

View File

@ -331,7 +331,7 @@ func eqmem(p ir.Node, q ir.Node, field *types.Sym, size int64) ir.Node {
call.Args.Append(nx) call.Args.Append(nx)
call.Args.Append(ny) call.Args.Append(ny)
if needsize { if needsize {
call.Args.Append(ir.NewInt(size)) call.Args.Append(ir.NewInt(base.Pos, size))
} }
return call return call

View File

@ -157,7 +157,7 @@ func registerMeta(cnames Names, hashv [16]byte, mdlen int) {
pos := cnames.InitFn.Pos() pos := cnames.InitFn.Pos()
elist := make([]ir.Node, 0, 16) elist := make([]ir.Node, 0, 16)
for i := 0; i < 16; i++ { for i := 0; i < 16; i++ {
elem := ir.NewInt(int64(hashv[i])) elem := ir.NewInt(base.Pos, int64(hashv[i]))
elist = append(elist, elem) elist = append(elist, elem)
} }
ht := types.NewArray(types.Types[types.TUINT8], 16) ht := types.NewArray(types.Types[types.TUINT8], 16)
@ -168,7 +168,7 @@ func registerMeta(cnames Names, hashv [16]byte, mdlen int) {
mdauspx := typecheck.ConvNop(mdax, types.Types[types.TUNSAFEPTR]) mdauspx := typecheck.ConvNop(mdax, types.Types[types.TUNSAFEPTR])
// Materialize expression for length. // Materialize expression for length.
lenx := ir.NewInt(int64(mdlen)) // untyped lenx := ir.NewInt(base.Pos, int64(mdlen)) // untyped
// Generate a call to runtime.addCovMeta, e.g. // Generate a call to runtime.addCovMeta, e.g.
// //
@ -176,10 +176,10 @@ func registerMeta(cnames Names, hashv [16]byte, mdlen int) {
// //
fn := typecheck.LookupRuntime("addCovMeta") fn := typecheck.LookupRuntime("addCovMeta")
pkid := coverage.HardCodedPkgID(base.Ctxt.Pkgpath) pkid := coverage.HardCodedPkgID(base.Ctxt.Pkgpath)
pkIdNode := ir.NewInt(int64(pkid)) pkIdNode := ir.NewInt(base.Pos, int64(pkid))
cmodeNode := ir.NewInt(int64(cnames.CounterMode)) cmodeNode := ir.NewInt(base.Pos, int64(cnames.CounterMode))
cgranNode := ir.NewInt(int64(cnames.CounterGran)) cgranNode := ir.NewInt(base.Pos, int64(cnames.CounterGran))
pkPathNode := ir.NewString(base.Ctxt.Pkgpath) pkPathNode := ir.NewString(base.Pos, base.Ctxt.Pkgpath)
callx := typecheck.Call(pos, fn, []ir.Node{mdauspx, lenx, hashx, callx := typecheck.Call(pos, fn, []ir.Node{mdauspx, lenx, hashx,
pkPathNode, pkIdNode, cmodeNode, cgranNode}, false) pkPathNode, pkIdNode, cmodeNode, cgranNode}, false)
assign := callx assign := callx
@ -202,7 +202,7 @@ func addInitHookCall(initfn *ir.Func, cmode coverage.CounterMode) {
pos := initfn.Pos() pos := initfn.Pos()
istest := cmode == coverage.CtrModeTestMain istest := cmode == coverage.CtrModeTestMain
initf := typecheck.LookupCoverage("initHook") initf := typecheck.LookupCoverage("initHook")
istestNode := ir.NewBool(istest) istestNode := ir.NewBool(base.Pos, istest)
args := []ir.Node{istestNode} args := []ir.Node{istestNode}
callx := typecheck.Call(pos, initf, args, false) callx := typecheck.Call(pos, initf, args, false)
initfn.Body.Append(callx) initfn.Body.Append(callx)

View File

@ -27,7 +27,7 @@ func fixRecoverCall(call *ir.CallExpr) {
// FP is equal to caller's SP plus FixedFrameSize. // FP is equal to caller's SP plus FixedFrameSize.
var fp ir.Node = ir.NewCallExpr(pos, ir.OGETCALLERSP, nil, nil) var fp ir.Node = ir.NewCallExpr(pos, ir.OGETCALLERSP, nil, nil)
if off := base.Ctxt.Arch.FixedFrameSize; off != 0 { if off := base.Ctxt.Arch.FixedFrameSize; off != 0 {
fp = ir.NewBinaryExpr(fp.Pos(), ir.OADD, fp, ir.NewInt(off)) fp = ir.NewBinaryExpr(fp.Pos(), ir.OADD, fp, ir.NewInt(base.Pos, off))
} }
// TODO(mdempsky): Replace *int32 with unsafe.Pointer, without upsetting checkptr. // TODO(mdempsky): Replace *int32 with unsafe.Pointer, without upsetting checkptr.
fp = ir.NewConvExpr(pos, ir.OCONVNOP, types.NewPtr(types.Types[types.TINT32]), fp) fp = ir.NewConvExpr(pos, ir.OCONVNOP, types.NewPtr(types.Types[types.TINT32]), fp)

View File

@ -11,18 +11,19 @@ import (
"cmd/compile/internal/base" "cmd/compile/internal/base"
"cmd/compile/internal/types" "cmd/compile/internal/types"
"cmd/internal/src"
) )
func NewBool(b bool) Node { func NewBool(pos src.XPos, b bool) Node {
return NewLiteral(constant.MakeBool(b)) return NewBasicLit(pos, constant.MakeBool(b))
} }
func NewInt(v int64) Node { func NewInt(pos src.XPos, v int64) Node {
return NewLiteral(constant.MakeInt64(v)) return NewBasicLit(pos, constant.MakeInt64(v))
} }
func NewString(s string) Node { func NewString(pos src.XPos, s string) Node {
return NewLiteral(constant.MakeString(s)) return NewBasicLit(pos, constant.MakeString(s))
} }
const ( const (

View File

@ -60,11 +60,6 @@ func ValidTypeForConst(t *types.Type, v constant.Value) bool {
panic("unreachable") panic("unreachable")
} }
// NewLiteral returns a new untyped constant with value v.
func NewLiteral(v constant.Value) Node {
return NewBasicLit(base.Pos, v)
}
func idealType(ct constant.Kind) *types.Type { func idealType(ct constant.Kind) *types.Type {
switch ct { switch ct {
case constant.String: case constant.String:

View File

@ -143,8 +143,8 @@ func Task() *ir.Name {
}, nil)) }, nil))
asancall := ir.NewCallExpr(base.Pos, ir.OCALL, asanf, nil) asancall := ir.NewCallExpr(base.Pos, ir.OCALL, asanf, nil)
asancall.Args.Append(typecheck.ConvNop(typecheck.NodAddr( asancall.Args.Append(typecheck.ConvNop(typecheck.NodAddr(
ir.NewIndexExpr(base.Pos, globals, ir.NewInt(0))), types.Types[types.TUNSAFEPTR])) ir.NewIndexExpr(base.Pos, globals, ir.NewInt(base.Pos, 0))), types.Types[types.TUNSAFEPTR]))
asancall.Args.Append(typecheck.ConvNop(ir.NewInt(int64(ni)), types.Types[types.TUINTPTR])) asancall.Args.Append(typecheck.ConvNop(ir.NewInt(base.Pos, int64(ni)), types.Types[types.TUINTPTR]))
fnInit.Body.Append(asancall) fnInit.Body.Append(asancall)
typecheck.FinishFuncBody() typecheck.FinishFuncBody()

View File

@ -69,7 +69,7 @@ func instrumentGlobals(fn *ir.Func) *ir.Name {
for i, n := range InstrumentGlobalsSlice { for i, n := range InstrumentGlobalsSlice {
setField := func(f string, val ir.Node, i int) { setField := func(f string, val ir.Node, i int) {
r := ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, r := ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT,
ir.NewIndexExpr(base.Pos, globals, ir.NewInt(int64(i))), lname(f)), val) ir.NewIndexExpr(base.Pos, globals, ir.NewInt(base.Pos, int64(i))), lname(f)), val)
init.Append(typecheck.Stmt(r)) init.Append(typecheck.Stmt(r))
} }
// globals[i].beg = uintptr(unsafe.Pointer(&n)) // globals[i].beg = uintptr(unsafe.Pointer(&n))
@ -79,19 +79,19 @@ func instrumentGlobals(fn *ir.Func) *ir.Name {
// Assign globals[i].size. // Assign globals[i].size.
g := n.(*ir.Name) g := n.(*ir.Name)
size := g.Type().Size() size := g.Type().Size()
c = tconv(ir.NewInt(size), types.Types[types.TUINTPTR]) c = tconv(ir.NewInt(base.Pos, size), types.Types[types.TUINTPTR])
setField("size", c, i) setField("size", c, i)
// Assign globals[i].sizeWithRedzone. // Assign globals[i].sizeWithRedzone.
rzSize := GetRedzoneSizeForGlobal(size) rzSize := GetRedzoneSizeForGlobal(size)
sizeWithRz := rzSize + size sizeWithRz := rzSize + size
c = tconv(ir.NewInt(sizeWithRz), types.Types[types.TUINTPTR]) c = tconv(ir.NewInt(base.Pos, sizeWithRz), types.Types[types.TUINTPTR])
setField("sizeWithRedzone", c, i) setField("sizeWithRedzone", c, i)
// The C string type is terminated by a null character "\0", Go should use three-digit // The C string type is terminated by a null character "\0", Go should use three-digit
// octal "\000" or two-digit hexadecimal "\x00" to create null terminated string. // octal "\000" or two-digit hexadecimal "\x00" to create null terminated string.
// asanName = symbol's linkname + "\000" // asanName = symbol's linkname + "\000"
// globals[i].name = (*defString)(unsafe.Pointer(&asanName)).data // globals[i].name = (*defString)(unsafe.Pointer(&asanName)).data
name := g.Linksym().Name name := g.Linksym().Name
init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, asanName, ir.NewString(name+"\000")))) init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, asanName, ir.NewString(base.Pos, name+"\000"))))
c = tconv(typecheck.NodAddr(asanName), types.Types[types.TUNSAFEPTR]) c = tconv(typecheck.NodAddr(asanName), types.Types[types.TUNSAFEPTR])
c = tconv(c, types.NewPtr(defStringstruct)) c = tconv(c, types.NewPtr(defStringstruct))
c = ir.NewSelectorExpr(base.Pos, ir.ODOT, c, lname("data")) c = ir.NewSelectorExpr(base.Pos, ir.ODOT, c, lname("data"))
@ -99,23 +99,23 @@ func instrumentGlobals(fn *ir.Func) *ir.Name {
// Set the name of package being compiled as a unique identifier of a module. // Set the name of package being compiled as a unique identifier of a module.
// asanModulename = pkgName + "\000" // asanModulename = pkgName + "\000"
init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, asanModulename, ir.NewString(types.LocalPkg.Name+"\000")))) init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, asanModulename, ir.NewString(base.Pos, types.LocalPkg.Name+"\000"))))
c = tconv(typecheck.NodAddr(asanModulename), types.Types[types.TUNSAFEPTR]) c = tconv(typecheck.NodAddr(asanModulename), types.Types[types.TUNSAFEPTR])
c = tconv(c, types.NewPtr(defStringstruct)) c = tconv(c, types.NewPtr(defStringstruct))
c = ir.NewSelectorExpr(base.Pos, ir.ODOT, c, lname("data")) c = ir.NewSelectorExpr(base.Pos, ir.ODOT, c, lname("data"))
setField("moduleName", c, i) setField("moduleName", c, i)
// Assign asanL[i].filename, asanL[i].line, asanL[i].column // Assign asanL[i].filename, asanL[i].line, asanL[i].column
// and assign globals[i].location = uintptr(unsafe.Pointer(&asanL[i])) // and assign globals[i].location = uintptr(unsafe.Pointer(&asanL[i]))
asanLi := ir.NewIndexExpr(base.Pos, asanlocation, ir.NewInt(int64(i))) asanLi := ir.NewIndexExpr(base.Pos, asanlocation, ir.NewInt(base.Pos, int64(i)))
filename := ir.NewString(base.Ctxt.PosTable.Pos(n.Pos()).Filename() + "\000") filename := ir.NewString(base.Pos, base.Ctxt.PosTable.Pos(n.Pos()).Filename()+"\000")
init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, asanFilename, filename))) init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, asanFilename, filename)))
c = tconv(typecheck.NodAddr(asanFilename), types.Types[types.TUNSAFEPTR]) c = tconv(typecheck.NodAddr(asanFilename), types.Types[types.TUNSAFEPTR])
c = tconv(c, types.NewPtr(defStringstruct)) c = tconv(c, types.NewPtr(defStringstruct))
c = ir.NewSelectorExpr(base.Pos, ir.ODOT, c, lname("data")) c = ir.NewSelectorExpr(base.Pos, ir.ODOT, c, lname("data"))
init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, asanLi, lname("filename")), c))) init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, asanLi, lname("filename")), c)))
line := ir.NewInt(int64(n.Pos().Line())) line := ir.NewInt(base.Pos, int64(n.Pos().Line()))
init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, asanLi, lname("line")), line))) init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, asanLi, lname("line")), line)))
col := ir.NewInt(int64(n.Pos().Col())) col := ir.NewInt(base.Pos, int64(n.Pos().Col()))
init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, asanLi, lname("column")), col))) init.Append(typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, asanLi, lname("column")), col)))
c = tconv(typecheck.NodAddr(asanLi), types.Types[types.TUNSAFEPTR]) c = tconv(typecheck.NodAddr(asanLi), types.Types[types.TUNSAFEPTR])
c = tconv(c, types.Types[types.TUINTPTR]) c = tconv(c, types.Types[types.TUINTPTR])

View File

@ -163,9 +163,9 @@ func hashFunc(t *types.Type) *ir.Func {
// for i := 0; i < nelem; i++ // for i := 0; i < nelem; i++
ni := typecheck.Temp(types.Types[types.TINT]) ni := typecheck.Temp(types.Types[types.TINT])
init := ir.NewAssignStmt(base.Pos, ni, ir.NewInt(0)) init := ir.NewAssignStmt(base.Pos, ni, ir.NewInt(base.Pos, 0))
cond := ir.NewBinaryExpr(base.Pos, ir.OLT, ni, ir.NewInt(t.NumElem())) cond := ir.NewBinaryExpr(base.Pos, ir.OLT, ni, ir.NewInt(base.Pos, t.NumElem()))
post := ir.NewAssignStmt(base.Pos, ni, ir.NewBinaryExpr(base.Pos, ir.OADD, ni, ir.NewInt(1))) post := ir.NewAssignStmt(base.Pos, ni, ir.NewBinaryExpr(base.Pos, ir.OADD, ni, ir.NewInt(base.Pos, 1)))
loop := ir.NewForStmt(base.Pos, nil, cond, post, nil) loop := ir.NewForStmt(base.Pos, nil, cond, post, nil)
loop.PtrInit().Append(init) loop.PtrInit().Append(init)
@ -216,7 +216,7 @@ func hashFunc(t *types.Type) *ir.Func {
na := typecheck.NodAddr(nx) na := typecheck.NodAddr(nx)
call.Args.Append(na) call.Args.Append(na)
call.Args.Append(nh) call.Args.Append(nh)
call.Args.Append(ir.NewInt(size)) call.Args.Append(ir.NewInt(base.Pos, size))
fn.Body.Append(ir.NewAssignStmt(base.Pos, nh, call)) fn.Body.Append(ir.NewAssignStmt(base.Pos, nh, call))
i = next i = next
@ -440,8 +440,8 @@ func eqFunc(t *types.Type) *ir.Func {
// Generate an unrolled for loop. // Generate an unrolled for loop.
// for i := 0; i < nelem/unroll*unroll; i += unroll // for i := 0; i < nelem/unroll*unroll; i += unroll
i := typecheck.Temp(types.Types[types.TINT]) i := typecheck.Temp(types.Types[types.TINT])
init := ir.NewAssignStmt(base.Pos, i, ir.NewInt(0)) init := ir.NewAssignStmt(base.Pos, i, ir.NewInt(base.Pos, 0))
cond := ir.NewBinaryExpr(base.Pos, ir.OLT, i, ir.NewInt(iterateTo)) cond := ir.NewBinaryExpr(base.Pos, ir.OLT, i, ir.NewInt(base.Pos, iterateTo))
loop := ir.NewForStmt(base.Pos, nil, cond, nil, nil) loop := ir.NewForStmt(base.Pos, nil, cond, nil, nil)
loop.PtrInit().Append(init) loop.PtrInit().Append(init)
@ -454,7 +454,7 @@ func eqFunc(t *types.Type) *ir.Func {
nif := ir.NewIfStmt(base.Pos, checkIdx(i), nil, nil) nif := ir.NewIfStmt(base.Pos, checkIdx(i), nil, nil)
nif.Else.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, neq)) nif.Else.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, neq))
loop.Body.Append(nif) loop.Body.Append(nif)
post := ir.NewAssignStmt(base.Pos, i, ir.NewBinaryExpr(base.Pos, ir.OADD, i, ir.NewInt(1))) post := ir.NewAssignStmt(base.Pos, i, ir.NewBinaryExpr(base.Pos, ir.OADD, i, ir.NewInt(base.Pos, 1)))
loop.Body.Append(post) loop.Body.Append(post)
} }
@ -462,7 +462,7 @@ func eqFunc(t *types.Type) *ir.Func {
if nelem == iterateTo { if nelem == iterateTo {
if last { if last {
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(true))) fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(base.Pos, true)))
} }
return return
} }
@ -479,12 +479,12 @@ func eqFunc(t *types.Type) *ir.Func {
// } // }
for j := iterateTo; j < nelem; j++ { for j := iterateTo; j < nelem; j++ {
// if check {} else { goto neq } // if check {} else { goto neq }
nif := ir.NewIfStmt(base.Pos, checkIdx(ir.NewInt(j)), nil, nil) nif := ir.NewIfStmt(base.Pos, checkIdx(ir.NewInt(base.Pos, j)), nil, nil)
nif.Else.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, neq)) nif.Else.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, neq))
fn.Body.Append(nif) fn.Body.Append(nif)
} }
if last { if last {
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, checkIdx(ir.NewInt(nelem)))) fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, checkIdx(ir.NewInt(base.Pos, nelem))))
} }
} }
@ -518,7 +518,7 @@ func eqFunc(t *types.Type) *ir.Func {
case types.TSTRUCT: case types.TSTRUCT:
flatConds := compare.EqStruct(t, np, nq) flatConds := compare.EqStruct(t, np, nq)
if len(flatConds) == 0 { if len(flatConds) == 0 {
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(true))) fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(base.Pos, true)))
} else { } else {
for _, c := range flatConds[:len(flatConds)-1] { for _, c := range flatConds[:len(flatConds)-1] {
// if cond {} else { goto neq } // if cond {} else { goto neq }
@ -540,7 +540,7 @@ func eqFunc(t *types.Type) *ir.Func {
// r = false // r = false
// return (or goto ret) // return (or goto ret)
fn.Body.Append(ir.NewLabelStmt(base.Pos, neq)) fn.Body.Append(ir.NewLabelStmt(base.Pos, neq))
fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(false))) fn.Body.Append(ir.NewAssignStmt(base.Pos, nr, ir.NewBool(base.Pos, false)))
if compare.EqCanPanic(t) || anyCall(fn) { if compare.EqCanPanic(t) || anyCall(fn) {
// Epilogue is large, so share it with the equal case. // Epilogue is large, so share it with the equal case.
fn.Body.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, ret)) fn.Body.Append(ir.NewBranchStmt(base.Pos, ir.OGOTO, ret))

View File

@ -678,7 +678,7 @@ func tcMake(n *ir.CallExpr) ir.Node {
return n return n
} }
} else { } else {
l = ir.NewInt(0) l = ir.NewInt(base.Pos, 0)
} }
nn = ir.NewMakeExpr(n.Pos(), ir.OMAKEMAP, l, nil) nn = ir.NewMakeExpr(n.Pos(), ir.OMAKEMAP, l, nil)
nn.SetEsc(n.Esc()) nn.SetEsc(n.Esc())
@ -699,7 +699,7 @@ func tcMake(n *ir.CallExpr) ir.Node {
return n return n
} }
} else { } else {
l = ir.NewInt(0) l = ir.NewInt(base.Pos, 0)
} }
nn = ir.NewMakeExpr(n.Pos(), ir.OMAKECHAN, l, nil) nn = ir.NewMakeExpr(n.Pos(), ir.OMAKECHAN, l, nil)
} }

View File

@ -1605,7 +1605,7 @@ func stringtoruneslit(n *ir.ConvExpr) ir.Node {
var l []ir.Node var l []ir.Node
i := 0 i := 0
for _, r := range ir.StringVal(n.X) { for _, r := range ir.StringVal(n.X) {
l = append(l, ir.NewKeyExpr(base.Pos, ir.NewInt(int64(i)), ir.NewInt(int64(r)))) l = append(l, ir.NewKeyExpr(base.Pos, ir.NewInt(base.Pos, int64(i)), ir.NewInt(base.Pos, int64(r))))
i++ i++
} }

View File

@ -559,7 +559,7 @@ func appendSlice(n *ir.CallExpr, init *ir.Nodes) ir.Node {
fn := typecheck.LookupRuntime("slicecopy") fn := typecheck.LookupRuntime("slicecopy")
fn = typecheck.SubstArgTypes(fn, ptr1.Type().Elem(), ptr2.Type().Elem()) fn = typecheck.SubstArgTypes(fn, ptr1.Type().Elem(), ptr2.Type().Elem())
ncopy = mkcall1(fn, types.Types[types.TINT], &nodes, ptr1, len1, ptr2, len2, ir.NewInt(elemtype.Size())) ncopy = mkcall1(fn, types.Types[types.TINT], &nodes, ptr1, len1, ptr2, len2, ir.NewInt(base.Pos, elemtype.Size()))
} else { } else {
// memmove(&s[idx], &l2[0], len(l2)*sizeof(T)) // memmove(&s[idx], &l2[0], len(l2)*sizeof(T))
ix := ir.NewIndexExpr(base.Pos, s, idx) ix := ir.NewIndexExpr(base.Pos, s, idx)
@ -569,7 +569,7 @@ func appendSlice(n *ir.CallExpr, init *ir.Nodes) ir.Node {
sptr := ir.NewUnaryExpr(base.Pos, ir.OSPTR, l2) sptr := ir.NewUnaryExpr(base.Pos, ir.OSPTR, l2)
nwid := cheapExpr(typecheck.Conv(ir.NewUnaryExpr(base.Pos, ir.OLEN, l2), types.Types[types.TUINTPTR]), &nodes) nwid := cheapExpr(typecheck.Conv(ir.NewUnaryExpr(base.Pos, ir.OLEN, l2), types.Types[types.TUINTPTR]), &nodes)
nwid = ir.NewBinaryExpr(base.Pos, ir.OMUL, nwid, ir.NewInt(elemtype.Size())) nwid = ir.NewBinaryExpr(base.Pos, ir.OMUL, nwid, ir.NewInt(base.Pos, elemtype.Size()))
// instantiate func memmove(to *any, frm *any, length uintptr) // instantiate func memmove(to *any, frm *any, length uintptr)
fn := typecheck.LookupRuntime("memmove") fn := typecheck.LookupRuntime("memmove")
@ -667,7 +667,7 @@ func extendSlice(n *ir.CallExpr, init *ir.Nodes) ir.Node {
var nodes []ir.Node var nodes []ir.Node
// if l2 >= 0 (likely happens), do nothing // if l2 >= 0 (likely happens), do nothing
nifneg := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OGE, l2, ir.NewInt(0)), nil, nil) nifneg := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OGE, l2, ir.NewInt(base.Pos, 0)), nil, nil)
nifneg.Likely = true nifneg.Likely = true
// else panicmakeslicelen() // else panicmakeslicelen()
@ -718,7 +718,7 @@ func extendSlice(n *ir.CallExpr, init *ir.Nodes) ir.Node {
hp := typecheck.ConvNop(typecheck.NodAddr(ix), types.Types[types.TUNSAFEPTR]) hp := typecheck.ConvNop(typecheck.NodAddr(ix), types.Types[types.TUNSAFEPTR])
// hn := l2 * sizeof(elem(s)) // hn := l2 * sizeof(elem(s))
hn := typecheck.Conv(ir.NewBinaryExpr(base.Pos, ir.OMUL, l2, ir.NewInt(elemtype.Size())), types.Types[types.TUINTPTR]) hn := typecheck.Conv(ir.NewBinaryExpr(base.Pos, ir.OMUL, l2, ir.NewInt(base.Pos, elemtype.Size())), types.Types[types.TUINTPTR])
clrname := "memclrNoHeapPointers" clrname := "memclrNoHeapPointers"
hasPointers := elemtype.HasPointers() hasPointers := elemtype.HasPointers()

View File

@ -83,7 +83,7 @@ func walkAppend(n *ir.CallExpr, init *ir.Nodes, dst ir.Node) ir.Node {
l = append(l, ir.NewAssignStmt(base.Pos, s, nsrc)) l = append(l, ir.NewAssignStmt(base.Pos, s, nsrc))
// num = number of things to append // num = number of things to append
num := ir.NewInt(int64(argc)) num := ir.NewInt(base.Pos, int64(argc))
// newLen := s.len + num // newLen := s.len + num
newLen := typecheck.Temp(types.Types[types.TINT]) newLen := typecheck.Temp(types.Types[types.TINT])
@ -119,7 +119,7 @@ func walkAppend(n *ir.CallExpr, init *ir.Nodes, dst ir.Node) ir.Node {
ls = n.Args[1:] ls = n.Args[1:]
for i, n := range ls { for i, n := range ls {
// s[s.len-argc+i] = arg // s[s.len-argc+i] = arg
ix := ir.NewIndexExpr(base.Pos, s, ir.NewBinaryExpr(base.Pos, ir.OSUB, newLen, ir.NewInt(int64(argc-i)))) ix := ir.NewIndexExpr(base.Pos, s, ir.NewBinaryExpr(base.Pos, ir.OSUB, newLen, ir.NewInt(base.Pos, int64(argc-i))))
ix.SetBounded(true) ix.SetBounded(true)
l = append(l, ir.NewAssignStmt(base.Pos, ix, n)) l = append(l, ir.NewAssignStmt(base.Pos, ix, n))
} }
@ -184,7 +184,7 @@ func walkCopy(n *ir.BinaryExpr, init *ir.Nodes, runtimecall bool) ir.Node {
fn := typecheck.LookupRuntime("slicecopy") fn := typecheck.LookupRuntime("slicecopy")
fn = typecheck.SubstArgTypes(fn, ptrL.Type().Elem(), ptrR.Type().Elem()) fn = typecheck.SubstArgTypes(fn, ptrL.Type().Elem(), ptrR.Type().Elem())
return mkcall1(fn, n.Type(), init, ptrL, lenL, ptrR, lenR, ir.NewInt(n.X.Type().Elem().Size())) return mkcall1(fn, n.Type(), init, ptrL, lenL, ptrR, lenR, ir.NewInt(base.Pos, n.X.Type().Elem().Size()))
} }
n.X = walkExpr(n.X, init) n.X = walkExpr(n.X, init)
@ -220,7 +220,7 @@ func walkCopy(n *ir.BinaryExpr, init *ir.Nodes, runtimecall bool) ir.Node {
nwid := ir.Node(typecheck.Temp(types.Types[types.TUINTPTR])) nwid := ir.Node(typecheck.Temp(types.Types[types.TUINTPTR]))
setwid := ir.NewAssignStmt(base.Pos, nwid, typecheck.Conv(nlen, types.Types[types.TUINTPTR])) setwid := ir.NewAssignStmt(base.Pos, nwid, typecheck.Conv(nlen, types.Types[types.TUINTPTR]))
ne.Body.Append(setwid) ne.Body.Append(setwid)
nwid = ir.NewBinaryExpr(base.Pos, ir.OMUL, nwid, ir.NewInt(nl.Type().Elem().Size())) nwid = ir.NewBinaryExpr(base.Pos, ir.OMUL, nwid, ir.NewInt(base.Pos, nl.Type().Elem().Size()))
call := mkcall1(fn, nil, init, nto, nfrm, nwid) call := mkcall1(fn, nil, init, nto, nfrm, nwid)
ne.Body.Append(call) ne.Body.Append(call)
@ -320,7 +320,7 @@ func walkMakeMap(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
// h.buckets = b // h.buckets = b
// } // }
nif := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OLE, hint, ir.NewInt(reflectdata.BUCKETSIZE)), nil, nil) nif := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OLE, hint, ir.NewInt(base.Pos, reflectdata.BUCKETSIZE)), nil, nil)
nif.Likely = true nif.Likely = true
// var bv bmap // var bv bmap
@ -416,8 +416,8 @@ func walkMakeSlice(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
// if len < 0 { panicmakeslicelen() } // if len < 0 { panicmakeslicelen() }
// panicmakeslicecap() // panicmakeslicecap()
// } // }
nif := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OGT, typecheck.Conv(l, types.Types[types.TUINT64]), ir.NewInt(i)), nil, nil) nif := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OGT, typecheck.Conv(l, types.Types[types.TUINT64]), ir.NewInt(base.Pos, i)), nil, nil)
niflen := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OLT, l, ir.NewInt(0)), nil, nil) niflen := ir.NewIfStmt(base.Pos, ir.NewBinaryExpr(base.Pos, ir.OLT, l, ir.NewInt(base.Pos, 0)), nil, nil)
niflen.Body = []ir.Node{mkcall("panicmakeslicelen", nil, init)} niflen.Body = []ir.Node{mkcall("panicmakeslicelen", nil, init)}
nif.Body.Append(niflen, mkcall("panicmakeslicecap", nil, init)) nif.Body.Append(niflen, mkcall("panicmakeslicecap", nil, init))
init.Append(typecheck.Stmt(nif)) init.Append(typecheck.Stmt(nif))
@ -478,11 +478,11 @@ func walkMakeSliceCopy(n *ir.MakeExpr, init *ir.Nodes) ir.Node {
// We do not check for overflow of len(to)*elem.Width here // We do not check for overflow of len(to)*elem.Width here
// since len(from) is an existing checked slice capacity // since len(from) is an existing checked slice capacity
// with same elem.Width for the from slice. // with same elem.Width for the from slice.
size := ir.NewBinaryExpr(base.Pos, ir.OMUL, typecheck.Conv(length, types.Types[types.TUINTPTR]), typecheck.Conv(ir.NewInt(t.Elem().Size()), types.Types[types.TUINTPTR])) size := ir.NewBinaryExpr(base.Pos, ir.OMUL, typecheck.Conv(length, types.Types[types.TUINTPTR]), typecheck.Conv(ir.NewInt(base.Pos, t.Elem().Size()), types.Types[types.TUINTPTR]))
// instantiate mallocgc(size uintptr, typ *byte, needszero bool) unsafe.Pointer // instantiate mallocgc(size uintptr, typ *byte, needszero bool) unsafe.Pointer
fn := typecheck.LookupRuntime("mallocgc") fn := typecheck.LookupRuntime("mallocgc")
ptr := mkcall1(fn, types.Types[types.TUNSAFEPTR], init, size, typecheck.NodNil(), ir.NewBool(false)) ptr := mkcall1(fn, types.Types[types.TUNSAFEPTR], init, size, typecheck.NodNil(), ir.NewBool(base.Pos, false))
ptr.MarkNonNil() ptr.MarkNonNil()
sh := ir.NewSliceHeaderExpr(base.Pos, t, ptr, length, length) sh := ir.NewSliceHeaderExpr(base.Pos, t, ptr, length, length)
@ -536,11 +536,11 @@ func walkPrint(nn *ir.CallExpr, init *ir.Nodes) ir.Node {
t := make([]ir.Node, 0, len(s)*2) t := make([]ir.Node, 0, len(s)*2)
for i, n := range s { for i, n := range s {
if i != 0 { if i != 0 {
t = append(t, ir.NewString(" ")) t = append(t, ir.NewString(base.Pos, " "))
} }
t = append(t, n) t = append(t, n)
} }
t = append(t, ir.NewString("\n")) t = append(t, ir.NewString(base.Pos, "\n"))
nn.Args = t nn.Args = t
} }
@ -554,7 +554,7 @@ func walkPrint(nn *ir.CallExpr, init *ir.Nodes) ir.Node {
i++ i++
} }
if len(strs) > 0 { if len(strs) > 0 {
t = append(t, ir.NewString(strings.Join(strs, ""))) t = append(t, ir.NewString(base.Pos, strings.Join(strs, "")))
} }
if i < len(s) { if i < len(s) {
t = append(t, s[i]) t = append(t, s[i])
@ -713,7 +713,7 @@ func walkUnsafeSlice(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
// if len < 0 { panicunsafeslicelen() } // if len < 0 { panicunsafeslicelen() }
nif := ir.NewIfStmt(base.Pos, nil, nil, nil) nif := ir.NewIfStmt(base.Pos, nil, nil, nil)
nif.Cond = ir.NewBinaryExpr(base.Pos, ir.OLT, typecheck.Conv(len, lenType), ir.NewInt(0)) nif.Cond = ir.NewBinaryExpr(base.Pos, ir.OLT, typecheck.Conv(len, lenType), ir.NewInt(base.Pos, 0))
nif.Body.Append(mkcall("panicunsafeslicelen", nil, &nif.Body)) nif.Body.Append(mkcall("panicunsafeslicelen", nil, &nif.Body))
appendWalkStmt(init, nif) appendWalkStmt(init, nif)
@ -723,7 +723,7 @@ func walkUnsafeSlice(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
// } // }
nifPtr := ir.NewIfStmt(base.Pos, nil, nil, nil) nifPtr := ir.NewIfStmt(base.Pos, nil, nil, nil)
isNil := ir.NewBinaryExpr(base.Pos, ir.OEQ, unsafePtr, typecheck.NodNil()) isNil := ir.NewBinaryExpr(base.Pos, ir.OEQ, unsafePtr, typecheck.NodNil())
gtZero := ir.NewBinaryExpr(base.Pos, ir.OGT, typecheck.Conv(len, lenType), ir.NewInt(0)) gtZero := ir.NewBinaryExpr(base.Pos, ir.OGT, typecheck.Conv(len, lenType), ir.NewInt(base.Pos, 0))
nifPtr.Cond = nifPtr.Cond =
ir.NewLogicalExpr(base.Pos, ir.OANDAND, isNil, gtZero) ir.NewLogicalExpr(base.Pos, ir.OANDAND, isNil, gtZero)
nifPtr.Body.Append(mkcall("panicunsafeslicenilptr", nil, &nifPtr.Body)) nifPtr.Body.Append(mkcall("panicunsafeslicenilptr", nil, &nifPtr.Body))
@ -740,7 +740,7 @@ func walkUnsafeSlice(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
mem := typecheck.Temp(types.Types[types.TUINTPTR]) mem := typecheck.Temp(types.Types[types.TUINTPTR])
overflow := typecheck.Temp(types.Types[types.TBOOL]) overflow := typecheck.Temp(types.Types[types.TBOOL])
fn := typecheck.LookupRuntime("mulUintptr") fn := typecheck.LookupRuntime("mulUintptr")
call := mkcall1(fn, fn.Type().Results(), init, ir.NewInt(sliceType.Elem().Size()), typecheck.Conv(typecheck.Conv(len, lenType), types.Types[types.TUINTPTR])) call := mkcall1(fn, fn.Type().Results(), init, ir.NewInt(base.Pos, sliceType.Elem().Size()), typecheck.Conv(typecheck.Conv(len, lenType), types.Types[types.TUINTPTR]))
appendWalkStmt(init, ir.NewAssignListStmt(base.Pos, ir.OAS2, []ir.Node{mem, overflow}, []ir.Node{call})) appendWalkStmt(init, ir.NewAssignListStmt(base.Pos, ir.OAS2, []ir.Node{mem, overflow}, []ir.Node{call}))
// if overflow || mem > -uintptr(ptr) { // if overflow || mem > -uintptr(ptr) {
@ -799,7 +799,7 @@ func walkUnsafeString(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
// if len < 0 { panicunsafestringlen() } // if len < 0 { panicunsafestringlen() }
nif := ir.NewIfStmt(base.Pos, nil, nil, nil) nif := ir.NewIfStmt(base.Pos, nil, nil, nil)
nif.Cond = ir.NewBinaryExpr(base.Pos, ir.OLT, typecheck.Conv(len, lenType), ir.NewInt(0)) nif.Cond = ir.NewBinaryExpr(base.Pos, ir.OLT, typecheck.Conv(len, lenType), ir.NewInt(base.Pos, 0))
nif.Body.Append(mkcall("panicunsafestringlen", nil, &nif.Body)) nif.Body.Append(mkcall("panicunsafestringlen", nil, &nif.Body))
appendWalkStmt(init, nif) appendWalkStmt(init, nif)

View File

@ -33,7 +33,7 @@ func fakePC(n ir.Node) ir.Node {
// those get the same `src.XPos` // those get the same `src.XPos`
io.WriteString(hash, fmt.Sprintf("%v", n)) io.WriteString(hash, fmt.Sprintf("%v", n))
return ir.NewInt(int64(hash.Sum32())) return ir.NewInt(base.Pos, int64(hash.Sum32()))
} }
// The result of walkCompare MUST be assigned back to n, e.g. // The result of walkCompare MUST be assigned back to n, e.g.
@ -195,7 +195,7 @@ func walkCompare(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
call.Args.Append(typecheck.NodAddr(cmpl)) call.Args.Append(typecheck.NodAddr(cmpl))
call.Args.Append(typecheck.NodAddr(cmpr)) call.Args.Append(typecheck.NodAddr(cmpr))
if needsLength { if needsLength {
call.Args.Append(ir.NewInt(t.Size())) call.Args.Append(ir.NewInt(base.Pos, t.Size()))
} }
res := ir.Node(call) res := ir.Node(call)
if n.Op() != ir.OEQ { if n.Op() != ir.OEQ {
@ -262,31 +262,31 @@ func walkCompare(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
} }
if step == 1 { if step == 1 {
comp( comp(
ir.NewIndexExpr(base.Pos, cmpl, ir.NewInt(i)), ir.NewIndexExpr(base.Pos, cmpl, ir.NewInt(base.Pos, i)),
ir.NewIndexExpr(base.Pos, cmpr, ir.NewInt(i)), ir.NewIndexExpr(base.Pos, cmpr, ir.NewInt(base.Pos, i)),
) )
i++ i++
remains -= t.Elem().Size() remains -= t.Elem().Size()
} else { } else {
elemType := t.Elem().ToUnsigned() elemType := t.Elem().ToUnsigned()
cmplw := ir.Node(ir.NewIndexExpr(base.Pos, cmpl, ir.NewInt(i))) cmplw := ir.Node(ir.NewIndexExpr(base.Pos, cmpl, ir.NewInt(base.Pos, i)))
cmplw = typecheck.Conv(cmplw, elemType) // convert to unsigned cmplw = typecheck.Conv(cmplw, elemType) // convert to unsigned
cmplw = typecheck.Conv(cmplw, convType) // widen cmplw = typecheck.Conv(cmplw, convType) // widen
cmprw := ir.Node(ir.NewIndexExpr(base.Pos, cmpr, ir.NewInt(i))) cmprw := ir.Node(ir.NewIndexExpr(base.Pos, cmpr, ir.NewInt(base.Pos, i)))
cmprw = typecheck.Conv(cmprw, elemType) cmprw = typecheck.Conv(cmprw, elemType)
cmprw = typecheck.Conv(cmprw, convType) cmprw = typecheck.Conv(cmprw, convType)
// For code like this: uint32(s[0]) | uint32(s[1])<<8 | uint32(s[2])<<16 ... // For code like this: uint32(s[0]) | uint32(s[1])<<8 | uint32(s[2])<<16 ...
// ssa will generate a single large load. // ssa will generate a single large load.
for offset := int64(1); offset < step; offset++ { for offset := int64(1); offset < step; offset++ {
lb := ir.Node(ir.NewIndexExpr(base.Pos, cmpl, ir.NewInt(i+offset))) lb := ir.Node(ir.NewIndexExpr(base.Pos, cmpl, ir.NewInt(base.Pos, i+offset)))
lb = typecheck.Conv(lb, elemType) lb = typecheck.Conv(lb, elemType)
lb = typecheck.Conv(lb, convType) lb = typecheck.Conv(lb, convType)
lb = ir.NewBinaryExpr(base.Pos, ir.OLSH, lb, ir.NewInt(8*t.Elem().Size()*offset)) lb = ir.NewBinaryExpr(base.Pos, ir.OLSH, lb, ir.NewInt(base.Pos, 8*t.Elem().Size()*offset))
cmplw = ir.NewBinaryExpr(base.Pos, ir.OOR, cmplw, lb) cmplw = ir.NewBinaryExpr(base.Pos, ir.OOR, cmplw, lb)
rb := ir.Node(ir.NewIndexExpr(base.Pos, cmpr, ir.NewInt(i+offset))) rb := ir.Node(ir.NewIndexExpr(base.Pos, cmpr, ir.NewInt(base.Pos, i+offset)))
rb = typecheck.Conv(rb, elemType) rb = typecheck.Conv(rb, elemType)
rb = typecheck.Conv(rb, convType) rb = typecheck.Conv(rb, convType)
rb = ir.NewBinaryExpr(base.Pos, ir.OLSH, rb, ir.NewInt(8*t.Elem().Size()*offset)) rb = ir.NewBinaryExpr(base.Pos, ir.OLSH, rb, ir.NewInt(base.Pos, 8*t.Elem().Size()*offset))
cmprw = ir.NewBinaryExpr(base.Pos, ir.OOR, cmprw, rb) cmprw = ir.NewBinaryExpr(base.Pos, ir.OOR, cmprw, rb)
} }
comp(cmplw, cmprw) comp(cmplw, cmprw)
@ -296,7 +296,7 @@ func walkCompare(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
} }
} }
if expr == nil { if expr == nil {
expr = ir.NewBool(n.Op() == ir.OEQ) expr = ir.NewBool(base.Pos, n.Op() == ir.OEQ)
// We still need to use cmpl and cmpr, in case they contain // We still need to use cmpl and cmpr, in case they contain
// an expression which might panic. See issue 23837. // an expression which might panic. See issue 23837.
a1 := typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.BlankNode, cmpl)) a1 := typecheck.Stmt(ir.NewAssignStmt(base.Pos, ir.BlankNode, cmpl))
@ -382,12 +382,12 @@ func walkCompareString(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
if len(s) > 0 { if len(s) > 0 {
ncs = safeExpr(ncs, init) ncs = safeExpr(ncs, init)
} }
r := ir.Node(ir.NewBinaryExpr(base.Pos, cmp, ir.NewUnaryExpr(base.Pos, ir.OLEN, ncs), ir.NewInt(int64(len(s))))) r := ir.Node(ir.NewBinaryExpr(base.Pos, cmp, ir.NewUnaryExpr(base.Pos, ir.OLEN, ncs), ir.NewInt(base.Pos, int64(len(s)))))
remains := len(s) remains := len(s)
for i := 0; remains > 0; { for i := 0; remains > 0; {
if remains == 1 || !canCombineLoads { if remains == 1 || !canCombineLoads {
cb := ir.NewInt(int64(s[i])) cb := ir.NewInt(base.Pos, int64(s[i]))
ncb := ir.NewIndexExpr(base.Pos, ncs, ir.NewInt(int64(i))) ncb := ir.NewIndexExpr(base.Pos, ncs, ir.NewInt(base.Pos, int64(i)))
r = ir.NewLogicalExpr(base.Pos, and, r, ir.NewBinaryExpr(base.Pos, cmp, ncb, cb)) r = ir.NewLogicalExpr(base.Pos, and, r, ir.NewBinaryExpr(base.Pos, cmp, ncb, cb))
remains-- remains--
i++ i++
@ -406,18 +406,18 @@ func walkCompareString(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
convType = types.Types[types.TUINT16] convType = types.Types[types.TUINT16]
step = 2 step = 2
} }
ncsubstr := typecheck.Conv(ir.NewIndexExpr(base.Pos, ncs, ir.NewInt(int64(i))), convType) ncsubstr := typecheck.Conv(ir.NewIndexExpr(base.Pos, ncs, ir.NewInt(base.Pos, int64(i))), convType)
csubstr := int64(s[i]) csubstr := int64(s[i])
// Calculate large constant from bytes as sequence of shifts and ors. // Calculate large constant from bytes as sequence of shifts and ors.
// Like this: uint32(s[0]) | uint32(s[1])<<8 | uint32(s[2])<<16 ... // Like this: uint32(s[0]) | uint32(s[1])<<8 | uint32(s[2])<<16 ...
// ssa will combine this into a single large load. // ssa will combine this into a single large load.
for offset := 1; offset < step; offset++ { for offset := 1; offset < step; offset++ {
b := typecheck.Conv(ir.NewIndexExpr(base.Pos, ncs, ir.NewInt(int64(i+offset))), convType) b := typecheck.Conv(ir.NewIndexExpr(base.Pos, ncs, ir.NewInt(base.Pos, int64(i+offset))), convType)
b = ir.NewBinaryExpr(base.Pos, ir.OLSH, b, ir.NewInt(int64(8*offset))) b = ir.NewBinaryExpr(base.Pos, ir.OLSH, b, ir.NewInt(base.Pos, int64(8*offset)))
ncsubstr = ir.NewBinaryExpr(base.Pos, ir.OOR, ncsubstr, b) ncsubstr = ir.NewBinaryExpr(base.Pos, ir.OOR, ncsubstr, b)
csubstr |= int64(s[i+offset]) << uint8(8*offset) csubstr |= int64(s[i+offset]) << uint8(8*offset)
} }
csubstrPart := ir.NewInt(csubstr) csubstrPart := ir.NewInt(base.Pos, csubstr)
// Compare "step" bytes as once // Compare "step" bytes as once
r = ir.NewLogicalExpr(base.Pos, and, r, ir.NewBinaryExpr(base.Pos, cmp, csubstrPart, ncsubstr)) r = ir.NewLogicalExpr(base.Pos, and, r, ir.NewBinaryExpr(base.Pos, cmp, csubstrPart, ncsubstr))
remains -= step remains -= step
@ -446,7 +446,7 @@ func walkCompareString(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
} else { } else {
// sys_cmpstring(s1, s2) :: 0 // sys_cmpstring(s1, s2) :: 0
r = mkcall("cmpstring", types.Types[types.TINT], init, typecheck.Conv(n.X, types.Types[types.TSTRING]), typecheck.Conv(n.Y, types.Types[types.TSTRING])) r = mkcall("cmpstring", types.Types[types.TINT], init, typecheck.Conv(n.X, types.Types[types.TSTRING]), typecheck.Conv(n.Y, types.Types[types.TSTRING]))
r = ir.NewBinaryExpr(base.Pos, n.Op(), r, ir.NewInt(0)) r = ir.NewBinaryExpr(base.Pos, n.Op(), r, ir.NewInt(base.Pos, 0))
} }
return finishCompare(n, r, init) return finishCompare(n, r, init)

View File

@ -204,7 +204,7 @@ func fixedlit(ctxt initContext, kind initKind, n *ir.CompLitExpr, var_ ir.Node,
} }
r = kv.Value r = kv.Value
} }
a := ir.NewIndexExpr(base.Pos, var_, ir.NewInt(k)) a := ir.NewIndexExpr(base.Pos, var_, ir.NewInt(base.Pos, k))
k++ k++
if isBlank { if isBlank {
return ir.BlankNode, r return ir.BlankNode, r
@ -377,7 +377,7 @@ func slicelit(ctxt initContext, n *ir.CompLitExpr, var_ ir.Node, init *ir.Nodes)
} }
value = kv.Value value = kv.Value
} }
a := ir.NewIndexExpr(base.Pos, vauto, ir.NewInt(index)) a := ir.NewIndexExpr(base.Pos, vauto, ir.NewInt(base.Pos, index))
a.SetBounded(true) a.SetBounded(true)
index++ index++
@ -416,7 +416,7 @@ func slicelit(ctxt initContext, n *ir.CompLitExpr, var_ ir.Node, init *ir.Nodes)
func maplit(n *ir.CompLitExpr, m ir.Node, init *ir.Nodes) { func maplit(n *ir.CompLitExpr, m ir.Node, init *ir.Nodes) {
// make the map var // make the map var
args := []ir.Node{ir.TypeNode(n.Type()), ir.NewInt(n.Len + int64(len(n.List)))} args := []ir.Node{ir.TypeNode(n.Type()), ir.NewInt(base.Pos, n.Len+int64(len(n.List)))}
a := typecheck.Expr(ir.NewCallExpr(base.Pos, ir.OMAKE, nil, args)).(*ir.MakeExpr) a := typecheck.Expr(ir.NewCallExpr(base.Pos, ir.OMAKE, nil, args)).(*ir.MakeExpr)
a.RType = n.RType a.RType = n.RType
a.SetEsc(n.Esc()) a.SetEsc(n.Esc())
@ -476,9 +476,9 @@ func maplit(n *ir.CompLitExpr, m ir.Node, init *ir.Nodes) {
base.AssertfAt(lhs.Op() == ir.OINDEXMAP, lhs.Pos(), "want OINDEXMAP, have %+v", lhs) base.AssertfAt(lhs.Op() == ir.OINDEXMAP, lhs.Pos(), "want OINDEXMAP, have %+v", lhs)
lhs.RType = n.RType lhs.RType = n.RType
zero := ir.NewAssignStmt(base.Pos, i, ir.NewInt(0)) zero := ir.NewAssignStmt(base.Pos, i, ir.NewInt(base.Pos, 0))
cond := ir.NewBinaryExpr(base.Pos, ir.OLT, i, ir.NewInt(tk.NumElem())) cond := ir.NewBinaryExpr(base.Pos, ir.OLT, i, ir.NewInt(base.Pos, tk.NumElem()))
incr := ir.NewAssignStmt(base.Pos, i, ir.NewBinaryExpr(base.Pos, ir.OADD, i, ir.NewInt(1))) incr := ir.NewAssignStmt(base.Pos, i, ir.NewBinaryExpr(base.Pos, ir.OADD, i, ir.NewInt(base.Pos, 1)))
var body ir.Node = ir.NewAssignStmt(base.Pos, lhs, rhs) var body ir.Node = ir.NewAssignStmt(base.Pos, lhs, rhs)
body = typecheck.Stmt(body) body = typecheck.Stmt(body)

View File

@ -140,9 +140,9 @@ func dataWord(conv *ir.ConvExpr, init *ir.Nodes) ir.Node {
n = cheapExpr(n, init) n = cheapExpr(n, init)
n = soleComponent(init, n) n = soleComponent(init, n)
// byteindex widens n so that the multiplication doesn't overflow. // byteindex widens n so that the multiplication doesn't overflow.
index := ir.NewBinaryExpr(base.Pos, ir.OLSH, byteindex(n), ir.NewInt(3)) index := ir.NewBinaryExpr(base.Pos, ir.OLSH, byteindex(n), ir.NewInt(base.Pos, 3))
if ssagen.Arch.LinkArch.ByteOrder == binary.BigEndian { if ssagen.Arch.LinkArch.ByteOrder == binary.BigEndian {
index = ir.NewBinaryExpr(base.Pos, ir.OADD, index, ir.NewInt(7)) index = ir.NewBinaryExpr(base.Pos, ir.OADD, index, ir.NewInt(base.Pos, 7))
} }
// The actual type is [256]uint64, but we use [256*8]uint8 so we can address // The actual type is [256]uint64, but we use [256*8]uint8 so we can address
// individual bytes. // individual bytes.
@ -418,7 +418,7 @@ func soleComponent(init *ir.Nodes, n ir.Node) ir.Node {
} }
n = typecheck.Expr(ir.NewSelectorExpr(n.Pos(), ir.OXDOT, n, n.Type().Field(0).Sym)) n = typecheck.Expr(ir.NewSelectorExpr(n.Pos(), ir.OXDOT, n, n.Type().Field(0).Sym))
case n.Type().IsArray(): case n.Type().IsArray():
n = typecheck.Expr(ir.NewIndexExpr(n.Pos(), n, ir.NewInt(0))) n = typecheck.Expr(ir.NewIndexExpr(n.Pos(), n, ir.NewInt(base.Pos, 0)))
default: default:
return n return n
} }

View File

@ -433,9 +433,9 @@ func (o *orderState) edge() {
// freezes the counter when it reaches the value of 255. However, a range // freezes the counter when it reaches the value of 255. However, a range
// of experiments showed that that decreases overall performance. // of experiments showed that that decreases overall performance.
o.append(ir.NewIfStmt(base.Pos, o.append(ir.NewIfStmt(base.Pos,
ir.NewBinaryExpr(base.Pos, ir.OEQ, counter, ir.NewInt(0xff)), ir.NewBinaryExpr(base.Pos, ir.OEQ, counter, ir.NewInt(base.Pos, 0xff)),
[]ir.Node{ir.NewAssignStmt(base.Pos, counter, ir.NewInt(1))}, []ir.Node{ir.NewAssignStmt(base.Pos, counter, ir.NewInt(base.Pos, 1))},
[]ir.Node{ir.NewAssignOpStmt(base.Pos, ir.OADD, counter, ir.NewInt(1))})) []ir.Node{ir.NewAssignOpStmt(base.Pos, ir.OADD, counter, ir.NewInt(base.Pos, 1))}))
} }
// orderBlock orders the block of statements in n into a new slice, // orderBlock orders the block of statements in n into a new slice,

View File

@ -102,7 +102,7 @@ func walkRange(nrange *ir.RangeStmt) ir.Node {
init = append(init, ir.NewAssignStmt(base.Pos, hn, ir.NewUnaryExpr(base.Pos, ir.OLEN, ha))) init = append(init, ir.NewAssignStmt(base.Pos, hn, ir.NewUnaryExpr(base.Pos, ir.OLEN, ha)))
nfor.Cond = ir.NewBinaryExpr(base.Pos, ir.OLT, hv1, hn) nfor.Cond = ir.NewBinaryExpr(base.Pos, ir.OLT, hv1, hn)
nfor.Post = ir.NewAssignStmt(base.Pos, hv1, ir.NewBinaryExpr(base.Pos, ir.OADD, hv1, ir.NewInt(1))) nfor.Post = ir.NewAssignStmt(base.Pos, hv1, ir.NewBinaryExpr(base.Pos, ir.OADD, hv1, ir.NewInt(base.Pos, 1)))
// for range ha { body } // for range ha { body }
if v1 == nil { if v1 == nil {
@ -214,7 +214,7 @@ func walkRange(nrange *ir.RangeStmt) ir.Node {
// This reads from hp and writes to hu. // This reads from hp and writes to hu.
huVal = ir.NewConvExpr(base.Pos, ir.OCONVNOP, types.Types[types.TUNSAFEPTR], hp) huVal = ir.NewConvExpr(base.Pos, ir.OCONVNOP, types.Types[types.TUNSAFEPTR], hp)
huVal = ir.NewConvExpr(base.Pos, ir.OCONVNOP, types.Types[types.TUINTPTR], huVal) huVal = ir.NewConvExpr(base.Pos, ir.OCONVNOP, types.Types[types.TUINTPTR], huVal)
as := ir.NewAssignStmt(base.Pos, hu, ir.NewBinaryExpr(base.Pos, ir.OADD, huVal, ir.NewInt(elem.Size()))) as := ir.NewAssignStmt(base.Pos, hu, ir.NewBinaryExpr(base.Pos, ir.OADD, huVal, ir.NewInt(base.Pos, elem.Size())))
nfor.Post = ir.NewBlockStmt(base.Pos, []ir.Node{nfor.Post, as}) nfor.Post = ir.NewBlockStmt(base.Pos, []ir.Node{nfor.Post, as})
case types.TMAP: case types.TMAP:
@ -260,7 +260,7 @@ func walkRange(nrange *ir.RangeStmt) ir.Node {
} }
hb := typecheck.Temp(types.Types[types.TBOOL]) hb := typecheck.Temp(types.Types[types.TBOOL])
nfor.Cond = ir.NewBinaryExpr(base.Pos, ir.ONE, hb, ir.NewBool(false)) nfor.Cond = ir.NewBinaryExpr(base.Pos, ir.ONE, hb, ir.NewBool(base.Pos, false))
lhs := []ir.Node{hv1, hb} lhs := []ir.Node{hv1, hb}
rhs := []ir.Node{ir.NewUnaryExpr(base.Pos, ir.ORECV, ha)} rhs := []ir.Node{ir.NewUnaryExpr(base.Pos, ir.ORECV, ha)}
a := ir.NewAssignListStmt(base.Pos, ir.OAS2RECV, lhs, rhs) a := ir.NewAssignListStmt(base.Pos, ir.OAS2RECV, lhs, rhs)
@ -317,10 +317,10 @@ func walkRange(nrange *ir.RangeStmt) ir.Node {
// if hv2 < utf8.RuneSelf // if hv2 < utf8.RuneSelf
nif := ir.NewIfStmt(base.Pos, nil, nil, nil) nif := ir.NewIfStmt(base.Pos, nil, nil, nil)
nif.Cond = ir.NewBinaryExpr(base.Pos, ir.OLT, hv2, ir.NewInt(utf8.RuneSelf)) nif.Cond = ir.NewBinaryExpr(base.Pos, ir.OLT, hv2, ir.NewInt(base.Pos, utf8.RuneSelf))
// hv1++ // hv1++
nif.Body = []ir.Node{ir.NewAssignStmt(base.Pos, hv1, ir.NewBinaryExpr(base.Pos, ir.OADD, hv1, ir.NewInt(1)))} nif.Body = []ir.Node{ir.NewAssignStmt(base.Pos, hv1, ir.NewBinaryExpr(base.Pos, ir.OADD, hv1, ir.NewInt(base.Pos, 1)))}
// } else { // } else {
// hv2, hv1 = decoderune(ha, hv1) // hv2, hv1 = decoderune(ha, hv1)
@ -524,19 +524,19 @@ func arrayClear(wbPos src.XPos, a ir.Node, nrange *ir.RangeStmt) ir.Node {
// i = len(a) - 1 // i = len(a) - 1
// } // }
n := ir.NewIfStmt(base.Pos, nil, nil, nil) n := ir.NewIfStmt(base.Pos, nil, nil, nil)
n.Cond = ir.NewBinaryExpr(base.Pos, ir.ONE, ir.NewUnaryExpr(base.Pos, ir.OLEN, a), ir.NewInt(0)) n.Cond = ir.NewBinaryExpr(base.Pos, ir.ONE, ir.NewUnaryExpr(base.Pos, ir.OLEN, a), ir.NewInt(base.Pos, 0))
// hp = &a[0] // hp = &a[0]
hp := typecheck.Temp(types.Types[types.TUNSAFEPTR]) hp := typecheck.Temp(types.Types[types.TUNSAFEPTR])
ix := ir.NewIndexExpr(base.Pos, a, ir.NewInt(0)) ix := ir.NewIndexExpr(base.Pos, a, ir.NewInt(base.Pos, 0))
ix.SetBounded(true) ix.SetBounded(true)
addr := typecheck.ConvNop(typecheck.NodAddr(ix), types.Types[types.TUNSAFEPTR]) addr := typecheck.ConvNop(typecheck.NodAddr(ix), types.Types[types.TUNSAFEPTR])
n.Body.Append(ir.NewAssignStmt(base.Pos, hp, addr)) n.Body.Append(ir.NewAssignStmt(base.Pos, hp, addr))
// hn = len(a) * sizeof(elem(a)) // hn = len(a) * sizeof(elem(a))
hn := typecheck.Temp(types.Types[types.TUINTPTR]) hn := typecheck.Temp(types.Types[types.TUINTPTR])
mul := typecheck.Conv(ir.NewBinaryExpr(base.Pos, ir.OMUL, ir.NewUnaryExpr(base.Pos, ir.OLEN, a), ir.NewInt(elemsize)), types.Types[types.TUINTPTR]) mul := typecheck.Conv(ir.NewBinaryExpr(base.Pos, ir.OMUL, ir.NewUnaryExpr(base.Pos, ir.OLEN, a), ir.NewInt(base.Pos, elemsize)), types.Types[types.TUINTPTR])
n.Body.Append(ir.NewAssignStmt(base.Pos, hn, mul)) n.Body.Append(ir.NewAssignStmt(base.Pos, hn, mul))
var fn ir.Node var fn ir.Node
@ -553,7 +553,7 @@ func arrayClear(wbPos src.XPos, a ir.Node, nrange *ir.RangeStmt) ir.Node {
// For array range clear, also set "i = len(a) - 1" // For array range clear, also set "i = len(a) - 1"
if nrange != nil { if nrange != nil {
idx := ir.NewAssignStmt(base.Pos, nrange.Key, ir.NewBinaryExpr(base.Pos, ir.OSUB, ir.NewUnaryExpr(base.Pos, ir.OLEN, a), ir.NewInt(1))) idx := ir.NewAssignStmt(base.Pos, nrange.Key, ir.NewBinaryExpr(base.Pos, ir.OSUB, ir.NewUnaryExpr(base.Pos, ir.OLEN, a), ir.NewInt(base.Pos, 1)))
n.Body.Append(idx) n.Body.Append(idx)
} }
@ -570,7 +570,7 @@ func addptr(p ir.Node, n int64) ir.Node {
p = ir.NewConvExpr(base.Pos, ir.OCONVNOP, nil, p) p = ir.NewConvExpr(base.Pos, ir.OCONVNOP, nil, p)
p.SetType(types.Types[types.TUINTPTR]) p.SetType(types.Types[types.TUINTPTR])
p = ir.NewBinaryExpr(base.Pos, ir.OADD, p, ir.NewInt(n)) p = ir.NewBinaryExpr(base.Pos, ir.OADD, p, ir.NewInt(base.Pos, n))
p = ir.NewConvExpr(base.Pos, ir.OCONVNOP, nil, p) p = ir.NewConvExpr(base.Pos, ir.OCONVNOP, nil, p)
p.SetType(t) p.SetType(t)

View File

@ -157,7 +157,7 @@ func walkSelectCases(cases []*ir.CommClause) []ir.Node {
var pc0, pcs ir.Node var pc0, pcs ir.Node
if base.Flag.Race { if base.Flag.Race {
pcs = typecheck.Temp(types.NewArray(types.Types[types.TUINTPTR], int64(ncas))) pcs = typecheck.Temp(types.NewArray(types.Types[types.TUINTPTR], int64(ncas)))
pc0 = typecheck.Expr(typecheck.NodAddr(ir.NewIndexExpr(base.Pos, pcs, ir.NewInt(0)))) pc0 = typecheck.Expr(typecheck.NodAddr(ir.NewIndexExpr(base.Pos, pcs, ir.NewInt(base.Pos, 0))))
} else { } else {
pc0 = typecheck.NodNil() pc0 = typecheck.NodNil()
} }
@ -196,7 +196,7 @@ func walkSelectCases(cases []*ir.CommClause) []ir.Node {
casorder[i] = cas casorder[i] = cas
setField := func(f string, val ir.Node) { setField := func(f string, val ir.Node) {
r := ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, ir.NewIndexExpr(base.Pos, selv, ir.NewInt(int64(i))), typecheck.Lookup(f)), val) r := ir.NewAssignStmt(base.Pos, ir.NewSelectorExpr(base.Pos, ir.ODOT, ir.NewIndexExpr(base.Pos, selv, ir.NewInt(base.Pos, int64(i))), typecheck.Lookup(f)), val)
init = append(init, typecheck.Stmt(r)) init = append(init, typecheck.Stmt(r))
} }
@ -210,7 +210,7 @@ func walkSelectCases(cases []*ir.CommClause) []ir.Node {
// TODO(mdempsky): There should be a cleaner way to // TODO(mdempsky): There should be a cleaner way to
// handle this. // handle this.
if base.Flag.Race { if base.Flag.Race {
r := mkcallstmt("selectsetpc", typecheck.NodAddr(ir.NewIndexExpr(base.Pos, pcs, ir.NewInt(int64(i))))) r := mkcallstmt("selectsetpc", typecheck.NodAddr(ir.NewIndexExpr(base.Pos, pcs, ir.NewInt(base.Pos, int64(i)))))
init = append(init, r) init = append(init, r)
} }
} }
@ -226,7 +226,7 @@ func walkSelectCases(cases []*ir.CommClause) []ir.Node {
r.Lhs = []ir.Node{chosen, recvOK} r.Lhs = []ir.Node{chosen, recvOK}
fn := typecheck.LookupRuntime("selectgo") fn := typecheck.LookupRuntime("selectgo")
var fnInit ir.Nodes var fnInit ir.Nodes
r.Rhs = []ir.Node{mkcall1(fn, fn.Type().Results(), &fnInit, bytePtrToIndex(selv, 0), bytePtrToIndex(order, 0), pc0, ir.NewInt(int64(nsends)), ir.NewInt(int64(nrecvs)), ir.NewBool(dflt == nil))} r.Rhs = []ir.Node{mkcall1(fn, fn.Type().Results(), &fnInit, bytePtrToIndex(selv, 0), bytePtrToIndex(order, 0), pc0, ir.NewInt(base.Pos, int64(nsends)), ir.NewInt(base.Pos, int64(nrecvs)), ir.NewBool(base.Pos, dflt == nil))}
init = append(init, fnInit...) init = append(init, fnInit...)
init = append(init, typecheck.Stmt(r)) init = append(init, typecheck.Stmt(r))
@ -261,7 +261,7 @@ func walkSelectCases(cases []*ir.CommClause) []ir.Node {
if dflt != nil { if dflt != nil {
ir.SetPos(dflt) ir.SetPos(dflt)
dispatch(ir.NewBinaryExpr(base.Pos, ir.OLT, chosen, ir.NewInt(0)), dflt) dispatch(ir.NewBinaryExpr(base.Pos, ir.OLT, chosen, ir.NewInt(base.Pos, 0)), dflt)
} }
for i, cas := range casorder { for i, cas := range casorder {
ir.SetPos(cas) ir.SetPos(cas)
@ -269,7 +269,7 @@ func walkSelectCases(cases []*ir.CommClause) []ir.Node {
dispatch(nil, cas) dispatch(nil, cas)
break break
} }
dispatch(ir.NewBinaryExpr(base.Pos, ir.OEQ, chosen, ir.NewInt(int64(i))), cas) dispatch(ir.NewBinaryExpr(base.Pos, ir.OEQ, chosen, ir.NewInt(base.Pos, int64(i))), cas)
} }
return init return init
@ -277,7 +277,7 @@ func walkSelectCases(cases []*ir.CommClause) []ir.Node {
// bytePtrToIndex returns a Node representing "(*byte)(&n[i])". // bytePtrToIndex returns a Node representing "(*byte)(&n[i])".
func bytePtrToIndex(n ir.Node, i int64) ir.Node { func bytePtrToIndex(n ir.Node, i int64) ir.Node {
s := typecheck.NodAddr(ir.NewIndexExpr(base.Pos, n, ir.NewInt(i))) s := typecheck.NodAddr(ir.NewIndexExpr(base.Pos, n, ir.NewInt(base.Pos, i)))
t := types.NewPtr(types.Types[types.TUINT8]) t := types.NewPtr(types.Types[types.TUINT8])
return typecheck.ConvNop(s, t) return typecheck.ConvNop(s, t)
} }

View File

@ -42,7 +42,7 @@ func walkSwitchExpr(sw *ir.SwitchStmt) {
// convert switch {...} to switch true {...} // convert switch {...} to switch true {...}
if cond == nil { if cond == nil {
cond = ir.NewBool(true) cond = ir.NewBool(base.Pos, true)
cond = typecheck.Expr(cond) cond = typecheck.Expr(cond)
cond = typecheck.DefaultLit(cond, nil) cond = typecheck.DefaultLit(cond, nil)
} }
@ -620,13 +620,13 @@ func (s *typeSwitch) flush() {
// TODO: figure out if we could use a jump table using some low bits of the type hashes. // TODO: figure out if we could use a jump table using some low bits of the type hashes.
binarySearch(len(cc), &s.done, binarySearch(len(cc), &s.done,
func(i int) ir.Node { func(i int) ir.Node {
return ir.NewBinaryExpr(base.Pos, ir.OLE, s.hashname, ir.NewInt(int64(cc[i-1].hash))) return ir.NewBinaryExpr(base.Pos, ir.OLE, s.hashname, ir.NewInt(base.Pos, int64(cc[i-1].hash)))
}, },
func(i int, nif *ir.IfStmt) { func(i int, nif *ir.IfStmt) {
// TODO(mdempsky): Omit hash equality check if // TODO(mdempsky): Omit hash equality check if
// there's only one type. // there's only one type.
c := cc[i] c := cc[i]
nif.Cond = ir.NewBinaryExpr(base.Pos, ir.OEQ, s.hashname, ir.NewInt(int64(c.hash))) nif.Cond = ir.NewBinaryExpr(base.Pos, ir.OEQ, s.hashname, ir.NewInt(base.Pos, int64(c.hash)))
nif.Body.Append(c.body.Take()...) nif.Body.Append(c.body.Take()...)
}, },
) )
@ -737,9 +737,9 @@ func stringSearch(expr ir.Node, cc []exprClause, out *ir.Nodes) {
slice := ir.NewConvExpr(base.Pos, ir.OSTR2BYTESTMP, types.NewSlice(types.Types[types.TINT8]), expr) slice := ir.NewConvExpr(base.Pos, ir.OSTR2BYTESTMP, types.NewSlice(types.Types[types.TINT8]), expr)
slice.SetTypecheck(1) // legacy typechecker doesn't handle this op slice.SetTypecheck(1) // legacy typechecker doesn't handle this op
// Load the byte we're splitting on. // Load the byte we're splitting on.
load := ir.NewIndexExpr(base.Pos, slice, ir.NewInt(int64(bestIdx))) load := ir.NewIndexExpr(base.Pos, slice, ir.NewInt(base.Pos, int64(bestIdx)))
// Compare with the value we're splitting on. // Compare with the value we're splitting on.
cmp := ir.Node(ir.NewBinaryExpr(base.Pos, ir.OLE, load, ir.NewInt(int64(bestByte)))) cmp := ir.Node(ir.NewBinaryExpr(base.Pos, ir.OLE, load, ir.NewInt(base.Pos, int64(bestByte))))
cmp = typecheck.DefaultLit(typecheck.Expr(cmp), nil) cmp = typecheck.DefaultLit(typecheck.Expr(cmp), nil)
nif := ir.NewIfStmt(base.Pos, cmp, nil, nil) nif := ir.NewIfStmt(base.Pos, cmp, nil, nil)