diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2017-04-27 15:30:31 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2017-04-27 22:57:57 +0000 |
commit | 94d540a4b6bf68ec472bf4469037955e3133fcf7 (patch) | |
tree | 856e77f96d70a7873f86b23684bf8417a7b2cf64 /src/cmd/compile/internal/mips | |
parent | 0b6a10ef246ff55085d6ec88f68f5fd96677b141 (diff) | |
download | go-94d540a4b6bf68ec472bf4469037955e3133fcf7.tar.gz go-94d540a4b6bf68ec472bf4469037955e3133fcf7.zip |
cmd/compile: add Type.MustSize and Type.MustAlignment
Type.Size and Type.Alignment are for the front end:
They calculate size and alignment if needed.
Type.MustSize and Type.MustAlignment are for the back end:
They call Fatal if size and alignment are not already calculated.
Most uses are of MustSize and MustAlignment,
but that's because the back end is newer,
and this API was added to support it.
This CL was mostly generated with sed and selective reversion.
The only mildly interesting bit is the change of the ssa.Type interface
and the supporting ssa dummy types.
Follow-up to review feedback on CL 41970.
Passes toolstash-check.
Change-Id: I0d9b9505e57453dae8fb6a236a07a7a02abd459e
Reviewed-on: https://go-review.googlesource.com/42016
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/mips')
-rw-r--r-- | src/cmd/compile/internal/mips/ggen.go | 2 | ||||
-rw-r--r-- | src/cmd/compile/internal/mips/ssa.go | 18 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/cmd/compile/internal/mips/ggen.go b/src/cmd/compile/internal/mips/ggen.go index acbe4a91de..126238d351 100644 --- a/src/cmd/compile/internal/mips/ggen.go +++ b/src/cmd/compile/internal/mips/ggen.go @@ -46,7 +46,7 @@ func zerorange(pp *gc.Progs, p *obj.Prog, off, cnt int64, _ *uint32) *obj.Prog { func zeroAuto(pp *gc.Progs, n *gc.Node) { // Note: this code must not clobber any registers. sym := n.Sym.Linksym() - size := n.Type.Size() + size := n.Type.MustSize() for i := int64(0); i < size; i += 4 { p := pp.Prog(mips.AMOVW) p.From.Type = obj.TYPE_REG diff --git a/src/cmd/compile/internal/mips/ssa.go b/src/cmd/compile/internal/mips/ssa.go index 3673523af0..be06632d5f 100644 --- a/src/cmd/compile/internal/mips/ssa.go +++ b/src/cmd/compile/internal/mips/ssa.go @@ -26,13 +26,13 @@ func isHILO(r int16) bool { // loadByType returns the load instruction of the given type. func loadByType(t ssa.Type, r int16) obj.As { if isFPreg(r) { - if t.Size() == 4 { // float32 or int32 + if t.MustSize() == 4 { // float32 or int32 return mips.AMOVF } else { // float64 or int64 return mips.AMOVD } } else { - switch t.Size() { + switch t.MustSize() { case 1: if t.IsSigned() { return mips.AMOVB @@ -55,13 +55,13 @@ func loadByType(t ssa.Type, r int16) obj.As { // storeByType returns the store instruction of the given type. func storeByType(t ssa.Type, r int16) obj.As { if isFPreg(r) { - if t.Size() == 4 { // float32 or int32 + if t.MustSize() == 4 { // float32 or int32 return mips.AMOVF } else { // float64 or int64 return mips.AMOVD } } else { - switch t.Size() { + switch t.MustSize() { case 1: return mips.AMOVB case 2: @@ -88,7 +88,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { as := mips.AMOVW if isFPreg(x) && isFPreg(y) { as = mips.AMOVF - if t.Size() == 8 { + if t.MustSize() == 8 { as = mips.AMOVD } } @@ -342,10 +342,10 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) { if a.Op == ssa.OpLoadReg { t := a.Type switch { - case v.Op == ssa.OpMIPSMOVBreg && t.Size() == 1 && t.IsSigned(), - v.Op == ssa.OpMIPSMOVBUreg && t.Size() == 1 && !t.IsSigned(), - v.Op == ssa.OpMIPSMOVHreg && t.Size() == 2 && t.IsSigned(), - v.Op == ssa.OpMIPSMOVHUreg && t.Size() == 2 && !t.IsSigned(): + case v.Op == ssa.OpMIPSMOVBreg && t.MustSize() == 1 && t.IsSigned(), + v.Op == ssa.OpMIPSMOVBUreg && t.MustSize() == 1 && !t.IsSigned(), + v.Op == ssa.OpMIPSMOVHreg && t.MustSize() == 2 && t.IsSigned(), + v.Op == ssa.OpMIPSMOVHUreg && t.MustSize() == 2 && !t.IsSigned(): // arg is a proper-typed load, already zero/sign-extended, don't extend again if v.Reg() == v.Args[0].Reg() { return |