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() {
fmt.Fprintln(w, "func (k BlockKind) String() string {return blockString[k]}")
// 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 _, b := range a.blocks {
if b.auxint == "" {
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, "func (k BlockKind) AuxIntType() string {return blockAuxIntType[k]}")
fmt.Fprintln(w, "return \"\"")
fmt.Fprintln(w, "}")
// generate Op* declarations
fmt.Fprintln(w, "const (")
......
......@@ -248,16 +248,20 @@ var blockString = [...]string{
}
func (k BlockKind) String() string { return blockString[k] }
var blockAuxIntType = [...]string{
BlockS390XCIJ: "Int8",
BlockS390XCGIJ: "Int8",
BlockS390XCLIJ: "UInt8",
BlockS390XCLGIJ: "UInt8",
func (k BlockKind) AuxIntType() string {
switch k {
case BlockS390XCIJ:
return "Int8"
case BlockS390XCGIJ:
return "Int8"
case BlockS390XCLIJ:
return "UInt8"
case BlockS390XCLGIJ:
return "UInt8"
}
return ""
}
func (k BlockKind) AuxIntType() string { return blockAuxIntType[k] }
const (
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