From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25671 invoked by alias); 20 Aug 2009 11:20:14 -0000 Received: (qmail 25651 invoked by uid 22791); 20 Aug 2009 11:20:12 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-px0-f179.google.com (HELO mail-px0-f179.google.com) (209.85.216.179) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 20 Aug 2009 11:20:02 +0000 Received: by pxi9 with SMTP id 9so793650pxi.14 for ; Thu, 20 Aug 2009 04:20:00 -0700 (PDT) Received: by 10.142.196.18 with SMTP id t18mr1333339wff.32.1250767200670; Thu, 20 Aug 2009 04:20:00 -0700 (PDT) Received: from Paullaptop (203-206-7-21.dyn.iinet.net.au [203.206.7.21]) by mx.google.com with ESMTPS id 30sm1216650wff.29.2009.08.20.04.19.57 (version=SSLv3 cipher=RC4-MD5); Thu, 20 Aug 2009 04:19:59 -0700 (PDT) Message-ID: <5D9A2D00E3CD4B858806C97D60082067@Paullaptop> From: "Paul Edwards" To: "Ulrich Weigand" Cc: References: <200908121348.n7CDmrV1012019@d12av02.megacenter.de.ibm.com> In-Reply-To: <200908121348.n7CDmrV1012019@d12av02.megacenter.de.ibm.com> Subject: Re: i370 port Date: Thu, 20 Aug 2009 12:49:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="Windows-1252"; reply-type=original Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-08/txt/msg00365.txt.bz2 >> > That depends a bit on the compiler version and optimization level, >> > but (in particular in the 3.x time frame) GCC may output assembler >> > code on a function-by-function basis, without necessarily reading >> > in the whole source file first. >> >> Ok, actually it doesn't matter if it doesn't work all the time. I'll >> always be compiling with -Os anyway, so it sounds like I'm in >> with a chance of the whole file being read first? >> >> If so, where is my first opportunity, in 3.2.3, to see if there's a >> "main" function in this file? > > Hmm, it seems 3.2.x would *always* operate on a function-by-function > basis. The unit-at-a-time mode was only introduced with 3.4 (I don't > recall if it was already present in 3.3). I don't think there is any > way in 3.2.3 to check whether there is a "main" function in the file > before it is processed ... Does that mean I could take advantage of this behaviour? Currently I have this change: /* Store in OUTPUT a string (made with alloca) containing an assembler-name for a local static variable named NAME. LABELNO is an integer which is different for each call. */ #ifdef TARGET_PDPMAC #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) ^I^I\ {^I^I^I^I^I^I^I^I^I\ (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10);^I^I^I\ sprintf ((OUTPUT), "__%d", (LABELNO));^I^I^I^I\ } to give the static functions unique names within the file. However, it has the unfortunate side-effect that this code: #if defined(TARGET_DIGNUS) || defined(TARGET_PDPMAC) #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL)^I^I^I\ {^I^I^I^I^I^I^I^I^I\ if (strlen (NAME) + 1 > mvs_function_name_length)^I^I^I\ {^I^I^I^I^I^I^I^I^I\ if (mvs_function_name)^I^I^I^I^I^I\ ^Ifree (mvs_function_name);^I^I^I^I^I\ mvs_function_name = 0;^I^I^I^I^I^I\ }^I^I^I^I^I^I^I^I^I\ if (!mvs_function_name)^I^I^I^I^I^I\ {^I^I^I^I^I^I^I^I^I\ mvs_function_name_length = strlen (NAME) * 2 + 1;^I^I^I\ mvs_function_name = (char *) xmalloc (mvs_function_name_length);^I\ }^I^I^I^I^I^I^I^I^I\ strcpy (mvs_function_name, NAME);^I^I^I^I^I\ mvs_need_to_globalize = 1;^I^I^I^I^I^I\ } #endif static void i370_output_function_prologue (f, l) FILE *f; HOST_WIDE_INT l; { /* Don't print stack and args in PDPMAC as it makes the comment too long */ #ifdef TARGET_PDPMAC fprintf (f, "* %c-func %s prologue\n", mvs_need_entry ? 'X' : 'S', mvs_function_name); #else is producing this output: * S-func __0 prologue @@0 PDPPRLG CINDEX=1,FRAME=88,BASER=12,ENTRY=NO B FEN1 LTORG FEN1 EQU * DROP 12 BALR 12,0 USING *,12 PG1 EQU * LR 11,1 L 10,=A(PGT1) * Function __0 code * 46 world.c SLR 15,15 * Function __0 epilogue PDPEPIL * Function __0 literal pool DS 0F LTORG * Function __0 page table DS 0F PGT1 EQU * DC A(PG1) for this function: static int aaa(void) { return (0); } ie the "aaa" is being completely lost, being replaced by __0 everywhere. Ideally the __0 would be aaa everywhere, with just the @@0 remaining generated. Indeed, I have just made this change: C:\devel\gcc\gcc>cd config\i370 C:\devel\gcc\gcc\config\i370>cvs diff cvs diff: Diffing . Index: i370.c =================================================================== RCS file: c:\cvsroot/gcc/gcc/config/i370/i370.c,v retrieving revision 1.34 diff -r1.34 i370.c 84a85,87 > /* original name of a static variable */ > char origmvsstatic[150]; > 1457c1460 < mvs_function_name); --- > mvs_need_entry ? mvs_function_name : origmvsstatic); 1599c1602,1603 < fprintf (f, "* Function %s code\n", mvs_function_name); --- > fprintf (f, "* Function %s code\n", > mvs_need_entry ? mvs_function_name : origmvsstatic); 1787c1791,1792 < fprintf (file, "* Function %s epilogue\n", mvs_function_name); --- > fprintf (file, "* Function %s epilogue\n", > mvs_need_entry ? mvs_function_name : origmvsstatic); 1818c1823,1824 < fprintf (file, "* Function %s literal pool\n", mvs_function_name); --- > fprintf (file, "* Function %s literal pool\n", > mvs_need_entry ? mvs_function_name : origmvsstatic); 1821c1827,1828 < fprintf (file, "* Function %s page table\n", mvs_function_name); --- > fprintf (file, "* Function %s page table\n", > mvs_need_entry ? mvs_function_name : origmvsstatic); C:\devel\gcc\gcc\config\i370>cvs diff -c i370.h Index: i370.h =================================================================== RCS file: c:\cvsroot/gcc/gcc/config/i370/i370.h,v retrieving revision 1.35 diff -c -r1.35 i370.h *** i370.h 18 Jul 2009 08:56:33 -0000 1.35 --- i370.h 20 Aug 2009 10:40:35 -0000 *************** *** 57,62 **** --- 57,63 ---- /* The source file module. */ extern char *mvs_module; + extern char origmvsstatic[]; /* Compile using char instructions (mvc, nc, oc, xc). On 4341 use this since these are more than twice as fast as load-op-store. *************** *** 1832,1837 **** --- 1833,1839 ---- #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ { \ (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10); \ + strcpy(origmvsstatic, NAME); \ sprintf ((OUTPUT), "__%d", (LABELNO)); \ } #else and it is working: * S-func aaa prologue @@0 PDPPRLG CINDEX=1,FRAME=88,BASER=12,ENTRY=NO B FEN1 LTORG FEN1 EQU * DROP 12 BALR 12,0 USING *,12 PG1 EQU * LR 11,1 L 10,=A(PGT1) * Function aaa code * 46 world.c SLR 15,15 * Function aaa epilogue PDPEPIL * Function aaa literal pool DS 0F LTORG * Function aaa page table DS 0F PGT1 EQU * DC A(PG1) But is that guaranteed? Thanks. Paul.