diff options
author | Bernd Schmidt <bernds@codesourcery.com> | 2014-11-13 13:54:07 +0000 |
---|---|---|
committer | Kirill Yukhin <kyukhin@gcc.gnu.org> | 2014-11-13 13:54:07 +0000 |
commit | c713ddc0314d680f961155610a723e7b882e2ae3 (patch) | |
tree | 2fe44e0f530c8b4cf77e4ce8d2d53f000fba9744 /gcc/lto-opts.c | |
parent | 1df3f84256114788e5340cc800b2cdea0e1c9486 (diff) | |
download | gcc-c713ddc0314d680f961155610a723e7b882e2ae3.zip gcc-c713ddc0314d680f961155610a723e7b882e2ae3.tar.gz gcc-c713ddc0314d680f961155610a723e7b882e2ae3.tar.bz2 |
[PATCH 6/7] OpenMP 4.0 offloading infrastructure: option handling.
gcc/
* common.opt (foffload, foffload-abi): New options.
* config/i386/i386.c (ix86_offload_options): New static function.
(TARGET_OFFLOAD_OPTIONS): Define.
* coretypes.h (enum offload_abi): New enum.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in (TARGET_OFFLOAD_OPTIONS): Document.
* gcc.c (offload_targets): New static variable.
(handle_foffload_option): New static function.
(driver_handle_option): Handle OPT_foffload_.
(driver::maybe_putenv_OFFLOAD_TARGETS): Set OFFLOAD_TARGET_NAMES
according to offload_targets.
* hooks.c (hook_charptr_void_null): New hook.
* hooks.h (hook_charptr_void_null): Declare.
* lto-opts.c: Include lto-section-names.h.
(lto_write_options): Append options from target offload_options hook and
store them to offload_lto section. Do not store target-specific,
driver and diagnostic options in offload_lto section.
* lto-wrapper.c (merge_and_complain): Handle OPT_foffload_ and
OPT_foffload_abi_.
(append_compiler_options, append_linker_options)
(append_offload_options): New static functions.
(compile_offload_image): Add new arguments with options.
Call append_compiler_options and append_offload_options.
(compile_images_for_offload_targets): Add new arguments with options.
(find_and_merge_options): New static function.
(run_gcc): Outline options handling into the new functions:
find_and_merge_options, append_compiler_options, append_linker_options.
* opts.c (common_handle_option): Don't handle OPT_foffload_.
Forbid OPT_foffload_abi_ for non-offload compiler.
* target.def (offload_options): New target hook.
Co-Authored-By: Andrey Turetskiy <andrey.turetskiy@intel.com>
Co-Authored-By: Ilya Verbin <ilya.verbin@intel.com>
From-SVN: r217493
Diffstat (limited to 'gcc/lto-opts.c')
-rw-r--r-- | gcc/lto-opts.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c index d1d153d0..72b0957 100644 --- a/gcc/lto-opts.c +++ b/gcc/lto-opts.c @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-ref.h" #include "cgraph.h" #include "lto-streamer.h" +#include "lto-section-names.h" #include "toplev.h" /* Append the option piece OPT to the COLLECT_GCC_OPTIONS string @@ -158,6 +159,23 @@ lto_write_options (void) append_to_collect_gcc_options (&temporary_obstack, &first_p, "-fno-strict-overflow"); + /* Append options from target hook and store them to offload_lto section. */ + if (strcmp (section_name_prefix, OFFLOAD_SECTION_NAME_PREFIX) == 0) + { + char *offload_opts = targetm.offload_options (); + char *offload_ptr = offload_opts; + while (offload_ptr) + { + char *next = strchr (offload_ptr, ' '); + if (next) + *next++ = '\0'; + append_to_collect_gcc_options (&temporary_obstack, &first_p, + offload_ptr); + offload_ptr = next; + } + free (offload_opts); + } + /* Output explicitly passed options. */ for (i = 1; i < save_decoded_options_count; ++i) { @@ -181,15 +199,23 @@ lto_write_options (void) if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO))) continue; + /* Do not store target-specific options in offload_lto section. */ + if ((cl_options[option->opt_index].flags & CL_TARGET) + && strcmp (section_name_prefix, OFFLOAD_SECTION_NAME_PREFIX) == 0) + continue; + /* Drop options created from the gcc driver that will be rejected when passed on to the driver again. */ if (cl_options[option->opt_index].cl_reject_driver) continue; /* Also drop all options that are handled by the driver as well, - which includes things like -o and -v or -fhelp for example. - We do not need those. Also drop all diagnostic options. */ - if (cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING)) + which includes things like -o and -v or -fhelp for example. + We do not need those. The only exception is -foffload option, if we + write it in offload_lto section. Also drop all diagnostic options. */ + if ((cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING)) + && (strcmp (section_name_prefix, OFFLOAD_SECTION_NAME_PREFIX) != 0 + || option->opt_index != OPT_foffload_)) continue; for (j = 0; j < option->canonical_option_num_elements; ++j) |