1
0
mirror of https://github.com/golang/go synced 2024-11-20 02:54:39 -07:00

cmd/5g etc: merge simple case expressions onto fewer lines

The c2go translation left a lot of case expressions on separate lines.
Merge expressions onto single lines subject to these constraints:

* Max 4 clauses, all literals or names
* Don't move expressions with comments

The change was created by running http://play.golang.org/p/yHajs72h-g:

$ mergecase cmd/internal/{ld,gc,obj}/*.go cmd/internal/obj/*/*.go

Passes toolstash -cmp.

Change-Id: Iba41b390d302e5486e5dc6ba7599a92270676556
Reviewed-on: https://go-review.googlesource.com/7593
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Josh Bleecher Snyder 2015-04-01 09:38:44 -07:00
parent 2c20eda1d8
commit b09925b31d
45 changed files with 358 additions and 851 deletions

View File

@ -151,10 +151,7 @@ func dowidth(t *Type) {
et := int32(t.Etype) et := int32(t.Etype)
switch et { switch et {
case TFUNC, case TFUNC, TCHAN, TMAP, TSTRING:
TCHAN,
TMAP,
TSTRING:
break break
/* simtype == 0 during bootstrap */ /* simtype == 0 during bootstrap */
@ -170,25 +167,17 @@ func dowidth(t *Type) {
Fatal("dowidth: unknown type: %v", Tconv(t, 0)) Fatal("dowidth: unknown type: %v", Tconv(t, 0))
/* compiler-specific stuff */ /* compiler-specific stuff */
case TINT8, case TINT8, TUINT8, TBOOL:
TUINT8,
TBOOL:
// bool is int8 // bool is int8
w = 1 w = 1
case TINT16, case TINT16, TUINT16:
TUINT16:
w = 2 w = 2
case TINT32, case TINT32, TUINT32, TFLOAT32:
TUINT32,
TFLOAT32:
w = 4 w = 4
case TINT64, case TINT64, TUINT64, TFLOAT64, TCOMPLEX64:
TUINT64,
TFLOAT64,
TCOMPLEX64:
w = 8 w = 8
t.Align = uint8(Widthreg) t.Align = uint8(Widthreg)

View File

@ -172,8 +172,7 @@ func Cgen(n *Node, res *Node) {
// can't do in walk because n->left->addable // can't do in walk because n->left->addable
// changes if n->left is an escaping local variable. // changes if n->left is an escaping local variable.
switch n.Op { switch n.Op {
case OSPTR, case OSPTR, OLEN:
OLEN:
if Isslice(n.Left.Type) || Istype(n.Left.Type, TSTRING) { if Isslice(n.Left.Type) || Istype(n.Left.Type, TSTRING) {
n.Addable = n.Left.Addable n.Addable = n.Left.Addable
} }
@ -665,9 +664,7 @@ func Cgen(n *Node, res *Node) {
} }
} }
case OLSH, case OLSH, ORSH, OLROT:
ORSH,
OLROT:
Thearch.Cgen_shift(int(n.Op), n.Bounded, nl, nr, res) Thearch.Cgen_shift(int(n.Op), n.Bounded, nl, nr, res)
} }
@ -1569,9 +1566,7 @@ func Igen(n *Node, a *Node, res *Node) {
Fixlargeoffset(a) Fixlargeoffset(a)
return return
case OCALLFUNC, case OCALLFUNC, OCALLMETH, OCALLINTER:
OCALLMETH,
OCALLINTER:
switch n.Op { switch n.Op {
case OCALLFUNC: case OCALLFUNC:
cgen_call(n, 0) cgen_call(n, 0)

View File

@ -486,8 +486,7 @@ func walkclosure(func_ *Node, init **NodeList) *Node {
func typecheckpartialcall(fn *Node, sym *Node) { func typecheckpartialcall(fn *Node, sym *Node) {
switch fn.Op { switch fn.Op {
case ODOTINTER, case ODOTINTER, ODOTMETH:
ODOTMETH:
break break
default: default:

View File

@ -96,8 +96,7 @@ func convlit1(np **Node, t *Type, explicit bool) {
return return
} }
case OLSH, case OLSH, ORSH:
ORSH:
convlit1(&n.Left, t, explicit && isideal(n.Left.Type)) convlit1(&n.Left, t, explicit && isideal(n.Left.Type))
t = n.Left.Type t = n.Left.Type
if t != nil && t.Etype == TIDEAL && n.Val.Ctype != CTINT { if t != nil && t.Etype == TIDEAL && n.Val.Ctype != CTINT {
@ -199,25 +198,19 @@ func convlit1(np **Node, t *Type, explicit bool) {
} }
} }
case CTSTR, case CTSTR, CTBOOL:
CTBOOL:
if et != int(n.Type.Etype) { if et != int(n.Type.Etype) {
goto bad goto bad
} }
case CTINT, case CTINT, CTRUNE, CTFLT, CTCPLX:
CTRUNE,
CTFLT,
CTCPLX:
ct := int(n.Val.Ctype) ct := int(n.Val.Ctype)
if Isint[et] { if Isint[et] {
switch ct { switch ct {
default: default:
goto bad goto bad
case CTCPLX, case CTCPLX, CTFLT, CTRUNE:
CTFLT,
CTRUNE:
n.Val = toint(n.Val) n.Val = toint(n.Val)
fallthrough fallthrough
@ -230,9 +223,7 @@ func convlit1(np **Node, t *Type, explicit bool) {
default: default:
goto bad goto bad
case CTCPLX, case CTCPLX, CTINT, CTRUNE:
CTINT,
CTRUNE:
n.Val = toflt(n.Val) n.Val = toflt(n.Val)
fallthrough fallthrough
@ -245,9 +236,7 @@ func convlit1(np **Node, t *Type, explicit bool) {
default: default:
goto bad goto bad
case CTFLT, case CTFLT, CTINT, CTRUNE:
CTINT,
CTRUNE:
n.Val = tocplx(n.Val) n.Val = tocplx(n.Val)
case CTCPLX: case CTCPLX:
@ -281,8 +270,7 @@ bad:
func copyval(v Val) Val { func copyval(v Val) Val {
switch v.Ctype { switch v.Ctype {
case CTINT, case CTINT, CTRUNE:
CTRUNE:
i := new(Mpint) i := new(Mpint)
mpmovefixfix(i, v.U.Xval) mpmovefixfix(i, v.U.Xval)
v.U.Xval = i v.U.Xval = i
@ -304,8 +292,7 @@ func copyval(v Val) Val {
func tocplx(v Val) Val { func tocplx(v Val) Val {
switch v.Ctype { switch v.Ctype {
case CTINT, case CTINT, CTRUNE:
CTRUNE:
c := new(Mpcplx) c := new(Mpcplx)
Mpmovefixflt(&c.Real, v.U.Xval) Mpmovefixflt(&c.Real, v.U.Xval)
Mpmovecflt(&c.Imag, 0.0) Mpmovecflt(&c.Imag, 0.0)
@ -325,8 +312,7 @@ func tocplx(v Val) Val {
func toflt(v Val) Val { func toflt(v Val) Val {
switch v.Ctype { switch v.Ctype {
case CTINT, case CTINT, CTRUNE:
CTRUNE:
f := new(Mpflt) f := new(Mpflt)
Mpmovefixflt(f, v.U.Xval) Mpmovefixflt(f, v.U.Xval)
v.Ctype = CTFLT v.Ctype = CTFLT
@ -375,8 +361,7 @@ func toint(v Val) Val {
func doesoverflow(v Val, t *Type) bool { func doesoverflow(v Val, t *Type) bool {
switch v.Ctype { switch v.Ctype {
case CTINT, case CTINT, CTRUNE:
CTRUNE:
if !Isint[t.Etype] { if !Isint[t.Etype] {
Fatal("overflow: %v integer constant", Tconv(t, 0)) Fatal("overflow: %v integer constant", Tconv(t, 0))
} }
@ -416,8 +401,7 @@ func overflow(v Val, t *Type) {
} }
switch v.Ctype { switch v.Ctype {
case CTINT, case CTINT, CTRUNE:
CTRUNE:
Yyerror("constant %v overflows %v", Bconv(v.U.Xval, 0), Tconv(t, 0)) Yyerror("constant %v overflows %v", Bconv(v.U.Xval, 0), Tconv(t, 0))
case CTFLT: case CTFLT:
@ -430,8 +414,7 @@ func overflow(v Val, t *Type) {
func tostr(v Val) Val { func tostr(v Val) Val {
switch v.Ctype { switch v.Ctype {
case CTINT, case CTINT, CTRUNE:
CTRUNE:
if Mpcmpfixfix(v.U.Xval, Minintval[TINT]) < 0 || Mpcmpfixfix(v.U.Xval, Maxintval[TINT]) > 0 { if Mpcmpfixfix(v.U.Xval, Minintval[TINT]) < 0 || Mpcmpfixfix(v.U.Xval, Maxintval[TINT]) > 0 {
Yyerror("overflow in int -> string") Yyerror("overflow in int -> string")
} }
@ -710,8 +693,7 @@ func evconst(n *Node) {
// right must be unsigned. // right must be unsigned.
// left can be ideal. // left can be ideal.
case OLSH, case OLSH, ORSH:
ORSH:
defaultlit(&nr, Types[TUINT]) defaultlit(&nr, Types[TUINT])
n.Right = nr n.Right = nr
@ -1089,10 +1071,7 @@ func nodlit(v Val) *Node {
case CTBOOL: case CTBOOL:
n.Type = idealbool n.Type = idealbool
case CTINT, case CTINT, CTRUNE, CTFLT, CTCPLX:
CTRUNE,
CTFLT,
CTCPLX:
n.Type = Types[TIDEAL] n.Type = Types[TIDEAL]
case CTNIL: case CTNIL:
@ -1158,8 +1137,7 @@ func idealkind(n *Node) int {
} }
fallthrough fallthrough
case OREAL, case OREAL, OIMAG:
OIMAG:
return CTFLT return CTFLT
case OCOMPLEX: case OCOMPLEX:
@ -1182,8 +1160,7 @@ func idealkind(n *Node) int {
return CTBOOL return CTBOOL
// shifts (beware!). // shifts (beware!).
case OLSH, case OLSH, ORSH:
ORSH:
return idealkind(n.Left) return idealkind(n.Left)
} }
} }
@ -1351,10 +1328,7 @@ func Smallintconst(n *Node) bool {
TPTR32: TPTR32:
return true return true
case TIDEAL, case TIDEAL, TINT64, TUINT64, TPTR64:
TINT64,
TUINT64,
TPTR64:
if Mpcmpfixfix(n.Val.U.Xval, Minintval[TINT32]) < 0 || Mpcmpfixfix(n.Val.U.Xval, Maxintval[TINT32]) > 0 { if Mpcmpfixfix(n.Val.U.Xval, Minintval[TINT32]) < 0 || Mpcmpfixfix(n.Val.U.Xval, Maxintval[TINT32]) > 0 {
break break
} }
@ -1412,8 +1386,7 @@ func iconv(x int64, et int) int64 {
case TUINT32: case TUINT32:
x = int64(uint32(x)) x = int64(uint32(x))
case TINT64, case TINT64, TUINT64:
TUINT64:
break break
} }
@ -1441,8 +1414,7 @@ func Convconst(con *Node, t *Type, val *Val) {
default: default:
Fatal("convconst ctype=%d %v", val.Ctype, Tconv(t, obj.FmtLong)) Fatal("convconst ctype=%d %v", val.Ctype, Tconv(t, obj.FmtLong))
case CTINT, case CTINT, CTRUNE:
CTRUNE:
i = Mpgetfix(val.U.Xval) i = Mpgetfix(val.U.Xval)
case CTBOOL: case CTBOOL:
@ -1606,8 +1578,7 @@ func isgoconst(n *Node) bool {
return true return true
} }
case OLEN, case OLEN, OCAP:
OCAP:
l := n.Left l := n.Left
if isgoconst(l) { if isgoconst(l) {
return true return true

View File

@ -352,8 +352,7 @@ func Complexgen(n *Node, res *Node) {
return return
} }
case OREAL, case OREAL, OIMAG:
OIMAG:
nl := n.Left nl := n.Left
if nl.Addable == 0 { if nl.Addable == 0 {
var tmp Node var tmp Node
@ -475,8 +474,7 @@ func Complexgen(n *Node, res *Node) {
case OMINUS: case OMINUS:
complexminus(nl, res) complexminus(nl, res)
case OADD, case OADD, OSUB:
OSUB:
complexadd(int(n.Op), nl, nr, res) complexadd(int(n.Op), nl, nr, res)
case OMUL: case OMUL:

View File

@ -234,8 +234,7 @@ var tags [16]*string
// mktag returns the string representation for an escape analysis tag. // mktag returns the string representation for an escape analysis tag.
func mktag(mask int) *string { func mktag(mask int) *string {
switch mask & EscMask { switch mask & EscMask {
case EscNone, case EscNone, EscReturn:
EscReturn:
break break
default: default:
@ -538,8 +537,7 @@ func esc(e *EscState, n *Node, up *Node) {
// This assignment is a no-op for escape analysis, // This assignment is a no-op for escape analysis,
// it does not store any new pointers into b that were not already there. // it does not store any new pointers into b that were not already there.
// However, without this special case b will escape, because we assign to OIND/ODOTPTR. // However, without this special case b will escape, because we assign to OIND/ODOTPTR.
case OAS, case OAS, OASOP:
OASOP:
if (n.Left.Op == OIND || n.Left.Op == ODOTPTR) && n.Left.Left.Op == ONAME && // dst is ONAME dereference if (n.Left.Op == OIND || n.Left.Op == ODOTPTR) && n.Left.Left.Op == ONAME && // dst is ONAME dereference
(n.Right.Op == OSLICE || n.Right.Op == OSLICE3 || n.Right.Op == OSLICESTR) && // src is slice operation (n.Right.Op == OSLICE || n.Right.Op == OSLICE3 || n.Right.Op == OSLICESTR) && // src is slice operation
(n.Right.Left.Op == OIND || n.Right.Left.Op == ODOTPTR) && n.Right.Left.Left.Op == ONAME && // slice is applied to ONAME dereference (n.Right.Left.Op == OIND || n.Right.Left.Op == ODOTPTR) && n.Right.Left.Left.Op == ONAME && // slice is applied to ONAME dereference
@ -604,9 +602,7 @@ func esc(e *EscState, n *Node, up *Node) {
escassign(e, &e.theSink, ll.N) escassign(e, &e.theSink, ll.N)
} }
case OCALLMETH, case OCALLMETH, OCALLFUNC, OCALLINTER:
OCALLFUNC,
OCALLINTER:
esccall(e, n, up) esccall(e, n, up)
// esccall already done on n->rlist->n. tie it's escretval to n->list // esccall already done on n->rlist->n. tie it's escretval to n->list
@ -653,8 +649,7 @@ func esc(e *EscState, n *Node, up *Node) {
} }
} }
case OCONV, case OCONV, OCONVNOP:
OCONVNOP:
escassign(e, n, n.Left) escassign(e, n, n.Left)
case OCONVIFACE: case OCONVIFACE:
@ -780,8 +775,7 @@ func esc(e *EscState, n *Node, up *Node) {
// so that writing the address of one result // so that writing the address of one result
// to another (or the same) result makes the // to another (or the same) result makes the
// first result move to the heap. // first result move to the heap.
case PPARAM, case PPARAM, PPARAMOUT:
PPARAMOUT:
n.Escloopdepth = 1 n.Escloopdepth = 1
} }
} }
@ -847,8 +841,7 @@ func escassign(e *EscState, dst *Node, src *Node) {
dst = &e.theSink // lose track of dereference dst = &e.theSink // lose track of dereference
case OIND, case OIND, ODOTPTR:
ODOTPTR:
dst = &e.theSink // lose track of dereference dst = &e.theSink // lose track of dereference
// lose track of key and value // lose track of key and value
@ -889,9 +882,7 @@ func escassign(e *EscState, dst *Node, src *Node) {
// Flowing multiple returns to a single dst happens when // Flowing multiple returns to a single dst happens when
// analyzing "go f(g())": here g() flows to sink (issue 4529). // analyzing "go f(g())": here g() flows to sink (issue 4529).
case OCALLMETH, case OCALLMETH, OCALLFUNC, OCALLINTER:
OCALLFUNC,
OCALLINTER:
for ll := src.Escretval; ll != nil; ll = ll.Next { for ll := src.Escretval; ll != nil; ll = ll.Next {
escflows(e, dst, ll.N) escflows(e, dst, ll.N)
} }
@ -1204,8 +1195,7 @@ func escflows(e *EscState, dst *Node, src *Node) {
// escaping to the global scope. // escaping to the global scope.
func escflood(e *EscState, dst *Node) { func escflood(e *EscState, dst *Node) {
switch dst.Op { switch dst.Op {
case ONAME, case ONAME, OCLOSURE:
OCLOSURE:
break break
default: default:
@ -1311,8 +1301,7 @@ func escwalk(e *EscState, level int, dst *Node, src *Node) {
escwalk(e, level, dst, src.Closure) escwalk(e, level, dst, src.Closure)
} }
case OPTRLIT, case OPTRLIT, OADDR:
OADDR:
if leaks { if leaks {
src.Esc = EscHeap src.Esc = EscHeap
addrescapes(src.Left) addrescapes(src.Left)
@ -1372,9 +1361,7 @@ func escwalk(e *EscState, level int, dst *Node, src *Node) {
fallthrough fallthrough
// fall through // fall through
case ODOTPTR, case ODOTPTR, OINDEXMAP, OIND:
OINDEXMAP,
OIND:
newlevel := level newlevel := level
if level > MinLevel { if level > MinLevel {

View File

@ -540,8 +540,7 @@ func typefmt(t *Type, flag int) string {
} }
switch t.Etype { switch t.Etype {
case TPTR32, case TPTR32, TPTR64:
TPTR64:
if fmtmode == FTypeId && (flag&obj.FmtShort != 0 /*untyped*/) { if fmtmode == FTypeId && (flag&obj.FmtShort != 0 /*untyped*/) {
return fmt.Sprintf("*%v", Tconv(t.Type, obj.FmtShort)) return fmt.Sprintf("*%v", Tconv(t.Type, obj.FmtShort))
} }
@ -764,9 +763,7 @@ func typefmt(t *Type, flag int) string {
// Statements which may be rendered with a simplestmt as init. // Statements which may be rendered with a simplestmt as init.
func stmtwithinit(op int) bool { func stmtwithinit(op int) bool {
switch op { switch op {
case OIF, case OIF, OFOR, OSWITCH:
OFOR,
OSWITCH:
return true return true
} }
@ -802,9 +799,7 @@ func stmtfmt(n *Node) string {
case ODCL: case ODCL:
if fmtmode == FExp { if fmtmode == FExp {
switch n.Left.Class &^ PHEAP { switch n.Left.Class &^ PHEAP {
case PPARAM, case PPARAM, PPARAMOUT, PAUTO:
PPARAMOUT,
PAUTO:
f += fmt.Sprintf("var %v %v", Nconv(n.Left, 0), Tconv(n.Left.Type, 0)) f += fmt.Sprintf("var %v %v", Nconv(n.Left, 0), Tconv(n.Left.Type, 0))
goto ret goto ret
} }
@ -853,10 +848,7 @@ func stmtfmt(n *Node) string {
fallthrough fallthrough
// fallthrough // fallthrough
case OAS2DOTTYPE, case OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV:
OAS2FUNC,
OAS2MAPR,
OAS2RECV:
f += fmt.Sprintf("%v = %v", Hconv(n.List, obj.FmtComma), Hconv(n.Rlist, obj.FmtComma)) f += fmt.Sprintf("%v = %v", Hconv(n.List, obj.FmtComma), Hconv(n.Rlist, obj.FmtComma))
case ORETURN: case ORETURN:
@ -919,8 +911,7 @@ func stmtfmt(n *Node) string {
f += fmt.Sprintf("for %v = range %v { %v }", Hconv(n.List, obj.FmtComma), Nconv(n.Right, 0), Hconv(n.Nbody, 0)) f += fmt.Sprintf("for %v = range %v { %v }", Hconv(n.List, obj.FmtComma), Nconv(n.Right, 0), Hconv(n.Nbody, 0))
case OSELECT, case OSELECT, OSWITCH:
OSWITCH:
if fmtmode == FErr { if fmtmode == FErr {
f += fmt.Sprintf("%v statement", Oconv(int(n.Op), 0)) f += fmt.Sprintf("%v statement", Oconv(int(n.Op), 0))
break break
@ -936,8 +927,7 @@ func stmtfmt(n *Node) string {
f += fmt.Sprintf(" { %v }", Hconv(n.List, 0)) f += fmt.Sprintf(" { %v }", Hconv(n.List, 0))
case OCASE, case OCASE, OXCASE:
OXCASE:
if n.List != nil { if n.List != nil {
f += fmt.Sprintf("case %v: %v", Hconv(n.List, obj.FmtComma), Hconv(n.Nbody, 0)) f += fmt.Sprintf("case %v: %v", Hconv(n.List, obj.FmtComma), Hconv(n.Nbody, 0))
} else { } else {
@ -1158,8 +1148,7 @@ func exprfmt(n *Node, prec int) string {
fallthrough fallthrough
//fallthrough //fallthrough
case OPACK, case OPACK, ONONAME:
ONONAME:
return Sconv(n.Sym, 0) return Sconv(n.Sym, 0)
case OTYPE: case OTYPE:
@ -1270,8 +1259,7 @@ func exprfmt(n *Node, prec int) string {
// fallthrough // fallthrough
case OARRAYLIT, case OARRAYLIT, OMAPLIT:
OMAPLIT:
if fmtmode == FErr { if fmtmode == FErr {
return fmt.Sprintf("%v literal", Tconv(n.Type, 0)) return fmt.Sprintf("%v literal", Tconv(n.Type, 0))
} }
@ -1313,8 +1301,7 @@ func exprfmt(n *Node, prec int) string {
f += fmt.Sprintf(".%v", Sconv(n.Right.Sym, obj.FmtShort|obj.FmtByte)) f += fmt.Sprintf(".%v", Sconv(n.Right.Sym, obj.FmtShort|obj.FmtByte))
return f return f
case ODOTTYPE, case ODOTTYPE, ODOTTYPE2:
ODOTTYPE2:
var f string var f string
f += exprfmt(n.Left, nprec) f += exprfmt(n.Left, nprec)
if n.Right != nil { if n.Right != nil {
@ -1336,8 +1323,7 @@ func exprfmt(n *Node, prec int) string {
f += fmt.Sprintf("[%v]", Nconv(n.Right, 0)) f += fmt.Sprintf("[%v]", Nconv(n.Right, 0))
return f return f
case OCOPY, case OCOPY, OCOMPLEX:
OCOMPLEX:
return fmt.Sprintf("%v(%v, %v)", Oconv(int(n.Op), obj.FmtSharp), Nconv(n.Left, 0), Nconv(n.Right, 0)) return fmt.Sprintf("%v(%v, %v)", Oconv(int(n.Op), obj.FmtSharp), Nconv(n.Left, 0), Nconv(n.Right, 0))
case OCONV, case OCONV,
@ -1377,10 +1363,7 @@ func exprfmt(n *Node, prec int) string {
} }
return fmt.Sprintf("%v(%v)", Oconv(int(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))
case OCALL, case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH:
OCALLFUNC,
OCALLINTER,
OCALLMETH:
var f string var f string
f += exprfmt(n.Left, nprec) f += exprfmt(n.Left, nprec)
if n.Isddd { if n.Isddd {
@ -1390,9 +1373,7 @@ func exprfmt(n *Node, prec int) string {
f += fmt.Sprintf("(%v)", Hconv(n.List, obj.FmtComma)) f += fmt.Sprintf("(%v)", Hconv(n.List, obj.FmtComma))
return f return f
case OMAKEMAP, case OMAKEMAP, OMAKECHAN, OMAKESLICE:
OMAKECHAN,
OMAKESLICE:
if n.List != nil { // pre-typecheck if n.List != nil { // pre-typecheck
return fmt.Sprintf("make(%v, %v)", Tconv(n.Type, 0), Hconv(n.List, obj.FmtComma)) return fmt.Sprintf("make(%v, %v)", Tconv(n.Type, 0), Hconv(n.List, obj.FmtComma))
} }
@ -1460,8 +1441,7 @@ func exprfmt(n *Node, prec int) string {
return f return f
case OCMPSTR, case OCMPSTR, OCMPIFACE:
OCMPIFACE:
var f string var f string
f += exprfmt(n.Left, nprec) f += exprfmt(n.Left, nprec)
f += fmt.Sprintf(" %v ", Oconv(int(n.Etype), obj.FmtSharp)) f += fmt.Sprintf(" %v ", Oconv(int(n.Etype), obj.FmtSharp))
@ -1533,15 +1513,13 @@ func nodedump(n *Node, flag int) string {
default: default:
fmt.Fprintf(&buf, "%v%v", Oconv(int(n.Op), 0), Jconv(n, 0)) fmt.Fprintf(&buf, "%v%v", Oconv(int(n.Op), 0), Jconv(n, 0))
case OREGISTER, case OREGISTER, OINDREG:
OINDREG:
fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), obj.Rconv(int(n.Val.U.Reg)), Jconv(n, 0)) fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), obj.Rconv(int(n.Val.U.Reg)), Jconv(n, 0))
case OLITERAL: 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(int(n.Op), 0), Vconv(&n.Val, 0), Jconv(n, 0))
case ONAME, case ONAME, ONONAME:
ONONAME:
if n.Sym != nil { if n.Sym != nil {
fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), Sconv(n.Sym, 0), Jconv(n, 0)) fmt.Fprintf(&buf, "%v-%v%v", Oconv(int(n.Op), 0), Sconv(n.Sym, 0), Jconv(n, 0))
} else { } else {
@ -1689,8 +1667,7 @@ func Nconv(n *Node, flag int) string {
_ = r _ = r
var str string var str string
switch fmtmode { switch fmtmode {
case FErr, case FErr, FExp:
FExp:
str = nodefmt(n, flag) str = nodefmt(n, flag)
case FDbg: case FDbg:

View File

@ -57,8 +57,7 @@ func addrescapes(n *Node) {
// so the param already has a valid xoffset. // so the param already has a valid xoffset.
// expression to refer to stack copy // expression to refer to stack copy
case PPARAM, case PPARAM, PPARAMOUT:
PPARAMOUT:
n.Stackparam = Nod(OPARAM, n, nil) n.Stackparam = Nod(OPARAM, n, nil)
n.Stackparam.Type = n.Type n.Stackparam.Type = n.Type
@ -93,8 +92,7 @@ func addrescapes(n *Node) {
Curfn = oldfn Curfn = oldfn
} }
case OIND, case OIND, ODOTPTR:
ODOTPTR:
break break
// ODOTPTR has already been introduced, // ODOTPTR has already been introduced,
@ -102,8 +100,7 @@ func addrescapes(n *Node) {
// In &x[0], if x is a slice, then x does not // In &x[0], if x is a slice, then x does not
// escape--the pointer inside x does, but that // escape--the pointer inside x does, but that
// is always a heap pointer anyway. // is always a heap pointer anyway.
case ODOT, case ODOT, OINDEX:
OINDEX:
if !Isslice(n.Left.Type) { if !Isslice(n.Left.Type) {
addrescapes(n.Left) addrescapes(n.Left)
} }
@ -338,23 +335,18 @@ func Clearslim(n *Node) {
z.Addable = 1 z.Addable = 1
switch Simtype[n.Type.Etype] { switch Simtype[n.Type.Etype] {
case TCOMPLEX64, case TCOMPLEX64, TCOMPLEX128:
TCOMPLEX128:
z.Val.U.Cval = new(Mpcplx) z.Val.U.Cval = new(Mpcplx)
Mpmovecflt(&z.Val.U.Cval.Real, 0.0) Mpmovecflt(&z.Val.U.Cval.Real, 0.0)
Mpmovecflt(&z.Val.U.Cval.Imag, 0.0) Mpmovecflt(&z.Val.U.Cval.Imag, 0.0)
case TFLOAT32, case TFLOAT32, TFLOAT64:
TFLOAT64:
var zero Mpflt var zero Mpflt
Mpmovecflt(&zero, 0.0) Mpmovecflt(&zero, 0.0)
z.Val.Ctype = CTFLT z.Val.Ctype = CTFLT
z.Val.U.Fval = &zero z.Val.U.Fval = &zero
case TPTR32, case TPTR32, TPTR64, TCHAN, TMAP:
TPTR64,
TCHAN,
TMAP:
z.Val.Ctype = CTNIL z.Val.Ctype = CTNIL
case TBOOL: case TBOOL:
@ -833,9 +825,7 @@ func gen(n *Node) {
if n.Defn != nil { if n.Defn != nil {
switch n.Defn.Op { switch n.Defn.Op {
// so stmtlabel can find the label // so stmtlabel can find the label
case OFOR, case OFOR, OSWITCH, OSELECT:
OSWITCH,
OSELECT:
n.Defn.Sym = lab.Sym n.Defn.Sym = lab.Sym
} }
} }
@ -1009,8 +999,7 @@ func gen(n *Node) {
case ODEFER: case ODEFER:
cgen_proc(n, 2) cgen_proc(n, 2)
case ORETURN, case ORETURN, ORETJMP:
ORETJMP:
cgen_ret(n) cgen_ret(n)
case OCHECKNIL: case OCHECKNIL:
@ -1175,8 +1164,7 @@ func Componentgen(nr *Node, nl *Node) bool {
goto no goto no
} }
case TSTRING, case TSTRING, TINTER:
TINTER:
break break
} }

View File

@ -250,9 +250,7 @@ func gused(n *Node) {
func Isfat(t *Type) bool { func Isfat(t *Type) bool {
if t != nil { if t != nil {
switch t.Etype { switch t.Etype {
case TSTRUCT, case TSTRUCT, TARRAY, TSTRING,
TARRAY,
TSTRING,
TINTER: // maybe remove later TINTER: // maybe remove later
return true return true
} }
@ -384,8 +382,7 @@ func Naddr(a *obj.Addr, n *Node) {
case PAUTO: case PAUTO:
a.Name = obj.NAME_AUTO a.Name = obj.NAME_AUTO
case PPARAM, case PPARAM, PPARAMOUT:
PPARAMOUT:
a.Name = obj.NAME_PARAM a.Name = obj.NAME_PARAM
case PFUNC: case PFUNC:
@ -409,8 +406,7 @@ func Naddr(a *obj.Addr, n *Node) {
a.Type = obj.TYPE_FCONST a.Type = obj.TYPE_FCONST
a.Val = mpgetflt(n.Val.U.Fval) a.Val = mpgetflt(n.Val.U.Fval)
case CTINT, case CTINT, CTRUNE:
CTRUNE:
a.Sym = nil a.Sym = nil
a.Type = obj.TYPE_CONST a.Type = obj.TYPE_CONST
a.Offset = Mpgetfix(n.Val.U.Xval) a.Offset = Mpgetfix(n.Val.U.Xval)

View File

@ -54,10 +54,7 @@ func anyinit(n *NodeList) bool {
// are there any interesting init statements // are there any interesting init statements
for l := n; l != nil; l = l.Next { for l := n; l != nil; l = l.Next {
switch l.N.Op { switch l.N.Op {
case ODCLFUNC, case ODCLFUNC, ODCLCONST, ODCLTYPE, OEMPTY:
ODCLCONST,
ODCLTYPE,
OEMPTY:
break break
case OAS: case OAS:

View File

@ -200,10 +200,7 @@ func ishairy(n *Node, budget *int) bool {
} }
// Things that are too hairy, irrespective of the budget // Things that are too hairy, irrespective of the budget
case OCALL, case OCALL, OCALLINTER, OPANIC, ORECOVER:
OCALLINTER,
OPANIC,
ORECOVER:
if Debug['l'] < 4 { if Debug['l'] < 4 {
return true return true
} }
@ -244,9 +241,7 @@ func inlcopy(n *Node) *Node {
} }
switch n.Op { switch n.Op {
case ONAME, case ONAME, OTYPE, OLITERAL:
OTYPE,
OLITERAL:
return n return n
} }
@ -338,11 +333,9 @@ func inlnode(np **Node) {
switch n.Op { switch n.Op {
// inhibit inlining of their argument // inhibit inlining of their argument
case ODEFER, case ODEFER, OPROC:
OPROC:
switch n.Left.Op { switch n.Left.Op {
case OCALLFUNC, case OCALLFUNC, OCALLMETH:
OCALLMETH:
n.Left.Etype = n.Op n.Left.Etype = n.Op
} }
fallthrough fallthrough
@ -453,8 +446,7 @@ func inlnode(np **Node) {
// transmogrify this node itself unless inhibited by the // transmogrify this node itself unless inhibited by the
// switch at the top of this function. // switch at the top of this function.
switch n.Op { switch n.Op {
case OCALLFUNC, case OCALLFUNC, OCALLMETH:
OCALLMETH:
if n.Etype == OPROC || n.Etype == ODEFER { if n.Etype == OPROC || n.Etype == ODEFER {
return return
} }
@ -647,10 +639,7 @@ func mkinlcall1(np **Node, fn *Node, isddd bool) {
if n.List != nil && n.List.Next == nil { if n.List != nil && n.List.Next == nil {
switch n.List.N.Op { switch n.List.N.Op {
case OCALL, case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH:
OCALLFUNC,
OCALLINTER,
OCALLMETH:
if n.List.N.Left.Type.Outtuple > 1 { if n.List.N.Left.Type.Outtuple > 1 {
multiret = n.List.N.Left.Type.Outtuple - 1 multiret = n.List.N.Left.Type.Outtuple - 1
} }
@ -920,8 +909,7 @@ func inlsubst(n *Node) *Node {
} }
return n return n
case OLITERAL, case OLITERAL, OTYPE:
OTYPE:
return n return n
// Since we don't handle bodies with closures, this return is guaranteed to belong to the current inlined function. // Since we don't handle bodies with closures, this return is guaranteed to belong to the current inlined function.
@ -950,8 +938,7 @@ func inlsubst(n *Node) *Node {
// dump("Return after substitution", m); // dump("Return after substitution", m);
return m return m
case OGOTO, case OGOTO, OLABEL:
OLABEL:
m := Nod(OXXX, nil, nil) m := Nod(OXXX, nil, nil)
*m = *n *m = *n
m.Ninit = nil m.Ninit = nil

View File

@ -1277,8 +1277,7 @@ l0:
* *
* i said it was clumsy. * i said it was clumsy.
*/ */
case '(', case '(', '[':
'[':
if loophack != 0 || _yylex_lstk != nil { if loophack != 0 || _yylex_lstk != nil {
h = new(Loophack) h = new(Loophack)
if h == nil { if h == nil {
@ -1295,8 +1294,7 @@ l0:
goto lx goto lx
case ')', case ')', ']':
']':
if _yylex_lstk != nil { if _yylex_lstk != nil {
h = _yylex_lstk h = _yylex_lstk
loophack = h.v loophack = h.v
@ -1382,10 +1380,7 @@ talph:
case LIGNORE: case LIGNORE:
goto l0 goto l0
case LFOR, case LFOR, LIF, LSWITCH, LSELECT:
LIF,
LSWITCH,
LSELECT:
loophack = 1 // see comment about loophack above loophack = 1 // see comment about loophack above
} }

View File

@ -340,8 +340,7 @@ func mpatoflt(a *Mpflt, as string) {
c := s[0] c := s[0]
s = s[1:] s = s[1:]
switch c { switch c {
case '-', case '-', '+':
'+':
break break
case '0': case '0':
@ -411,9 +410,7 @@ func mpatoflt(a *Mpflt, as string) {
f = 1 f = 1
fallthrough fallthrough
case ' ', case ' ', '\t', '+':
'\t',
'+':
continue continue
case '.': case '.':
@ -442,13 +439,11 @@ func mpatoflt(a *Mpflt, as string) {
} }
continue continue
case 'P', case 'P', 'p':
'p':
eb = 1 eb = 1
fallthrough fallthrough
case 'E', case 'E', 'e':
'e':
ex = 0 ex = 0
ef = 0 ef = 0
for { for {

View File

@ -105,8 +105,7 @@ func ordercopyexpr(n *Node, t *Type, order *Order, clear int) *Node {
// and then returns tmp. // and then returns tmp.
func ordercheapexpr(n *Node, order *Order) *Node { func ordercheapexpr(n *Node, order *Order) *Node {
switch n.Op { switch n.Op {
case ONAME, case ONAME, OLITERAL:
OLITERAL:
return n return n
} }
@ -122,8 +121,7 @@ func ordercheapexpr(n *Node, order *Order) *Node {
// The intended use is to apply to x when rewriting x += y into x = x + y. // The intended use is to apply to x when rewriting x += y into x = x + y.
func ordersafeexpr(n *Node, order *Order) *Node { func ordersafeexpr(n *Node, order *Order) *Node {
switch n.Op { switch n.Op {
case ONAME, case ONAME, OLITERAL:
OLITERAL:
return n return n
case ODOT: case ODOT:
@ -138,8 +136,7 @@ func ordersafeexpr(n *Node, order *Order) *Node {
typecheck(&a, Erv) typecheck(&a, Erv)
return a return a
case ODOTPTR, case ODOTPTR, OIND:
OIND:
l := ordercheapexpr(n.Left, order) l := ordercheapexpr(n.Left, order)
if l == n.Left { if l == n.Left {
return n return n
@ -151,8 +148,7 @@ func ordersafeexpr(n *Node, order *Order) *Node {
typecheck(&a, Erv) typecheck(&a, Erv)
return a return a
case OINDEX, case OINDEX, OINDEXMAP:
OINDEXMAP:
var l *Node var l *Node
if Isfixedarray(n.Left.Type) { if Isfixedarray(n.Left.Type) {
l = ordersafeexpr(n.Left, order) l = ordersafeexpr(n.Left, order)
@ -315,9 +311,7 @@ func ismulticall(l *NodeList) bool {
default: default:
return false return false
case OCALLFUNC, case OCALLFUNC, OCALLMETH, OCALLINTER:
OCALLMETH,
OCALLINTER:
break break
} }
@ -409,10 +403,7 @@ func ordermapassign(n *Node, order *Order) {
order.out = list(order.out, a) order.out = list(order.out, a)
} }
case OAS2, case OAS2, OAS2DOTTYPE, OAS2MAPR, OAS2FUNC:
OAS2DOTTYPE,
OAS2MAPR,
OAS2FUNC:
var post *NodeList var post *NodeList
var m *Node var m *Node
var a *Node var a *Node
@ -470,9 +461,7 @@ func orderstmt(n *Node, order *Order) {
orderexprlist(n.List, order) orderexprlist(n.List, order)
orderexprlist(n.Rlist, order) orderexprlist(n.Rlist, order)
switch n.Op { switch n.Op {
case OAS, case OAS, OAS2, OAS2DOTTYPE:
OAS2,
OAS2DOTTYPE:
ordermapassign(n, order) ordermapassign(n, order)
default: default:
@ -579,8 +568,7 @@ func orderstmt(n *Node, order *Order) {
cleantemp(t, order) cleantemp(t, order)
// Special: does not save n onto out. // Special: does not save n onto out.
case OBLOCK, case OBLOCK, OEMPTY:
OEMPTY:
orderstmtlist(n.List, order) orderstmtlist(n.List, order)
// Special: n->left is not an expression; save as is. // Special: n->left is not an expression; save as is.
@ -597,9 +585,7 @@ func orderstmt(n *Node, order *Order) {
order.out = list(order.out, n) order.out = list(order.out, n)
// Special: handle call arguments. // Special: handle call arguments.
case OCALLFUNC, case OCALLFUNC, OCALLINTER, OCALLMETH:
OCALLINTER,
OCALLMETH:
t := marktemp(order) t := marktemp(order)
ordercall(n, order) ordercall(n, order)
@ -607,8 +593,7 @@ func orderstmt(n *Node, order *Order) {
cleantemp(t, order) cleantemp(t, order)
// Special: order arguments to inner call but not call itself. // Special: order arguments to inner call but not call itself.
case ODEFER, case ODEFER, OPROC:
OPROC:
t := marktemp(order) t := marktemp(order)
switch n.Left.Op { switch n.Left.Op {
@ -713,8 +698,7 @@ func orderstmt(n *Node, order *Order) {
// chan, string, slice, array ranges use value multiple times. // chan, string, slice, array ranges use value multiple times.
// make copy. // make copy.
// fall through // fall through
case TCHAN, case TCHAN, TSTRING:
TSTRING:
r := n.Right r := n.Right
if r.Type.Etype == TSTRING && r.Type != Types[TSTRING] { if r.Type.Etype == TSTRING && r.Type != Types[TSTRING] {
@ -785,8 +769,7 @@ func orderstmt(n *Node, order *Order) {
// the ODCL nodes to declare x and y. We want to delay that // the ODCL nodes to declare x and y. We want to delay that
// declaration (and possible allocation) until inside the case body. // declaration (and possible allocation) until inside the case body.
// Delete the ODCL nodes here and recreate them inside the body below. // Delete the ODCL nodes here and recreate them inside the body below.
case OSELRECV, case OSELRECV, OSELRECV2:
OSELRECV2:
if r.Colas != 0 { if r.Colas != 0 {
t = r.Ninit t = r.Ninit
if t != nil && t.N.Op == ODCL && t.N.Left == r.Left { if t != nil && t.N.Op == ODCL && t.N.Left == r.Left {
@ -1052,8 +1035,7 @@ func orderexpr(np **Node, order *Order) {
orderaddrtemp(&n.Left, order) orderaddrtemp(&n.Left, order)
} }
case OANDAND, case OANDAND, OOROR:
OOROR:
mark := marktemp(order) mark := marktemp(order)
orderexpr(&n.Left, order) orderexpr(&n.Left, order)
@ -1089,8 +1071,7 @@ func orderexpr(np **Node, order *Order) {
n.Alloc = ordertemp(Types[TUINT8], order, false) // walk will fill in correct type n.Alloc = ordertemp(Types[TUINT8], order, false) // walk will fill in correct type
} }
case OARRAYLIT, case OARRAYLIT, OCALLPART:
OCALLPART:
orderexpr(&n.Left, order) orderexpr(&n.Left, order)
orderexpr(&n.Right, order) orderexpr(&n.Right, order)
orderexprlist(n.List, order) orderexprlist(n.List, order)
@ -1121,8 +1102,7 @@ func orderexpr(np **Node, order *Order) {
orderexpr(&n.Left, order) orderexpr(&n.Left, order)
n = ordercopyexpr(n, n.Type, order, 1) n = ordercopyexpr(n, n.Type, order, 1)
case OEQ, case OEQ, ONE:
ONE:
orderexpr(&n.Left, order) orderexpr(&n.Left, order)
orderexpr(&n.Right, order) orderexpr(&n.Right, order)
t := n.Left.Type t := n.Left.Type

View File

@ -93,9 +93,7 @@ func gvardefx(n *Node, as int) {
} }
switch n.Class { switch n.Class {
case PAUTO, case PAUTO, PPARAM, PPARAMOUT:
PPARAM,
PPARAMOUT:
Thearch.Gins(as, nil, n) Thearch.Gins(as, nil, n)
} }
} }
@ -473,9 +471,7 @@ func compile(fn *Node) {
continue continue
} }
switch n.Class { switch n.Class {
case PAUTO, case PAUTO, PPARAM, PPARAMOUT:
PPARAM,
PPARAMOUT:
Nodconst(&nod1, Types[TUINTPTR], l.N.Type.Width) Nodconst(&nod1, Types[TUINTPTR], l.N.Type.Width)
p = Thearch.Gins(obj.ATYPE, l.N, &nod1) p = Thearch.Gins(obj.ATYPE, l.N, &nod1)
p.From.Gotype = Linksym(ngotype(l.N)) p.From.Gotype = Linksym(ngotype(l.N))

View File

@ -243,8 +243,7 @@ func getvariables(fn *Node) []*Node {
result = append(result, ll.N) result = append(result, ll.N)
} }
case PPARAM, case PPARAM, PPARAMOUT:
PPARAMOUT:
ll.N.Opt = int32(len(result)) ll.N.Opt = int32(len(result))
result = append(result, ll.N) result = append(result, ll.N)
} }
@ -616,9 +615,7 @@ func progeffects(prog *obj.Prog, vars []*Node, uevar Bvec, varkill Bvec, avarini
from := &prog.From from := &prog.From
if from.Node != nil && from.Sym != nil && ((from.Node).(*Node)).Curfn == Curfn { if from.Node != nil && from.Sym != nil && ((from.Node).(*Node)).Curfn == Curfn {
switch ((from.Node).(*Node)).Class &^ PHEAP { switch ((from.Node).(*Node)).Class &^ PHEAP {
case PAUTO, case PAUTO, PPARAM, PPARAMOUT:
PPARAM,
PPARAMOUT:
pos, ok := from.Node.(*Node).Opt.(int32) // index in vars pos, ok := from.Node.(*Node).Opt.(int32) // index in vars
if !ok { if !ok {
goto Next goto Next
@ -647,9 +644,7 @@ Next:
to := &prog.To to := &prog.To
if to.Node != nil && to.Sym != nil && ((to.Node).(*Node)).Curfn == Curfn { if to.Node != nil && to.Sym != nil && ((to.Node).(*Node)).Curfn == Curfn {
switch ((to.Node).(*Node)).Class &^ PHEAP { switch ((to.Node).(*Node)).Class &^ PHEAP {
case PAUTO, case PAUTO, PPARAM, PPARAMOUT:
PPARAM,
PPARAMOUT:
pos, ok := to.Node.(*Node).Opt.(int32) // index in vars pos, ok := to.Node.(*Node).Opt.(int32) // index in vars
if !ok { if !ok {
return return
@ -1011,8 +1006,7 @@ func twobitlivepointermap(lv *Liveness, liveout Bvec, vars []*Node, args Bvec, l
xoffset = node.Xoffset + stkptrsize xoffset = node.Xoffset + stkptrsize
twobitwalktype1(node.Type, &xoffset, locals) twobitwalktype1(node.Type, &xoffset, locals)
case PPARAM, case PPARAM, PPARAMOUT:
PPARAMOUT:
xoffset = node.Xoffset xoffset = node.Xoffset
twobitwalktype1(node.Type, &xoffset, args) twobitwalktype1(node.Type, &xoffset, args)
} }
@ -1202,8 +1196,7 @@ func livenesssolve(lv *Liveness) {
// Check whether n is marked live in args/locals. // Check whether n is marked live in args/locals.
func islive(n *Node, args Bvec, locals Bvec) bool { func islive(n *Node, args Bvec, locals Bvec) bool {
switch n.Class { switch n.Class {
case PPARAM, case PPARAM, PPARAMOUT:
PPARAMOUT:
for i := 0; int64(i) < n.Type.Width/int64(Widthptr)*obj.BitsPerPointer; i++ { for i := 0; int64(i) < n.Type.Width/int64(Widthptr)*obj.BitsPerPointer; i++ {
if bvget(args, int32(n.Xoffset/int64(Widthptr)*obj.BitsPerPointer+int64(i))) != 0 { if bvget(args, int32(n.Xoffset/int64(Widthptr)*obj.BitsPerPointer+int64(i))) != 0 {
return true return true

View File

@ -137,15 +137,13 @@ func racewalknode(np **Node, init **NodeList, wr int, skip int) {
default: default:
Fatal("racewalk: unknown node type %v", Oconv(int(n.Op), 0)) Fatal("racewalk: unknown node type %v", Oconv(int(n.Op), 0))
case OAS, case OAS, OAS2FUNC:
OAS2FUNC:
racewalknode(&n.Left, init, 1, 0) racewalknode(&n.Left, init, 1, 0)
racewalknode(&n.Right, init, 0, 0) racewalknode(&n.Right, init, 0, 0)
goto ret goto ret
// can't matter // can't matter
case OCFUNC, case OCFUNC, OVARKILL:
OVARKILL:
goto ret goto ret
case OBLOCK: case OBLOCK:
@ -158,9 +156,7 @@ func racewalknode(np **Node, init **NodeList, wr int, skip int) {
// x, y := f() becomes BLOCK{CALL f, AS x [SP+0], AS y [SP+n]} // x, y := f() becomes BLOCK{CALL f, AS x [SP+0], AS y [SP+n]}
// We don't want to instrument between the statements because it will // We don't want to instrument between the statements because it will
// smash the results. // smash the results.
case OCALLFUNC, case OCALLFUNC, OCALLMETH, OCALLINTER:
OCALLMETH,
OCALLINTER:
racewalknode(&n.List.N, &n.List.N.Ninit, 0, 0) racewalknode(&n.List.N, &n.List.N.Ninit, 0, 0)
var fini *NodeList var fini *NodeList
@ -248,9 +244,7 @@ func racewalknode(np **Node, init **NodeList, wr int, skip int) {
callinstr(&n, init, wr, skip) callinstr(&n, init, wr, skip)
goto ret goto ret
case OSPTR, case OSPTR, OLEN, OCAP:
OLEN,
OCAP:
racewalknode(&n.Left, init, 0, 0) racewalknode(&n.Left, init, 0, 0)
if Istype(n.Left.Type, TMAP) { if Istype(n.Left.Type, TMAP) {
n1 := Nod(OCONVNOP, n.Left, nil) n1 := Nod(OCONVNOP, n.Left, nil)
@ -284,8 +278,7 @@ func racewalknode(np **Node, init **NodeList, wr int, skip int) {
racewalknode(&n.Right, init, wr, 0) racewalknode(&n.Right, init, wr, 0)
goto ret goto ret
case OANDAND, case OANDAND, OOROR:
OOROR:
racewalknode(&n.Left, init, wr, 0) racewalknode(&n.Left, init, wr, 0)
// walk has ensured the node has moved to a location where // walk has ensured the node has moved to a location where
@ -308,8 +301,7 @@ func racewalknode(np **Node, init **NodeList, wr int, skip int) {
racewalknode(&n.Left, init, wr, 0) racewalknode(&n.Left, init, wr, 0)
goto ret goto ret
case ODIV, case ODIV, OMOD:
OMOD:
racewalknode(&n.Left, init, wr, 0) racewalknode(&n.Left, init, wr, 0)
racewalknode(&n.Right, init, wr, 0) racewalknode(&n.Right, init, wr, 0)
goto ret goto ret
@ -333,10 +325,7 @@ func racewalknode(np **Node, init **NodeList, wr int, skip int) {
// Seems to only lead to double instrumentation. // Seems to only lead to double instrumentation.
//racewalknode(&n->left, init, 0, 0); //racewalknode(&n->left, init, 0, 0);
case OSLICE, case OSLICE, OSLICEARR, OSLICE3, OSLICE3ARR:
OSLICEARR,
OSLICE3,
OSLICE3ARR:
goto ret goto ret
case OADDR: case OADDR:
@ -399,8 +388,7 @@ func racewalknode(np **Node, init **NodeList, wr int, skip int) {
goto ret goto ret
// impossible nodes: only appear in backend. // impossible nodes: only appear in backend.
case ORROTC, case ORROTC, OEXTEND:
OEXTEND:
Yyerror("racewalk: %v cannot exist now", Oconv(int(n.Op), 0)) Yyerror("racewalk: %v cannot exist now", Oconv(int(n.Op), 0))
goto ret goto ret
@ -559,8 +547,7 @@ func makeaddable(n *Node) {
} }
// Turn T(v).Field into v.Field // Turn T(v).Field into v.Field
case ODOT, case ODOT, OXDOT:
OXDOT:
if n.Left.Op == OCONVNOP { if n.Left.Op == OCONVNOP {
n.Left = n.Left.Left n.Left = n.Left.Left
} }
@ -621,10 +608,7 @@ func foreach(n *Node, f func(*Node, interface{}), c interface{}) {
func hascallspred(n *Node, c interface{}) { func hascallspred(n *Node, c interface{}) {
switch n.Op { switch n.Op {
case OCALL, case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER:
OCALLFUNC,
OCALLMETH,
OCALLINTER:
(*c.(*int))++ (*c.(*int))++
} }
} }
@ -640,8 +624,7 @@ func appendinit(np **Node, init *NodeList) {
switch n.Op { switch n.Op {
// There may be multiple refs to this node; // There may be multiple refs to this node;
// introduce OCONVNOP to hold init list. // introduce OCONVNOP to hold init list.
case ONAME, case ONAME, OLITERAL:
OLITERAL:
n = Nod(OCONVNOP, n, nil) n = Nod(OCONVNOP, n, nil)
n.Type = n.Left.Type n.Type = n.Left.Type

View File

@ -1148,8 +1148,7 @@ ok:
ot = duint16(s, ot, uint16(mapbucket(t).Width)) ot = duint16(s, ot, uint16(mapbucket(t).Width))
ot = duint8(s, ot, uint8(bool2int(isreflexive(t.Down)))) ot = duint8(s, ot, uint8(bool2int(isreflexive(t.Down))))
case TPTR32, case TPTR32, TPTR64:
TPTR64:
if t.Type.Etype == TANY { if t.Type.Etype == TANY {
// ../../runtime/type.go:/UnsafePointerType // ../../runtime/type.go:/UnsafePointerType
ot = dcommontype(s, ot, t) ot = dcommontype(s, ot, t)
@ -1213,9 +1212,7 @@ ok:
// we want be able to find. // we want be able to find.
if t.Sym == nil { if t.Sym == nil {
switch t.Etype { switch t.Etype {
case TARRAY, case TARRAY, TCHAN, TMAP:
TCHAN,
TMAP:
slink := typelinksym(t) slink := typelinksym(t)
dsymptr(slink, 0, s, 0) dsymptr(slink, 0, s, 0)
ggloblsym(slink, int32(Widthptr), int8(dupok|obj.RODATA)) ggloblsym(slink, int32(Widthptr), int8(dupok|obj.RODATA))

View File

@ -390,8 +390,7 @@ func mkvar(f *Flow, a *obj.Addr) Bits {
} }
switch et { switch et {
case 0, case 0, TFUNC:
TFUNC:
return zbits return zbits
} }
@ -678,8 +677,7 @@ func allreg(b uint64, r *Rgn) uint64 {
return Thearch.RtoB(i) return Thearch.RtoB(i)
} }
case TFLOAT32, case TFLOAT32, TFLOAT64:
TFLOAT64:
i := Thearch.BtoF(^b) i := Thearch.BtoF(^b)
if i != 0 && r.cost > 0 { if i != 0 && r.cost > 0 {
r.regno = int16(i) r.regno = int16(i)

View File

@ -129,8 +129,7 @@ func walkselect(sel *Node) {
case OSEND: case OSEND:
ch = n.Left ch = n.Left
case OSELRECV, case OSELRECV, OSELRECV2:
OSELRECV2:
ch = n.Right.Left ch = n.Right.Left
if n.Op == OSELRECV || n.Ntest == nil { if n.Op == OSELRECV || n.Ntest == nil {
if n.Left == nil { if n.Left == nil {
@ -185,8 +184,7 @@ func walkselect(sel *Node) {
n.Right = Nod(OADDR, n.Right, nil) n.Right = Nod(OADDR, n.Right, nil)
typecheck(&n.Right, Erv) typecheck(&n.Right, Erv)
case OSELRECV, case OSELRECV, OSELRECV2:
OSELRECV2:
if n.Op == OSELRECV2 && n.Ntest == nil { if n.Op == OSELRECV2 && n.Ntest == nil {
n.Op = OSELRECV n.Op = OSELRECV
} }

View File

@ -42,8 +42,7 @@ func init1(n *Node, out **NodeList) {
return return
} }
switch n.Class { switch n.Class {
case PEXTERN, case PEXTERN, PFUNC:
PFUNC:
break break
default: default:
@ -172,10 +171,7 @@ func init1(n *Node, out **NodeList) {
*out = list(*out, n.Defn) *out = list(*out, n.Defn)
} }
case OAS2FUNC, case OAS2FUNC, OAS2MAPR, OAS2DOTTYPE, OAS2RECV:
OAS2MAPR,
OAS2DOTTYPE,
OAS2RECV:
if n.Defn.Initorder != InitNotStarted { if n.Defn.Initorder != InitNotStarted {
break break
} }
@ -244,9 +240,7 @@ func initreorder(l *NodeList, out **NodeList) {
for ; l != nil; l = l.Next { for ; l != nil; l = l.Next {
n = l.N n = l.N
switch n.Op { switch n.Op {
case ODCLFUNC, case ODCLFUNC, ODCLCONST, ODCLTYPE:
ODCLCONST,
ODCLTYPE:
continue continue
} }
@ -333,9 +327,7 @@ func staticcopy(l *Node, r *Node, out **NodeList) bool {
break break
// copy pointer // copy pointer
case OARRAYLIT, case OARRAYLIT, OSTRUCTLIT, OMAPLIT:
OSTRUCTLIT,
OMAPLIT:
gdata(l, Nod(OADDR, r.Nname, nil), int(l.Type.Width)) gdata(l, Nod(OADDR, r.Nname, nil), int(l.Type.Width))
return true return true
@ -430,9 +422,7 @@ func staticassign(l *Node, r *Node, out **NodeList) bool {
break break
// Init pointer. // Init pointer.
case OARRAYLIT, case OARRAYLIT, OMAPLIT, OSTRUCTLIT:
OMAPLIT,
OSTRUCTLIT:
a := staticname(r.Left.Type, 1) a := staticname(r.Left.Type, 1)
r.Nname = a r.Nname = a
@ -1222,9 +1212,7 @@ func oaslit(n *Node, init **NodeList) bool {
// not a special composit literal assignment // not a special composit literal assignment
return false return false
case OSTRUCTLIT, case OSTRUCTLIT, OARRAYLIT, OMAPLIT:
OARRAYLIT,
OMAPLIT:
if vmatch1(n.Left, n.Right) { if vmatch1(n.Left, n.Right) {
// not a special composit literal assignment // not a special composit literal assignment
return false return false
@ -1377,8 +1365,7 @@ func iszero(n *Node) bool {
case CTBOOL: case CTBOOL:
return n.Val.U.Bval == 0 return n.Val.U.Bval == 0
case CTINT, case CTINT, CTRUNE:
CTRUNE:
return mpcmpfixc(n.Val.U.Xval, 0) == 0 return mpcmpfixc(n.Val.U.Xval, 0) == 0
case CTFLT: case CTFLT:
@ -1522,8 +1509,7 @@ func gen_as_init(n *Node) bool {
TFLOAT64: TFLOAT64:
gdata(&nam, nr, int(nr.Type.Width)) gdata(&nam, nr, int(nr.Type.Width))
case TCOMPLEX64, case TCOMPLEX64, TCOMPLEX128:
TCOMPLEX128:
gdatacomplex(&nam, nr.Val.U.Cval) gdatacomplex(&nam, nr.Val.U.Cval)
case TSTRING: case TSTRING:

View File

@ -257,10 +257,7 @@ func setlineno(n *Node) int32 {
lno := lineno lno := lineno
if n != nil { if n != nil {
switch n.Op { switch n.Op {
case ONAME, case ONAME, OTYPE, OPACK, OLITERAL:
OTYPE,
OPACK,
OLITERAL:
break break
default: default:
@ -435,8 +432,7 @@ func algtype1(t *Type, bad **Type) int {
switch t.Etype { switch t.Etype {
// will be defined later. // will be defined later.
case TANY, case TANY, TFORW:
TFORW:
*bad = t *bad = t
return -1 return -1
@ -459,8 +455,7 @@ func algtype1(t *Type, bad **Type) int {
TUNSAFEPTR: TUNSAFEPTR:
return AMEM return AMEM
case TFUNC, case TFUNC, TMAP:
TMAP:
if bad != nil { if bad != nil {
*bad = t *bad = t
} }
@ -741,8 +736,7 @@ func aindex(b *Node, t *Type) *Type {
default: default:
Yyerror("array bound must be an integer expression") Yyerror("array bound must be an integer expression")
case CTINT, case CTINT, CTRUNE:
CTRUNE:
bound = Mpgetfix(b.Val.U.Xval) bound = Mpgetfix(b.Val.U.Xval)
if bound < 0 { if bound < 0 {
Yyerror("array bound must be non negative") Yyerror("array bound must be non negative")
@ -791,9 +785,7 @@ func treecopy(n *Node) *Node {
fallthrough fallthrough
// fall through // fall through
case ONAME, case ONAME, OLITERAL, OTYPE:
OLITERAL,
OTYPE:
m = n m = n
} }
@ -875,8 +867,7 @@ func isideal(t *Type) bool {
return true return true
} }
switch t.Etype { switch t.Etype {
case TNIL, case TNIL, TIDEAL:
TIDEAL:
return true return true
} }
@ -985,8 +976,7 @@ func eqtype1(t1 *Type, t2 *Type, assumed_equal *TypePairList) bool {
return true return true
} }
case TINT, case TINT, TINT32:
TINT32:
if (t1 == Types[runetype.Etype] || t1 == runetype) && (t2 == Types[runetype.Etype] || t2 == runetype) { if (t1 == Types[runetype.Etype] || t1 == runetype) && (t2 == Types[runetype.Etype] || t2 == runetype) {
return true return true
} }
@ -1004,8 +994,7 @@ func eqtype1(t1 *Type, t2 *Type, assumed_equal *TypePairList) bool {
l.t2 = t2 l.t2 = t2
switch t1.Etype { switch t1.Etype {
case TINTER, case TINTER, TSTRUCT:
TSTRUCT:
t1 = t1.Type t1 = t1.Type
t2 = t2.Type t2 = t2.Type
for ; t1 != nil && t2 != nil; t1, t2 = t1.Down, t2.Down { for ; t1 != nil && t2 != nil; t1, t2 = t1.Down, t2.Down {
@ -1430,9 +1419,7 @@ func Is64(t *Type) bool {
return false return false
} }
switch Simtype[t.Etype] { switch Simtype[t.Etype] {
case TINT64, case TINT64, TUINT64, TPTR64:
TUINT64,
TPTR64:
return true return true
} }
@ -1447,22 +1434,16 @@ func Noconv(t1 *Type, t2 *Type) bool {
e2 := int(Simtype[t2.Etype]) e2 := int(Simtype[t2.Etype])
switch e1 { switch e1 {
case TINT8, case TINT8, TUINT8:
TUINT8:
return e2 == TINT8 || e2 == TUINT8 return e2 == TINT8 || e2 == TUINT8
case TINT16, case TINT16, TUINT16:
TUINT16:
return e2 == TINT16 || e2 == TUINT16 return e2 == TINT16 || e2 == TUINT16
case TINT32, case TINT32, TUINT32, TPTR32:
TUINT32,
TPTR32:
return e2 == TINT32 || e2 == TUINT32 || e2 == TPTR32 return e2 == TINT32 || e2 == TUINT32 || e2 == TPTR32
case TINT64, case TINT64, TUINT64, TPTR64:
TUINT64,
TPTR64:
return e2 == TINT64 || e2 == TUINT64 || e2 == TPTR64 return e2 == TINT64 || e2 == TUINT64 || e2 == TPTR64
case TFLOAT32: case TFLOAT32:
@ -1501,10 +1482,7 @@ func deep(t *Type) *Type {
nt = shallow(t) nt = shallow(t)
nt.Copyany = 1 nt.Copyany = 1
case TPTR32, case TPTR32, TPTR64, TCHAN, TARRAY:
TPTR64,
TCHAN,
TARRAY:
nt = shallow(t) nt = shallow(t)
nt.Type = deep(t.Type) nt.Type = deep(t.Type)
@ -1642,25 +1620,19 @@ func ullmancalc(n *Node) {
} }
switch n.Op { switch n.Op {
case OREGISTER, case OREGISTER, OLITERAL, ONAME:
OLITERAL,
ONAME:
ul = 1 ul = 1
if n.Class == PPARAMREF || (n.Class&PHEAP != 0) { if n.Class == PPARAMREF || (n.Class&PHEAP != 0) {
ul++ ul++
} }
goto out goto out
case OCALL, case OCALL, OCALLFUNC, OCALLMETH, OCALLINTER:
OCALLFUNC,
OCALLMETH,
OCALLINTER:
ul = UINF ul = UINF
goto out goto out
// hard with race detector // hard with race detector
case OANDAND, case OANDAND, OOROR:
OOROR:
if flag_race != 0 { if flag_race != 0 {
ul = UINF ul = UINF
goto out goto out
@ -1726,9 +1698,7 @@ func Structfirst(s *Iter, nn **Type) *Type {
default: default:
goto bad goto bad
case TSTRUCT, case TSTRUCT, TINTER, TFUNC:
TINTER,
TFUNC:
break break
} }
@ -1903,8 +1873,7 @@ func safeexpr(n *Node, init **NodeList) *Node {
} }
switch n.Op { switch n.Op {
case ONAME, case ONAME, OLITERAL:
OLITERAL:
return n return n
case ODOT: case ODOT:
@ -1919,8 +1888,7 @@ func safeexpr(n *Node, init **NodeList) *Node {
walkexpr(&r, init) walkexpr(&r, init)
return r return r
case ODOTPTR, case ODOTPTR, OIND:
OIND:
l := safeexpr(n.Left, init) l := safeexpr(n.Left, init)
if l == n.Left { if l == n.Left {
return n return n
@ -1931,8 +1899,7 @@ func safeexpr(n *Node, init **NodeList) *Node {
walkexpr(&a, init) walkexpr(&a, init)
return a return a
case OINDEX, case OINDEX, OINDEXMAP:
OINDEXMAP:
l := safeexpr(n.Left, init) l := safeexpr(n.Left, init)
r := safeexpr(n.Right, init) r := safeexpr(n.Right, init)
if l == n.Left && r == n.Right { if l == n.Left && r == n.Right {
@ -1968,8 +1935,7 @@ func copyexpr(n *Node, t *Type, init **NodeList) *Node {
*/ */
func cheapexpr(n *Node, init **NodeList) *Node { func cheapexpr(n *Node, init **NodeList) *Node {
switch n.Op { switch n.Op {
case ONAME, case ONAME, OLITERAL:
OLITERAL:
return n return n
} }
@ -3472,8 +3438,7 @@ func addinit(np **Node, init *NodeList) {
switch n.Op { switch n.Op {
// There may be multiple refs to this node; // There may be multiple refs to this node;
// introduce OCONVNOP to hold init list. // introduce OCONVNOP to hold init list.
case ONAME, case ONAME, OLITERAL:
OLITERAL:
n = Nod(OCONVNOP, n, nil) n = Nod(OCONVNOP, n, nil)
n.Type = n.Left.Type n.Type = n.Left.Type

View File

@ -146,10 +146,7 @@ func typecheck(np **Node, top int) *Node {
// But re-typecheck ONAME/OTYPE/OLITERAL/OPACK node in case context has changed. // But re-typecheck ONAME/OTYPE/OLITERAL/OPACK node in case context has changed.
if n.Typecheck == 1 { if n.Typecheck == 1 {
switch n.Op { switch n.Op {
case ONAME, case ONAME, OTYPE, OLITERAL, OPACK:
OTYPE,
OLITERAL,
OPACK:
break break
default: default:
@ -265,10 +262,7 @@ func indexlit(np **Node) {
return return
} }
switch consttype(n) { switch consttype(n) {
case CTINT, case CTINT, CTRUNE, CTFLT, CTCPLX:
CTRUNE,
CTFLT,
CTCPLX:
defaultlit(np, Types[TINT]) defaultlit(np, Types[TINT])
} }
@ -385,8 +379,7 @@ OpSwitch:
l := typecheck(&n.Left, Erv) l := typecheck(&n.Left, Erv)
var v Val var v Val
switch consttype(l) { switch consttype(l) {
case CTINT, case CTINT, CTRUNE:
CTRUNE:
v = l.Val v = l.Val
case CTFLT: case CTFLT:
@ -790,10 +783,7 @@ OpSwitch:
n.Type = t n.Type = t
break OpSwitch break OpSwitch
case OCOM, case OCOM, OMINUS, ONOT, OPLUS:
OMINUS,
ONOT,
OPLUS:
ok |= Erv ok |= Erv
l := typecheck(&n.Left, Erv|top&Eiota) l := typecheck(&n.Left, Erv|top&Eiota)
t := l.Type t := l.Type
@ -939,8 +929,7 @@ OpSwitch:
} }
switch n.Op { switch n.Op {
case ODOTINTER, case ODOTINTER, ODOTMETH:
ODOTMETH:
if top&Ecall != 0 { if top&Ecall != 0 {
ok |= Ecall ok |= Ecall
} else { } else {
@ -1020,8 +1009,7 @@ OpSwitch:
n.Type = nil n.Type = nil
return return
case TSTRING, case TSTRING, TARRAY:
TARRAY:
indexlit(&n.Right) indexlit(&n.Right)
if t.Etype == TSTRING { if t.Etype == TSTRING {
n.Type = Types[TUINT8] n.Type = Types[TUINT8]
@ -1390,10 +1378,7 @@ OpSwitch:
n.Type = getoutargx(l.Type) n.Type = getoutargx(l.Type)
break OpSwitch break OpSwitch
case OCAP, case OCAP, OLEN, OREAL, OIMAG:
OLEN,
OREAL,
OIMAG:
ok |= Erv ok |= Erv
if onearg(n, "%v", Oconv(int(n.Op), 0)) < 0 { if onearg(n, "%v", Oconv(int(n.Op), 0)) < 0 {
n.Type = nil n.Type = nil
@ -1419,8 +1404,7 @@ OpSwitch:
goto badcall1 goto badcall1
} }
case OREAL, case OREAL, OIMAG:
OIMAG:
if !Iscomplex[t.Etype] { if !Iscomplex[t.Etype] {
goto badcall1 goto badcall1
} }
@ -1935,8 +1919,7 @@ OpSwitch:
n.Type = Ptrto(t) n.Type = Ptrto(t)
break OpSwitch break OpSwitch
case OPRINT, case OPRINT, OPRINTN:
OPRINTN:
ok |= Etop ok |= Etop
typechecklist(n.List, Erv|Eindir) // Eindir: address does not escape typechecklist(n.List, Erv|Eindir) // Eindir: address does not escape
for args := n.List; args != nil; args = args.Next { for args := n.List; args != nil; args = args.Next {
@ -2801,8 +2784,7 @@ func keydup(n *Node, hash []*Node) {
default: // unknown, bool, nil default: // unknown, bool, nil
b = 23 b = 23
case CTINT, case CTINT, CTRUNE:
CTRUNE:
b = uint32(Mpgetfix(n.Val.U.Xval)) b = uint32(Mpgetfix(n.Val.U.Xval))
case CTFLT: case CTFLT:
@ -2919,17 +2901,12 @@ func inithash(n *Node, autohash []*Node) []*Node {
func iscomptype(t *Type) bool { func iscomptype(t *Type) bool {
switch t.Etype { switch t.Etype {
case TARRAY, case TARRAY, TSTRUCT, TMAP:
TSTRUCT,
TMAP:
return true return true
case TPTR32, case TPTR32, TPTR64:
TPTR64:
switch t.Type.Etype { switch t.Type.Etype {
case TARRAY, case TARRAY, TSTRUCT, TMAP:
TSTRUCT,
TMAP:
return true return true
} }
} }
@ -3225,10 +3202,7 @@ func islvalue(n *Node) bool {
fallthrough fallthrough
// fall through // fall through
case OIND, case OIND, ODOTPTR, OCLOSUREVAR, OPARAM:
ODOTPTR,
OCLOSUREVAR,
OPARAM:
return true return true
case ODOT: case ODOT:
@ -3298,12 +3272,10 @@ func samesafeexpr(l *Node, r *Node) bool {
} }
switch l.Op { switch l.Op {
case ONAME, case ONAME, OCLOSUREVAR:
OCLOSUREVAR:
return l == r return l == r
case ODOT, case ODOT, ODOTPTR:
ODOTPTR:
return l.Right != nil && r.Right != nil && l.Right.Sym == r.Right.Sym && samesafeexpr(l.Left, r.Left) return l.Right != nil && r.Right != nil && l.Right.Sym == r.Right.Sym && samesafeexpr(l.Left, r.Left)
case OIND: case OIND:
@ -3364,9 +3336,7 @@ func typecheckas(n *Node) {
switch n.Right.Op { switch n.Right.Op {
// For x = x[0:y], x can be updated in place, without touching pointer. // For x = x[0:y], x can be updated in place, without touching pointer.
// TODO(rsc): Reenable once it is actually updated in place without touching the pointer. // TODO(rsc): Reenable once it is actually updated in place without touching the pointer.
case OSLICE, case OSLICE, OSLICE3, OSLICESTR:
OSLICE3,
OSLICESTR:
if false && samesafeexpr(n.Left, n.Right.Left) && (n.Right.Right.Left == nil || iszero(n.Right.Right.Left)) { if false && samesafeexpr(n.Left, n.Right.Left) && (n.Right.Right.Left == nil || iszero(n.Right.Right.Left)) {
n.Right.Reslice = true n.Right.Reslice = true
} }
@ -3439,9 +3409,7 @@ func typecheckas2(n *Node) {
goto out goto out
} }
switch r.Op { switch r.Op {
case OCALLMETH, case OCALLMETH, OCALLINTER, OCALLFUNC:
OCALLINTER,
OCALLFUNC:
if r.Type.Etype != TSTRUCT || r.Type.Funarg == 0 { if r.Type.Etype != TSTRUCT || r.Type.Funarg == 0 {
break break
} }
@ -3766,8 +3734,7 @@ func typecheckdef(n *Node) *Node {
Fatal("typecheckdef %v", Oconv(int(n.Op), 0)) Fatal("typecheckdef %v", Oconv(int(n.Op), 0))
// not really syms // not really syms
case OGOTO, case OGOTO, OLABEL:
OLABEL:
break break
case OLITERAL: case OLITERAL:
@ -3901,10 +3868,7 @@ ret:
func checkmake(t *Type, arg string, n *Node) int { func checkmake(t *Type, arg string, n *Node) int {
if n.Op == OLITERAL { if n.Op == OLITERAL {
switch n.Val.Ctype { switch n.Val.Ctype {
case CTINT, case CTINT, CTRUNE, CTFLT, CTCPLX:
CTRUNE,
CTFLT,
CTCPLX:
n.Val = toint(n.Val) n.Val = toint(n.Val)
if mpcmpfixc(n.Val.U.Xval, 0) < 0 { if mpcmpfixc(n.Val.U.Xval, 0) < 0 {
Yyerror("negative %s argument in make(%v)", arg, Tconv(t, 0)) Yyerror("negative %s argument in make(%v)", arg, Tconv(t, 0))
@ -4054,9 +4018,7 @@ func isterminating(l *NodeList, top int) bool {
case OIF: case OIF:
return isterminating(n.Nbody, 0) && isterminating(n.Nelse, 0) return isterminating(n.Nbody, 0) && isterminating(n.Nelse, 0)
case OSWITCH, case OSWITCH, OTYPESW, OSELECT:
OTYPESW,
OSELECT:
if n.Hasbreak { if n.Hasbreak {
return false return false
} }

View File

@ -62,8 +62,7 @@ func unsafenmagic(nn *Node) *Node {
base := r.Left base := r.Left
typecheck(&r, Erv) typecheck(&r, Erv)
switch r.Op { switch r.Op {
case ODOT, case ODOT, ODOTPTR:
ODOTPTR:
break break
case OCALLPART: case OCALLPART:

View File

@ -232,8 +232,7 @@ func walkstmt(np **Node) {
case ODEFER: case ODEFER:
Hasdefer = 1 Hasdefer = 1
switch n.Left.Op { switch n.Left.Op {
case OPRINT, case OPRINT, OPRINTN:
OPRINTN:
walkprintfunc(&n.Left, &n.Ninit) walkprintfunc(&n.Left, &n.Ninit)
case OCOPY: case OCOPY:
@ -265,8 +264,7 @@ func walkstmt(np **Node) {
case OPROC: case OPROC:
switch n.Left.Op { switch n.Left.Op {
case OPRINT, case OPRINT, OPRINTN:
OPRINTN:
walkprintfunc(&n.Left, &n.Ninit) walkprintfunc(&n.Left, &n.Ninit)
case OCOPY: case OCOPY:
@ -466,13 +464,11 @@ func walkexpr(np **Node, init **NodeList) {
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
goto ret goto ret
case OSPTR, case OSPTR, OITAB:
OITAB:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
goto ret goto ret
case OLEN, case OLEN, OCAP:
OCAP:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
// replace len(*[10]int) with 10. // replace len(*[10]int) with 10.
@ -490,8 +486,7 @@ func walkexpr(np **Node, init **NodeList) {
goto ret goto ret
case OLSH, case OLSH, ORSH:
ORSH:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
t := n.Left.Type t := n.Left.Type
@ -521,15 +516,13 @@ func walkexpr(np **Node, init **NodeList) {
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
goto ret goto ret
case OOR, case OOR, OXOR:
OXOR:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
walkrotate(&n) walkrotate(&n)
goto ret goto ret
case OEQ, case OEQ, ONE:
ONE:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
@ -545,8 +538,7 @@ func walkexpr(np **Node, init **NodeList) {
safemode = old_safemode safemode = old_safemode
goto ret goto ret
case OANDAND, case OANDAND, OOROR:
OOROR:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
// cannot put side effects from n.Right on init, // cannot put side effects from n.Right on init,
@ -558,8 +550,7 @@ func walkexpr(np **Node, init **NodeList) {
addinit(&n.Right, ll) addinit(&n.Right, ll)
goto ret goto ret
case OPRINT, case OPRINT, OPRINTN:
OPRINTN:
walkexprlist(n.List, init) walkexprlist(n.List, init)
n = walkprint(n, init) n = walkprint(n, init)
goto ret goto ret
@ -576,8 +567,7 @@ func walkexpr(np **Node, init **NodeList) {
n.Addable = 1 n.Addable = 1
goto ret goto ret
case OCLOSUREVAR, case OCLOSUREVAR, OCFUNC:
OCFUNC:
n.Addable = 1 n.Addable = 1
goto ret goto ret
@ -784,12 +774,10 @@ func walkexpr(np **Node, init **NodeList) {
p := "" p := ""
if t.Type.Width <= 128 { // Check ../../runtime/hashmap.go:maxValueSize before changing. if t.Type.Width <= 128 { // Check ../../runtime/hashmap.go:maxValueSize before changing.
switch Simsimtype(t.Down) { switch Simsimtype(t.Down) {
case TINT32, case TINT32, TUINT32:
TUINT32:
p = "mapaccess2_fast32" p = "mapaccess2_fast32"
case TINT64, case TINT64, TUINT64:
TUINT64:
p = "mapaccess2_fast64" p = "mapaccess2_fast64"
case TSTRING: case TSTRING:
@ -1066,8 +1054,7 @@ func walkexpr(np **Node, init **NodeList) {
walkexpr(&n, init) walkexpr(&n, init)
goto ret goto ret
case OCONV, case OCONV, OCONVNOP:
OCONVNOP:
if Thearch.Thechar == '5' { if Thearch.Thechar == '5' {
if Isfloat[n.Left.Type.Etype] { if Isfloat[n.Left.Type.Etype] {
if n.Type.Etype == TINT64 { if n.Type.Etype == TINT64 {
@ -1111,8 +1098,7 @@ func walkexpr(np **Node, init **NodeList) {
walkmul(&n, init) walkmul(&n, init)
goto ret goto ret
case ODIV, case ODIV, OMOD:
OMOD:
walkexpr(&n.Left, init) walkexpr(&n.Left, init)
walkexpr(&n.Right, init) walkexpr(&n.Right, init)
@ -1141,8 +1127,7 @@ func walkexpr(np **Node, init **NodeList) {
* on 32-bit architectures. * on 32-bit architectures.
*/ */
switch n.Op { switch n.Op {
case OMOD, case OMOD, ODIV:
ODIV:
if Widthreg >= 8 || (et != TUINT64 && et != TINT64) { if Widthreg >= 8 || (et != TUINT64 && et != TINT64) {
goto ret goto ret
} }
@ -1229,12 +1214,10 @@ func walkexpr(np **Node, init **NodeList) {
p := "" p := ""
if t.Type.Width <= 128 { // Check ../../runtime/hashmap.go:maxValueSize before changing. if t.Type.Width <= 128 { // Check ../../runtime/hashmap.go:maxValueSize before changing.
switch Simsimtype(t.Down) { switch Simsimtype(t.Down) {
case TINT32, case TINT32, TUINT32:
TUINT32:
p = "mapaccess1_fast32" p = "mapaccess1_fast32"
case TINT64, case TINT64, TUINT64:
TUINT64:
p = "mapaccess1_fast64" p = "mapaccess1_fast64"
case TSTRING: case TSTRING:
@ -1277,8 +1260,7 @@ func walkexpr(np **Node, init **NodeList) {
fallthrough fallthrough
// fallthrough // fallthrough
case OSLICEARR, case OSLICEARR, OSLICESTR:
OSLICESTR:
if n.Right == nil { // already processed if n.Right == nil { // already processed
goto ret goto ret
} }
@ -1299,8 +1281,7 @@ func walkexpr(np **Node, init **NodeList) {
n = sliceany(n, init) // chops n.Right, sets n.List n = sliceany(n, init) // chops n.Right, sets n.List
goto ret goto ret
case OSLICE3, case OSLICE3, OSLICE3ARR:
OSLICE3ARR:
if n.Right == nil { // already processed if n.Right == nil { // already processed
goto ret goto ret
} }
@ -1606,10 +1587,7 @@ func walkexpr(np **Node, init **NodeList) {
n = r n = r
goto ret goto ret
case OARRAYLIT, case OARRAYLIT, OMAPLIT, OSTRUCTLIT, OPTRLIT:
OMAPLIT,
OSTRUCTLIT,
OPTRLIT:
var_ := temp(n.Type) var_ := temp(n.Type)
anylit(0, n, var_, init) anylit(0, n, var_, init)
n = var_ n = var_
@ -2125,9 +2103,7 @@ func isstack(n *Node) bool {
case ONAME: case ONAME:
switch n.Class { switch n.Class {
case PAUTO, case PAUTO, PPARAM, PPARAMOUT:
PPARAM,
PPARAMOUT:
return true return true
} }
} }
@ -2207,10 +2183,7 @@ func needwritebarrier(l *Node, r *Node) bool {
// small compared to the cost of the allocation.) // small compared to the cost of the allocation.)
if r.Reslice { if r.Reslice {
switch r.Op { switch r.Op {
case OSLICE, case OSLICE, OSLICE3, OSLICESTR, OAPPEND:
OSLICE3,
OSLICESTR,
OAPPEND:
break break
default: default:
@ -2449,16 +2422,14 @@ func reorder3(all *NodeList) *NodeList {
case ONAME: case ONAME:
break break
case OINDEX, case OINDEX, OINDEXMAP:
OINDEXMAP:
reorder3save(&l.Left, all, list, &early) reorder3save(&l.Left, all, list, &early)
reorder3save(&l.Right, all, list, &early) reorder3save(&l.Right, all, list, &early)
if l.Op == OINDEXMAP { if l.Op == OINDEXMAP {
list.N = convas(list.N, &mapinit) list.N = convas(list.N, &mapinit)
} }
case OIND, case OIND, ODOTPTR:
ODOTPTR:
reorder3save(&l.Left, all, list, &early) reorder3save(&l.Left, all, list, &early)
} }
@ -2544,9 +2515,7 @@ func aliased(n *Node, all *NodeList, stop *NodeList) bool {
varwrite = 1 varwrite = 1
continue continue
case PAUTO, case PAUTO, PPARAM, PPARAMOUT:
PPARAM,
PPARAMOUT:
if n.Addrtaken { if n.Addrtaken {
varwrite = 1 varwrite = 1
continue continue
@ -2596,9 +2565,7 @@ func varexpr(n *Node) bool {
case ONAME: case ONAME:
switch n.Class { switch n.Class {
case PAUTO, case PAUTO, PPARAM, PPARAMOUT:
PPARAM,
PPARAMOUT:
if !n.Addrtaken { if !n.Addrtaken {
return true return true
} }
@ -2679,9 +2646,7 @@ func vmatch1(l *Node, r *Node) bool {
switch l.Op { switch l.Op {
case ONAME: case ONAME:
switch l.Class { switch l.Class {
case PPARAM, case PPARAM, PPARAMREF, PAUTO:
PPARAMREF,
PAUTO:
break break
// assignment to non-stack variable // assignment to non-stack variable
@ -3622,8 +3587,7 @@ func samecheap(a *Node, b *Node) bool {
case ONAME: case ONAME:
return a == b return a == b
case ODOT, case ODOT, ODOTPTR:
ODOTPTR:
ar = a.Right ar = a.Right
br = b.Right br = b.Right
if ar.Op != ONAME || br.Op != ONAME || ar.Sym != br.Sym { if ar.Op != ONAME || br.Op != ONAME || ar.Sym != br.Sym {
@ -3845,9 +3809,7 @@ func walkdiv(np **Node, init **NodeList) {
return return
// n1 = nl * magic >> w (HMUL) // n1 = nl * magic >> w (HMUL)
case TUINT8, case TUINT8, TUINT16, TUINT32:
TUINT16,
TUINT32:
nc := Nod(OXXX, nil, nil) nc := Nod(OXXX, nil, nil)
Nodconst(nc, nl.Type, int64(m.Um)) Nodconst(nc, nl.Type, int64(m.Um))
@ -3861,15 +3823,13 @@ func walkdiv(np **Node, init **NodeList) {
default: default:
return return
case TUINT8, case TUINT8, TUINT16:
TUINT16:
twide = Types[TUINT32] twide = Types[TUINT32]
case TUINT32: case TUINT32:
twide = Types[TUINT64] twide = Types[TUINT64]
case TINT8, case TINT8, TINT16:
TINT16:
twide = Types[TINT32] twide = Types[TINT32]
case TINT32: case TINT32:
@ -3894,9 +3854,7 @@ func walkdiv(np **Node, init **NodeList) {
} }
// n1 = nl * magic >> w // n1 = nl * magic >> w
case TINT8, case TINT8, TINT16, TINT32:
TINT16,
TINT32:
nc := Nod(OXXX, nil, nil) nc := Nod(OXXX, nil, nil)
Nodconst(nc, nl.Type, m.Sm) Nodconst(nc, nl.Type, m.Sm)
@ -4111,8 +4069,7 @@ func usefield(n *Node) {
default: default:
Fatal("usefield %v", Oconv(int(n.Op), 0)) Fatal("usefield %v", Oconv(int(n.Op), 0))
case ODOT, case ODOT, ODOTPTR:
ODOTPTR:
break break
} }
@ -4220,8 +4177,7 @@ func candiscard(n *Node) bool {
break break
// Discardable as long as we know it's not division by zero. // Discardable as long as we know it's not division by zero.
case ODIV, case ODIV, OMOD:
OMOD:
if Isconst(n.Right, CTINT) && mpcmpfixc(n.Right.Val.U.Xval, 0) != 0 { if Isconst(n.Right, CTINT) && mpcmpfixc(n.Right.Val.U.Xval, 0) != 0 {
break break
} }
@ -4231,8 +4187,7 @@ func candiscard(n *Node) bool {
return false return false
// Discardable as long as we know it won't fail because of a bad size. // Discardable as long as we know it won't fail because of a bad size.
case OMAKECHAN, case OMAKECHAN, OMAKEMAP:
OMAKEMAP:
if Isconst(n.Left, CTINT) && mpcmpfixc(n.Left.Val.U.Xval, 0) == 0 { if Isconst(n.Left, CTINT) && mpcmpfixc(n.Left.Val.U.Xval, 0) == 0 {
break break
} }

View File

@ -465,8 +465,7 @@ func relocsym(s *LSym) {
} }
// r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call. // r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call.
case R_CALL, case R_CALL, R_PCREL:
R_PCREL:
if Linkmode == LinkExternal && r.Sym != nil && r.Sym.Type != SCONST && r.Sym.Sect != Ctxt.Cursym.Sect { if Linkmode == LinkExternal && r.Sym != nil && r.Sym.Type != SCONST && r.Sym.Sect != Ctxt.Cursym.Sect {
r.Done = 0 r.Done = 0

View File

@ -1557,10 +1557,7 @@ func defdwsymb(sym *LSym, s string, t int, v int64, size int64, ver int, gotype
default: default:
return return
case 'd', case 'd', 'b', 'D', 'B':
'b',
'D',
'B':
dv = newdie(&dwglobals, DW_ABRV_VARIABLE, s) dv = newdie(&dwglobals, DW_ABRV_VARIABLE, s)
newabslocexprattr(dv, v, sym) newabslocexprattr(dv, v, sym)
if ver == 0 { if ver == 0 {
@ -1569,8 +1566,7 @@ func defdwsymb(sym *LSym, s string, t int, v int64, size int64, ver int, gotype
fallthrough fallthrough
// fallthrough // fallthrough
case 'a', case 'a', 'p':
'p':
dt = defgotype(gotype) dt = defgotype(gotype)
} }
@ -2054,8 +2050,7 @@ func writeinfo() {
*/ */
func ispubname(die *DWDie) bool { func ispubname(die *DWDie) bool {
switch die.abbrev { switch die.abbrev {
case DW_ABRV_FUNCTION, case DW_ABRV_FUNCTION, DW_ABRV_VARIABLE:
DW_ABRV_VARIABLE:
a := getattr(die, DW_AT_external) a := getattr(die, DW_AT_external)
return a != nil && a.value != 0 return a != nil && a.value != 0
} }

View File

@ -2044,9 +2044,7 @@ func Asmbelf(symo int64) {
} }
switch eh.machine { switch eh.machine {
case EM_X86_64, case EM_X86_64, EM_PPC64, EM_AARCH64:
EM_PPC64,
EM_AARCH64:
sh := elfshname(".rela.plt") sh := elfshname(".rela.plt")
sh.type_ = SHT_RELA sh.type_ = SHT_RELA
sh.flags = SHF_ALLOC sh.flags = SHF_ALLOC

View File

@ -885,9 +885,7 @@ func readelfsym(elfobj *ElfObj, i int, sym *ElfSym, needSym int) (err error) {
case ElfSymTypeSection: case ElfSymTypeSection:
s = elfobj.sect[sym.shndx].sym s = elfobj.sect[sym.shndx].sym
case ElfSymTypeObject, case ElfSymTypeObject, ElfSymTypeFunc, ElfSymTypeNone:
ElfSymTypeFunc,
ElfSymTypeNone:
switch sym.bind { switch sym.bind {
case ElfSymBindGlobal: case ElfSymBindGlobal:
if needSym != 0 { if needSym != 0 {

View File

@ -312,16 +312,14 @@ func ldpe(f *Biobuf, pkg string, length int64, pn string) {
Diag("%s: unknown relocation type %d;", pn, type_) Diag("%s: unknown relocation type %d;", pn, type_)
fallthrough fallthrough
case IMAGE_REL_I386_REL32, case IMAGE_REL_I386_REL32, IMAGE_REL_AMD64_REL32,
IMAGE_REL_AMD64_REL32,
IMAGE_REL_AMD64_ADDR32, // R_X86_64_PC32 IMAGE_REL_AMD64_ADDR32, // R_X86_64_PC32
IMAGE_REL_AMD64_ADDR32NB: IMAGE_REL_AMD64_ADDR32NB:
rp.Type = R_PCREL rp.Type = R_PCREL
rp.Add = int64(int32(Le32(rsect.base[rp.Off:]))) rp.Add = int64(int32(Le32(rsect.base[rp.Off:])))
case IMAGE_REL_I386_DIR32NB, case IMAGE_REL_I386_DIR32NB, IMAGE_REL_I386_DIR32:
IMAGE_REL_I386_DIR32:
rp.Type = R_ADDR rp.Type = R_ADDR
// load addend from image // load addend from image
@ -510,15 +508,12 @@ func readpesym(peobj *PeObj, i int, y **PeSym) (err error) {
err = fmt.Errorf("%s: invalid symbol type %d", sym.name, sym.type_) err = fmt.Errorf("%s: invalid symbol type %d", sym.name, sym.type_)
return err return err
case IMAGE_SYM_DTYPE_FUNCTION, case IMAGE_SYM_DTYPE_FUNCTION, IMAGE_SYM_DTYPE_NULL:
IMAGE_SYM_DTYPE_NULL:
switch sym.sclass { switch sym.sclass {
case IMAGE_SYM_CLASS_EXTERNAL: //global case IMAGE_SYM_CLASS_EXTERNAL: //global
s = Linklookup(Ctxt, name, 0) s = Linklookup(Ctxt, name, 0)
case IMAGE_SYM_CLASS_NULL, case IMAGE_SYM_CLASS_NULL, IMAGE_SYM_CLASS_STATIC, IMAGE_SYM_CLASS_LABEL:
IMAGE_SYM_CLASS_STATIC,
IMAGE_SYM_CLASS_LABEL:
s = Linklookup(Ctxt, name, Ctxt.Version) s = Linklookup(Ctxt, name, Ctxt.Version)
s.Dupok = 1 s.Dupok = 1

View File

@ -706,8 +706,7 @@ func hostlink() {
case '8': case '8':
argv = append(argv, "-m32") argv = append(argv, "-m32")
case '6', case '6', '9':
'9':
argv = append(argv, "-m64") argv = append(argv, "-m64")
case '5': case '5':
@ -1173,10 +1172,7 @@ func stkcheck(up *Chain, depth int) int {
r = &s.R[ri] r = &s.R[ri]
switch r.Type { switch r.Type {
// Direct call. // Direct call.
case R_CALL, case R_CALL, R_CALLARM, R_CALLARM64, R_CALLPOWER:
R_CALLARM,
R_CALLARM64,
R_CALLPOWER:
ch.limit = int(int32(limit) - pcsp.value - int32(callsize())) ch.limit = int(int32(limit) - pcsp.value - int32(callsize()))
ch.sym = r.Sym ch.sym = r.Sym
@ -1357,8 +1353,7 @@ func genasmsym(put func(*LSym, string, int, int64, int64, int, *LSym)) {
} }
put(s, s.Name, 'D', Symaddr(s), s.Size, int(s.Version), s.Gotype) put(s, s.Name, 'D', Symaddr(s), s.Size, int(s.Version), s.Gotype)
case SBSS, case SBSS, SNOPTRBSS:
SNOPTRBSS:
if !s.Reachable { if !s.Reachable {
continue continue
} }

View File

@ -125,8 +125,7 @@ var load_budget int = INITIAL_MACHO_HEADR - 2*1024
func Machoinit() { func Machoinit() {
switch Thearch.Thechar { switch Thearch.Thechar {
// 64-bit architectures // 64-bit architectures
case '6', case '6', '9':
'9':
macho64 = true macho64 = true
// 32-bit architectures // 32-bit architectures
@ -565,9 +564,7 @@ func addsym(s *LSym, name string, type_ int, addr int64, size int64, ver int, go
default: default:
return return
case 'D', case 'D', 'B', 'T':
'B',
'T':
break break
} }

View File

@ -948,10 +948,7 @@ func addpesym(s *LSym, name string, type_ int, addr int64, size int64, ver int,
default: default:
return return
case 'D', case 'D', 'B', 'T', 'U':
'B',
'T',
'U':
break break
} }

View File

@ -92,8 +92,7 @@ func linknew(arch *LinkArch) *Link {
default: default:
log.Fatalf("unknown thread-local storage offset for %s", Headstr(ctxt.Headtype)) log.Fatalf("unknown thread-local storage offset for %s", Headstr(ctxt.Headtype))
case Hplan9, case Hplan9, Hwindows:
Hwindows:
break break
/* /*

View File

@ -57,9 +57,7 @@ func putelfstr(s string) int {
func putelfsyment(off int, addr int64, size int64, info int, shndx int, other int) { func putelfsyment(off int, addr int64, size int64, info int, shndx int, other int) {
switch Thearch.Thechar { switch Thearch.Thechar {
case '6', case '6', '7', '9':
'7',
'9':
Thearch.Lput(uint32(off)) Thearch.Lput(uint32(off))
Cput(uint8(info)) Cput(uint8(info))
Cput(uint8(other)) Cput(uint8(other))
@ -197,10 +195,7 @@ func Asmelfsym() {
func putplan9sym(x *LSym, s string, t int, addr int64, size int64, ver int, go_ *LSym) { func putplan9sym(x *LSym, s string, t int, addr int64, size int64, ver int, go_ *LSym) {
switch t { switch t {
case 'T', case 'T', 'L', 'D', 'B':
'L',
'D',
'B':
if ver != 0 { if ver != 0 {
t += 'a' - 'A' t += 'a' - 'A'
} }

View File

@ -334,8 +334,7 @@ func asmoutnacl(ctxt *obj.Link, origPC int32, p *obj.Prog, o *Optab, out []uint3
} }
} }
case AB, case AB, ABL:
ABL:
if p.To.Type != obj.TYPE_MEM { if p.To.Type != obj.TYPE_MEM {
if out != nil { if out != nil {
asmout(ctxt, p, o, out) asmout(ctxt, p, o, out)
@ -1265,8 +1264,7 @@ func cmp(a int, b int) bool {
case C_HFAUTO: case C_HFAUTO:
return b == C_HAUTO || b == C_FAUTO return b == C_HAUTO || b == C_FAUTO
case C_FAUTO, case C_FAUTO, C_HAUTO:
C_HAUTO:
return b == C_HFAUTO return b == C_HFAUTO
case C_SAUTO: case C_SAUTO:
@ -1278,15 +1276,13 @@ func cmp(a int, b int) bool {
case C_HFOREG: case C_HFOREG:
return b == C_HOREG || b == C_FOREG return b == C_HOREG || b == C_FOREG
case C_FOREG, case C_FOREG, C_HOREG:
C_HOREG:
return b == C_HFOREG return b == C_HFOREG
case C_SROREG: case C_SROREG:
return cmp(C_SOREG, b) || cmp(C_ROREG, b) return cmp(C_SOREG, b) || cmp(C_ROREG, b)
case C_SOREG, case C_SOREG, C_ROREG:
C_ROREG:
return b == C_SROREG || cmp(C_HFOREG, b) return b == C_SROREG || cmp(C_HFOREG, b)
case C_LOREG: case C_LOREG:
@ -1868,8 +1864,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
o1 |= (uint32(p.To.Reg) & 1) << 22 o1 |= (uint32(p.To.Reg) & 1) << 22
o1 |= (uint32(p.From.Reg) & 15) << 0 o1 |= (uint32(p.From.Reg) & 15) << 0
case 38, case 38, 39:
39:
switch o.type_ { switch o.type_ {
case 38: /* movm $con,oreg -> stm */ case 38: /* movm $con,oreg -> stm */
o1 = 0x4 << 25 o1 = 0x4 << 25
@ -2462,8 +2457,7 @@ func oprrr(ctxt *obj.Link, a int, sc int) uint32 {
ctxt.Diag(".nil/.W on dp instruction") ctxt.Diag(".nil/.W on dp instruction")
} }
switch a { switch a {
case AMULU, case AMULU, AMUL:
AMUL:
return o | 0x0<<21 | 0x9<<4 return o | 0x0<<21 | 0x9<<4
case AMULA: case AMULA:
return o | 0x1<<21 | 0x9<<4 return o | 0x1<<21 | 0x9<<4
@ -2502,9 +2496,7 @@ func oprrr(ctxt *obj.Link, a int, sc int) uint32 {
case AORR: case AORR:
return o | 0xc<<21 return o | 0xc<<21
case AMOVB, case AMOVB, AMOVH, AMOVW:
AMOVH,
AMOVW:
return o | 0xd<<21 return o | 0xd<<21
case ABIC: case ABIC:
return o | 0xe<<21 return o | 0xe<<21

View File

@ -283,10 +283,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
case obj.ARET: case obj.ARET:
break break
case ADIV, case ADIV, ADIVU, AMOD, AMODU:
ADIVU,
AMOD,
AMODU:
q = p q = p
if ctxt.Sym_div == nil { if ctxt.Sym_div == nil {
initdiv(ctxt) initdiv(ctxt)
@ -524,10 +521,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
p.Spadj = int32(p.From.Offset) p.Spadj = int32(p.From.Offset)
} }
case ADIV, case ADIV, ADIVU, AMOD, AMODU:
ADIVU,
AMOD,
AMODU:
if ctxt.Debugdivmod != 0 { if ctxt.Debugdivmod != 0 {
break break
} }

View File

@ -1595,8 +1595,7 @@ func buildop(ctxt *obj.Link) {
case ATBZ: case ATBZ:
oprange[ATBNZ] = t oprange[ATBNZ] = t
case AADR, case AADR, AADRP:
AADRP:
break break
case ACLREX: case ACLREX:
@ -1670,8 +1669,7 @@ func buildop(ctxt *obj.Link) {
case AFCSELD: case AFCSELD:
oprange[AFCSELS] = t oprange[AFCSELS] = t
case AFMOVS, case AFMOVS, AFMOVD:
AFMOVD:
break break
case AFCVTZSD: case AFCVTZSD:
@ -1698,16 +1696,14 @@ func buildop(ctxt *obj.Link) {
oprange[AIC] = t oprange[AIC] = t
oprange[ATLBI] = t oprange[ATLBI] = t
case ASYSL, case ASYSL, AHINT:
AHINT:
break break
case ADMB: case ADMB:
oprange[ADSB] = t oprange[ADSB] = t
oprange[AISB] = t oprange[AISB] = t
case AMRS, case AMRS, AMSR:
AMSR:
break break
case ALDAR: case ALDAR:
@ -2518,24 +2514,19 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
as = AMOVWU /* clearer in disassembly */ as = AMOVWU /* clearer in disassembly */
} }
switch as { switch as {
case AMOVB, case AMOVB, ASXTB:
ASXTB:
o1 = opbfm(ctxt, ASBFM, 0, 7, rf, rt) o1 = opbfm(ctxt, ASBFM, 0, 7, rf, rt)
case AMOVH, case AMOVH, ASXTH:
ASXTH:
o1 = opbfm(ctxt, ASBFM, 0, 15, rf, rt) o1 = opbfm(ctxt, ASBFM, 0, 15, rf, rt)
case AMOVW, case AMOVW, ASXTW:
ASXTW:
o1 = opbfm(ctxt, ASBFM, 0, 31, rf, rt) o1 = opbfm(ctxt, ASBFM, 0, 31, rf, rt)
case AMOVBU, case AMOVBU, AUXTB:
AUXTB:
o1 = opbfm(ctxt, AUBFM, 0, 7, rf, rt) o1 = opbfm(ctxt, AUBFM, 0, 7, rf, rt)
case AMOVHU, case AMOVHU, AUXTH:
AUXTH:
o1 = opbfm(ctxt, AUBFM, 0, 15, rf, rt) o1 = opbfm(ctxt, AUBFM, 0, 15, rf, rt)
case AMOVWU: case AMOVWU:
@ -2814,20 +2805,16 @@ func oprrr(ctxt *obj.Link, a int) uint32 {
case AADCSW: case AADCSW:
return S32 | 0<<30 | 1<<29 | 0xd0<<21 | 0<<10 return S32 | 0<<30 | 1<<29 | 0xd0<<21 | 0<<10
case ANGC, case ANGC, ASBC:
ASBC:
return S64 | 1<<30 | 0<<29 | 0xd0<<21 | 0<<10 return S64 | 1<<30 | 0<<29 | 0xd0<<21 | 0<<10
case ANGCS, case ANGCS, ASBCS:
ASBCS:
return S64 | 1<<30 | 1<<29 | 0xd0<<21 | 0<<10 return S64 | 1<<30 | 1<<29 | 0xd0<<21 | 0<<10
case ANGCW, case ANGCW, ASBCW:
ASBCW:
return S32 | 1<<30 | 0<<29 | 0xd0<<21 | 0<<10 return S32 | 1<<30 | 0<<29 | 0xd0<<21 | 0<<10
case ANGCSW, case ANGCSW, ASBCSW:
ASBCSW:
return S32 | 1<<30 | 1<<29 | 0xd0<<21 | 0<<10 return S32 | 1<<30 | 1<<29 | 0xd0<<21 | 0<<10
case AADD: case AADD:
@ -2836,12 +2823,10 @@ func oprrr(ctxt *obj.Link, a int) uint32 {
case AADDW: case AADDW:
return S32 | 0<<30 | 0<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10 return S32 | 0<<30 | 0<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10
case ACMN, case ACMN, AADDS:
AADDS:
return S64 | 0<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10 return S64 | 0<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10
case ACMNW, case ACMNW, AADDSW:
AADDSW:
return S32 | 0<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10 return S32 | 0<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10
case ASUB: case ASUB:
@ -2850,12 +2835,10 @@ func oprrr(ctxt *obj.Link, a int) uint32 {
case ASUBW: case ASUBW:
return S32 | 1<<30 | 0<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10 return S32 | 1<<30 | 0<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10
case ACMP, case ACMP, ASUBS:
ASUBS:
return S64 | 1<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10 return S64 | 1<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10
case ACMPW, case ACMPW, ASUBSW:
ASUBSW:
return S32 | 1<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10 return S32 | 1<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 0<<21 | 0<<10
case AAND: case AAND:
@ -2864,13 +2847,11 @@ func oprrr(ctxt *obj.Link, a int) uint32 {
case AANDW: case AANDW:
return S32 | 0<<29 | 0xA<<24 return S32 | 0<<29 | 0xA<<24
case AMOVD, case AMOVD, AORR:
AORR:
return S64 | 1<<29 | 0xA<<24 return S64 | 1<<29 | 0xA<<24
// case AMOVW: // case AMOVW:
case AMOVWU, case AMOVWU, AORRW:
AORRW:
return S32 | 1<<29 | 0xA<<24 return S32 | 1<<29 | 0xA<<24
case AEOR: case AEOR:
@ -2903,12 +2884,10 @@ func oprrr(ctxt *obj.Link, a int) uint32 {
case AEONW: case AEONW:
return S32 | 2<<29 | 0xA<<24 | 1<<21 return S32 | 2<<29 | 0xA<<24 | 1<<21
case AMVN, case AMVN, AORN:
AORN:
return S64 | 1<<29 | 0xA<<24 | 1<<21 return S64 | 1<<29 | 0xA<<24 | 1<<21
case AMVNW, case AMVNW, AORNW:
AORNW:
return S32 | 1<<29 | 0xA<<24 | 1<<21 return S32 | 1<<29 | 0xA<<24 | 1<<21
case AASR: case AASR:
@ -2989,44 +2968,34 @@ func oprrr(ctxt *obj.Link, a int) uint32 {
case ACSETMW: case ACSETMW:
return S32 | 1<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 0<<10 return S32 | 1<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 0<<10
case ACINC, case ACINC, ACSINC:
ACSINC:
return S64 | 0<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 1<<10 return S64 | 0<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 1<<10
case ACINCW, case ACINCW, ACSINCW:
ACSINCW:
return S32 | 0<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 1<<10 return S32 | 0<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 1<<10
case ACINV, case ACINV, ACSINV:
ACSINV:
return S64 | 1<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 0<<10 return S64 | 1<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 0<<10
case ACINVW, case ACINVW, ACSINVW:
ACSINVW:
return S32 | 1<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 0<<10 return S32 | 1<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 0<<10
case ACNEG, case ACNEG, ACSNEG:
ACSNEG:
return S64 | 1<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 1<<10 return S64 | 1<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 1<<10
case ACNEGW, case ACNEGW, ACSNEGW:
ACSNEGW:
return S32 | 1<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 1<<10 return S32 | 1<<30 | 0<<29 | 0xD4<<21 | 0<<11 | 1<<10
case AMUL, case AMUL, AMADD:
AMADD:
return S64 | 0<<29 | 0x1B<<24 | 0<<21 | 0<<15 return S64 | 0<<29 | 0x1B<<24 | 0<<21 | 0<<15
case AMULW, case AMULW, AMADDW:
AMADDW:
return S32 | 0<<29 | 0x1B<<24 | 0<<21 | 0<<15 return S32 | 0<<29 | 0x1B<<24 | 0<<21 | 0<<15
case AMNEG, case AMNEG, AMSUB:
AMSUB:
return S64 | 0<<29 | 0x1B<<24 | 0<<21 | 1<<15 return S64 | 0<<29 | 0x1B<<24 | 0<<21 | 1<<15
case AMNEGW, case AMNEGW, AMSUBW:
AMSUBW:
return S32 | 0<<29 | 0x1B<<24 | 0<<21 | 1<<15 return S32 | 0<<29 | 0x1B<<24 | 0<<21 | 1<<15
case AMRS: case AMRS:
@ -3047,42 +3016,34 @@ func oprrr(ctxt *obj.Link, a int) uint32 {
case ANEGSW: case ANEGSW:
return S32 | 1<<30 | 1<<29 | 0xB<<24 | 0<<21 return S32 | 1<<30 | 1<<29 | 0xB<<24 | 0<<21
case AREM, case AREM, ASDIV:
ASDIV:
return S64 | OPDP2(3) return S64 | OPDP2(3)
case AREMW, case AREMW, ASDIVW:
ASDIVW:
return S32 | OPDP2(3) return S32 | OPDP2(3)
case ASMULL, case ASMULL, ASMADDL:
ASMADDL:
return OPDP3(1, 0, 1, 0) return OPDP3(1, 0, 1, 0)
case ASMNEGL, case ASMNEGL, ASMSUBL:
ASMSUBL:
return OPDP3(1, 0, 1, 1) return OPDP3(1, 0, 1, 1)
case ASMULH: case ASMULH:
return OPDP3(1, 0, 2, 0) return OPDP3(1, 0, 2, 0)
case AUMULL, case AUMULL, AUMADDL:
AUMADDL:
return OPDP3(1, 0, 5, 0) return OPDP3(1, 0, 5, 0)
case AUMNEGL, case AUMNEGL, AUMSUBL:
AUMSUBL:
return OPDP3(1, 0, 5, 1) return OPDP3(1, 0, 5, 1)
case AUMULH: case AUMULH:
return OPDP3(1, 0, 6, 0) return OPDP3(1, 0, 6, 0)
case AUREM, case AUREM, AUDIV:
AUDIV:
return S64 | OPDP2(2) return S64 | OPDP2(2)
case AUREMW, case AUREMW, AUDIVW:
AUDIVW:
return S32 | OPDP2(2) return S32 | OPDP2(2)
case AAESE: case AAESE:
@ -3356,34 +3317,28 @@ func oprrr(ctxt *obj.Link, a int) uint32 {
func opirr(ctxt *obj.Link, a int) uint32 { func opirr(ctxt *obj.Link, a int) uint32 {
switch a { switch a {
/* op $addcon, Rn, Rd */ /* op $addcon, Rn, Rd */
case AMOVD, case AMOVD, AADD:
AADD:
return S64 | 0<<30 | 0<<29 | 0x11<<24 return S64 | 0<<30 | 0<<29 | 0x11<<24
case ACMN, case ACMN, AADDS:
AADDS:
return S64 | 0<<30 | 1<<29 | 0x11<<24 return S64 | 0<<30 | 1<<29 | 0x11<<24
case AMOVW, case AMOVW, AADDW:
AADDW:
return S32 | 0<<30 | 0<<29 | 0x11<<24 return S32 | 0<<30 | 0<<29 | 0x11<<24
case ACMNW, case ACMNW, AADDSW:
AADDSW:
return S32 | 0<<30 | 1<<29 | 0x11<<24 return S32 | 0<<30 | 1<<29 | 0x11<<24
case ASUB: case ASUB:
return S64 | 1<<30 | 0<<29 | 0x11<<24 return S64 | 1<<30 | 0<<29 | 0x11<<24
case ACMP, case ACMP, ASUBS:
ASUBS:
return S64 | 1<<30 | 1<<29 | 0x11<<24 return S64 | 1<<30 | 1<<29 | 0x11<<24
case ASUBW: case ASUBW:
return S32 | 1<<30 | 0<<29 | 0x11<<24 return S32 | 1<<30 | 0<<29 | 0x11<<24
case ACMPW, case ACMPW, ASUBSW:
ASUBSW:
return S32 | 1<<30 | 1<<29 | 0x11<<24 return S32 | 1<<30 | 1<<29 | 0x11<<24
/* op $imm(SB), Rd; op label, Rd */ /* op $imm(SB), Rd; op label, Rd */
@ -3594,12 +3549,10 @@ func opxrrr(ctxt *obj.Link, a int) uint32 {
case AADDW: case AADDW:
return S32 | 0<<30 | 0<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_32 return S32 | 0<<30 | 0<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_32
case ACMN, case ACMN, AADDS:
AADDS:
return S64 | 0<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_64 return S64 | 0<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_64
case ACMNW, case ACMNW, AADDSW:
AADDSW:
return S32 | 0<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_32 return S32 | 0<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_32
case ASUB: case ASUB:
@ -3608,12 +3561,10 @@ func opxrrr(ctxt *obj.Link, a int) uint32 {
case ASUBW: case ASUBW:
return S32 | 1<<30 | 0<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_32 return S32 | 1<<30 | 0<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_32
case ACMP, case ACMP, ASUBS:
ASUBS:
return S64 | 1<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_64 return S64 | 1<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_64
case ACMPW, case ACMPW, ASUBSW:
ASUBSW:
return S32 | 1<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_32 return S32 | 1<<30 | 1<<29 | 0x0b<<24 | 0<<22 | 1<<21 | LSL0_32
} }
@ -4109,9 +4060,7 @@ func omovlit(ctxt *obj.Link, as int, p *obj.Prog, a *obj.Addr, dr int) uint32 {
w = 2 /* sign extend */ w = 2 /* sign extend */
} }
case AMOVB, case AMOVB, AMOVH, AMOVW:
AMOVH,
AMOVW:
w = 2 /* 32 bit, sign-extended to 64 */ w = 2 /* 32 bit, sign-extended to 64 */
break break
} }
@ -4171,16 +4120,13 @@ func movesize(a int) int {
case AMOVD: case AMOVD:
return 3 return 3
case AMOVW, case AMOVW, AMOVWU:
AMOVWU:
return 2 return 2
case AMOVH, case AMOVH, AMOVHU:
AMOVHU:
return 1 return 1
case AMOVB, case AMOVB, AMOVBU:
AMOVBU:
return 0 return 0
case AFMOVS: case AFMOVS:

View File

@ -787,8 +787,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
p.To.Reg = REGLINK p.To.Reg = REGLINK
p.Spadj = +ctxt.Autosize p.Spadj = +ctxt.Autosize
case AADD, case AADD, ASUB:
ASUB:
if p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP && p.From.Type == obj.TYPE_CONST { if p.To.Type == obj.TYPE_REG && p.To.Reg == REGSP && p.From.Type == obj.TYPE_CONST {
if p.As == AADD { if p.As == AADD {
p.Spadj = int32(-p.From.Offset) p.Spadj = int32(-p.From.Offset)

View File

@ -95,8 +95,7 @@ func checkaddr(ctxt *Link, p *Prog, a *Addr) {
} }
return return
case TYPE_FCONST, case TYPE_FCONST, TYPE_SCONST:
TYPE_SCONST:
if a.Reg != 0 || a.Index != 0 || a.Scale != 0 || a.Name != 0 || a.Offset != 0 || a.Sym != nil { if a.Reg != 0 || a.Index != 0 || a.Scale != 0 || a.Name != 0 || a.Offset != 0 || a.Sym != nil {
break break
} }

View File

@ -1708,15 +1708,13 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
maskgen64(ctxt, p, mask[:], uint64(d)) maskgen64(ctxt, p, mask[:], uint64(d))
var a int var a int
switch p.As { switch p.As {
case ARLDCL, case ARLDCL, ARLDCLCC:
ARLDCLCC:
a = int(mask[0]) /* MB */ a = int(mask[0]) /* MB */
if mask[1] != 63 { if mask[1] != 63 {
ctxt.Diag("invalid mask for rotate: %x (end != bit 63)\n%v", uint64(d), p) ctxt.Diag("invalid mask for rotate: %x (end != bit 63)\n%v", uint64(d), p)
} }
case ARLDCR, case ARLDCR, ARLDCRCC:
ARLDCRCC:
a = int(mask[1]) /* ME */ a = int(mask[1]) /* ME */
if mask[0] != 0 { if mask[0] != 0 {
ctxt.Diag("invalid mask for rotate: %x (start != 0)\n%v", uint64(d), p) ctxt.Diag("invalid mask for rotate: %x (start != 0)\n%v", uint64(d), p)
@ -1878,13 +1876,11 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
} }
var a int var a int
switch p.As { switch p.As {
case ASLD, case ASLD, ASLDCC:
ASLDCC:
a = int(63 - v) a = int(63 - v)
o1 = OP_RLDICR o1 = OP_RLDICR
case ASRD, case ASRD, ASRDCC:
ASRDCC:
a = int(v) a = int(v)
v = 64 - v v = 64 - v
o1 = OP_RLDICL o1 = OP_RLDICL
@ -1947,22 +1943,19 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
maskgen64(ctxt, p, mask[:], uint64(d)) maskgen64(ctxt, p, mask[:], uint64(d))
var a int var a int
switch p.As { switch p.As {
case ARLDC, case ARLDC, ARLDCCC:
ARLDCCC:
a = int(mask[0]) /* MB */ a = int(mask[0]) /* MB */
if int32(mask[1]) != (63 - v) { if int32(mask[1]) != (63 - v) {
ctxt.Diag("invalid mask for shift: %x (shift %d)\n%v", uint64(d), v, p) ctxt.Diag("invalid mask for shift: %x (shift %d)\n%v", uint64(d), v, p)
} }
case ARLDCL, case ARLDCL, ARLDCLCC:
ARLDCLCC:
a = int(mask[0]) /* MB */ a = int(mask[0]) /* MB */
if mask[1] != 63 { if mask[1] != 63 {
ctxt.Diag("invalid mask for shift: %x (shift %d)\n%v", uint64(d), v, p) ctxt.Diag("invalid mask for shift: %x (shift %d)\n%v", uint64(d), v, p)
} }
case ARLDCR, case ARLDCR, ARLDCRCC:
ARLDCRCC:
a = int(mask[1]) /* ME */ a = int(mask[1]) /* ME */
if mask[0] != 0 { if mask[0] != 0 {
ctxt.Diag("invalid mask for shift: %x (shift %d)\n%v", uint64(d), v, p) ctxt.Diag("invalid mask for shift: %x (shift %d)\n%v", uint64(d), v, p)
@ -2523,68 +2516,52 @@ func oprrr(ctxt *obj.Link, a int) int32 {
case ADCBZ: case ADCBZ:
return int32(OPVCC(31, 1014, 0, 0)) return int32(OPVCC(31, 1014, 0, 0))
case AREM, case AREM, ADIVW:
ADIVW:
return int32(OPVCC(31, 491, 0, 0)) return int32(OPVCC(31, 491, 0, 0))
case AREMCC, case AREMCC, ADIVWCC:
ADIVWCC:
return int32(OPVCC(31, 491, 0, 1)) return int32(OPVCC(31, 491, 0, 1))
case AREMV, case AREMV, ADIVWV:
ADIVWV:
return int32(OPVCC(31, 491, 1, 0)) return int32(OPVCC(31, 491, 1, 0))
case AREMVCC, case AREMVCC, ADIVWVCC:
ADIVWVCC:
return int32(OPVCC(31, 491, 1, 1)) return int32(OPVCC(31, 491, 1, 1))
case AREMU, case AREMU, ADIVWU:
ADIVWU:
return int32(OPVCC(31, 459, 0, 0)) return int32(OPVCC(31, 459, 0, 0))
case AREMUCC, case AREMUCC, ADIVWUCC:
ADIVWUCC:
return int32(OPVCC(31, 459, 0, 1)) return int32(OPVCC(31, 459, 0, 1))
case AREMUV, case AREMUV, ADIVWUV:
ADIVWUV:
return int32(OPVCC(31, 459, 1, 0)) return int32(OPVCC(31, 459, 1, 0))
case AREMUVCC, case AREMUVCC, ADIVWUVCC:
ADIVWUVCC:
return int32(OPVCC(31, 459, 1, 1)) return int32(OPVCC(31, 459, 1, 1))
case AREMD, case AREMD, ADIVD:
ADIVD:
return int32(OPVCC(31, 489, 0, 0)) return int32(OPVCC(31, 489, 0, 0))
case AREMDCC, case AREMDCC, ADIVDCC:
ADIVDCC:
return int32(OPVCC(31, 489, 0, 1)) return int32(OPVCC(31, 489, 0, 1))
case AREMDV, case AREMDV, ADIVDV:
ADIVDV:
return int32(OPVCC(31, 489, 1, 0)) return int32(OPVCC(31, 489, 1, 0))
case AREMDVCC, case AREMDVCC, ADIVDVCC:
ADIVDVCC:
return int32(OPVCC(31, 489, 1, 1)) return int32(OPVCC(31, 489, 1, 1))
case AREMDU, case AREMDU, ADIVDU:
ADIVDU:
return int32(OPVCC(31, 457, 0, 0)) return int32(OPVCC(31, 457, 0, 0))
case AREMDUCC, case AREMDUCC, ADIVDUCC:
ADIVDUCC:
return int32(OPVCC(31, 457, 0, 1)) return int32(OPVCC(31, 457, 0, 1))
case AREMDUV, case AREMDUV, ADIVDUV:
ADIVDUV:
return int32(OPVCC(31, 457, 1, 0)) return int32(OPVCC(31, 457, 1, 0))
case AREMDUVCC, case AREMDUVCC, ADIVDUVCC:
ADIVDUVCC:
return int32(OPVCC(31, 457, 1, 1)) return int32(OPVCC(31, 457, 1, 1))
case AEIEIO: case AEIEIO:
@ -2661,8 +2638,7 @@ func oprrr(ctxt *obj.Link, a int) int32 {
case AFMADDSCC: case AFMADDSCC:
return int32(OPVCC(59, 29, 0, 1)) return int32(OPVCC(59, 29, 0, 1))
case AFMOVS, case AFMOVS, AFMOVD:
AFMOVD:
return int32(OPVCC(63, 72, 0, 0)) /* load */ return int32(OPVCC(63, 72, 0, 0)) /* load */
case AFMOVDCC: case AFMOVDCC:
return int32(OPVCC(63, 72, 0, 1)) return int32(OPVCC(63, 72, 0, 1))
@ -3082,13 +3058,11 @@ func opload(ctxt *obj.Link, a int) int32 {
return int32(OPVCC(58, 0, 0, 0) | 1<<1) /* lwa */ return int32(OPVCC(58, 0, 0, 0) | 1<<1) /* lwa */
/* no AMOVWU */ /* no AMOVWU */
case AMOVB, case AMOVB, AMOVBZ:
AMOVBZ:
return int32(OPVCC(34, 0, 0, 0)) return int32(OPVCC(34, 0, 0, 0))
/* load */ /* load */
case AMOVBU, case AMOVBU, AMOVBZU:
AMOVBZU:
return int32(OPVCC(35, 0, 0, 0)) return int32(OPVCC(35, 0, 0, 0))
case AFMOVD: case AFMOVD:
return int32(OPVCC(50, 0, 0, 0)) return int32(OPVCC(50, 0, 0, 0))
@ -3128,12 +3102,10 @@ func oploadx(ctxt *obj.Link, a int) int32 {
case AMOVWU: case AMOVWU:
return int32(OPVCC(31, 373, 0, 0)) /* lwaux */ return int32(OPVCC(31, 373, 0, 0)) /* lwaux */
case AMOVB, case AMOVB, AMOVBZ:
AMOVBZ:
return int32(OPVCC(31, 87, 0, 0)) /* lbzx */ return int32(OPVCC(31, 87, 0, 0)) /* lbzx */
case AMOVBU, case AMOVBU, AMOVBZU:
AMOVBZU:
return int32(OPVCC(31, 119, 0, 0)) /* lbzux */ return int32(OPVCC(31, 119, 0, 0)) /* lbzux */
case AFMOVD: case AFMOVD:
return int32(OPVCC(31, 599, 0, 0)) /* lfdx */ return int32(OPVCC(31, 599, 0, 0)) /* lfdx */
@ -3178,12 +3150,10 @@ func oploadx(ctxt *obj.Link, a int) int32 {
*/ */
func opstore(ctxt *obj.Link, a int) int32 { func opstore(ctxt *obj.Link, a int) int32 {
switch a { switch a {
case AMOVB, case AMOVB, AMOVBZ:
AMOVBZ:
return int32(OPVCC(38, 0, 0, 0)) /* stb */ return int32(OPVCC(38, 0, 0, 0)) /* stb */
case AMOVBU, case AMOVBU, AMOVBZU:
AMOVBZU:
return int32(OPVCC(39, 0, 0, 0)) /* stbu */ return int32(OPVCC(39, 0, 0, 0)) /* stbu */
case AFMOVD: case AFMOVD:
return int32(OPVCC(54, 0, 0, 0)) /* stfd */ return int32(OPVCC(54, 0, 0, 0)) /* stfd */
@ -3194,24 +3164,20 @@ func opstore(ctxt *obj.Link, a int) int32 {
case AFMOVSU: case AFMOVSU:
return int32(OPVCC(53, 0, 0, 0)) /* stfsu */ return int32(OPVCC(53, 0, 0, 0)) /* stfsu */
case AMOVHZ, case AMOVHZ, AMOVH:
AMOVH:
return int32(OPVCC(44, 0, 0, 0)) /* sth */ return int32(OPVCC(44, 0, 0, 0)) /* sth */
case AMOVHZU, case AMOVHZU, AMOVHU:
AMOVHU:
return int32(OPVCC(45, 0, 0, 0)) /* sthu */ return int32(OPVCC(45, 0, 0, 0)) /* sthu */
case AMOVMW: case AMOVMW:
return int32(OPVCC(47, 0, 0, 0)) /* stmw */ return int32(OPVCC(47, 0, 0, 0)) /* stmw */
case ASTSW: case ASTSW:
return int32(OPVCC(31, 725, 0, 0)) /* stswi */ return int32(OPVCC(31, 725, 0, 0)) /* stswi */
case AMOVWZ, case AMOVWZ, AMOVW:
AMOVW:
return int32(OPVCC(36, 0, 0, 0)) /* stw */ return int32(OPVCC(36, 0, 0, 0)) /* stw */
case AMOVWZU, case AMOVWZU, AMOVWU:
AMOVWU:
return int32(OPVCC(37, 0, 0, 0)) /* stwu */ return int32(OPVCC(37, 0, 0, 0)) /* stwu */
case AMOVD: case AMOVD:
return int32(OPVCC(62, 0, 0, 0)) /* std */ return int32(OPVCC(62, 0, 0, 0)) /* std */
@ -3228,12 +3194,10 @@ func opstore(ctxt *obj.Link, a int) int32 {
*/ */
func opstorex(ctxt *obj.Link, a int) int32 { func opstorex(ctxt *obj.Link, a int) int32 {
switch a { switch a {
case AMOVB, case AMOVB, AMOVBZ:
AMOVBZ:
return int32(OPVCC(31, 215, 0, 0)) /* stbx */ return int32(OPVCC(31, 215, 0, 0)) /* stbx */
case AMOVBU, case AMOVBU, AMOVBZU:
AMOVBZU:
return int32(OPVCC(31, 247, 0, 0)) /* stbux */ return int32(OPVCC(31, 247, 0, 0)) /* stbux */
case AFMOVD: case AFMOVD:
return int32(OPVCC(31, 727, 0, 0)) /* stfdx */ return int32(OPVCC(31, 727, 0, 0)) /* stfdx */
@ -3244,22 +3208,18 @@ func opstorex(ctxt *obj.Link, a int) int32 {
case AFMOVSU: case AFMOVSU:
return int32(OPVCC(31, 695, 0, 0)) /* stfsux */ return int32(OPVCC(31, 695, 0, 0)) /* stfsux */
case AMOVHZ, case AMOVHZ, AMOVH:
AMOVH:
return int32(OPVCC(31, 407, 0, 0)) /* sthx */ return int32(OPVCC(31, 407, 0, 0)) /* sthx */
case AMOVHBR: case AMOVHBR:
return int32(OPVCC(31, 918, 0, 0)) /* sthbrx */ return int32(OPVCC(31, 918, 0, 0)) /* sthbrx */
case AMOVHZU, case AMOVHZU, AMOVHU:
AMOVHU:
return int32(OPVCC(31, 439, 0, 0)) /* sthux */ return int32(OPVCC(31, 439, 0, 0)) /* sthux */
case AMOVWZ, case AMOVWZ, AMOVW:
AMOVW:
return int32(OPVCC(31, 151, 0, 0)) /* stwx */ return int32(OPVCC(31, 151, 0, 0)) /* stwx */
case AMOVWZU, case AMOVWZU, AMOVWU:
AMOVWU:
return int32(OPVCC(31, 183, 0, 0)) /* stwux */ return int32(OPVCC(31, 183, 0, 0)) /* stwux */
case ASTSW: case ASTSW:
return int32(OPVCC(31, 661, 0, 0)) /* stswx */ return int32(OPVCC(31, 661, 0, 0)) /* stswx */

View File

@ -198,9 +198,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
p.Mark |= LABEL | SYNC p.Mark |= LABEL | SYNC
continue continue
case AMOVW, case AMOVW, AMOVWZ, AMOVD:
AMOVWZ,
AMOVD:
q = p q = p
if p.From.Reg >= REG_SPECIAL || p.To.Reg >= REG_SPECIAL { if p.From.Reg >= REG_SPECIAL || p.To.Reg >= REG_SPECIAL {
p.Mark |= LABEL | SYNC p.Mark |= LABEL | SYNC
@ -285,8 +283,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
} }
continue continue
case AFCMPO, case AFCMPO, AFCMPU:
AFCMPU:
q = p q = p
p.Mark |= FCMP | FLOAT p.Mark |= FCMP | FLOAT
continue continue

View File

@ -157,8 +157,7 @@ func Linknew(arch *LinkArch) *Link {
default: default:
log.Fatalf("unknown thread-local storage offset for %s", Headstr(ctxt.Headtype)) log.Fatalf("unknown thread-local storage offset for %s", Headstr(ctxt.Headtype))
case Hplan9, case Hplan9, Hwindows:
Hwindows:
break break
/* /*

View File

@ -2138,8 +2138,7 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
case REG_CX: case REG_CX:
return Ycx return Ycx
case REG_DX, case REG_DX, REG_BX:
REG_BX:
return Yrx return Yrx
case REG_R8, /* not really Yrl */ case REG_R8, /* not really Yrl */
@ -2155,10 +2154,7 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
} }
fallthrough fallthrough
case REG_SP, case REG_SP, REG_BP, REG_SI, REG_DI:
REG_BP,
REG_SI,
REG_DI:
if p.Mode == 32 { if p.Mode == 32 {
return Yrl32 return Yrl32
} }
@ -2841,9 +2837,7 @@ var ymovtab = []Movtab{
func isax(a *obj.Addr) bool { func isax(a *obj.Addr) bool {
switch a.Reg { switch a.Reg {
case REG_AX, case REG_AX, REG_AL, REG_AH:
REG_AL,
REG_AH:
return true return true
} }
@ -2885,10 +2879,7 @@ func subreg(p *obj.Prog, from int, to int) {
func mediaop(ctxt *obj.Link, o *Optab, op int, osize int, z int) int { func mediaop(ctxt *obj.Link, o *Optab, op int, osize int, z int) int {
switch op { switch op {
case Pm, case Pm, Pe, Pf2, Pf3:
Pe,
Pf2,
Pf3:
if osize != 1 { if osize != 1 {
if op != Pm { if op != Pm {
ctxt.Andptr[0] = byte(op) ctxt.Andptr[0] = byte(op)
@ -3255,8 +3246,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
ctxt.Andptr[0] = byte(vaddr(ctxt, p, &p.From, nil)) ctxt.Andptr[0] = byte(vaddr(ctxt, p, &p.From, nil))
ctxt.Andptr = ctxt.Andptr[1:] ctxt.Andptr = ctxt.Andptr[1:]
case Z_ib, case Z_ib, Zib_:
Zib_:
if yt.zcase == Zib_ { if yt.zcase == Zib_ {
a = &p.From a = &p.From
} else { } else {
@ -3348,8 +3338,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
ctxt.Andptr[0] = byte(vaddr(ctxt, p, &p.From, nil)) ctxt.Andptr[0] = byte(vaddr(ctxt, p, &p.From, nil))
ctxt.Andptr = ctxt.Andptr[1:] ctxt.Andptr = ctxt.Andptr[1:]
case Z_il, case Z_il, Zil_:
Zil_:
if yt.zcase == Zil_ { if yt.zcase == Zil_ {
a = &p.From a = &p.From
} else { } else {
@ -3367,8 +3356,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
relput4(ctxt, p, a) relput4(ctxt, p, a)
} }
case Zm_ilo, case Zm_ilo, Zilo_m:
Zilo_m:
ctxt.Andptr[0] = byte(op) ctxt.Andptr[0] = byte(op)
ctxt.Andptr = ctxt.Andptr[1:] ctxt.Andptr = ctxt.Andptr[1:]
if yt.zcase == Zilo_m { if yt.zcase == Zilo_m {
@ -3482,9 +3470,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
} }
// TODO: jump across functions needs reloc // TODO: jump across functions needs reloc
case Zbr, case Zbr, Zjmp, Zloop:
Zjmp,
Zloop:
if p.To.Sym != nil { if p.To.Sym != nil {
if yt.zcase != Zjmp { if yt.zcase != Zjmp {
ctxt.Diag("branch to ATEXT") ctxt.Diag("branch to ATEXT")
@ -4049,24 +4035,16 @@ func byteswapreg(ctxt *obj.Link, a *obj.Addr) int {
cand = 0 cand = 0
cana = cand cana = cand
case REG_AX, case REG_AX, REG_AL, REG_AH:
REG_AL,
REG_AH:
cana = 0 cana = 0
case REG_BX, case REG_BX, REG_BL, REG_BH:
REG_BL,
REG_BH:
canb = 0 canb = 0
case REG_CX, case REG_CX, REG_CL, REG_CH:
REG_CL,
REG_CH:
canc = 0 canc = 0
case REG_DX, case REG_DX, REG_DL, REG_DH:
REG_DL,
REG_DH:
cand = 0 cand = 0
} }
} }
@ -4301,10 +4279,7 @@ func asmins(ctxt *obj.Link, p *obj.Prog) {
copy(ctxt.Andptr, naclstos) copy(ctxt.Andptr, naclstos)
ctxt.Andptr = ctxt.Andptr[len(naclstos):] ctxt.Andptr = ctxt.Andptr[len(naclstos):]
case AMOVSB, case AMOVSB, AMOVSW, AMOVSL, AMOVSQ:
AMOVSW,
AMOVSL,
AMOVSQ:
copy(ctxt.Andptr, naclmovs) copy(ctxt.Andptr, naclmovs)
ctxt.Andptr = ctxt.Andptr[len(naclmovs):] ctxt.Andptr = ctxt.Andptr[len(naclmovs):]
} }

View File

@ -317,9 +317,7 @@ func nacladdr(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) {
if a.Type == obj.TYPE_MEM && a.Name == obj.NAME_NONE { if a.Type == obj.TYPE_MEM && a.Name == obj.NAME_NONE {
switch a.Reg { switch a.Reg {
// all ok // all ok
case REG_BP, case REG_BP, REG_SP, REG_R15:
REG_SP,
REG_R15:
break break
default: default:
@ -641,38 +639,32 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
default: default:
continue continue
case APUSHL, case APUSHL, APUSHFL:
APUSHFL:
deltasp += 4 deltasp += 4
p.Spadj = 4 p.Spadj = 4
continue continue
case APUSHQ, case APUSHQ, APUSHFQ:
APUSHFQ:
deltasp += 8 deltasp += 8
p.Spadj = 8 p.Spadj = 8
continue continue
case APUSHW, case APUSHW, APUSHFW:
APUSHFW:
deltasp += 2 deltasp += 2
p.Spadj = 2 p.Spadj = 2
continue continue
case APOPL, case APOPL, APOPFL:
APOPFL:
deltasp -= 4 deltasp -= 4
p.Spadj = -4 p.Spadj = -4
continue continue
case APOPQ, case APOPQ, APOPFQ:
APOPFQ:
deltasp -= 8 deltasp -= 8
p.Spadj = -8 p.Spadj = -8
continue continue
case APOPW, case APOPW, APOPFW:
APOPFW:
deltasp -= 2 deltasp -= 2
p.Spadj = -2 p.Spadj = -2
continue continue