Only allow e500 double in SPE_SIMD_REGNO_P registers.
[official-gcc.git] / gcc / lto-opts.c
blobceccb6f44cb0c328a047be17d817c76e7270f80e
1 /* LTO IL options.
3 Copyright (C) 2009-2014 Free Software Foundation, Inc.
4 Contributed by Simon Baldwin <simonb@google.com>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "tree.h"
26 #include "basic-block.h"
27 #include "tree-ssa-alias.h"
28 #include "internal-fn.h"
29 #include "gimple-expr.h"
30 #include "is-a.h"
31 #include "gimple.h"
32 #include "hashtab.h"
33 #include "bitmap.h"
34 #include "flags.h"
35 #include "opts.h"
36 #include "options.h"
37 #include "common/common-target.h"
38 #include "diagnostic.h"
39 #include "lto-streamer.h"
40 #include "toplev.h"
42 /* Append the option piece OPT to the COLLECT_GCC_OPTIONS string
43 set up by OB, appropriately quoted and separated by spaces
44 (if !*FIRST_P). */
46 static void
47 append_to_collect_gcc_options (struct obstack *ob,
48 bool *first_p, const char *opt)
50 const char *p, *q = opt;
51 if (!*first_p)
52 obstack_grow (ob, " ", 1);
53 obstack_grow (ob, "'", 1);
54 while ((p = strchr (q, '\'')))
56 obstack_grow (ob, q, p - q);
57 obstack_grow (ob, "'\\''", 4);
58 q = ++p;
60 obstack_grow (ob, q, strlen (q));
61 obstack_grow (ob, "'", 1);
62 *first_p = false;
65 /* Write currently held options to an LTO IL section. */
67 void
68 lto_write_options (void)
70 char *section_name;
71 struct obstack temporary_obstack;
72 unsigned int i, j;
73 char *args;
74 bool first_p = true;
76 section_name = lto_get_section_name (LTO_section_opts, NULL, NULL);
77 lto_begin_section (section_name, false);
79 obstack_init (&temporary_obstack);
81 /* Output options that affect GIMPLE IL semantics and are implicitly
82 enabled by the frontend.
83 This for now includes an explicit set of options that we also handle
84 explicitly in lto-wrapper.c. In the end the effects on GIMPLE IL
85 semantics should be explicitely encoded in the IL or saved per
86 function rather than per compilation unit. */
87 /* -fexceptions causes the EH machinery to be initialized, enabling
88 generation of unwind data so that explicit throw() calls work. */
89 if (!global_options_set.x_flag_exceptions
90 && global_options.x_flag_exceptions)
91 append_to_collect_gcc_options (&temporary_obstack, &first_p,
92 "-fexceptions");
93 /* -fnon-call-exceptions changes the generation of exception
94 regions. It is enabled implicitly by the Go frontend. */
95 if (!global_options_set.x_flag_non_call_exceptions
96 && global_options.x_flag_non_call_exceptions)
97 append_to_collect_gcc_options (&temporary_obstack, &first_p,
98 "-fnon-call-exceptions");
99 /* The default -ffp-contract changes depending on the language
100 standard. Pass thru conservative standard settings. */
101 if (!global_options_set.x_flag_fp_contract_mode)
102 switch (global_options.x_flag_fp_contract_mode)
104 case FP_CONTRACT_OFF:
105 append_to_collect_gcc_options (&temporary_obstack, &first_p,
106 "-ffp-contract=off");
107 break;
108 case FP_CONTRACT_ON:
109 append_to_collect_gcc_options (&temporary_obstack, &first_p,
110 "-ffp-contract=on");
111 break;
112 case FP_CONTRACT_FAST:
113 /* Nothing. That merges conservatively and is the default for LTO. */
114 break;
115 default:
116 gcc_unreachable ();
118 /* The default -fmath-errno, -fsigned-zeros and -ftrapping-math change
119 depending on the language (they can be disabled by the Ada and Java
120 front-ends). Pass thru conservative standard settings. */
121 if (!global_options_set.x_flag_errno_math)
122 append_to_collect_gcc_options (&temporary_obstack, &first_p,
123 global_options.x_flag_errno_math
124 ? "-fmath-errno"
125 : "-fno-math-errno");
126 if (!global_options_set.x_flag_signed_zeros)
127 append_to_collect_gcc_options (&temporary_obstack, &first_p,
128 global_options.x_flag_signed_zeros
129 ? "-fsigned-zeros"
130 : "-fno-signed-zeros");
131 if (!global_options_set.x_flag_trapping_math)
132 append_to_collect_gcc_options (&temporary_obstack, &first_p,
133 global_options.x_flag_trapping_math
134 ? "-ftrapping-math"
135 : "-fno-trapping-math");
136 /* We need to merge -f[no-]strict-overflow, -f[no-]wrapv and -f[no-]trapv
137 conservatively, so stream out their defaults. */
138 if (!global_options_set.x_flag_wrapv
139 && global_options.x_flag_wrapv)
140 append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fwrapv");
141 if (!global_options_set.x_flag_trapv
142 && !global_options.x_flag_trapv)
143 append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fno-trapv");
144 if (!global_options_set.x_flag_strict_overflow
145 && !global_options.x_flag_strict_overflow)
146 append_to_collect_gcc_options (&temporary_obstack, &first_p,
147 "-fno-strict-overflow");
149 /* Output explicitly passed options. */
150 for (i = 1; i < save_decoded_options_count; ++i)
152 struct cl_decoded_option *option = &save_decoded_options[i];
154 /* Skip explicitly some common options that we do not need. */
155 switch (option->opt_index)
157 case OPT_dumpbase:
158 case OPT_SPECIAL_unknown:
159 case OPT_SPECIAL_ignore:
160 case OPT_SPECIAL_program_name:
161 case OPT_SPECIAL_input_file:
162 continue;
164 default:
165 break;
168 /* Skip frontend and driver specific options here. */
169 if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO)))
170 continue;
172 /* Drop options created from the gcc driver that will be rejected
173 when passed on to the driver again. */
174 if (cl_options[option->opt_index].cl_reject_driver)
175 continue;
177 /* Also drop all options that are handled by the driver as well,
178 which includes things like -o and -v or -fhelp for example.
179 We do not need those. Also drop all diagnostic options. */
180 if (cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING))
181 continue;
183 for (j = 0; j < option->canonical_option_num_elements; ++j)
184 append_to_collect_gcc_options (&temporary_obstack, &first_p,
185 option->canonical_option[j]);
187 obstack_grow (&temporary_obstack, "\0", 1);
188 args = XOBFINISH (&temporary_obstack, char *);
189 lto_write_data (args, strlen (args) + 1);
190 lto_end_section ();
192 obstack_free (&temporary_obstack, NULL);
193 free (section_name);