1 // go-optimize.cc -- Go frontend optimizer flags.
3 // Copyright 2011 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
10 #include "go-optimize.h"
14 // The list of optimizations.
16 Go_optimize* optimizations;
18 } // End empty namespace.
20 // Create a new optimization.
22 Go_optimize::Go_optimize(const char* name)
23 : next_(optimizations), name_(name), is_enabled_(false)
28 // Enable an optimization by name.
31 Go_optimize::enable_by_name(const char* name)
33 bool is_all = strcmp(name, "all") == 0;
35 for (Go_optimize* p = optimizations; p != NULL; p = p->next_)
37 if (is_all || strcmp(name, p->name_) == 0)
39 p->is_enabled_ = true;
46 // Enable an optimization. Return 1 if this is a real name, 0 if not.
50 go_enable_optimize(const char* name)
52 return Go_optimize::enable_by_name(name) ? 1 : 0;