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

cmd/compile: code cleanup

Change-Id: Ibf68e663f29a5cb3b64a7d923c005c16da647769
Reviewed-on: https://go-review.googlesource.com/c/go/+/266537
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Michele Di Pede 2020-10-30 11:55:18 +01:00 committed by Keith Randall
parent 7191f1136b
commit 94b3fd06cb
3 changed files with 30 additions and 26 deletions

View File

@ -42,10 +42,11 @@ func ssaMarkMoves(s *gc.SSAGenState, b *ssa.Block) {
// loadByType returns the load instruction of the given type.
func loadByType(t *types.Type) obj.As {
// Avoid partial register write
if !t.IsFloat() && t.Size() <= 2 {
if t.Size() == 1 {
if !t.IsFloat() {
switch t.Size() {
case 1:
return x86.AMOVBLZX
} else {
case 2:
return x86.AMOVWLZX
}
}
@ -1070,7 +1071,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
p := s.Prog(v.Op.Asm())
val := v.AuxInt
// 0 means math.RoundToEven, 1 Floor, 2 Ceil, 3 Trunc
if val != 0 && val != 1 && val != 2 && val != 3 {
if val < 0 || val > 3 {
v.Fatalf("Invalid rounding mode")
}
p.From.Offset = val

View File

@ -304,37 +304,39 @@ commas. For example:
`
}
if phase == "check" && flag == "on" {
checkEnabled = val != 0
debugPoset = checkEnabled // also turn on advanced self-checking in prove's datastructure
return ""
}
if phase == "check" && flag == "off" {
checkEnabled = val == 0
debugPoset = checkEnabled
return ""
}
if phase == "check" && flag == "seed" {
checkEnabled = true
checkRandSeed = val
debugPoset = checkEnabled
return ""
if phase == "check" {
switch flag {
case "on":
checkEnabled = val != 0
debugPoset = checkEnabled // also turn on advanced self-checking in prove's datastructure
return ""
case "off":
checkEnabled = val == 0
debugPoset = checkEnabled
return ""
case "seed":
checkEnabled = true
checkRandSeed = val
debugPoset = checkEnabled
return ""
}
}
alltime := false
allmem := false
alldump := false
if phase == "all" {
if flag == "time" {
switch flag {
case "time":
alltime = val != 0
} else if flag == "mem" {
case "mem":
allmem = val != 0
} else if flag == "dump" {
case "dump":
alldump = val != 0
if alldump {
BuildDump = valString
}
} else {
default:
return fmt.Sprintf("Did not find a flag matching %s in -d=ssa/%s debug option", flag, phase)
}
}

View File

@ -42,10 +42,11 @@ func ssaMarkMoves(s *gc.SSAGenState, b *ssa.Block) {
// loadByType returns the load instruction of the given type.
func loadByType(t *types.Type) obj.As {
// Avoid partial register write
if !t.IsFloat() && t.Size() <= 2 {
if t.Size() == 1 {
if !t.IsFloat() {
switch t.Size() {
case 1:
return x86.AMOVBLZX
} else {
case 2:
return x86.AMOVWLZX
}
}