aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/rewrite.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewrite.go')
-rw-r--r--src/cmd/compile/internal/ssa/rewrite.go72
1 files changed, 57 insertions, 15 deletions
diff --git a/src/cmd/compile/internal/ssa/rewrite.go b/src/cmd/compile/internal/ssa/rewrite.go
index 09f94ef53e..d9c3e455a0 100644
--- a/src/cmd/compile/internal/ssa/rewrite.go
+++ b/src/cmd/compile/internal/ssa/rewrite.go
@@ -393,15 +393,9 @@ func canMergeLoad(target, load *Value) bool {
return true
}
-// symNamed reports whether sym's name is name.
-func symNamed(sym Sym, name string) bool {
- return sym.String() == name
-}
-
-// isSameSym reports whether sym is the same as the given named symbol
-func isSameSym(sym interface{}, name string) bool {
- s, ok := sym.(fmt.Stringer)
- return ok && s.String() == name
+// isSameCall reports whether sym is the same as the given named symbol
+func isSameCall(sym interface{}, name string) bool {
+ return sym.(*AuxCall).Fn.String() == name
}
// nlz returns the number of leading zeros.
@@ -713,6 +707,9 @@ func auxToSym(i interface{}) Sym {
func auxToType(i interface{}) *types.Type {
return i.(*types.Type)
}
+func auxToCall(i interface{}) *AuxCall {
+ return i.(*AuxCall)
+}
func auxToS390xCCMask(i interface{}) s390x.CCMask {
return i.(s390x.CCMask)
}
@@ -726,6 +723,9 @@ func stringToAux(s string) interface{} {
func symToAux(s Sym) interface{} {
return s
}
+func callToAux(s *AuxCall) interface{} {
+ return s
+}
func typeToAux(t *types.Type) interface{} {
return t
}
@@ -743,7 +743,7 @@ func uaddOvf(a, b int64) bool {
// de-virtualize an InterCall
// 'sym' is the symbol for the itab
-func devirt(v *Value, sym Sym, offset int64) *obj.LSym {
+func devirt(v *Value, aux interface{}, sym Sym, offset int64) *AuxCall {
f := v.Block.Func
n, ok := sym.(*obj.LSym)
if !ok {
@@ -757,7 +757,11 @@ func devirt(v *Value, sym Sym, offset int64) *obj.LSym {
f.Warnl(v.Pos, "couldn't de-virtualize call")
}
}
- return lsym
+ if lsym == nil {
+ return nil
+ }
+ va := aux.(*AuxCall)
+ return StaticAuxCall(lsym, va.args, va.results)
}
// isSamePtr reports whether p1 and p2 point to the same address.
@@ -1321,6 +1325,44 @@ func hasSmallRotate(c *Config) bool {
}
}
+func newPPC64ShiftAuxInt(sh, mb, me, sz int64) int32 {
+ if sh < 0 || sh >= sz {
+ panic("PPC64 shift arg sh out of range")
+ }
+ if mb < 0 || mb >= sz {
+ panic("PPC64 shift arg mb out of range")
+ }
+ if me < 0 || me >= sz {
+ panic("PPC64 shift arg me out of range")
+ }
+ return int32(sh<<16 | mb<<8 | me)
+}
+
+func GetPPC64Shiftsh(auxint int64) int64 {
+ return int64(int8(auxint >> 16))
+}
+
+func GetPPC64Shiftmb(auxint int64) int64 {
+ return int64(int8(auxint >> 8))
+}
+
+func GetPPC64Shiftme(auxint int64) int64 {
+ return int64(int8(auxint))
+}
+
+// Catch the simple ones first
+// TODO: Later catch more cases
+func isPPC64ValidShiftMask(v int64) bool {
+ if ((v + 1) & v) == 0 {
+ return true
+ }
+ return false
+}
+
+func getPPC64ShiftMaskLength(v int64) int64 {
+ return int64(bits.Len64(uint64(v)))
+}
+
// encodes the lsb and width for arm(64) bitfield ops into the expected auxInt format.
func armBFAuxInt(lsb, width int64) arm64BitField {
if lsb < 0 || lsb > 63 {
@@ -1377,12 +1419,12 @@ func registerizable(b *Block, typ *types.Type) bool {
}
// needRaceCleanup reports whether this call to racefuncenter/exit isn't needed.
-func needRaceCleanup(sym Sym, v *Value) bool {
+func needRaceCleanup(sym *AuxCall, v *Value) bool {
f := v.Block.Func
if !f.Config.Race {
return false
}
- if !symNamed(sym, "runtime.racefuncenter") && !symNamed(sym, "runtime.racefuncexit") {
+ if !isSameCall(sym, "runtime.racefuncenter") && !isSameCall(sym, "runtime.racefuncexit") {
return false
}
for _, b := range f.Blocks {
@@ -1391,7 +1433,7 @@ func needRaceCleanup(sym Sym, v *Value) bool {
case OpStaticCall:
// Check for racefuncenter will encounter racefuncexit and vice versa.
// Allow calls to panic*
- s := v.Aux.(fmt.Stringer).String()
+ s := v.Aux.(*AuxCall).Fn.String()
switch s {
case "runtime.racefuncenter", "runtime.racefuncexit",
"runtime.panicdivide", "runtime.panicwrap",
@@ -1409,7 +1451,7 @@ func needRaceCleanup(sym Sym, v *Value) bool {
}
}
}
- if symNamed(sym, "runtime.racefuncenter") {
+ if isSameCall(sym, "runtime.racefuncenter") {
// If we're removing racefuncenter, remove its argument as well.
if v.Args[0].Op != OpStore {
return false