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: Keith Randall <khr@golang.org>
"path"
"regexp"
"sort"
+ "strings"
)
type arch struct {
typ string // default result type
aux string
rematerializeable bool
- 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)
- 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
- clobberFlags bool // this op clobbers flags register
- call bool // is a function call
- 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)
- faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset)
- usesScratch bool // this op requires scratch memory space
- hasSideEffects bool // for "reasons", not to be eliminated. E.g., atomic store, #19182.
+ 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)
+ 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
+ clobberFlags bool // this op clobbers flags register
+ call bool // is a function call
+ 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)
+ faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset)
+ usesScratch bool // this op requires scratch memory space
+ 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 {
if v.hasSideEffects {
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" {
fmt.Fprintln(w, "generic:true,")
fmt.Fprintln(w, "},") // close op
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
for _, a := range archs {
if a.generic {
auxType auxType
argLen int32 // the number of arguments, -1 if variable length
asm obj.As
- generic bool // this is a generic (arch-independent) opcode
- rematerializeable bool // this op is rematerializeable
- 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
- resultNotInArgs bool // outputs must not be allocated to the same registers as inputs
- clobberFlags bool // this op clobbers flags register
- call bool // is a function call
- 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)
- faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset)
- usesScratch bool // this op requires scratch memory space
- hasSideEffects bool // for "reasons", not to be eliminated. E.g., atomic store, #19182.
+ generic bool // this is a generic (arch-independent) opcode
+ rematerializeable bool // this op is rematerializeable
+ 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
+ resultNotInArgs bool // outputs must not be allocated to the same registers as inputs
+ clobberFlags bool // this op clobbers flags register
+ call bool // is a function call
+ 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)
+ faultOnNilArg1 bool // this op will fault if arg1 is nil (and aux encodes a small offset)
+ usesScratch bool // this op requires scratch memory space
+ 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 {
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
// both a value and a pointer offset.
// A ValAndOff is intended to be encoded into an AuxInt field.
},
}
-func (o Op) Asm() obj.As { return opcodeTable[o].asm }
-func (o Op) String() string { return opcodeTable[o].name }
-func (o Op) UsesScratch() bool { return opcodeTable[o].usesScratch }
+func (o Op) Asm() obj.As { return opcodeTable[o].asm }
+func (o Op) String() string { return opcodeTable[o].name }
+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{
{0, x86.REG_AX, "AX"},