Commit 1cdf4bf3 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile/internal/ssa: add SymEffect attribute to SSA Ops

To replace the progeffects tables for liveness analysis.

Change-Id: Idc4b990665cb0a9aa300d62cdf8ad12e51c5b991
Reviewed-on: https://go-review.googlesource.com/38083
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent 5f5d882f
...@@ -18,6 +18,7 @@ import ( ...@@ -18,6 +18,7 @@ import (
"path" "path"
"regexp" "regexp"
"sort" "sort"
"strings"
) )
type arch struct { type arch struct {
...@@ -42,17 +43,18 @@ type opData struct { ...@@ -42,17 +43,18 @@ type opData struct {
typ string // default result type typ string // default result type
aux string aux string
rematerializeable bool rematerializeable bool
argLength int32 // number of arguments, if -1, then this operation has a variable number of arguments argLength int32 // number of arguments, if -1, then this operation has a variable number of arguments
commutative bool // this operation is commutative on its first 2 arguments (e.g. addition) commutative bool // this operation is commutative on its first 2 arguments (e.g. addition)
resultInArg0 bool // (first, if a tuple) output of v and v.Args[0] must be allocated to the same register resultInArg0 bool // (first, if a tuple) output of v and v.Args[0] must be allocated to the same register
resultNotInArgs bool // outputs must not be allocated to the same registers as inputs resultNotInArgs bool // outputs must not be allocated to the same registers as inputs
clobberFlags bool // this op clobbers flags register clobberFlags bool // this op clobbers flags register
call bool // is a function call call bool // is a function call
nilCheck bool // this op is a nil check on arg0 nilCheck bool // this op is a nil check on arg0
faultOnNilArg0 bool // this op will fault if arg0 is nil (and aux encodes a small offset) faultOnNilArg0 bool // this op will fault if arg0 is nil (and aux encodes a small offset)
faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset) faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset)
usesScratch bool // this op requires scratch memory space usesScratch bool // this op requires scratch memory space
hasSideEffects bool // for "reasons", not to be eliminated. E.g., atomic store, #19182. hasSideEffects bool // for "reasons", not to be eliminated. E.g., atomic store, #19182.
symEffect string // effect this op has on symbol in aux
} }
type blockData struct { type blockData struct {
...@@ -212,6 +214,12 @@ func genOp() { ...@@ -212,6 +214,12 @@ func genOp() {
if v.hasSideEffects { if v.hasSideEffects {
fmt.Fprintln(w, "hasSideEffects: true,") fmt.Fprintln(w, "hasSideEffects: true,")
} }
if v.symEffect != "" {
if !strings.HasPrefix(v.aux, "Sym") {
log.Fatalf("symEffect with aux %s not allowed", v.aux)
}
fmt.Fprintf(w, "symEffect: Sym%s,\n", v.symEffect)
}
if a.name == "generic" { if a.name == "generic" {
fmt.Fprintln(w, "generic:true,") fmt.Fprintln(w, "generic:true,")
fmt.Fprintln(w, "},") // close op fmt.Fprintln(w, "},") // close op
...@@ -273,6 +281,9 @@ func genOp() { ...@@ -273,6 +281,9 @@ func genOp() {
fmt.Fprintln(w, "func (o Op) UsesScratch() bool { return opcodeTable[o].usesScratch }") fmt.Fprintln(w, "func (o Op) UsesScratch() bool { return opcodeTable[o].usesScratch }")
fmt.Fprintln(w, "func (o Op) SymEffect() SymEffect { return opcodeTable[o].symEffect }")
fmt.Fprintln(w, "func (o Op) IsCall() bool { return opcodeTable[o].call }")
// generate registers // generate registers
for _, a := range archs { for _, a := range archs {
if a.generic { if a.generic {
......
...@@ -23,18 +23,19 @@ type opInfo struct { ...@@ -23,18 +23,19 @@ type opInfo struct {
auxType auxType auxType auxType
argLen int32 // the number of arguments, -1 if variable length argLen int32 // the number of arguments, -1 if variable length
asm obj.As asm obj.As
generic bool // this is a generic (arch-independent) opcode generic bool // this is a generic (arch-independent) opcode
rematerializeable bool // this op is rematerializeable rematerializeable bool // this op is rematerializeable
commutative bool // this operation is commutative (e.g. addition) commutative bool // this operation is commutative (e.g. addition)
resultInArg0 bool // (first, if a tuple) output of v and v.Args[0] must be allocated to the same register resultInArg0 bool // (first, if a tuple) output of v and v.Args[0] must be allocated to the same register
resultNotInArgs bool // outputs must not be allocated to the same registers as inputs resultNotInArgs bool // outputs must not be allocated to the same registers as inputs
clobberFlags bool // this op clobbers flags register clobberFlags bool // this op clobbers flags register
call bool // is a function call call bool // is a function call
nilCheck bool // this op is a nil check on arg0 nilCheck bool // this op is a nil check on arg0
faultOnNilArg0 bool // this op will fault if arg0 is nil (and aux encodes a small offset) faultOnNilArg0 bool // this op will fault if arg0 is nil (and aux encodes a small offset)
faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset) faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset)
usesScratch bool // this op requires scratch memory space usesScratch bool // this op requires scratch memory space
hasSideEffects bool // for "reasons", not to be eliminated. E.g., atomic store, #19182. hasSideEffects bool // for "reasons", not to be eliminated. E.g., atomic store, #19182.
symEffect SymEffect // effect this op has on symbol in aux
} }
type inputInfo struct { type inputInfo struct {
...@@ -75,6 +76,20 @@ const ( ...@@ -75,6 +76,20 @@ const (
auxSymInt32 // aux is a symbol, auxInt is a 32-bit integer auxSymInt32 // aux is a symbol, auxInt is a 32-bit integer
) )
// A SymEffect describes the effect that an SSA Value has on the variable
// identified by the symbol in its Aux field.
type SymEffect int8
const (
SymRead SymEffect = 1 << iota
SymWrite
SymAddr
SymRdWr = SymRead | SymWrite
SymNone SymEffect = 0
)
// A ValAndOff is used by the several opcodes. It holds // A ValAndOff is used by the several opcodes. It holds
// both a value and a pointer offset. // both a value and a pointer offset.
// A ValAndOff is intended to be encoded into an AuxInt field. // A ValAndOff is intended to be encoded into an AuxInt field.
......
...@@ -21852,9 +21852,11 @@ var opcodeTable = [...]opInfo{ ...@@ -21852,9 +21852,11 @@ var opcodeTable = [...]opInfo{
}, },
} }
func (o Op) Asm() obj.As { return opcodeTable[o].asm } func (o Op) Asm() obj.As { return opcodeTable[o].asm }
func (o Op) String() string { return opcodeTable[o].name } func (o Op) String() string { return opcodeTable[o].name }
func (o Op) UsesScratch() bool { return opcodeTable[o].usesScratch } func (o Op) UsesScratch() bool { return opcodeTable[o].usesScratch }
func (o Op) SymEffect() SymEffect { return opcodeTable[o].symEffect }
func (o Op) IsCall() bool { return opcodeTable[o].call }
var registers386 = [...]Register{ var registers386 = [...]Register{
{0, x86.REG_AX, "AX"}, {0, x86.REG_AX, "AX"},
......
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