From 1cdf4bf33f57ca7910ab4ee1121ea7f05a6adcd1 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Thu, 9 Mar 2017 14:45:37 -0800 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/cmd/compile/internal/ssa/gen/main.go | 33 +++++++++++++------- src/cmd/compile/internal/ssa/op.go | 39 ++++++++++++++++-------- src/cmd/compile/internal/ssa/opGen.go | 8 +++-- 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/src/cmd/compile/internal/ssa/gen/main.go b/src/cmd/compile/internal/ssa/gen/main.go index 19b904adab..757c752e64 100644 --- a/src/cmd/compile/internal/ssa/gen/main.go +++ b/src/cmd/compile/internal/ssa/gen/main.go @@ -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 { diff --git a/src/cmd/compile/internal/ssa/op.go b/src/cmd/compile/internal/ssa/op.go index 37b2f74f95..f01870e95d 100644 --- a/src/cmd/compile/internal/ssa/op.go +++ b/src/cmd/compile/internal/ssa/op.go @@ -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. diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go index 90cb5869ef..30287d8fa5 100644 --- a/src/cmd/compile/internal/ssa/opGen.go +++ b/src/cmd/compile/internal/ssa/opGen.go @@ -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"}, -- 2.48.1