From patchwork Wed Sep 30 09:09:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 524183 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 24ADF140D17 for ; Wed, 30 Sep 2015 19:10:14 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=d7n+ox3A; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; q=dns; s=default; b=vLJz1zIy4K+Gi1cx PRhhbl5pReyZRm4u8GyGgkC656i68AHSW+5AVaOh38R0D15eBIopW/aSyDX4iNk0 w7DmJoMl1MUGrU4gQqLENbVLoz9StkxYmdb0A+la6PRJ7vaTXi5urTpenLjy+8Kd aJJAJSm48UoL3OEt5mTmWiRnsXo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=default; bh=VqNA29Y5TqyAiUkIM1yYaG AR/fE=; b=d7n+ox3AkNNJxUL8lPkB8/+P4Z2TAvRWpjPEA0uX5h6z65OdPiFfpL sapSvxF62sp/0CzC2DuFQ2erWJwMFF801U4M6O48+khHkTwztXJ46Dc7WkNeb+BW LH7P+LAdnJMWF3Gak+n826hlO1/8szpqIH0IDQcBR3JaBis1EvatQ= Received: (qmail 128220 invoked by alias); 30 Sep 2015 09:10:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 128200 invoked by uid 89); 30 Sep 2015 09:10:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 30 Sep 2015 09:10:04 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ZhDOi-0006Br-44 from Thomas_Schwinge@mentor.com ; Wed, 30 Sep 2015 02:10:00 -0700 Received: from feldtkeller.schwinge.homeip.net (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Wed, 30 Sep 2015 10:09:58 +0100 From: Thomas Schwinge To: Bernd Schmidt , "H.J. Lu" CC: Kirill Yukhin , Andrey Turetskiy , Jakub Jelinek , Ilya Verbin , GCC Patches Subject: Re: Use gcc/coretypes.h:enum offload_abi in mkoffloads In-Reply-To: <5609143D.6010605@redhat.com> References: <20141021171323.GA47586@msticlxl57.ims.intel.com> <20141021171602.GB47586@msticlxl57.ims.intel.com> <20141022082103.GH10376@tucnak.redhat.com> <20141022185701.GA21398@msticlxl57.ims.intel.com> <87sig8ylhv.fsf@kepler.schwinge.homeip.net> <20141222112820.GJ1667@tucnak.redhat.com> <87ioghwc6e.fsf@schwinge.name> <87io8vmhar.fsf@kepler.schwinge.homeip.net> <87vbavuft0.fsf@kepler.schwinge.homeip.net> <5609143D.6010605@redhat.com> User-Agent: Notmuch/0.9-125-g4686d11 (http://notmuchmail.org) Emacs/24.5.1 (i586-pc-linux-gnu) Date: Wed, 30 Sep 2015 11:09:48 +0200 Message-ID: <87a8s4tgrn.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Hi! On Mon, 28 Sep 2015 12:19:41 +0200, Bernd Schmidt wrote: > > Use gcc/coretypes.h:enum offload_abi in mkoffloads > > + abort (); > > Can we have gcc_unreachable() in these tools? Good suggestion, thanks! > Other than that, it looks ok but it also doesn't seem to do anything. Thanks for the review. This refactoring patch happend to come into existance when I worked on the other mkoffload patches that I recently posted, and as I considered it an improvement in its own right, I posted it. > Are you intending to add more ABIs? As I had quoted in my previous email, H.J. Lu expressed an interest in supporting the x32 ABI, , which is now more easy to do than before. With the abort calls replaced with gcc_unreachable, committed in r228283: commit dc0452858cb0d7f56fada1bb2f795f92cd551795 Author: tschwinge Date: Wed Sep 30 08:58:04 2015 +0000 Use gcc/coretypes.h:enum offload_abi in mkoffloads gcc/ * config/i386/intelmic-mkoffload.c (target_ilp32): Remove variable, replacing it with... (offload_abi): ... this new variable. Adjust all users. * config/nvptx/mkoffload.c (target_ilp32, offload_abi): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228283 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++ gcc/config/i386/intelmic-mkoffload.c | 90 ++++++++++++++++++++++++------------ gcc/config/nvptx/mkoffload.c | 56 +++++++++++++++------- 3 files changed, 108 insertions(+), 45 deletions(-) Grüße, Thomas diff --git gcc/ChangeLog gcc/ChangeLog index e24c7bc..d29e5d9 100644 --- gcc/ChangeLog +++ gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-09-30 Thomas Schwinge + + * config/i386/intelmic-mkoffload.c (target_ilp32): Remove + variable, replacing it with... + (offload_abi): ... this new variable. Adjust all users. + * config/nvptx/mkoffload.c (target_ilp32, offload_abi): Likewise. + 2015-09-30 Matthias Klose * configure.ac: Remove extraneous ;;. diff --git gcc/config/i386/intelmic-mkoffload.c gcc/config/i386/intelmic-mkoffload.c index 4a7812c..065d408 100644 --- gcc/config/i386/intelmic-mkoffload.c +++ gcc/config/i386/intelmic-mkoffload.c @@ -42,8 +42,7 @@ int num_temps = 0; const int MAX_NUM_TEMPS = 10; const char *temp_files[MAX_NUM_TEMPS]; -/* Shows if we should compile binaries for i386 instead of x86-64. */ -bool target_ilp32 = false; +enum offload_abi offload_abi = OFFLOAD_ABI_UNSET; /* Delete tempfiles and exit function. */ void @@ -200,10 +199,17 @@ out: static void compile_for_target (struct obstack *argv_obstack) { - if (target_ilp32) - obstack_ptr_grow (argv_obstack, "-m32"); - else - obstack_ptr_grow (argv_obstack, "-m64"); + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + obstack_ptr_grow (argv_obstack, "-m64"); + break; + case OFFLOAD_ABI_ILP32: + obstack_ptr_grow (argv_obstack, "-m32"); + break; + default: + gcc_unreachable (); + } obstack_ptr_grow (argv_obstack, NULL); char **argv = XOBFINISH (argv_obstack, char **); @@ -379,10 +385,17 @@ generate_host_descr_file (const char *host_compiler) new_argv[new_argc++] = "-c"; new_argv[new_argc++] = "-fPIC"; new_argv[new_argc++] = "-shared"; - if (target_ilp32) - new_argv[new_argc++] = "-m32"; - else - new_argv[new_argc++] = "-m64"; + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + new_argv[new_argc++] = "-m64"; + break; + case OFFLOAD_ABI_ILP32: + new_argv[new_argc++] = "-m32"; + break; + default: + gcc_unreachable (); + } new_argv[new_argc++] = src_filename; new_argv[new_argc++] = "-o"; new_argv[new_argc++] = obj_filename; @@ -442,10 +455,17 @@ prepare_target_image (const char *target_compiler, int argc, char **argv) objcopy_argv[3] = "-I"; objcopy_argv[4] = "binary"; objcopy_argv[5] = "-O"; - if (target_ilp32) - objcopy_argv[6] = "elf32-i386"; - else - objcopy_argv[6] = "elf64-x86-64"; + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + objcopy_argv[6] = "elf64-x86-64"; + break; + case OFFLOAD_ABI_ILP32: + objcopy_argv[6] = "elf32-i386"; + break; + default: + gcc_unreachable (); + } objcopy_argv[7] = target_so_filename; objcopy_argv[8] = "--rename-section"; objcopy_argv[9] = rename_section_opt; @@ -518,17 +538,22 @@ main (int argc, char **argv) passed with @file. Expand them into argv before processing. */ expandargv (&argc, &argv); - /* Find out whether we should compile binaries for i386 or x86-64. */ - for (int i = argc - 1; i > 0; i--) - if (strncmp (argv[i], "-foffload-abi=", sizeof ("-foffload-abi=") - 1) == 0) - { - if (strstr (argv[i], "ilp32")) - target_ilp32 = true; - else if (!strstr (argv[i], "lp64")) - fatal_error (input_location, - "unrecognizable argument of option -foffload-abi"); - break; - } + /* Scan the argument vector. */ + for (int i = 1; i < argc; i++) + { +#define STR "-foffload-abi=" + if (strncmp (argv[i], STR, strlen (STR)) == 0) + { + if (strcmp (argv[i] + strlen (STR), "lp64") == 0) + offload_abi = OFFLOAD_ABI_LP64; + else if (strcmp (argv[i] + strlen (STR), "ilp32") == 0) + offload_abi = OFFLOAD_ABI_ILP32; + else + fatal_error (input_location, + "unrecognizable argument of option " STR); + } +#undef STR + } const char *target_so_filename = prepare_target_image (target_compiler, argc, argv); @@ -541,10 +566,17 @@ main (int argc, char **argv) const char *new_argv[9]; new_argv[new_argc++] = "ld"; new_argv[new_argc++] = "-m"; - if (target_ilp32) - new_argv[new_argc++] = "elf_i386"; - else - new_argv[new_argc++] = "elf_x86_64"; + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + new_argv[new_argc++] = "elf_x86_64"; + break; + case OFFLOAD_ABI_ILP32: + new_argv[new_argc++] = "elf_i386"; + break; + default: + gcc_unreachable (); + } new_argv[new_argc++] = "--relocatable"; new_argv[new_argc++] = host_descr_filename; new_argv[new_argc++] = target_so_filename; diff --git gcc/config/nvptx/mkoffload.c gcc/config/nvptx/mkoffload.c index e0ff8fc..fe0e8cd 100644 --- gcc/config/nvptx/mkoffload.c +++ gcc/config/nvptx/mkoffload.c @@ -126,8 +126,7 @@ static id_map *var_ids, **vars_tail = &var_ids; static const char *ptx_name; static const char *ptx_cfile_name; -/* Shows if we should compile binaries for i386 instead of x86-64. */ -bool target_ilp32 = false; +enum offload_abi offload_abi = OFFLOAD_ABI_UNSET; /* Delete tempfiles. */ @@ -926,7 +925,17 @@ compile_native (const char *infile, const char *outfile, const char *compiler) struct obstack argv_obstack; obstack_init (&argv_obstack); obstack_ptr_grow (&argv_obstack, compiler); - obstack_ptr_grow (&argv_obstack, target_ilp32 ? "-m32" : "-m64"); + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + obstack_ptr_grow (&argv_obstack, "-m64"); + break; + case OFFLOAD_ABI_ILP32: + obstack_ptr_grow (&argv_obstack, "-m32"); + break; + default: + gcc_unreachable (); + } obstack_ptr_grow (&argv_obstack, infile); obstack_ptr_grow (&argv_obstack, "-c"); obstack_ptr_grow (&argv_obstack, "-o"); @@ -1004,23 +1013,38 @@ main (int argc, char **argv) passed with @file. Expand them into argv before processing. */ expandargv (&argc, &argv); - /* Find out whether we should compile binaries for i386 or x86-64. */ - for (int i = argc - 1; i > 0; i--) - if (strncmp (argv[i], "-foffload-abi=", sizeof ("-foffload-abi=") - 1) == 0) - { - if (strstr (argv[i], "ilp32")) - target_ilp32 = true; - else if (!strstr (argv[i], "lp64")) - fatal_error (input_location, - "unrecognizable argument of option -foffload-abi"); - break; - } + /* Scan the argument vector. */ + for (int i = 1; i < argc; i++) + { +#define STR "-foffload-abi=" + if (strncmp (argv[i], STR, strlen (STR)) == 0) + { + if (strcmp (argv[i] + strlen (STR), "lp64") == 0) + offload_abi = OFFLOAD_ABI_LP64; + else if (strcmp (argv[i] + strlen (STR), "ilp32") == 0) + offload_abi = OFFLOAD_ABI_ILP32; + else + fatal_error (input_location, + "unrecognizable argument of option " STR); + } +#undef STR + } struct obstack argv_obstack; obstack_init (&argv_obstack); obstack_ptr_grow (&argv_obstack, driver); obstack_ptr_grow (&argv_obstack, "-xlto"); - obstack_ptr_grow (&argv_obstack, target_ilp32 ? "-m32" : "-m64"); + switch (offload_abi) + { + case OFFLOAD_ABI_LP64: + obstack_ptr_grow (&argv_obstack, "-m64"); + break; + case OFFLOAD_ABI_ILP32: + obstack_ptr_grow (&argv_obstack, "-m32"); + break; + default: + gcc_unreachable (); + } obstack_ptr_grow (&argv_obstack, "-S"); for (int ix = 1; ix != argc; ix++) @@ -1039,7 +1063,7 @@ main (int argc, char **argv) /* PR libgomp/65099: Currently, we only support offloading in 64-bit configurations. */ - if (!target_ilp32) + if (offload_abi == OFFLOAD_ABI_LP64) { ptx_name = make_temp_file (".mkoffload"); obstack_ptr_grow (&argv_obstack, "-o");