]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/ssa: add SymEffect attribute to SSA Ops
authorMatthew Dempsky <mdempsky@google.com>
Thu, 9 Mar 2017 22:45:37 +0000 (14:45 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 14 Mar 2017 18:34:38 +0000 (18:34 +0000)
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>
src/cmd/compile/internal/ssa/gen/main.go
src/cmd/compile/internal/ssa/op.go
src/cmd/compile/internal/ssa/opGen.go

index 19b904adabe09f8be8be12ae16e4ee3c111b9ff0..757c752e64f939f0203839d0ffe13364025d287c 100644 (file)
@@ -18,6 +18,7 @@ import (
        "path"
        "regexp"
        "sort"
+       "strings"
 )
 
 type arch struct {
@@ -42,17 +43,18 @@ type opData 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 {
@@ -212,6 +214,12 @@ func genOp() {
                        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
@@ -273,6 +281,9 @@ func genOp() {
 
        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 {
index 37b2f74f954f6e4a661aa22d611ead738373f01c..f01870e95d793ee0c973da37a96645f2eef0b48b 100644 (file)
@@ -23,18 +23,19 @@ type opInfo struct {
        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 {
@@ -75,6 +76,20 @@ const (
        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.
index 90cb5869ef8c7184d826be43a692be6bb26a94fe..30287d8fa5f8d22f222d92bd9c189267ba055986 100644 (file)
@@ -21852,9 +21852,11 @@ var opcodeTable = [...]opInfo{
        },
 }
 
-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"},