1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // This file defines the BuilderMode type and its command-line flag.
14 // BuilderMode is a bitmask of options for diagnostics and checking.
16 // *BuilderMode satisfies the flag.Value interface. Example:
18 // var mode = ssa.BuilderMode(0)
19 // func init() { flag.Var(&mode, "build", ssa.BuilderModeDoc) }
24 PrintPackages BuilderMode = 1 << iota // Print package inventory to stdout
25 PrintFunctions // Print function SSA code to stdout
26 LogSource // Log source locations as SSA builder progresses
27 SanityCheckFunctions // Perform sanity checking of function bodies
28 NaiveForm // Build naïve SSA form: don't replace local loads/stores with registers
29 BuildSerially // Build packages serially, not in parallel.
30 GlobalDebug // Enable debug info for all packages
31 BareInits // Build init functions without guards or calls to dependent inits
34 const BuilderModeDoc = `Options controlling the SSA builder.
35 The value is a sequence of zero or more of these letters:
36 C perform sanity [C]hecking of the SSA form.
37 D include [D]ebug info for every function.
38 P print [P]ackage inventory.
39 F print [F]unction SSA code.
40 S log [S]ource locations as SSA builder progresses.
41 L build distinct packages seria[L]ly instead of in parallel.
42 N build [N]aive SSA form: don't replace local loads/stores with registers.
43 I build bare [I]nit functions: no init guards or calls to dependent inits.
46 func (m BuilderMode) String() string {
48 if m&GlobalDebug != 0 {
51 if m&PrintPackages != 0 {
54 if m&PrintFunctions != 0 {
60 if m&SanityCheckFunctions != 0 {
66 if m&BuildSerially != 0 {
72 // Set parses the flag characters in s and updates *m.
73 func (m *BuilderMode) Set(s string) error {
82 mode |= PrintFunctions
84 mode |= LogSource | BuildSerially
86 mode |= SanityCheckFunctions
92 return fmt.Errorf("unknown BuilderMode option: %q", c)
100 func (m BuilderMode) Get() interface{} { return m }