From patchwork Tue Jun 24 18:45:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edelsohn X-Patchwork-Id: 363599 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 2E7F614009E for ; Wed, 25 Jun 2014 04:46:01 +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=F78wvxygMVjiOBF54z/7sf6shLfpmRFL349DipNDAjw tTa9n0sxRFPlHzn4pDa+LLd+wooyVskO3ArGLeRUiPr00SinBbL5sIzYVdPWFkzS 2AvnxlepW9TpXbOZ0L5zrnCvCgV26cEp1fj8h0IE4sMMDHjQrpODBiah4WMc1Q7s = 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=c2zaDluzYLcgTOywIIg/gPm67HU=; b=U20kuyHP+mj3MqmiT LEjSKbj5OSQ6QkzvhydEpDByIwXyKvPbxRH1NiUM6j9RlomfoD5hybw9wNhFCeAR bsNG4OULW4ntF5h2uGhgJ3eiuPdT6nxNxfhBeeCY2cShaAB4Y4cNhrOqjzF9oJzQ qS6T/L4STcAPipcYEkIFKzo1l0= Received: (qmail 17338 invoked by alias); 24 Jun 2014 18:45:55 -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 17327 invoked by uid 89); 24 Jun 2014 18:45:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ve0-f181.google.com Received: from mail-ve0-f181.google.com (HELO mail-ve0-f181.google.com) (209.85.128.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 24 Jun 2014 18:45:52 +0000 Received: by mail-ve0-f181.google.com with SMTP id db11so796586veb.40 for ; Tue, 24 Jun 2014 11:45:49 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.220.253.132 with SMTP id na4mr2191942vcb.39.1403635549787; Tue, 24 Jun 2014 11:45:49 -0700 (PDT) Received: by 10.220.11.5 with HTTP; Tue, 24 Jun 2014 11:45:49 -0700 (PDT) Date: Tue, 24 Jun 2014 14:45:49 -0400 Message-ID: Subject: [PATCH] Convert XCOFF ASM_DECLARE_FUNCTION_NAME to function From: David Edelsohn To: GCC Patches Cc: Jan Hubicka In preparation to fix the alias issues on AIX, this patch changes ASM_DECLARE_FUNCTION_NAME from a macro to a function. Bootstrap on powerpc-ibm-aix7.1.0.0 in progress. * config/rs6000/xcoff.h (ASM_DECLARE_FUNCTION_NAME): Remove definition and call... * config/rs6000/rs6000.c (rs6000_xcoff_declare_function_name): New function. * config/rs6000/rs6000-protos.h (rs6000_xcoff_declare_function_name): Declare. Thanks, David * config/rs6000/xcoff.h (ASM_DECLARE_FUNCTION_NAME): Remove definition and call... * config/rs6000/rs6000.c (rs6000_xcoff_declare_function_name): New function. * config/rs6000/rs6000-protos.h (rs6000_xcoff_declare_function_name): Declare. Index: rs6000-protos.h =================================================================== --- rs6000-protos.h (revision 211938) +++ rs6000-protos.h (working copy) @@ -164,6 +164,7 @@ extern rtx rs6000_va_arg (tree, tree); extern int function_ok_for_sibcall (tree); extern int rs6000_reg_parm_stack_space (tree, bool); +extern void rs6000_xcoff_declare_function_name (FILE *, const char *, tree); extern void rs6000_elf_declare_function_name (FILE *, const char *, tree); extern bool rs6000_elf_in_small_data_p (const_tree); #ifdef ARGS_SIZE_RTX Index: rs6000.c =================================================================== --- rs6000.c (revision 211938) +++ rs6000.c (working copy) @@ -29452,6 +29452,71 @@ asm_out_file); } +/* This macro produces the initial definition of a function name. + On the RS/6000, we need to place an extra '.' in the function name and + output the function descriptor. + Dollar signs are converted to underscores. + + The csect for the function will have already been created when + text_section was selected. We do have to go back to that csect, however. + + The third and fourth parameters to the .function pseudo-op (16 and 044) + are placeholders which no longer have any use. */ + +void +rs6000_xcoff_declare_function_name (FILE *file, const char *name, tree decl) +{ + char *buffer = (char *) alloca (strlen (name) + 1); + char *p; + int dollar_inside = 0; + strcpy (buffer, name); + p = strchr (buffer, '$'); + while (p) { + *p = '_'; + dollar_inside++; + p = strchr (p + 1, '$'); + } + if (TREE_PUBLIC (decl)) + { + if (!RS6000_WEAK || !DECL_WEAK (decl)) + { + if (dollar_inside) { + fprintf(file, "\t.rename .%s,\".%s\"\n", buffer, name); + fprintf(file, "\t.rename %s,\"%s\"\n", buffer, name); + } + fputs ("\t.globl .", file); + RS6000_OUTPUT_BASENAME (file, buffer); + putc ('\n', file); + } + } + else + { + if (dollar_inside) { + fprintf(file, "\t.rename .%s,\".%s\"\n", buffer, name); + fprintf(file, "\t.rename %s,\"%s\"\n", buffer, name); + } + fputs ("\t.lglobl .", file); + RS6000_OUTPUT_BASENAME (file, buffer); + putc ('\n', file); + } + fputs ("\t.csect ", file); + RS6000_OUTPUT_BASENAME (file, buffer); + fputs (TARGET_32BIT ? "[DS]\n" : "[DS],3\n", file); + RS6000_OUTPUT_BASENAME (file, buffer); + fputs (":\n", file); + fputs (TARGET_32BIT ? "\t.long ." : "\t.llong .", file); + RS6000_OUTPUT_BASENAME (file, buffer); + fputs (", TOC[tc0], 0\n", file); + in_section = NULL; + switch_to_section (function_section (decl)); + putc ('.', file); + RS6000_OUTPUT_BASENAME (file, buffer); + fputs (":\n", file); + if (write_symbols != NO_DEBUG && !DECL_IGNORED_P (decl)) + xcoffout_declare_function (file, decl, buffer); + return; +} + #ifdef HAVE_AS_TLS static void rs6000_xcoff_encode_section_info (tree decl, rtx rtl, int first) Index: xcoff.h =================================================================== --- xcoff.h (revision 211938) +++ xcoff.h (working copy) @@ -134,68 +134,12 @@ #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE #define TARGET_ASM_FILE_START_FILE_DIRECTIVE false -/* This macro produces the initial definition of a function name. - On the RS/6000, we need to place an extra '.' in the function name and - output the function descriptor. - Dollar signs are converted to underscores. +/* This macro produces the initial definition of a function name. */ - The csect for the function will have already been created when - text_section was selected. We do have to go back to that csect, however. +#undef ASM_DECLARE_FUNCTION_NAME +#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ + rs6000_xcoff_declare_function_name ((FILE), (NAME), (DECL)) - The third and fourth parameters to the .function pseudo-op (16 and 044) - are placeholders which no longer have any use. */ - -#define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL) \ -{ char *buffer = (char *) alloca (strlen (NAME) + 1); \ - char *p; \ - int dollar_inside = 0; \ - strcpy (buffer, NAME); \ - p = strchr (buffer, '$'); \ - while (p) { \ - *p = '_'; \ - dollar_inside++; \ - p = strchr (p + 1, '$'); \ - } \ - if (TREE_PUBLIC (DECL)) \ - { \ - if (!RS6000_WEAK || !DECL_WEAK (decl)) \ - { \ - if (dollar_inside) { \ - fprintf(FILE, "\t.rename .%s,\".%s\"\n", buffer, NAME); \ - fprintf(FILE, "\t.rename %s,\"%s\"\n", buffer, NAME); \ - } \ - fputs ("\t.globl .", FILE); \ - RS6000_OUTPUT_BASENAME (FILE, buffer); \ - putc ('\n', FILE); \ - } \ - } \ - else \ - { \ - if (dollar_inside) { \ - fprintf(FILE, "\t.rename .%s,\".%s\"\n", buffer, NAME); \ - fprintf(FILE, "\t.rename %s,\"%s\"\n", buffer, NAME); \ - } \ - fputs ("\t.lglobl .", FILE); \ - RS6000_OUTPUT_BASENAME (FILE, buffer); \ - putc ('\n', FILE); \ - } \ - fputs ("\t.csect ", FILE); \ - RS6000_OUTPUT_BASENAME (FILE, buffer); \ - fputs (TARGET_32BIT ? "[DS]\n" : "[DS],3\n", FILE); \ - RS6000_OUTPUT_BASENAME (FILE, buffer); \ - fputs (":\n", FILE); \ - fputs (TARGET_32BIT ? "\t.long ." : "\t.llong .", FILE); \ - RS6000_OUTPUT_BASENAME (FILE, buffer); \ - fputs (", TOC[tc0], 0\n", FILE); \ - in_section = NULL; \ - switch_to_section (function_section (DECL)); \ - putc ('.', FILE); \ - RS6000_OUTPUT_BASENAME (FILE, buffer); \ - fputs (":\n", FILE); \ - if (write_symbols != NO_DEBUG && !DECL_IGNORED_P (DECL)) \ - xcoffout_declare_function (FILE, DECL, buffer); \ -} - /* Output a reference to SYM on FILE. */ #define ASM_OUTPUT_SYMBOL_REF(FILE, SYM) \