Commit ac8966aa authored by Michael Munday's avatar Michael Munday

cmd/compile/internal/ssa: fix block AuxIntType lookup

Avoid an out-of-range error when calling LongString on a generic
block.

Change-Id: I33ca88940d899bc71e3155bc63d2aa925cf83230
Reviewed-on: https://go-review.googlesource.com/c/go/+/200737
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarDaniel Martí <mvdan@mvdan.cc>
parent 1627714c
...@@ -221,17 +221,19 @@ func genOp() { ...@@ -221,17 +221,19 @@ func genOp() {
fmt.Fprintln(w, "func (k BlockKind) String() string {return blockString[k]}") fmt.Fprintln(w, "func (k BlockKind) String() string {return blockString[k]}")
// generate block kind auxint method // generate block kind auxint method
fmt.Fprintln(w, "var blockAuxIntType = [...]string{") fmt.Fprintln(w, "func (k BlockKind) AuxIntType() string {")
fmt.Fprintln(w, "switch k {")
for _, a := range archs { for _, a := range archs {
for _, b := range a.blocks { for _, b := range a.blocks {
if b.auxint == "" { if b.auxint == "" {
continue continue
} }
fmt.Fprintf(w, "Block%s%s:\"%s\",\n", a.Name(), b.name, b.auxint) fmt.Fprintf(w, "case Block%s%s: return \"%s\"\n", a.Name(), b.name, b.auxint)
} }
} }
fmt.Fprintln(w, "}") fmt.Fprintln(w, "}")
fmt.Fprintln(w, "func (k BlockKind) AuxIntType() string {return blockAuxIntType[k]}") fmt.Fprintln(w, "return \"\"")
fmt.Fprintln(w, "}")
// generate Op* declarations // generate Op* declarations
fmt.Fprintln(w, "const (") fmt.Fprintln(w, "const (")
......
...@@ -248,16 +248,20 @@ var blockString = [...]string{ ...@@ -248,16 +248,20 @@ var blockString = [...]string{
} }
func (k BlockKind) String() string { return blockString[k] } func (k BlockKind) String() string { return blockString[k] }
func (k BlockKind) AuxIntType() string {
var blockAuxIntType = [...]string{ switch k {
BlockS390XCIJ: "Int8", case BlockS390XCIJ:
BlockS390XCGIJ: "Int8", return "Int8"
BlockS390XCLIJ: "UInt8", case BlockS390XCGIJ:
BlockS390XCLGIJ: "UInt8", return "Int8"
case BlockS390XCLIJ:
return "UInt8"
case BlockS390XCLGIJ:
return "UInt8"
}
return ""
} }
func (k BlockKind) AuxIntType() string { return blockAuxIntType[k] }
const ( const (
OpInvalid Op = iota OpInvalid Op = iota
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment