Mercurial > hg > CbC > CbC_gcc
comparison gcc/go/gofrontend/go-optimize.cc @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 // go-optimize.cc -- Go frontend optimizer flags. | |
2 | |
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. | |
6 | |
7 #include "go-system.h" | |
8 | |
9 #include "go-c.h" | |
10 #include "go-optimize.h" | |
11 | |
12 namespace { | |
13 | |
14 // The list of optimizations. | |
15 | |
16 Go_optimize* optimizations; | |
17 | |
18 } // End empty namespace. | |
19 | |
20 // Create a new optimization. | |
21 | |
22 Go_optimize::Go_optimize(const char* name) | |
23 : next_(optimizations), name_(name), is_enabled_(false) | |
24 { | |
25 optimizations = this; | |
26 } | |
27 | |
28 // Enable an optimization by name. | |
29 | |
30 bool | |
31 Go_optimize::enable_by_name(const char* name) | |
32 { | |
33 bool is_all = strcmp(name, "all") == 0; | |
34 bool found = false; | |
35 for (Go_optimize* p = optimizations; p != NULL; p = p->next_) | |
36 { | |
37 if (is_all || strcmp(name, p->name_) == 0) | |
38 { | |
39 p->is_enabled_ = true; | |
40 found = true; | |
41 } | |
42 } | |
43 return found; | |
44 } | |
45 | |
46 // Enable an optimization. Return 1 if this is a real name, 0 if not. | |
47 | |
48 GO_EXTERN_C | |
49 int | |
50 go_enable_optimize(const char* name) | |
51 { | |
52 return Go_optimize::enable_by_name(name) ? 1 : 0; | |
53 } |