From patchwork Tue Aug 10 20:23:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Sokolov X-Patchwork-Id: 61407 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]) by ozlabs.org (Postfix) with SMTP id 4947DB70AA for ; Wed, 11 Aug 2010 06:23:21 +1000 (EST) Received: (qmail 7860 invoked by alias); 10 Aug 2010 20:23:19 -0000 Received: (qmail 7851 invoked by uid 22791); 10 Aug 2010 20:23:17 -0000 X-SWARE-Spam-Status: No, hits=1.5 required=5.0 tests=AWL, BAYES_00, KAM_THEBAT, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from contrabass.post.ru (HELO contrabass.post.ru) (85.21.78.5) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 Aug 2010 20:23:12 +0000 Received: from corbina.ru (mail.post.ru [195.14.50.16]) by contrabass.post.ru (Postfix) with ESMTP id 0F443998C; Wed, 11 Aug 2010 00:23:09 +0400 (MSD) Received: from [89.178.253.228] (account aesok@post.ru HELO Vista.corbina.ru) by corbina.ru (CommuniGate Pro SMTP 5.1.14) with ESMTPA id 243746192; Wed, 11 Aug 2010 00:23:08 +0400 Date: Wed, 11 Aug 2010 00:23:42 +0400 From: Anatoly Sokolov Message-ID: <806212633.20100811002342@post.ru> To: Richard Henderson CC: gcc-patches@gcc.gnu.org Subject: Re[2]: [PATCH] Hookize TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA In-Reply-To: <4C6171DD.9010600@redhat.com> References: <653112981.20100807125752@post.ru> <4C6171DD.9010600@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes 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 Hello. On 08/10/2010 01:57 AM, Richard Henderson wrote: > On 08/07/2010 01:57 AM, Anatoly Sokolov wrote: >> * target.def (output_addr_const_extra): New hook. >> * doc/tm.texi.in (TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA): Document. >> * doc/tm.texi: Regenerate. > Ok, modulo since this is new (OUTPUT_ADDR_CONST_EXTRA > was undocumented), the body of the documentation should be placed > in the target.def string. No, documentation of the TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA target hook is modified version of the OUTPUT_ADDR_CONST_EXTRA macro documentation. I'm change type of the second argument of output_addr_const function and TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA target from const_rtx back to rtx. Use const_rtx causes bootsrap failure on hppa target. The patch has been bootstrapped on and regression tested on x86_64-unknown-linux-gnu for c. * target.def (output_addr_const_extra): New hook. * doc/tm.texi.in (TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA): Document. * doc/tm.texi: Regenerate. * targhooks.c (default_asm_output_addr_const_extra): New function. * targhooks.h (default_asm_output_addr_const_extra): Declare. * final.c: (output_addr_const): Use TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA target hook. * config/i386/i386.h (OUTPUT_ADDR_CONST_EXTRA): Remove. * config/i386/i386-protos.h (output_addr_const_extra): Remove. * config/i386/i386.h (output_addr_const_extra): Rename to... (i386_asm_output_addr_const_extra): ...this. Make static. (TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA): Define Anatoly. Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi (revision 163077) +++ gcc/doc/tm.texi (working copy) @@ -7410,6 +7410,18 @@ when the relevant string is @code{NULL}. @end deftypefn +@deftypefn {Target Hook} bool TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA (FILE *@var{file}, rtx @var{x}) +A target hook to recognize @var{rtx} patterns that @code{output_addr_const} +can't deal with, and output assembly code to @var{file} corresponding to +the pattern @var{x}. This may be used to allow machine-dependent +@code{UNSPEC}s to appear within constants. + +If target hook fails to recognize a pattern, it must return @code{false}, +so that a standard error message is printed. If it prints an error message +itself, by calling, for example, @code{output_operand_lossage}, it may just +return @code{true}. +@end deftypefn + @defmac OUTPUT_ADDR_CONST_EXTRA (@var{stream}, @var{x}, @var{fail}) A C statement to recognize @var{rtx} patterns that @code{output_addr_const} can't deal with, and output assembly code to Index: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in (revision 163077) +++ gcc/doc/tm.texi.in (working copy) @@ -7401,6 +7401,18 @@ when the relevant string is @code{NULL}. @end deftypefn +@hook TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA +A target hook to recognize @var{rtx} patterns that @code{output_addr_const} +can't deal with, and output assembly code to @var{file} corresponding to +the pattern @var{x}. This may be used to allow machine-dependent +@code{UNSPEC}s to appear within constants. + +If target hook fails to recognize a pattern, it must return @code{false}, +so that a standard error message is printed. If it prints an error message +itself, by calling, for example, @code{output_operand_lossage}, it may just +return @code{true}. +@end deftypefn + @defmac OUTPUT_ADDR_CONST_EXTRA (@var{stream}, @var{x}, @var{fail}) A C statement to recognize @var{rtx} patterns that @code{output_addr_const} can't deal with, and output assembly code to Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c (revision 163077) +++ gcc/targhooks.c (working copy) @@ -356,6 +356,21 @@ #endif } +/* The default implementation of TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA. */ + +bool +default_asm_output_addr_const_extra (FILE *file ATTRIBUTE_UNUSED, + rtx x ATTRIBUTE_UNUSED) +{ +#ifdef OUTPUT_ADDR_CONST_EXTRA + OUTPUT_ADDR_CONST_EXTRA (file, x, fail); + return true; + +fail: +#endif + return false; +} + /* True if MODE is valid for the target. By "valid", we mean able to be manipulated in non-trivial ways. In particular, this means all the arithmetic is supported. Index: gcc/targhooks.h =================================================================== --- gcc/targhooks.h (revision 163077) +++ gcc/targhooks.h (working copy) @@ -65,6 +65,7 @@ extern void default_print_operand (FILE *, rtx, int); extern void default_print_operand_address (FILE *, rtx); extern bool default_print_operand_punct_valid_p (unsigned char); +extern bool default_asm_output_addr_const_extra (FILE *, rtx); extern bool default_scalar_mode_supported_p (enum machine_mode); extern bool default_decimal_float_supported_p (void); Index: gcc/target.def =================================================================== --- gcc/target.def (revision 163077) +++ gcc/target.def (working copy) @@ -415,6 +415,12 @@ void ,(FILE *file, const char *name), default_asm_output_source_filename) +DEFHOOK +(output_addr_const_extra, + "", + bool, (FILE *file, rtx x), + default_asm_output_addr_const_extra) + /* ??? The TARGET_PRINT_OPERAND* hooks are part of the asm_out struct, even though that is not reflected in the macro name to override their initializers. */ Index: gcc/final.c =================================================================== --- gcc/final.c (revision 163077) +++ gcc/final.c (working copy) @@ -3620,12 +3620,9 @@ break; default: -#ifdef OUTPUT_ADDR_CONST_EXTRA - OUTPUT_ADDR_CONST_EXTRA (file, x, fail); - break; + if (targetm.asm_out.output_addr_const_extra (file, x)) + break; - fail: -#endif output_operand_lossage ("invalid expression as operand"); } } Index: gcc/config/i386/i386.h =================================================================== --- gcc/config/i386/i386.h (revision 163077) +++ gcc/config/i386/i386.h (working copy) @@ -2117,12 +2117,6 @@ "call " CRT_MKSTR(__USER_LABEL_PREFIX__) #FUNC "\n" \ TEXT_SECTION_ASM_OP); -#define OUTPUT_ADDR_CONST_EXTRA(FILE, X, FAIL) \ -do { \ - if (! output_addr_const_extra (FILE, (X))) \ - goto FAIL; \ -} while (0); - /* Which processor to schedule for. The cpu attribute defines a list that mirrors this list, so changes to i386.md must be made at the same time. */ Index: gcc/config/i386/i386-protos.h =================================================================== --- gcc/config/i386/i386-protos.h (revision 163077) +++ gcc/config/i386/i386-protos.h (working copy) @@ -62,7 +62,6 @@ extern void print_reg (rtx, int, FILE*); extern void ix86_print_operand (FILE *, rtx, int); -extern bool output_addr_const_extra (FILE*, rtx); extern void split_di (rtx[], int, rtx[], rtx[]); extern void split_ti (rtx[], int, rtx[], rtx[]); Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c (revision 163077) +++ gcc/config/i386/i386.c (working copy) @@ -13124,8 +13124,10 @@ } } -bool -output_addr_const_extra (FILE *file, rtx x) +/* Implementation of TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA. */ + +static bool +i386_asm_output_addr_const_extra (FILE *file, rtx x) { rtx op; @@ -31539,6 +31541,8 @@ #define TARGET_PRINT_OPERAND_ADDRESS ix86_print_operand_address #undef TARGET_PRINT_OPERAND_PUNCT_VALID_P #define TARGET_PRINT_OPERAND_PUNCT_VALID_P ix86_print_operand_punct_valid_p +#undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA +#define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA i386_asm_output_addr_const_extra #undef TARGET_SCHED_ADJUST_COST #define TARGET_SCHED_ADJUST_COST ix86_adjust_cost