From: Cuong Manh Le Date: Sat, 25 Apr 2020 07:37:33 +0000 (+0700) Subject: cmd/compile: rewrite decArgs rules to use typed aux field X-Git-Tag: go1.15beta1~365 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f1a2a0e0bf1a31f0f32c7756229afbca98473237;p=gostls13.git cmd/compile: rewrite decArgs rules to use typed aux field Passes toolstash-check. Change-Id: I386fb9d52709c4844b313f59f62a4f47c10e490d Reviewed-on: https://go-review.googlesource.com/c/go/+/230117 Run-TryBot: Cuong Manh Le TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/ssa/gen/decArgs.rules b/src/cmd/compile/internal/ssa/gen/decArgs.rules index e9322b0789..1c9a0bb23d 100644 --- a/src/cmd/compile/internal/ssa/gen/decArgs.rules +++ b/src/cmd/compile/internal/ssa/gen/decArgs.rules @@ -5,54 +5,54 @@ // Decompose compound argument values // Do this early to simplify tracking names for debugging. -(Arg {n} [off]) && v.Type.IsString() -> +(Arg {n} [off]) && v.Type.IsString() => (StringMake (Arg {n} [off]) - (Arg {n} [off+config.PtrSize])) + (Arg {n} [off+int32(config.PtrSize)])) -(Arg {n} [off]) && v.Type.IsSlice() -> +(Arg {n} [off]) && v.Type.IsSlice() => (SliceMake (Arg {n} [off]) - (Arg {n} [off+config.PtrSize]) - (Arg {n} [off+2*config.PtrSize])) + (Arg {n} [off+int32(config.PtrSize)]) + (Arg {n} [off+2*int32(config.PtrSize)])) -(Arg {n} [off]) && v.Type.IsInterface() -> +(Arg {n} [off]) && v.Type.IsInterface() => (IMake (Arg {n} [off]) - (Arg {n} [off+config.PtrSize])) + (Arg {n} [off+int32(config.PtrSize)])) -(Arg {n} [off]) && v.Type.IsComplex() && v.Type.Size() == 16 -> +(Arg {n} [off]) && v.Type.IsComplex() && v.Type.Size() == 16 => (ComplexMake (Arg {n} [off]) (Arg {n} [off+8])) -(Arg {n} [off]) && v.Type.IsComplex() && v.Type.Size() == 8 -> +(Arg {n} [off]) && v.Type.IsComplex() && v.Type.Size() == 8 => (ComplexMake (Arg {n} [off]) (Arg {n} [off+4])) -(Arg ) && t.IsStruct() && t.NumFields() == 0 && fe.CanSSA(t) -> +(Arg ) && t.IsStruct() && t.NumFields() == 0 && fe.CanSSA(t) => (StructMake0) -(Arg {n} [off]) && t.IsStruct() && t.NumFields() == 1 && fe.CanSSA(t) -> +(Arg {n} [off]) && t.IsStruct() && t.NumFields() == 1 && fe.CanSSA(t) => (StructMake1 - (Arg {n} [off+t.FieldOff(0)])) -(Arg {n} [off]) && t.IsStruct() && t.NumFields() == 2 && fe.CanSSA(t) -> + (Arg {n} [off+int32(t.FieldOff(0))])) +(Arg {n} [off]) && t.IsStruct() && t.NumFields() == 2 && fe.CanSSA(t) => (StructMake2 - (Arg {n} [off+t.FieldOff(0)]) - (Arg {n} [off+t.FieldOff(1)])) -(Arg {n} [off]) && t.IsStruct() && t.NumFields() == 3 && fe.CanSSA(t) -> + (Arg {n} [off+int32(t.FieldOff(0))]) + (Arg {n} [off+int32(t.FieldOff(1))])) +(Arg {n} [off]) && t.IsStruct() && t.NumFields() == 3 && fe.CanSSA(t) => (StructMake3 - (Arg {n} [off+t.FieldOff(0)]) - (Arg {n} [off+t.FieldOff(1)]) - (Arg {n} [off+t.FieldOff(2)])) -(Arg {n} [off]) && t.IsStruct() && t.NumFields() == 4 && fe.CanSSA(t) -> + (Arg {n} [off+int32(t.FieldOff(0))]) + (Arg {n} [off+int32(t.FieldOff(1))]) + (Arg {n} [off+int32(t.FieldOff(2))])) +(Arg {n} [off]) && t.IsStruct() && t.NumFields() == 4 && fe.CanSSA(t) => (StructMake4 - (Arg {n} [off+t.FieldOff(0)]) - (Arg {n} [off+t.FieldOff(1)]) - (Arg {n} [off+t.FieldOff(2)]) - (Arg {n} [off+t.FieldOff(3)])) + (Arg {n} [off+int32(t.FieldOff(0))]) + (Arg {n} [off+int32(t.FieldOff(1))]) + (Arg {n} [off+int32(t.FieldOff(2))]) + (Arg {n} [off+int32(t.FieldOff(3))])) -(Arg ) && t.IsArray() && t.NumElem() == 0 -> +(Arg ) && t.IsArray() && t.NumElem() == 0 => (ArrayMake0) -(Arg {n} [off]) && t.IsArray() && t.NumElem() == 1 && fe.CanSSA(t) -> +(Arg {n} [off]) && t.IsArray() && t.NumElem() == 1 && fe.CanSSA(t) => (ArrayMake1 (Arg {n} [off])) diff --git a/src/cmd/compile/internal/ssa/rewritedecArgs.go b/src/cmd/compile/internal/ssa/rewritedecArgs.go index eec3acfcda..23ff417eee 100644 --- a/src/cmd/compile/internal/ssa/rewritedecArgs.go +++ b/src/cmd/compile/internal/ssa/rewritedecArgs.go @@ -17,61 +17,61 @@ func rewriteValuedecArgs_OpArg(v *Value) bool { typ := &b.Func.Config.Types // match: (Arg {n} [off]) // cond: v.Type.IsString() - // result: (StringMake (Arg {n} [off]) (Arg {n} [off+config.PtrSize])) + // result: (StringMake (Arg {n} [off]) (Arg {n} [off+int32(config.PtrSize)])) for { - off := v.AuxInt - n := v.Aux + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) if !(v.Type.IsString()) { break } v.reset(OpStringMake) v0 := b.NewValue0(v.Pos, OpArg, typ.BytePtr) - v0.AuxInt = off - v0.Aux = n + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(n) v1 := b.NewValue0(v.Pos, OpArg, typ.Int) - v1.AuxInt = off + config.PtrSize - v1.Aux = n + v1.AuxInt = int32ToAuxInt(off + int32(config.PtrSize)) + v1.Aux = symToAux(n) v.AddArg2(v0, v1) return true } // match: (Arg {n} [off]) // cond: v.Type.IsSlice() - // result: (SliceMake (Arg {n} [off]) (Arg {n} [off+config.PtrSize]) (Arg {n} [off+2*config.PtrSize])) + // result: (SliceMake (Arg {n} [off]) (Arg {n} [off+int32(config.PtrSize)]) (Arg {n} [off+2*int32(config.PtrSize)])) for { - off := v.AuxInt - n := v.Aux + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) if !(v.Type.IsSlice()) { break } v.reset(OpSliceMake) v0 := b.NewValue0(v.Pos, OpArg, v.Type.Elem().PtrTo()) - v0.AuxInt = off - v0.Aux = n + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(n) v1 := b.NewValue0(v.Pos, OpArg, typ.Int) - v1.AuxInt = off + config.PtrSize - v1.Aux = n + v1.AuxInt = int32ToAuxInt(off + int32(config.PtrSize)) + v1.Aux = symToAux(n) v2 := b.NewValue0(v.Pos, OpArg, typ.Int) - v2.AuxInt = off + 2*config.PtrSize - v2.Aux = n + v2.AuxInt = int32ToAuxInt(off + 2*int32(config.PtrSize)) + v2.Aux = symToAux(n) v.AddArg3(v0, v1, v2) return true } // match: (Arg {n} [off]) // cond: v.Type.IsInterface() - // result: (IMake (Arg {n} [off]) (Arg {n} [off+config.PtrSize])) + // result: (IMake (Arg {n} [off]) (Arg {n} [off+int32(config.PtrSize)])) for { - off := v.AuxInt - n := v.Aux + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) if !(v.Type.IsInterface()) { break } v.reset(OpIMake) v0 := b.NewValue0(v.Pos, OpArg, typ.Uintptr) - v0.AuxInt = off - v0.Aux = n + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(n) v1 := b.NewValue0(v.Pos, OpArg, typ.BytePtr) - v1.AuxInt = off + config.PtrSize - v1.Aux = n + v1.AuxInt = int32ToAuxInt(off + int32(config.PtrSize)) + v1.Aux = symToAux(n) v.AddArg2(v0, v1) return true } @@ -79,18 +79,18 @@ func rewriteValuedecArgs_OpArg(v *Value) bool { // cond: v.Type.IsComplex() && v.Type.Size() == 16 // result: (ComplexMake (Arg {n} [off]) (Arg {n} [off+8])) for { - off := v.AuxInt - n := v.Aux + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) if !(v.Type.IsComplex() && v.Type.Size() == 16) { break } v.reset(OpComplexMake) v0 := b.NewValue0(v.Pos, OpArg, typ.Float64) - v0.AuxInt = off - v0.Aux = n + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(n) v1 := b.NewValue0(v.Pos, OpArg, typ.Float64) - v1.AuxInt = off + 8 - v1.Aux = n + v1.AuxInt = int32ToAuxInt(off + 8) + v1.Aux = symToAux(n) v.AddArg2(v0, v1) return true } @@ -98,18 +98,18 @@ func rewriteValuedecArgs_OpArg(v *Value) bool { // cond: v.Type.IsComplex() && v.Type.Size() == 8 // result: (ComplexMake (Arg {n} [off]) (Arg {n} [off+4])) for { - off := v.AuxInt - n := v.Aux + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) if !(v.Type.IsComplex() && v.Type.Size() == 8) { break } v.reset(OpComplexMake) v0 := b.NewValue0(v.Pos, OpArg, typ.Float32) - v0.AuxInt = off - v0.Aux = n + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(n) v1 := b.NewValue0(v.Pos, OpArg, typ.Float32) - v1.AuxInt = off + 4 - v1.Aux = n + v1.AuxInt = int32ToAuxInt(off + 4) + v1.Aux = symToAux(n) v.AddArg2(v0, v1) return true } @@ -126,87 +126,87 @@ func rewriteValuedecArgs_OpArg(v *Value) bool { } // match: (Arg {n} [off]) // cond: t.IsStruct() && t.NumFields() == 1 && fe.CanSSA(t) - // result: (StructMake1 (Arg {n} [off+t.FieldOff(0)])) + // result: (StructMake1 (Arg {n} [off+int32(t.FieldOff(0))])) for { t := v.Type - off := v.AuxInt - n := v.Aux + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) if !(t.IsStruct() && t.NumFields() == 1 && fe.CanSSA(t)) { break } v.reset(OpStructMake1) v0 := b.NewValue0(v.Pos, OpArg, t.FieldType(0)) - v0.AuxInt = off + t.FieldOff(0) - v0.Aux = n + v0.AuxInt = int32ToAuxInt(off + int32(t.FieldOff(0))) + v0.Aux = symToAux(n) v.AddArg(v0) return true } // match: (Arg {n} [off]) // cond: t.IsStruct() && t.NumFields() == 2 && fe.CanSSA(t) - // result: (StructMake2 (Arg {n} [off+t.FieldOff(0)]) (Arg {n} [off+t.FieldOff(1)])) + // result: (StructMake2 (Arg {n} [off+int32(t.FieldOff(0))]) (Arg {n} [off+int32(t.FieldOff(1))])) for { t := v.Type - off := v.AuxInt - n := v.Aux + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) if !(t.IsStruct() && t.NumFields() == 2 && fe.CanSSA(t)) { break } v.reset(OpStructMake2) v0 := b.NewValue0(v.Pos, OpArg, t.FieldType(0)) - v0.AuxInt = off + t.FieldOff(0) - v0.Aux = n + v0.AuxInt = int32ToAuxInt(off + int32(t.FieldOff(0))) + v0.Aux = symToAux(n) v1 := b.NewValue0(v.Pos, OpArg, t.FieldType(1)) - v1.AuxInt = off + t.FieldOff(1) - v1.Aux = n + v1.AuxInt = int32ToAuxInt(off + int32(t.FieldOff(1))) + v1.Aux = symToAux(n) v.AddArg2(v0, v1) return true } // match: (Arg {n} [off]) // cond: t.IsStruct() && t.NumFields() == 3 && fe.CanSSA(t) - // result: (StructMake3 (Arg {n} [off+t.FieldOff(0)]) (Arg {n} [off+t.FieldOff(1)]) (Arg {n} [off+t.FieldOff(2)])) + // result: (StructMake3 (Arg {n} [off+int32(t.FieldOff(0))]) (Arg {n} [off+int32(t.FieldOff(1))]) (Arg {n} [off+int32(t.FieldOff(2))])) for { t := v.Type - off := v.AuxInt - n := v.Aux + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) if !(t.IsStruct() && t.NumFields() == 3 && fe.CanSSA(t)) { break } v.reset(OpStructMake3) v0 := b.NewValue0(v.Pos, OpArg, t.FieldType(0)) - v0.AuxInt = off + t.FieldOff(0) - v0.Aux = n + v0.AuxInt = int32ToAuxInt(off + int32(t.FieldOff(0))) + v0.Aux = symToAux(n) v1 := b.NewValue0(v.Pos, OpArg, t.FieldType(1)) - v1.AuxInt = off + t.FieldOff(1) - v1.Aux = n + v1.AuxInt = int32ToAuxInt(off + int32(t.FieldOff(1))) + v1.Aux = symToAux(n) v2 := b.NewValue0(v.Pos, OpArg, t.FieldType(2)) - v2.AuxInt = off + t.FieldOff(2) - v2.Aux = n + v2.AuxInt = int32ToAuxInt(off + int32(t.FieldOff(2))) + v2.Aux = symToAux(n) v.AddArg3(v0, v1, v2) return true } // match: (Arg {n} [off]) // cond: t.IsStruct() && t.NumFields() == 4 && fe.CanSSA(t) - // result: (StructMake4 (Arg {n} [off+t.FieldOff(0)]) (Arg {n} [off+t.FieldOff(1)]) (Arg {n} [off+t.FieldOff(2)]) (Arg {n} [off+t.FieldOff(3)])) + // result: (StructMake4 (Arg {n} [off+int32(t.FieldOff(0))]) (Arg {n} [off+int32(t.FieldOff(1))]) (Arg {n} [off+int32(t.FieldOff(2))]) (Arg {n} [off+int32(t.FieldOff(3))])) for { t := v.Type - off := v.AuxInt - n := v.Aux + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) if !(t.IsStruct() && t.NumFields() == 4 && fe.CanSSA(t)) { break } v.reset(OpStructMake4) v0 := b.NewValue0(v.Pos, OpArg, t.FieldType(0)) - v0.AuxInt = off + t.FieldOff(0) - v0.Aux = n + v0.AuxInt = int32ToAuxInt(off + int32(t.FieldOff(0))) + v0.Aux = symToAux(n) v1 := b.NewValue0(v.Pos, OpArg, t.FieldType(1)) - v1.AuxInt = off + t.FieldOff(1) - v1.Aux = n + v1.AuxInt = int32ToAuxInt(off + int32(t.FieldOff(1))) + v1.Aux = symToAux(n) v2 := b.NewValue0(v.Pos, OpArg, t.FieldType(2)) - v2.AuxInt = off + t.FieldOff(2) - v2.Aux = n + v2.AuxInt = int32ToAuxInt(off + int32(t.FieldOff(2))) + v2.Aux = symToAux(n) v3 := b.NewValue0(v.Pos, OpArg, t.FieldType(3)) - v3.AuxInt = off + t.FieldOff(3) - v3.Aux = n + v3.AuxInt = int32ToAuxInt(off + int32(t.FieldOff(3))) + v3.Aux = symToAux(n) v.AddArg4(v0, v1, v2, v3) return true } @@ -226,15 +226,15 @@ func rewriteValuedecArgs_OpArg(v *Value) bool { // result: (ArrayMake1 (Arg {n} [off])) for { t := v.Type - off := v.AuxInt - n := v.Aux + off := auxIntToInt32(v.AuxInt) + n := auxToSym(v.Aux) if !(t.IsArray() && t.NumElem() == 1 && fe.CanSSA(t)) { break } v.reset(OpArrayMake1) v0 := b.NewValue0(v.Pos, OpArg, t.Elem()) - v0.AuxInt = off - v0.Aux = n + v0.AuxInt = int32ToAuxInt(off) + v0.Aux = symToAux(n) v.AddArg(v0) return true }