From patchwork Wed May 8 18:41:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 242633 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 9BAA32C00D2 for ; Thu, 9 May 2013 04:42:04 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=ONTBcR0nSd3lRovtKfWe1njJDpHDdSd8xvaWEqHrWgv RYrKkBILPiBrMNeJNPUZUVr+Lw4qADezfMLcm+6/coVJf9FINpB+CykNBv7uUcwF TR+kFZW3IAdaksfsOXIo9cVeRDKski0br7q7U5cIqUJUx90Qz7RaEcJ2XJGdlLdc = 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 :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=c4vdoCN9xoZHsr4ld7FRVz5U7to=; b=DBZMU/5xvjMNWeCn4 FAJuhwfBbjRAfkxVrTl1R53z3Ect8eVYMsgWd4BM+HmcRdzez0d92SUINexFsjvV h/ZYdg4E2g1IIJHduLBYWuW+g8GKwM50lxIcj+w8DWgKLxUgrOf94GSPHW7CA7ob uwe5iatAOxIKD/S7BlImYSBQ2g= Received: (qmail 22086 invoked by alias); 8 May 2013 18:41:56 -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 22071 invoked by uid 89); 8 May 2013 18:41:55 -0000 X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS autolearn=no version=3.3.1 Received: from mail-ia0-f170.google.com (HELO mail-ia0-f170.google.com) (209.85.210.170) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 08 May 2013 18:41:54 +0000 Received: by mail-ia0-f170.google.com with SMTP id k20so2352377iak.1 for ; Wed, 08 May 2013 11:41:53 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.33.11 with SMTP id n11mr2925009igi.40.1368038513062; Wed, 08 May 2013 11:41:53 -0700 (PDT) Received: by 10.64.227.205 with HTTP; Wed, 8 May 2013 11:41:53 -0700 (PDT) Date: Wed, 8 May 2013 20:41:53 +0200 Message-ID: Subject: [patch i386 windows]: Fix for PR/56975 From: Kai Tietz To: GCC Patches Cc: Richard Henderson Hi, initial patch for supporting x64 add some checks for MS_ABI. That caused for 32-bit cygwin to some regression due cygwin-32 uses SYSV_ABI as default ABI. So I introduce in this patch the define TARGET_PECOFF to indicate if targets use pe-coff or ELF-object/image sematics. This approach has also the advantage that ELF/PE-COFF specific code is just used for these targets. ChangeLog 2013-05-08 Kai Tietz PR target/56975 * config/i386/cygming.h (TARGET_PECOFF): Define as true. * config/i386/i386.h (TARGET_PECOFF): Define by default as false. (PIC_OFFSET_TABLE_REGNUM): Use TARGET_PECOFF. * config/i386/i386.c (ix86_option_override_internal): Likewise. (ix86_expand_prologue): Likewise. (ix86_expand_split_stack_prologue): Likewise. (legitimate_pic_address_disp_p): Likewise. (legitimize_pic_address): Likewise. (legitimize_tls_address): Likewise. (legitimize_pe_coff_symbol): Likewise. (output_pic_addr_const): Likewise. (construct_plt_address): Likewise. (ix86_expand_call): Likewise. (x86_output_mi_thunk): Likewise. (x86_function_profiler): Likewise. Tested for x86_64-w64-mingw32, x86_64-pc-cygwin, i686-pc-cygwin, and i686-w64-mingw32. Ok for apply? Regards, Kai Index: cygming.h =================================================================== --- cygming.h (Revision 198060) +++ cygming.h (Arbeitskopie) @@ -55,6 +55,9 @@ along with GCC; see the file COPYING3. If not see #undef DEFAULT_ABI #define DEFAULT_ABI (TARGET_64BIT ? MS_ABI : SYSV_ABI) +#undef TARGET_PECOFF +#define TARGET_PECOFF 1 + #if ! defined (USE_MINGW64_LEADING_UNDERSCORES) #undef USER_LABEL_PREFIX #define USER_LABEL_PREFIX (TARGET_64BIT ? "" : "_") Index: i386.c =================================================================== --- i386.c (Revision 198060) +++ i386.c (Arbeitskopie) @@ -3235,7 +3235,7 @@ ix86_option_override_internal (bool main_args_p) use of rip-relative addressing. This eliminates fixups that would otherwise be needed if this object is to be placed in a DLL, and is essentially just as efficient as direct addressing. */ - if (TARGET_64BIT && (TARGET_RDOS || DEFAULT_ABI == MS_ABI)) + if (TARGET_64BIT && (TARGET_RDOS || TARGET_PECOFF)) ix86_cmodel = CM_MEDIUM_PIC, flag_pic = 1; else if (TARGET_64BIT) ix86_cmodel = flag_pic ? CM_SMALL_PIC : CM_SMALL; @@ -10581,7 +10595,7 @@ ix86_expand_prologue (void) pic_reg_used = false; /* We don't use pic-register for pe-coff target. */ if (pic_offset_table_rtx - && DEFAULT_ABI != MS_ABI + && !TARGET_PECOFF && (df_regs_ever_live_p (REAL_PIC_OFFSET_TABLE_REGNUM) || crtl->profile)) { @@ -11387,7 +11401,7 @@ ix86_expand_split_stack_prologue (void) } if ((ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC) - && DEFAULT_ABI != MS_ABI) + && !TARGET_PECOFF) { HOST_WIDE_INT argval; @@ -12112,7 +12126,7 @@ legitimate_pic_address_disp_p (rtx disp) || (TARGET_DLLIMPORT_DECL_ATTRIBUTES && SYMBOL_REF_DLLIMPORT_P (op0))) return false; - if (DEFAULT_ABI == MS_ABI) + if (TARGET_PECOFF) { if (is_imported_p (op0)) return true; @@ -12199,7 +12213,7 @@ legitimate_pic_address_disp_p (rtx disp) if ((GET_CODE (XVECEXP (disp, 0, 0)) == SYMBOL_REF || GET_CODE (XVECEXP (disp, 0, 0)) == LABEL_REF) && !TARGET_64BIT) - return DEFAULT_ABI != MS_ABI && gotoff_operand (XVECEXP (disp, 0, 0), Pmode); + return !TARGET_PECOFF && gotoff_operand (XVECEXP (disp, 0, 0), Pmode); return false; case UNSPEC_GOTTPOFF: case UNSPEC_GOTNTPOFF: @@ -12543,7 +12557,7 @@ legitimize_pic_address (rtx orig, rtx reg) if (TARGET_64BIT && legitimate_pic_address_disp_p (addr)) new_rtx = addr; - else if (TARGET_64BIT && DEFAULT_ABI != MS_ABI + else if (TARGET_64BIT && !TARGET_PECOFF && ix86_cmodel != CM_SMALL_PIC && gotoff_operand (addr, Pmode)) { rtx tmpreg; @@ -12578,7 +12592,7 @@ legitimize_pic_address (rtx orig, rtx reg) else new_rtx = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, tmpreg); } - else if (!TARGET_64BIT && DEFAULT_ABI != MS_ABI && gotoff_operand (addr, Pmode)) + else if (!TARGET_64BIT && !TARGET_PECOFF && gotoff_operand (addr, Pmode)) { /* This symbol may be referenced via a displacement from the PIC base address (@GOTOFF). */ @@ -12615,7 +12629,7 @@ legitimize_pic_address (rtx orig, rtx reg) /* For x64 PE-COFF there is no GOT table. So we use address directly. */ - if (TARGET_64BIT && DEFAULT_ABI == MS_ABI) + if (TARGET_64BIT && TARGET_PECOFF) { new_rtx = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_PCREL); new_rtx = gen_rtx_CONST (Pmode, new_rtx); @@ -12693,7 +12707,7 @@ legitimize_pic_address (rtx orig, rtx reg) /* Check first to see if this is a constant offset from a @GOTOFF symbol reference. */ - if (DEFAULT_ABI != MS_ABI && gotoff_operand (op0, Pmode) + if (!TARGET_PECOFF && gotoff_operand (op0, Pmode) && CONST_INT_P (op1)) { if (!TARGET_64BIT) @@ -12837,7 +12851,7 @@ legitimize_tls_address (rtx x, enum tls_model mode if (!TARGET_64BIT) { - if (flag_pic && DEFAULT_ABI != MS_ABI) + if (flag_pic && !TARGET_PECOFF) pic = pic_offset_table_rtx; else { @@ -13160,7 +13174,7 @@ legitimize_dllimport_symbol (rtx symbol, bool want static rtx legitimize_pe_coff_symbol (rtx addr, bool inreg) { - if (DEFAULT_ABI != MS_ABI) + if (!TARGET_PECOFF) return NULL_RTX; if (TARGET_DLLIMPORT_DECL_ATTRIBUTES) @@ -13442,7 +13456,7 @@ output_pic_addr_const (FILE *file, rtx x, int code #endif assemble_name (file, name); } - if (!TARGET_MACHO && !(TARGET_64BIT && DEFAULT_ABI == MS_ABI) + if (!TARGET_MACHO && !(TARGET_64BIT && TARGET_PECOFF) && code == 'P' && ! SYMBOL_REF_LOCAL_P (x)) fputs ("@PLT", file); break; @@ -23688,7 +23702,7 @@ construct_plt_address (rtx symbol) rtx tmp, unspec; gcc_assert (GET_CODE (symbol) == SYMBOL_REF); - gcc_assert (ix86_cmodel == CM_LARGE_PIC && DEFAULT_ABI != MS_ABI); + gcc_assert (ix86_cmodel == CM_LARGE_PIC && !TARGET_PECOFF); gcc_assert (Pmode == DImode); tmp = gen_reg_rtx (Pmode); @@ -23731,7 +23745,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx call { /* Static functions and indirect calls don't need the pic register. */ if (flag_pic && (!TARGET_64BIT - || (ix86_cmodel == CM_LARGE_PIC && DEFAULT_ABI != MS_ABI)) + || (ix86_cmodel == CM_LARGE_PIC && !TARGET_PECOFF)) && GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF && ! SYMBOL_REF_LOCAL_P (XEXP (fnaddr, 0))) use_reg (&use, pic_offset_table_rtx); @@ -23745,7 +23759,7 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx call } if (ix86_cmodel == CM_LARGE_PIC - && DEFAULT_ABI != MS_ABI + && !TARGET_PECOFF && MEM_P (fnaddr) && GET_CODE (XEXP (fnaddr, 0)) == SYMBOL_REF && !local_symbolic_operand (XEXP (fnaddr, 0), VOIDmode)) @@ -35089,7 +35103,7 @@ x86_output_mi_thunk (FILE *file, if (TARGET_64BIT) { if (!flag_pic || targetm.binds_local_p (function) - || DEFAULT_ABI == MS_ABI) + || TARGET_PECOFF) ; else { @@ -35202,7 +35216,7 @@ x86_function_profiler (FILE *file, int labelno ATT fprintf (file, "\tleaq\t%sP%d(%%rip),%%r11\n", LPREFIX, labelno); #endif - if (DEFAULT_ABI == SYSV_ABI && flag_pic) + if (!TARGET_PECOFF && flag_pic) fprintf (file, "\tcall\t*%s@GOTPCREL(%%rip)\n", mcount_name); else fprintf (file, "\tcall\t%s\n", mcount_name); Index: i386.h =================================================================== --- i386.h (Revision 198060) +++ i386.h (Arbeitskopie) @@ -533,6 +533,9 @@ extern tree x86_mfence; /* This is re-defined by cygming.h. */ #define TARGET_SEH 0 +/* This is re-defined by cygming.h. */ +#define TARGET_PECOFF 0 + /* The default abi used by target. */ #define DEFAULT_ABI SYSV_ABI @@ -1183,7 +1186,7 @@ enum target_cpu_default #define PIC_OFFSET_TABLE_REGNUM \ ((TARGET_64BIT && (ix86_cmodel == CM_SMALL_PIC \ - || DEFAULT_ABI == MS_ABI)) \ + || TARGET_PECOFF)) \ || !flag_pic ? INVALID_REGNUM \ : reload_completed ? REGNO (pic_offset_table_rtx) \ : REAL_PIC_OFFSET_TABLE_REGNUM)