Commit c3dfad5d authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: change Oconv to take an Op parameter

Eliminates type conversions in a bunch of Oconv(int(n.Op), ...) calls.

Notably, this identified a misuse of Oconv in amd64/gsubr.go to try to
print an assembly instruction op instead of a compiler node op.

Change-Id: I93b5aa49fe14a5eaf868b05426d3b8cd8ab52bc5
Reviewed-on: https://go-review.googlesource.com/20298
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 0de0cafb
......@@ -722,7 +722,7 @@ func optoas(op gc.Op, t *gc.Type) int {
a := obj.AXXX
switch uint32(op)<<16 | uint32(gc.Simtype[t.Etype]) {
default:
gc.Fatalf("optoas: no entry %v-%v", gc.Oconv(int(op), 0), t)
gc.Fatalf("optoas: no entry %v-%v", gc.Oconv(op, 0), t)
case OADDR_ | gc.TPTR32:
a = x86.ALEAL
......@@ -1264,7 +1264,7 @@ func jmptoset(jmp int) int {
case x86.AJPS:
return x86.ASETPS
}
gc.Fatalf("jmptoset: no entry for %v", gc.Oconv(jmp, 0))
gc.Fatalf("jmptoset: no entry for %v", jmp)
panic("unreachable")
}
......
......@@ -19,7 +19,7 @@ func cgen64(n *gc.Node, res *gc.Node) {
if res.Op != gc.OINDREG && res.Op != gc.ONAME {
gc.Dump("n", n)
gc.Dump("res", res)
gc.Fatalf("cgen64 %v of %v", gc.Oconv(int(n.Op), 0), gc.Oconv(int(res.Op), 0))
gc.Fatalf("cgen64 %v of %v", gc.Oconv(n.Op, 0), gc.Oconv(res.Op, 0))
}
l := n.Left
......@@ -35,7 +35,7 @@ func cgen64(n *gc.Node, res *gc.Node) {
split64(l, &lo1, &hi1)
switch n.Op {
default:
gc.Fatalf("cgen64 %v", gc.Oconv(int(n.Op), 0))
gc.Fatalf("cgen64 %v", gc.Oconv(n.Op, 0))
case gc.OMINUS:
var lo2 gc.Node
......@@ -793,7 +793,7 @@ func cmp64(nl *gc.Node, nr *gc.Node, op gc.Op, likely int, to *obj.Prog) {
var br *obj.Prog
switch op {
default:
gc.Fatalf("cmp64 %v %v", gc.Oconv(int(op), 0), t)
gc.Fatalf("cmp64 %v %v", gc.Oconv(op, 0), t)
// cmp hi
// bne L
......
......@@ -719,7 +719,7 @@ func raddr(n *gc.Node, p *obj.Prog) {
gc.Naddr(&a, n)
if a.Type != obj.TYPE_REG {
if n != nil {
gc.Fatalf("bad in raddr: %v", gc.Oconv(int(n.Op), 0))
gc.Fatalf("bad in raddr: %v", gc.Oconv(n.Op, 0))
} else {
gc.Fatalf("bad in raddr: <null>")
}
......@@ -790,7 +790,7 @@ func optoas(op gc.Op, t *gc.Type) int {
a := obj.AXXX
switch uint32(op)<<16 | uint32(gc.Simtype[t.Etype]) {
default:
gc.Fatalf("optoas: no entry %v-%v etype %v simtype %v", gc.Oconv(int(op), 0), t, gc.Types[t.Etype], gc.Types[gc.Simtype[t.Etype]])
gc.Fatalf("optoas: no entry %v-%v etype %v simtype %v", gc.Oconv(op, 0), t, gc.Types[t.Etype], gc.Types[gc.Simtype[t.Etype]])
/* case CASE(OADDR, TPTR32):
a = ALEAL;
......
......@@ -567,7 +567,7 @@ func raddr(n *gc.Node, p *obj.Prog) {
gc.Naddr(&a, n)
if a.Type != obj.TYPE_REG {
if n != nil {
gc.Fatalf("bad in raddr: %v", gc.Oconv(int(n.Op), 0))
gc.Fatalf("bad in raddr: %v", gc.Oconv(n.Op, 0))
} else {
gc.Fatalf("bad in raddr: <null>")
}
......@@ -579,7 +579,7 @@ func raddr(n *gc.Node, p *obj.Prog) {
func gcmp(as int, lhs *gc.Node, rhs *gc.Node) *obj.Prog {
if lhs.Op != gc.OREGISTER {
gc.Fatalf("bad operands to gcmp: %v %v", gc.Oconv(int(lhs.Op), 0), gc.Oconv(int(rhs.Op), 0))
gc.Fatalf("bad operands to gcmp: %v %v", gc.Oconv(lhs.Op, 0), gc.Oconv(rhs.Op, 0))
}
p := rawgins(as, rhs, nil)
......@@ -622,7 +622,7 @@ func optoas(op gc.Op, t *gc.Type) int {
a := int(obj.AXXX)
switch uint32(op)<<16 | uint32(gc.Simtype[t.Etype]) {
default:
gc.Fatalf("optoas: no entry for op=%v type=%v", gc.Oconv(int(op), 0), t)
gc.Fatalf("optoas: no entry for op=%v type=%v", gc.Oconv(op, 0), t)
case OEQ_ | gc.TBOOL,
OEQ_ | gc.TINT8,
......
......@@ -221,7 +221,7 @@ func Export(out *obj.Biobuf, trace bool) int {
types = append(types, t)
default:
Fatalf("exporter: unexpected export symbol: %v %v", Oconv(int(n.Op), 0), sym)
Fatalf("exporter: unexpected export symbol: %v %v", Oconv(n.Op, 0), sym)
}
}
}
......
......@@ -1792,7 +1792,7 @@ func bgenx(n, res *Node, wantTrue bool, likely int, to *obj.Prog) {
}
if n.Type.Etype != TBOOL {
Fatalf("bgen: bad type %v for %v", n.Type, Oconv(int(n.Op), 0))
Fatalf("bgen: bad type %v for %v", n.Type, Oconv(n.Op, 0))
}
for n.Op == OCONVNOP {
......@@ -2439,12 +2439,12 @@ func Ginscall(f *Node, proc int) {
func cgen_callinter(n *Node, res *Node, proc int) {
i := n.Left
if i.Op != ODOTINTER {
Fatalf("cgen_callinter: not ODOTINTER %v", Oconv(int(i.Op), 0))
Fatalf("cgen_callinter: not ODOTINTER %v", Oconv(i.Op, 0))
}
f := i.Right // field
if f.Op != ONAME {
Fatalf("cgen_callinter: not ONAME %v", Oconv(int(f.Op), 0))
Fatalf("cgen_callinter: not ONAME %v", Oconv(f.Op, 0))
}
i = i.Left // interface
......
......@@ -648,7 +648,7 @@ func evconst(n *Node) {
switch uint32(n.Op)<<16 | uint32(v.Ctype()) {
default:
if n.Diag == 0 {
Yyerror("illegal constant expression %v %v", Oconv(int(n.Op), 0), nl.Type)
Yyerror("illegal constant expression %v %v", Oconv(n.Op, 0), nl.Type)
n.Diag = 1
}
return
......@@ -1135,7 +1135,7 @@ setfalse:
illegal:
if n.Diag == 0 {
Yyerror("illegal constant expression: %v %v %v", nl.Type, Oconv(int(n.Op), 0), nr.Type)
Yyerror("illegal constant expression: %v %v %v", nl.Type, Oconv(n.Op, 0), nr.Type)
n.Diag = 1
}
}
......
......@@ -398,7 +398,7 @@ func Complexgen(n *Node, res *Node) {
switch n.Op {
default:
Dump("complexgen: unknown op", n)
Fatalf("complexgen: unknown op %v", Oconv(int(n.Op), 0))
Fatalf("complexgen: unknown op %v", Oconv(n.Op, 0))
case ODOT,
ODOTPTR,
......@@ -457,7 +457,7 @@ func Complexgen(n *Node, res *Node) {
switch n.Op {
default:
Fatalf("complexgen: unknown op %v", Oconv(int(n.Op), 0))
Fatalf("complexgen: unknown op %v", Oconv(n.Op, 0))
case OCONV:
Complexmove(nl, res)
......
......@@ -564,7 +564,7 @@ func funchdr(n *Node) {
func funcargs(nt *Node) {
if nt.Op != OTFUNC {
Fatalf("funcargs %v", Oconv(int(nt.Op), 0))
Fatalf("funcargs %v", Oconv(nt.Op, 0))
}
// re-start the variable generation number
......@@ -578,7 +578,7 @@ func funcargs(nt *Node) {
if nt.Left != nil {
n := nt.Left
if n.Op != ODCLFIELD {
Fatalf("funcargs receiver %v", Oconv(int(n.Op), 0))
Fatalf("funcargs receiver %v", Oconv(n.Op, 0))
}
if n.Left != nil {
n.Left.Op = ONAME
......@@ -595,7 +595,7 @@ func funcargs(nt *Node) {
for it := nodeSeqIterate(nt.List); !it.Done(); it.Next() {
n = it.N()
if n.Op != ODCLFIELD {
Fatalf("funcargs in %v", Oconv(int(n.Op), 0))
Fatalf("funcargs in %v", Oconv(n.Op, 0))
}
if n.Left != nil {
n.Left.Op = ONAME
......@@ -616,7 +616,7 @@ func funcargs(nt *Node) {
n = it.N()
if n.Op != ODCLFIELD {
Fatalf("funcargs out %v", Oconv(int(n.Op), 0))
Fatalf("funcargs out %v", Oconv(n.Op, 0))
}
if n.Left == nil {
......
......@@ -943,8 +943,8 @@ func escassign(e *EscState, dst *Node, src *Node) {
if Debug['m'] > 1 {
fmt.Printf("%v:[%d] %v escassign: %v(%v)[%v] = %v(%v)[%v]\n",
linestr(lineno), e.loopdepth, funcSym(Curfn),
Nconv(dst, obj.FmtShort), Jconv(dst, obj.FmtShort), Oconv(int(dst.Op), 0),
Nconv(src, obj.FmtShort), Jconv(src, obj.FmtShort), Oconv(int(src.Op), 0))
Nconv(dst, obj.FmtShort), Jconv(dst, obj.FmtShort), Oconv(dst.Op, 0),
Nconv(src, obj.FmtShort), Jconv(src, obj.FmtShort), Oconv(src.Op, 0))
}
setlineno(dst)
......@@ -1639,7 +1639,7 @@ func escwalkBody(e *EscState, level Level, dst *Node, src *Node, extraloopdepth
if Debug['m'] > 1 {
fmt.Printf("escwalk: level:%d depth:%d %.*s op=%v %v(%v) scope:%v[%d] extraloopdepth=%v\n",
level, e.pdepth, e.pdepth, "\t\t\t\t\t\t\t\t\t\t", Oconv(int(src.Op), 0), Nconv(src, obj.FmtShort), Jconv(src, obj.FmtShort), e.curfnSym(src), srcE.Escloopdepth, extraloopdepth)
level, e.pdepth, e.pdepth, "\t\t\t\t\t\t\t\t\t\t", Oconv(src.Op, 0), Nconv(src, obj.FmtShort), Jconv(src, obj.FmtShort), e.curfnSym(src), srcE.Escloopdepth, extraloopdepth)
}
e.pdepth++
......
......@@ -338,7 +338,7 @@ func dumpsym(s *Sym) {
switch s.Def.Op {
default:
Yyerror("unexpected export symbol: %v %v", Oconv(int(s.Def.Op), 0), s)
Yyerror("unexpected export symbol: %v %v", Oconv(s.Def.Op, 0), s)
case OLITERAL:
dumpexportconst(s)
......
......@@ -174,14 +174,14 @@ var goopnames = []string{
}
// Fmt "%O": Node opcodes
func Oconv(o int, flag int) string {
func Oconv(o Op, flag int) string {
if (flag&obj.FmtSharp != 0) || fmtmode != FDbg {
if o >= 0 && o < len(goopnames) && goopnames[o] != "" {
if o >= 0 && int(o) < len(goopnames) && goopnames[o] != "" {
return goopnames[o]
}
}
if o >= 0 && o < len(opnames) && opnames[o] != "" {
if o >= 0 && int(o) < len(opnames) && opnames[o] != "" {
return opnames[o]
}
......@@ -859,7 +859,7 @@ func stmtfmt(n *Node) string {
break
}
f += fmt.Sprintf("%v %v= %v", n.Left, Oconv(int(n.Etype), obj.FmtSharp), n.Right)
f += fmt.Sprintf("%v %v= %v", n.Left, Oconv(Op(n.Etype), obj.FmtSharp), n.Right)
case OAS2:
if n.Colas && !complexinit {
......@@ -933,11 +933,11 @@ func stmtfmt(n *Node) string {
case OSELECT, OSWITCH:
if fmtmode == FErr {
f += fmt.Sprintf("%v statement", Oconv(int(n.Op), 0))
f += fmt.Sprintf("%v statement", Oconv(n.Op, 0))
break
}
f += Oconv(int(n.Op), obj.FmtSharp)
f += Oconv(n.Op, obj.FmtSharp)
if simpleinit {
f += fmt.Sprintf(" %v;", nodeSeqFirst(n.Ninit))
}
......@@ -960,9 +960,9 @@ func stmtfmt(n *Node) string {
OFALL,
OXFALL:
if n.Left != nil {
f += fmt.Sprintf("%v %v", Oconv(int(n.Op), obj.FmtSharp), n.Left)
f += fmt.Sprintf("%v %v", Oconv(n.Op, obj.FmtSharp), n.Left)
} else {
f += Oconv(int(n.Op), obj.FmtSharp)
f += Oconv(n.Op, obj.FmtSharp)
}
case OEMPTY:
......@@ -1341,7 +1341,7 @@ func exprfmt(n *Node, prec int) string {
return f
case OCOPY, OCOMPLEX:
return fmt.Sprintf("%v(%v, %v)", Oconv(int(n.Op), obj.FmtSharp), n.Left, n.Right)
return fmt.Sprintf("%v(%v, %v)", Oconv(n.Op, obj.FmtSharp), n.Left, n.Right)
case OCONV,
OCONVIFACE,
......@@ -1373,12 +1373,12 @@ func exprfmt(n *Node, prec int) string {
OPRINT,
OPRINTN:
if n.Left != nil {
return fmt.Sprintf("%v(%v)", Oconv(int(n.Op), obj.FmtSharp), n.Left)
return fmt.Sprintf("%v(%v)", Oconv(n.Op, obj.FmtSharp), n.Left)
}
if n.Isddd {
return fmt.Sprintf("%v(%v...)", Oconv(int(n.Op), obj.FmtSharp), Hconv(n.List, obj.FmtComma))
return fmt.Sprintf("%v(%v...)", Oconv(n.Op, obj.FmtSharp), Hconv(n.List, obj.FmtComma))
}
return fmt.Sprintf("%v(%v)", Oconv(int(n.Op), obj.FmtSharp), Hconv(n.List, obj.FmtComma))
return fmt.Sprintf("%v(%v)", Oconv(n.Op, obj.FmtSharp), Hconv(n.List, obj.FmtComma))
case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG:
var f string
......@@ -1412,9 +1412,9 @@ func exprfmt(n *Node, prec int) string {
ORECV:
var f string
if n.Left.Op == n.Op {
f += fmt.Sprintf("%v ", Oconv(int(n.Op), obj.FmtSharp))
f += fmt.Sprintf("%v ", Oconv(n.Op, obj.FmtSharp))
} else {
f += Oconv(int(n.Op), obj.FmtSharp)
f += Oconv(n.Op, obj.FmtSharp)
}
f += exprfmt(n.Left, nprec+1)
return f
......@@ -1443,7 +1443,7 @@ func exprfmt(n *Node, prec int) string {
var f string
f += exprfmt(n.Left, nprec)
f += fmt.Sprintf(" %v ", Oconv(int(n.Op), obj.FmtSharp))
f += fmt.Sprintf(" %v ", Oconv(n.Op, obj.FmtSharp))
f += exprfmt(n.Right, nprec+1)
return f
......@@ -1464,12 +1464,12 @@ func exprfmt(n *Node, prec int) string {
var f string
f += exprfmt(n.Left, nprec)
// TODO(marvin): Fix Node.EType type union.
f += fmt.Sprintf(" %v ", Oconv(int(n.Etype), obj.FmtSharp))
f += fmt.Sprintf(" %v ", Oconv(Op(n.Etype), obj.FmtSharp))
f += exprfmt(n.Right, nprec+1)
return f
}
return fmt.Sprintf("<node %v>", Oconv(int(n.Op), 0))
return fmt.Sprintf("<node %v>", Oconv(n.Op, 0))
}
func nodefmt(n *Node, flag int) string {
......@@ -1524,40 +1524,40 @@ func nodedump(n *Node, flag int) string {
}
if nodeSeqLen(n.Ninit) != 0 {
fmt.Fprintf(&buf, "%v-init%v", Oconv(int(n.Op), 0), n.Ninit)
fmt.Fprintf(&buf, "%v-init%v", Oconv(n.Op, 0), n.Ninit)
indent(&buf)
}
}
switch n.Op {
default:
fmt.Fprintf(&buf, "%v%v", Oconv(int(n.Op), 0), Jconv(n, 0))
fmt.Fprintf(&buf, "%v%v", Oconv(n.Op, 0), Jconv(n, 0))
case OREGISTER, OINDREG:
fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), obj.Rconv(int(n.Reg)), Jconv(n, 0))
fmt.Fprintf(&buf, "%v-%v%v", Oconv(n.Op, 0), obj.Rconv(int(n.Reg)), Jconv(n, 0))
case OLITERAL:
fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), Vconv(n.Val(), 0), Jconv(n, 0))
fmt.Fprintf(&buf, "%v-%v%v", Oconv(n.Op, 0), Vconv(n.Val(), 0), Jconv(n, 0))
case ONAME, ONONAME:
if n.Sym != nil {
fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), n.Sym, Jconv(n, 0))
fmt.Fprintf(&buf, "%v-%v%v", Oconv(n.Op, 0), n.Sym, Jconv(n, 0))
} else {
fmt.Fprintf(&buf, "%v%v", Oconv(int(n.Op), 0), Jconv(n, 0))
fmt.Fprintf(&buf, "%v%v", Oconv(n.Op, 0), Jconv(n, 0))
}
if recur && n.Type == nil && n.Name != nil && n.Name.Param != nil && n.Name.Param.Ntype != nil {
indent(&buf)
fmt.Fprintf(&buf, "%v-ntype%v", Oconv(int(n.Op), 0), n.Name.Param.Ntype)
fmt.Fprintf(&buf, "%v-ntype%v", Oconv(n.Op, 0), n.Name.Param.Ntype)
}
case OASOP:
fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), Oconv(int(n.Etype), 0), Jconv(n, 0))
fmt.Fprintf(&buf, "%v-%v%v", Oconv(n.Op, 0), Oconv(Op(n.Etype), 0), Jconv(n, 0))
case OTYPE:
fmt.Fprintf(&buf, "%v %v%v type=%v", Oconv(int(n.Op), 0), n.Sym, Jconv(n, 0), n.Type)
fmt.Fprintf(&buf, "%v %v%v type=%v", Oconv(n.Op, 0), n.Sym, Jconv(n, 0), n.Type)
if recur && n.Type == nil && n.Name.Param.Ntype != nil {
indent(&buf)
fmt.Fprintf(&buf, "%v-ntype%v", Oconv(int(n.Op), 0), n.Name.Param.Ntype)
fmt.Fprintf(&buf, "%v-ntype%v", Oconv(n.Op, 0), n.Name.Param.Ntype)
}
}
......@@ -1578,17 +1578,17 @@ func nodedump(n *Node, flag int) string {
}
if nodeSeqLen(n.List) != 0 {
indent(&buf)
fmt.Fprintf(&buf, "%v-list%v", Oconv(int(n.Op), 0), n.List)
fmt.Fprintf(&buf, "%v-list%v", Oconv(n.Op, 0), n.List)
}
if nodeSeqLen(n.Rlist) != 0 {
indent(&buf)
fmt.Fprintf(&buf, "%v-rlist%v", Oconv(int(n.Op), 0), n.Rlist)
fmt.Fprintf(&buf, "%v-rlist%v", Oconv(n.Op, 0), n.Rlist)
}
if len(n.Nbody.Slice()) != 0 {
indent(&buf)
fmt.Fprintf(&buf, "%v-body%v", Oconv(int(n.Op), 0), n.Nbody)
fmt.Fprintf(&buf, "%v-body%v", Oconv(n.Op, 0), n.Nbody)
}
}
......
......@@ -225,7 +225,7 @@ func Genlist(l nodesOrNodeList) {
func cgen_proc(n *Node, proc int) {
switch n.Left.Op {
default:
Fatalf("cgen_proc: unknown call %v", Oconv(int(n.Left.Op), 0))
Fatalf("cgen_proc: unknown call %v", Oconv(n.Left.Op, 0))
case OCALLMETH:
cgen_callmeth(n.Left, proc)
......
......@@ -322,7 +322,7 @@ func Naddr(a *obj.Addr, n *Node) {
a := a // copy to let escape into Ctxt.Dconv
Debug['h'] = 1
Dump("naddr", n)
Fatalf("naddr: bad %v %v", Oconv(int(n.Op), 0), Ctxt.Dconv(a))
Fatalf("naddr: bad %v %v", Oconv(n.Op, 0), Ctxt.Dconv(a))
case OREGISTER:
a.Type = obj.TYPE_REG
......@@ -423,7 +423,7 @@ func Naddr(a *obj.Addr, n *Node) {
if n.Left.Type.Etype != TSTRUCT || n.Left.Type.Type.Sym != n.Right.Sym {
Debug['h'] = 1
Dump("naddr", n)
Fatalf("naddr: bad %v %v", Oconv(int(n.Op), 0), Ctxt.Dconv(a))
Fatalf("naddr: bad %v %v", Oconv(n.Op, 0), Ctxt.Dconv(a))
}
Naddr(a, n.Left)
......@@ -466,7 +466,7 @@ func Naddr(a *obj.Addr, n *Node) {
}
if a.Type != obj.TYPE_MEM {
a := a // copy to let escape into Ctxt.Dconv
Fatalf("naddr: OADDR %v (from %v)", Ctxt.Dconv(a), Oconv(int(n.Left.Op), 0))
Fatalf("naddr: OADDR %v (from %v)", Ctxt.Dconv(a), Oconv(n.Left.Op, 0))
}
a.Type = obj.TYPE_ADDR
......
......@@ -174,7 +174,7 @@ func ordersafeexpr(n *Node, order *Order) *Node {
return a
}
Fatalf("ordersafeexpr %v", Oconv(int(n.Op), 0))
Fatalf("ordersafeexpr %v", Oconv(n.Op, 0))
return nil // not reached
}
......@@ -427,7 +427,7 @@ func ordercall(n *Node, order *Order) {
func ordermapassign(n *Node, order *Order) {
switch n.Op {
default:
Fatalf("ordermapassign %v", Oconv(int(n.Op), 0))
Fatalf("ordermapassign %v", Oconv(n.Op, 0))
case OAS:
order.out = append(order.out, n)
......@@ -486,7 +486,7 @@ func orderstmt(n *Node, order *Order) {
switch n.Op {
default:
Fatalf("orderstmt %v", Oconv(int(n.Op), 0))
Fatalf("orderstmt %v", Oconv(n.Op, 0))
case OVARKILL, OVARLIVE:
order.out = append(order.out, n)
......@@ -802,7 +802,7 @@ func orderstmt(n *Node, order *Order) {
var r *Node
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
if it.N().Op != OXCASE {
Fatalf("order select case %v", Oconv(int(it.N().Op), 0))
Fatalf("order select case %v", Oconv(it.N().Op, 0))
}
r = it.N().Left
setlineno(it.N())
......@@ -815,7 +815,7 @@ func orderstmt(n *Node, order *Order) {
if r != nil {
switch r.Op {
default:
Yyerror("unknown op in select %v", Oconv(int(r.Op), 0))
Yyerror("unknown op in select %v", Oconv(r.Op, 0))
Dump("select case", r)
// If this is case x := <-ch or case x, y := <-ch, the case has
......@@ -957,7 +957,7 @@ func orderstmt(n *Node, order *Order) {
orderexpr(&n.Left, order, nil)
for it := nodeSeqIterate(n.List); !it.Done(); it.Next() {
if it.N().Op != OXCASE {
Fatalf("order switch case %v", Oconv(int(it.N().Op), 0))
Fatalf("order switch case %v", Oconv(it.N().Op, 0))
}
orderexprlistinplace(it.N().List, order)
orderblockNodes(&it.N().Nbody)
......
......@@ -90,7 +90,7 @@ func gvardefx(n *Node, as int) {
Fatalf("gvardef nil")
}
if n.Op != ONAME {
Yyerror("gvardef %v; %v", Oconv(int(n.Op), obj.FmtSharp), n)
Yyerror("gvardef %v; %v", Oconv(n.Op, obj.FmtSharp), n)
return
}
......
......@@ -135,7 +135,7 @@ func instrumentnode(np **Node, init nodesOrNodeListPtr, wr int, skip int) {
switch n.Op {
default:
Fatalf("instrument: unknown node type %v", Oconv(int(n.Op), 0))
Fatalf("instrument: unknown node type %v", Oconv(n.Op, 0))
case OAS, OASWB, OAS2FUNC:
instrumentnode(&n.Left, init, 1, 0)
......@@ -364,13 +364,13 @@ func instrumentnode(np **Node, init nodesOrNodeListPtr, wr int, skip int) {
OAS2RECV,
OAS2MAPR,
OASOP:
Yyerror("instrument: %v must be lowered by now", Oconv(int(n.Op), 0))
Yyerror("instrument: %v must be lowered by now", Oconv(n.Op, 0))
goto ret
// impossible nodes: only appear in backend.
case ORROTC, OEXTEND:
Yyerror("instrument: %v cannot exist now", Oconv(int(n.Op), 0))
Yyerror("instrument: %v cannot exist now", Oconv(n.Op, 0))
goto ret
case OGETG:
......
......@@ -18,7 +18,7 @@ func typecheckselect(sel *Node) {
ncase = it.N()
setlineno(ncase)
if ncase.Op != OXCASE {
Fatalf("typecheckselect %v", Oconv(int(ncase.Op), 0))
Fatalf("typecheckselect %v", Oconv(ncase.Op, 0))
}
if nodeSeqLen(ncase.List) == 0 {
......@@ -121,7 +121,7 @@ func walkselect(sel *Node) {
var ch *Node
switch n.Op {
default:
Fatalf("select %v", Oconv(int(n.Op), 0))
Fatalf("select %v", Oconv(n.Op, 0))
// ok already
case OSEND:
......@@ -218,7 +218,7 @@ func walkselect(sel *Node) {
setNodeSeq(&r.Ninit, cas.Ninit)
switch n.Op {
default:
Fatalf("select %v", Oconv(int(n.Op), 0))
Fatalf("select %v", Oconv(n.Op, 0))
// if selectnbsend(c, v) { body } else { default body }
case OSEND:
......@@ -284,7 +284,7 @@ func walkselect(sel *Node) {
} else {
switch n.Op {
default:
Fatalf("select %v", Oconv(int(n.Op), 0))
Fatalf("select %v", Oconv(n.Op, 0))
// selectsend(sel *byte, hchan *chan any, elem *any) (selected bool);
case OSEND:
......
......@@ -2328,7 +2328,7 @@ func (s *state) call(n *Node, k callKind) *ssa.Value {
// want to set it here.
case OCALLINTER:
if fn.Op != ODOTINTER {
Fatalf("OCALLINTER: n.Left not an ODOTINTER: %v", Oconv(int(fn.Op), 0))
Fatalf("OCALLINTER: n.Left not an ODOTINTER: %v", Oconv(fn.Op, 0))
}
i := s.expr(fn.Left)
itab := s.newValue1(ssa.OpITab, Types[TUINTPTR], i)
......@@ -2558,7 +2558,7 @@ func (s *state) addr(n *Node, bounded bool) *ssa.Value {
return s.call(n, callNormal)
default:
s.Unimplementedf("unhandled addr %v", Oconv(int(n.Op), 0))
s.Unimplementedf("unhandled addr %v", Oconv(n.Op, 0))
return nil
}
}
......
......@@ -1376,9 +1376,9 @@ func printframenode(n *Node) {
}
switch n.Op {
case ONAME:
fmt.Printf("%v %v G%d %v width=%d\n", Oconv(int(n.Op), 0), n.Sym, n.Name.Vargen, n.Type, w)
fmt.Printf("%v %v G%d %v width=%d\n", Oconv(n.Op, 0), n.Sym, n.Name.Vargen, n.Type, w)
case OTYPE:
fmt.Printf("%v %v width=%d\n", Oconv(int(n.Op), 0), n.Type, w)
fmt.Printf("%v %v width=%d\n", Oconv(n.Op, 0), n.Type, w)
}
}
......@@ -1459,7 +1459,7 @@ func badtype(op Op, tl *Type, tr *Type) {
}
s := fmt_
Yyerror("illegal types for operand: %v%s", Oconv(int(op), 0), s)
Yyerror("illegal types for operand: %v%s", Oconv(op, 0), s)
}
// iterator to walk a structure declaration
......@@ -1601,7 +1601,7 @@ func Brcom(op Op) Op {
case OGE:
return OLT
}
Fatalf("brcom: no com for %v\n", Oconv(int(op), 0))
Fatalf("brcom: no com for %v\n", Oconv(op, 0))
return op
}
......@@ -1622,7 +1622,7 @@ func Brrev(op Op) Op {
case OGE:
return OLE
}
Fatalf("brrev: no rev for %v\n", Oconv(int(op), 0))
Fatalf("brrev: no rev for %v\n", Oconv(op, 0))
return op
}
......
......@@ -349,7 +349,7 @@ func casebody(sw *Node, typeswvar *Node) {
n := it.N()
setlineno(n)
if n.Op != OXCASE {
Fatalf("casebody %v", Oconv(int(n.Op), 0))
Fatalf("casebody %v", Oconv(n.Op, 0))
}
n.Op = OCASE
needvar := nodeSeqLen(n.List) != 1 || nodeSeqFirst(n.List).Op == OLITERAL
......
......@@ -273,7 +273,7 @@ OpSwitch:
default:
Dump("typecheck", n)
Fatalf("typecheck %v", Oconv(int(n.Op), 0))
Fatalf("typecheck %v", Oconv(n.Op, 0))
// names
case OLITERAL:
......@@ -592,7 +592,7 @@ OpSwitch:
aop = assignop(l.Type, r.Type, nil)
if aop != 0 {
if Isinter(r.Type) && !Isinter(l.Type) && algtype1(l.Type, nil) == ANOEQ {
Yyerror("invalid operation: %v (operator %v not defined on %s)", n, Oconv(int(op), 0), typekind(l.Type))
Yyerror("invalid operation: %v (operator %v not defined on %s)", n, Oconv(op, 0), typekind(l.Type))
n.Type = nil
return
}
......@@ -614,7 +614,7 @@ OpSwitch:
aop = assignop(r.Type, l.Type, nil)
if aop != 0 {
if Isinter(l.Type) && !Isinter(r.Type) && algtype1(r.Type, nil) == ANOEQ {
Yyerror("invalid operation: %v (operator %v not defined on %s)", n, Oconv(int(op), 0), typekind(r.Type))
Yyerror("invalid operation: %v (operator %v not defined on %s)", n, Oconv(op, 0), typekind(r.Type))
n.Type = nil
return
}
......@@ -645,7 +645,7 @@ OpSwitch:
}
if !okfor[op][et] {
Yyerror("invalid operation: %v (operator %v not defined on %s)", n, Oconv(int(op), 0), typekind(t))
Yyerror("invalid operation: %v (operator %v not defined on %s)", n, Oconv(op, 0), typekind(t))
n.Type = nil
return
}
......@@ -753,7 +753,7 @@ OpSwitch:
return
}
if !okfor[n.Op][t.Etype] {
Yyerror("invalid operation: %v %v", Oconv(int(n.Op), 0), t)
Yyerror("invalid operation: %v %v", Oconv(n.Op, 0), t)
n.Type = nil
return
}
......@@ -1369,7 +1369,7 @@ OpSwitch:
case OCAP, OLEN, OREAL, OIMAG:
ok |= Erv
if !onearg(n, "%v", Oconv(int(n.Op), 0)) {
if !onearg(n, "%v", Oconv(n.Op, 0)) {
n.Type = nil
return
}
......@@ -1438,7 +1438,7 @@ OpSwitch:
break OpSwitch
badcall1:
Yyerror("invalid argument %v for %v", Nconv(n.Left, obj.FmtLong), Oconv(int(n.Op), 0))
Yyerror("invalid argument %v for %v", Nconv(n.Left, obj.FmtLong), Oconv(n.Op, 0))
n.Type = nil
return
......@@ -1519,7 +1519,7 @@ OpSwitch:
break OpSwitch
case OCLOSE:
if !onearg(n, "%v", Oconv(int(n.Op), 0)) {
if !onearg(n, "%v", Oconv(n.Op, 0)) {
n.Type = nil
return
}
......@@ -2356,19 +2356,19 @@ func twoarg(n *Node) bool {
return true
}
if nodeSeqLen(n.List) == 0 {
Yyerror("missing argument to %v - %v", Oconv(int(n.Op), 0), n)
Yyerror("missing argument to %v - %v", Oconv(n.Op, 0), n)
return false
}
n.Left = nodeSeqFirst(n.List)
if nodeSeqLen(n.List) == 1 {
Yyerror("missing argument to %v - %v", Oconv(int(n.Op), 0), n)
Yyerror("missing argument to %v - %v", Oconv(n.Op, 0), n)
setNodeSeq(&n.List, nil)
return false
}
if nodeSeqLen(n.List) > 2 {
Yyerror("too many arguments to %v - %v", Oconv(int(n.Op), 0), n)
Yyerror("too many arguments to %v - %v", Oconv(n.Op, 0), n)
setNodeSeq(&n.List, nil)
return false
}
......@@ -2744,7 +2744,7 @@ func typecheckaste(op Op, call *Node, isddd bool, tstruct *Type, nl *NodeList, d
if call != nil {
Yyerror("invalid use of ... in call to %v", call)
} else {
Yyerror("invalid use of ... in %v", Oconv(int(op), 0))
Yyerror("invalid use of ... in %v", Oconv(op, 0))
}
}
......@@ -2764,7 +2764,7 @@ notenough:
Yyerror("not enough arguments in call to %v", call)
}
} else {
Yyerror("not enough arguments to %v", Oconv(int(op), 0))
Yyerror("not enough arguments to %v", Oconv(op, 0))
}
if n != nil {
n.Diag = 1
......@@ -2777,7 +2777,7 @@ toomany:
if call != nil {
Yyerror("too many arguments in call to %v", call)
} else {
Yyerror("too many arguments to %v", Oconv(int(op), 0))
Yyerror("too many arguments to %v", Oconv(op, 0))
}
goto out
}
......@@ -3679,7 +3679,7 @@ func typecheckdef(n *Node) *Node {
switch n.Op {
default:
Fatalf("typecheckdef %v", Oconv(int(n.Op), 0))
Fatalf("typecheckdef %v", Oconv(n.Op, 0))
// not really syms
case OGOTO, OLABEL:
......
......@@ -87,7 +87,7 @@ func unsafenmagic(nn *Node) *Node {
default:
Dump("unsafenmagic", r)
Fatalf("impossible %v node after dot insertion", Oconv(int(r1.Op), obj.FmtSharp))
Fatalf("impossible %v node after dot insertion", Oconv(r1.Op, obj.FmtSharp))
goto bad
}
}
......
......@@ -163,7 +163,7 @@ func walkstmt(np **Node) {
if n.Op == ONAME {
Yyerror("%v is not a top level statement", n.Sym)
} else {
Yyerror("%v is not a top level statement", Oconv(int(n.Op), 0))
Yyerror("%v is not a top level statement", Oconv(n.Op, 0))
}
Dump("nottop", n)
......@@ -1559,7 +1559,7 @@ opswitch:
// ifaceeq(i1 any-1, i2 any-2) (ret bool);
case OCMPIFACE:
if !Eqtype(n.Left.Type, n.Right.Type) {
Fatalf("ifaceeq %v %v %v", Oconv(int(n.Op), 0), n.Left.Type, n.Right.Type)
Fatalf("ifaceeq %v %v %v", Oconv(n.Op, 0), n.Left.Type, n.Right.Type)
}
var fn *Node
if isnilinter(n.Left.Type) {
......@@ -1685,7 +1685,7 @@ func ascompatee(op Op, nl *NodeList, nr *NodeList, init nodesOrNodeListPtr) *Nod
// cannot happen: caller checked that lists had same length
if ll != nil || lr != nil {
Yyerror("error in shape across %v %v %v / %d %d [%s]", Hconv(nl, obj.FmtSign), Oconv(int(op), 0), Hconv(nr, obj.FmtSign), count(nl), count(nr), Curfn.Func.Nname.Sym.Name)
Yyerror("error in shape across %v %v %v / %d %d [%s]", Hconv(nl, obj.FmtSign), Oconv(op, 0), Hconv(nr, obj.FmtSign), count(nl), count(nr), Curfn.Func.Nname.Sym.Name)
}
return nn
}
......@@ -1930,9 +1930,9 @@ loop:
l1 = dumptypes(nl, "expected")
l2 = dumpnodetypes(lr0, "given")
if l != nil {
Yyerror("not enough arguments to %v\n%s\n%s", Oconv(int(op), 0), l1, l2)
Yyerror("not enough arguments to %v\n%s\n%s", Oconv(op, 0), l1, l2)
} else {
Yyerror("too many arguments to %v\n%s\n%s", Oconv(int(op), 0), l1, l2)
Yyerror("too many arguments to %v\n%s\n%s", Oconv(op, 0), l1, l2)
}
}
......@@ -2205,7 +2205,7 @@ func applywritebarrier(n *Node) *Node {
func convas(n *Node, init nodesOrNodeListPtr) *Node {
if n.Op != OAS {
Fatalf("convas: not OAS %v", Oconv(int(n.Op), 0))
Fatalf("convas: not OAS %v", Oconv(n.Op, 0))
}
n.Typecheck = 1
......@@ -2352,7 +2352,7 @@ func reorder3(all *NodeList) *NodeList {
switch l.Op {
default:
Fatalf("reorder3 unexpected lvalue %v", Oconv(int(l.Op), obj.FmtSharp))
Fatalf("reorder3 unexpected lvalue %v", Oconv(l.Op, obj.FmtSharp))
case ONAME:
break
......@@ -3813,7 +3813,7 @@ func usefield(n *Node) {
switch n.Op {
default:
Fatalf("usefield %v", Oconv(int(n.Op), 0))
Fatalf("usefield %v", Oconv(n.Op, 0))
case ODOT, ODOTPTR:
break
......
......@@ -148,7 +148,7 @@ func ginscmp(op gc.Op, t *gc.Type, n1, n2 *gc.Node, likely int) *obj.Prog {
case gc.TFLOAT32:
switch op {
default:
gc.Fatalf("ginscmp: no entry for op=%v type=%v", gc.Oconv(int(op), 0), t)
gc.Fatalf("ginscmp: no entry for op=%v type=%v", gc.Oconv(op, 0), t)
case gc.OEQ,
gc.ONE:
......@@ -165,7 +165,7 @@ func ginscmp(op gc.Op, t *gc.Type, n1, n2 *gc.Node, likely int) *obj.Prog {
case gc.TFLOAT64:
switch op {
default:
gc.Fatalf("ginscmp: no entry for op=%v type=%v", gc.Oconv(int(op), 0), t)
gc.Fatalf("ginscmp: no entry for op=%v type=%v", gc.Oconv(op, 0), t)
case gc.OEQ,
gc.ONE:
......@@ -715,7 +715,7 @@ func optoas(op gc.Op, t *gc.Type) int {
a := int(obj.AXXX)
switch uint32(op)<<16 | uint32(gc.Simtype[t.Etype]) {
default:
gc.Fatalf("optoas: no entry for op=%v type=%v", gc.Oconv(int(op), 0), t)
gc.Fatalf("optoas: no entry for op=%v type=%v", gc.Oconv(op, 0), t)
case OEQ_ | gc.TBOOL,
OEQ_ | gc.TINT8,
......
......@@ -711,7 +711,7 @@ func optoas(op gc.Op, t *gc.Type) int {
a := int(obj.AXXX)
switch uint32(op)<<16 | uint32(gc.Simtype[t.Etype]) {
default:
gc.Fatalf("optoas: no entry for op=%v type=%v", gc.Oconv(int(op), 0), t)
gc.Fatalf("optoas: no entry for op=%v type=%v", gc.Oconv(op, 0), t)
case OEQ_ | gc.TBOOL,
OEQ_ | gc.TINT8,
......
......@@ -19,12 +19,12 @@ func cgen64(n *gc.Node, res *gc.Node) {
if res.Op != gc.OINDREG && res.Op != gc.ONAME {
gc.Dump("n", n)
gc.Dump("res", res)
gc.Fatalf("cgen64 %v of %v", gc.Oconv(int(n.Op), 0), gc.Oconv(int(res.Op), 0))
gc.Fatalf("cgen64 %v of %v", gc.Oconv(n.Op, 0), gc.Oconv(res.Op, 0))
}
switch n.Op {
default:
gc.Fatalf("cgen64 %v", gc.Oconv(int(n.Op), 0))
gc.Fatalf("cgen64 %v", gc.Oconv(n.Op, 0))
case gc.OMINUS:
gc.Cgen(n.Left, res)
......@@ -531,7 +531,7 @@ func cmp64(nl *gc.Node, nr *gc.Node, op gc.Op, likely int, to *obj.Prog) {
var br *obj.Prog
switch op {
default:
gc.Fatalf("cmp64 %v %v", gc.Oconv(int(op), 0), t)
gc.Fatalf("cmp64 %v %v", gc.Oconv(op, 0), t)
// cmp hi
// jne L
......
......@@ -661,7 +661,7 @@ func cgen_floatsse(n *gc.Node, res *gc.Node) {
switch n.Op {
default:
gc.Dump("cgen_floatsse", n)
gc.Fatalf("cgen_floatsse %v", gc.Oconv(int(n.Op), 0))
gc.Fatalf("cgen_floatsse %v", gc.Oconv(n.Op, 0))
return
case gc.OMINUS,
......
......@@ -91,7 +91,7 @@ func optoas(op gc.Op, t *gc.Type) int {
a := obj.AXXX
switch uint32(op)<<16 | uint32(gc.Simtype[t.Etype]) {
default:
gc.Fatalf("optoas: no entry %v-%v", gc.Oconv(int(op), 0), t)
gc.Fatalf("optoas: no entry %v-%v", gc.Oconv(op, 0), t)
case OADDR_ | gc.TPTR32:
a = x86.ALEAL
......@@ -454,7 +454,7 @@ func foptoas(op gc.Op, t *gc.Type, flg int) int {
if !gc.Thearch.Use387 {
switch uint32(op)<<16 | uint32(et) {
default:
gc.Fatalf("foptoas-sse: no entry %v-%v", gc.Oconv(int(op), 0), t)
gc.Fatalf("foptoas-sse: no entry %v-%v", gc.Oconv(op, 0), t)
case OCMP_ | gc.TFLOAT32:
a = x86.AUCOMISS
......@@ -587,7 +587,7 @@ func foptoas(op gc.Op, t *gc.Type, flg int) int {
return x86.AFCHS
}
gc.Fatalf("foptoas %v %v %#x", gc.Oconv(int(op), 0), t, flg)
gc.Fatalf("foptoas %v %v %#x", gc.Oconv(op, 0), t, flg)
return 0
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment