From: Robert Griesemer Date: Fri, 31 Mar 2017 17:26:30 +0000 (-0700) Subject: cmd/compile: use std "DO NOT EDIT" comment for generated files X-Git-Tag: go1.9beta1~872 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9e28ea0c08d00fda167f47669711cefd83aa942a;p=gostls13.git cmd/compile: use std "DO NOT EDIT" comment for generated files Also: Fix (testdata/gen/) copyGen.go, zeroGen.go, and arithConstGen.go to actually match (testdata/) copy.go, zero.go, and arithConst.go, all of which were manually edited in https://go-review.googlesource.com/20823 and https://go-review.googlesource.com/22748 despite the 'do not edit' (or perhaps because it was missing in the case of arithConst.go). For #13560. Change-Id: I366e1b521e51885e0d318ae848760e5e14ccd488 Reviewed-on: https://go-review.googlesource.com/39172 Reviewed-by: Rob Pike --- diff --git a/src/cmd/compile/internal/gc/builtin.go b/src/cmd/compile/internal/gc/builtin.go index 4d67fe285a..294fc4fc16 100644 --- a/src/cmd/compile/internal/gc/builtin.go +++ b/src/cmd/compile/internal/gc/builtin.go @@ -1,4 +1,4 @@ -// AUTO-GENERATED by mkbuiltin.go; DO NOT EDIT +// Code generated by mkbuiltin.go. DO NOT EDIT. package gc diff --git a/src/cmd/compile/internal/gc/constFold_test.go b/src/cmd/compile/internal/gc/constFold_test.go index fe57717907..59f905dad9 100644 --- a/src/cmd/compile/internal/gc/constFold_test.go +++ b/src/cmd/compile/internal/gc/constFold_test.go @@ -1,3 +1,6 @@ +// run +// Code generated by gen/constFoldGen.go. DO NOT EDIT. + package gc import "testing" diff --git a/src/cmd/compile/internal/gc/mkbuiltin.go b/src/cmd/compile/internal/gc/mkbuiltin.go index 6d918f8d25..38fb5f700c 100644 --- a/src/cmd/compile/internal/gc/mkbuiltin.go +++ b/src/cmd/compile/internal/gc/mkbuiltin.go @@ -31,7 +31,7 @@ func main() { flag.Parse() var b bytes.Buffer - fmt.Fprintln(&b, "// AUTO-GENERATED by mkbuiltin.go; DO NOT EDIT") + fmt.Fprintln(&b, "// Code generated by mkbuiltin.go. DO NOT EDIT.") fmt.Fprintln(&b) fmt.Fprintln(&b, "package gc") diff --git a/src/cmd/compile/internal/gc/testdata/arithBoundary.go b/src/cmd/compile/internal/gc/testdata/arithBoundary.go index 929e4e1f0b..4a7afe690f 100644 --- a/src/cmd/compile/internal/gc/testdata/arithBoundary.go +++ b/src/cmd/compile/internal/gc/testdata/arithBoundary.go @@ -1,3 +1,6 @@ +// run +// Code generated by gen/arithBoundaryGen.go. DO NOT EDIT. + package main import "fmt" diff --git a/src/cmd/compile/internal/gc/testdata/arithConst.go b/src/cmd/compile/internal/gc/testdata/arithConst.go index 21bcd633e1..cadea7b3bc 100644 --- a/src/cmd/compile/internal/gc/testdata/arithConst.go +++ b/src/cmd/compile/internal/gc/testdata/arithConst.go @@ -1,3 +1,6 @@ +// run +// Code generated by gen/arithConstGen.go. DO NOT EDIT. + package main import "fmt" diff --git a/src/cmd/compile/internal/gc/testdata/copy.go b/src/cmd/compile/internal/gc/testdata/copy.go index 0b6f878cbe..c24fdc3985 100644 --- a/src/cmd/compile/internal/gc/testdata/copy.go +++ b/src/cmd/compile/internal/gc/testdata/copy.go @@ -1,5 +1,6 @@ // run -// autogenerated from gen/copyGen.go - do not edit! +// Code generated by gen/copyGen.go. DO NOT EDIT. + package main import "fmt" diff --git a/src/cmd/compile/internal/gc/testdata/gen/arithBoundaryGen.go b/src/cmd/compile/internal/gc/testdata/gen/arithBoundaryGen.go index 866431e1ae..cbdd162636 100644 --- a/src/cmd/compile/internal/gc/testdata/gen/arithBoundaryGen.go +++ b/src/cmd/compile/internal/gc/testdata/gen/arithBoundaryGen.go @@ -90,8 +90,9 @@ type op struct { var ops = []op{op{"add", "+"}, op{"sub", "-"}, op{"div", "/"}, op{"mod", "%%"}, op{"mul", "*"}} func main() { - w := new(bytes.Buffer) + fmt.Fprintf(w, "// run\n") + fmt.Fprintf(w, "// Code generated by gen/arithBoundaryGen.go. DO NOT EDIT.\n\n") fmt.Fprintf(w, "package main;\n") fmt.Fprintf(w, "import \"fmt\"\n") diff --git a/src/cmd/compile/internal/gc/testdata/gen/arithConstGen.go b/src/cmd/compile/internal/gc/testdata/gen/arithConstGen.go index 97434ea34c..07a3749b16 100644 --- a/src/cmd/compile/internal/gc/testdata/gen/arithConstGen.go +++ b/src/cmd/compile/internal/gc/testdata/gen/arithConstGen.go @@ -30,24 +30,31 @@ type szD struct { i []int64 } -var szs []szD = []szD{ - szD{name: "uint64", sn: "64", u: []uint64{0, 1, 4294967296, 0xffffFFFFffffFFFF}}, - szD{name: "int64", sn: "64", i: []int64{-0x8000000000000000, -0x7FFFFFFFFFFFFFFF, +var szs = []szD{ + {name: "uint64", sn: "64", u: []uint64{0, 1, 4294967296, 0xffffFFFFffffFFFF}}, + {name: "int64", sn: "64", i: []int64{-0x8000000000000000, -0x7FFFFFFFFFFFFFFF, -4294967296, -1, 0, 1, 4294967296, 0x7FFFFFFFFFFFFFFE, 0x7FFFFFFFFFFFFFFF}}, - szD{name: "uint32", sn: "32", u: []uint64{0, 1, 4294967295}}, - szD{name: "int32", sn: "32", i: []int64{-0x80000000, -0x7FFFFFFF, -1, 0, + {name: "uint32", sn: "32", u: []uint64{0, 1, 4294967295}}, + {name: "int32", sn: "32", i: []int64{-0x80000000, -0x7FFFFFFF, -1, 0, 1, 0x7FFFFFFF}}, - szD{name: "uint16", sn: "16", u: []uint64{0, 1, 65535}}, - szD{name: "int16", sn: "16", i: []int64{-32768, -32767, -1, 0, 1, 32766, 32767}}, + {name: "uint16", sn: "16", u: []uint64{0, 1, 65535}}, + {name: "int16", sn: "16", i: []int64{-32768, -32767, -1, 0, 1, 32766, 32767}}, - szD{name: "uint8", sn: "8", u: []uint64{0, 1, 255}}, - szD{name: "int8", sn: "8", i: []int64{-128, -127, -1, 0, 1, 126, 127}}, + {name: "uint8", sn: "8", u: []uint64{0, 1, 255}}, + {name: "int8", sn: "8", i: []int64{-128, -127, -1, 0, 1, 126, 127}}, } -var ops []op = []op{op{"add", "+"}, op{"sub", "-"}, op{"div", "/"}, op{"mul", "*"}, - op{"lsh", "<<"}, op{"rsh", ">>"}, op{"mod", "%"}} +var ops = []op{ + {"add", "+"}, + {"sub", "-"}, + {"div", "/"}, + {"mul", "*"}, + {"lsh", "<<"}, + {"rsh", ">>"}, + {"mod", "%"}, +} // compute the result of i op j, cast as type t. func ansU(i, j uint64, t, op string) string { @@ -118,9 +125,9 @@ func ansS(i, j int64, t, op string) string { } func main() { - w := new(bytes.Buffer) - + fmt.Fprintf(w, "// run\n") + fmt.Fprintf(w, "// Code generated by gen/arithConstGen.go. DO NOT EDIT.\n\n") fmt.Fprintf(w, "package main;\n") fmt.Fprintf(w, "import \"fmt\"\n") @@ -160,7 +167,14 @@ func main() { // avoid division by zero if o.name != "mod" && o.name != "div" || i != 0 { + // introduce uint64 cast for rhs shift operands + // if they are too large for default uint type + number := fd.Number + if (o.name == "lsh" || o.name == "rsh") && uint64(uint32(i)) != i { + fd.Number = fmt.Sprintf("uint64(%s)", number) + } fncCnst1.Execute(w, fd) + fd.Number = number } fncCnst2.Execute(w, fd) diff --git a/src/cmd/compile/internal/gc/testdata/gen/constFoldGen.go b/src/cmd/compile/internal/gc/testdata/gen/constFoldGen.go index f266749ce9..2b8a331c8d 100644 --- a/src/cmd/compile/internal/gc/testdata/gen/constFoldGen.go +++ b/src/cmd/compile/internal/gc/testdata/gen/constFoldGen.go @@ -118,9 +118,9 @@ func ansS(i, j int64, t, op string) string { } func main() { - w := new(bytes.Buffer) - + fmt.Fprintf(w, "// run\n") + fmt.Fprintf(w, "// Code generated by gen/constFoldGen.go. DO NOT EDIT.\n\n") fmt.Fprintf(w, "package gc\n") fmt.Fprintf(w, "import \"testing\"\n") diff --git a/src/cmd/compile/internal/gc/testdata/gen/copyGen.go b/src/cmd/compile/internal/gc/testdata/gen/copyGen.go index 2d2240c435..a3857de75d 100644 --- a/src/cmd/compile/internal/gc/testdata/gen/copyGen.go +++ b/src/cmd/compile/internal/gc/testdata/gen/copyGen.go @@ -23,7 +23,7 @@ var sizes = [...]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 23, 24, 25, 31, func main() { w := new(bytes.Buffer) fmt.Fprintf(w, "// run\n") - fmt.Fprintf(w, "// autogenerated from gen/copyGen.go - do not edit!\n") + fmt.Fprintf(w, "// Code generated by gen/copyGen.go. DO NOT EDIT.\n\n") fmt.Fprintf(w, "package main\n") fmt.Fprintf(w, "import \"fmt\"\n") @@ -36,8 +36,8 @@ func main() { fmt.Fprintf(w, "}\n") // function being tested + fmt.Fprintf(w, "//go:noinline\n") fmt.Fprintf(w, "func t%dcopy_ssa(y, x *[%d]byte) {\n", s, s) - fmt.Fprintf(w, " switch{}\n") fmt.Fprintf(w, " *y = *x\n") fmt.Fprintf(w, "}\n") diff --git a/src/cmd/compile/internal/gc/testdata/gen/zeroGen.go b/src/cmd/compile/internal/gc/testdata/gen/zeroGen.go index 6482f07fda..fa70b16495 100644 --- a/src/cmd/compile/internal/gc/testdata/gen/zeroGen.go +++ b/src/cmd/compile/internal/gc/testdata/gen/zeroGen.go @@ -23,7 +23,7 @@ var sizes = [...]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 16, 17, 23, 24, 25, 31, func main() { w := new(bytes.Buffer) fmt.Fprintf(w, "// run\n") - fmt.Fprintf(w, "// autogenerated from gen/zeroGen.go - do not edit!\n") + fmt.Fprintf(w, "// Code generated by gen/zeroGen.go. DO NOT EDIT.\n\n") fmt.Fprintf(w, "package main\n") fmt.Fprintf(w, "import \"fmt\"\n") @@ -36,8 +36,8 @@ func main() { fmt.Fprintf(w, "}\n") // function being tested + fmt.Fprintf(w, "//go:noinline\n") fmt.Fprintf(w, "func zero%d_ssa(x *[%d]byte) {\n", s, s) - fmt.Fprintf(w, " switch{}\n") fmt.Fprintf(w, " *x = [%d]byte{}\n", s) fmt.Fprintf(w, "}\n") diff --git a/src/cmd/compile/internal/gc/testdata/zero.go b/src/cmd/compile/internal/gc/testdata/zero.go index 68334db108..f6354868cb 100644 --- a/src/cmd/compile/internal/gc/testdata/zero.go +++ b/src/cmd/compile/internal/gc/testdata/zero.go @@ -1,5 +1,6 @@ // run -// autogenerated from gen/zeroGen.go - do not edit! +// Code generated by gen/zeroGen.go. DO NOT EDIT. + package main import "fmt"