From patchwork Sun Aug 22 11:42:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Sokolov X-Patchwork-Id: 62373 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 05B16B70D4 for ; Sun, 22 Aug 2010 21:42:41 +1000 (EST) Received: (qmail 304 invoked by alias); 22 Aug 2010 11:42:39 -0000 Received: (qmail 32762 invoked by uid 22791); 22 Aug 2010 11:42:37 -0000 X-SWARE-Spam-Status: No, hits=1.2 required=5.0 tests=AWL, BAYES_00, KAM_THEBAT, RCVD_IN_DNSWL_NONE, TW_XF, 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; Sun, 22 Aug 2010 11:42:32 +0000 Received: from corbina.ru (mail.post.ru [195.14.50.16]) by contrabass.post.ru (Postfix) with ESMTP id 96A9B962F; Sun, 22 Aug 2010 15:42:29 +0400 (MSD) Received: from [95.26.2.68] (account aesok@post.ru HELO Vista.corbina.ru) by corbina.ru (CommuniGate Pro SMTP 5.1.14) with ESMTPA id 247774024; Sun, 22 Aug 2010 15:42:29 +0400 Date: Sun, 22 Aug 2010 15:42:48 +0400 From: Anatoly Sokolov Message-ID: <746758766.20100822154248@post.ru> To: Nathan Froyd CC: gcc-patches@gcc.gnu.org, law@redhat.com, dave.anglin@nrc-cnrc.gc.ca Subject: Re[2]: [PA] Hookize various target macros in PA back end In-Reply-To: <20100821145841.GW25394@codesourcery.com> References: <482716898.20100821123646@post.ru> <20100821145841.GW25394@codesourcery.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 Sat, Aug 21, 2010 at 12:36:46PM +0400, Anatoly Sokolov wrote: >> This patch removes obsolete OVERRIDE_OPTIONS, FUNCTION_VALUE_REGNO_P, >> LIBCALL_VALUE, REGISTER_MOVE_COST and PRINT_OPERAND_PUNCT_VALID_P macros from >> the PA back end in the GCC and introduces equivalent target hooks. >> >> >> +/* Implement the TARGET_PRINT_OPERAND_PUNCT_VALID_P hook. >> + .... >> + >> +static int >> +hppa_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, >> + reg_class_t from, reg_class_t to) > The first line of the comment does not match the function. Sorry. Updated patch. * config/pa/pa.c (hppa_register_move_cost, pa_libcall_value, pa_function_value_regno_p, pa_print_operand_punct_valid_p): New. (pa_function_value): Make static. (override_options): Rename to... (pa_option_override): ...this. Make static. (TARGET_PRINT_OPERAND_PUNCT_VALID_P, TARGET_REGISTER_MOVE_COST, TARGET_LIBCALL_VALUE, TARGET_FUNCTION_VALUE_REGNO_P, TARGET_OPTION_OVERRIDE): Define. * config/pa/pa.h (OVERRIDE_OPTIONS, FUNCTION_VALUE_REGNO_P, LIBCALL_VALUE, REGISTER_MOVE_COST, PRINT_OPERAND_PUNCT_VALID_P): Remove. * config/pa/pa-protos.h (override_options): Remove. Anatoly. Index: gcc/config/pa/pa-protos.h =================================================================== --- gcc/config/pa/pa-protos.h (revision 163384) +++ gcc/config/pa/pa-protos.h (working copy) @@ -131,7 +131,6 @@ extern int ldil_cint_p (HOST_WIDE_INT); extern int zdepi_cint_p (unsigned HOST_WIDE_INT); -extern void override_options (void); extern void output_ascii (FILE *, const char *, int); extern HOST_WIDE_INT compute_frame_size (HOST_WIDE_INT, int *); extern int and_mask_p (unsigned HOST_WIDE_INT); Index: gcc/config/pa/pa.c =================================================================== --- gcc/config/pa/pa.c (revision 163384) +++ gcc/config/pa/pa.c (working copy) @@ -84,9 +84,12 @@ #endif #endif +static void pa_option_override (void); static void copy_reg_pointer (rtx, rtx); static void fix_range (const char *); static bool pa_handle_option (size_t, const char *, int); +static int hppa_register_move_cost (enum machine_mode mode, reg_class_t, + reg_class_t); static int hppa_address_cost (rtx, bool); static bool hppa_rtx_costs (rtx, int, int, int *, bool); static inline rtx force_mode (enum machine_mode, rtx); @@ -104,6 +107,8 @@ static void load_reg (int, HOST_WIDE_INT, int); static void set_reg_plus_d (int, int, HOST_WIDE_INT, int); static rtx pa_function_value (const_tree, const_tree, bool); +static rtx pa_libcall_value (enum machine_mode, const_rtx); +static bool pa_function_value_regno_p (const unsigned int); static void pa_output_function_prologue (FILE *, HOST_WIDE_INT); static void update_total_code_bytes (unsigned int); static void pa_output_function_epilogue (FILE *, HOST_WIDE_INT); @@ -168,6 +173,7 @@ static void pa_trampoline_init (rtx, tree, rtx); static rtx pa_trampoline_adjust_address (rtx); static rtx pa_delegitimize_address (rtx); +static bool pa_print_operand_punct_valid_p (unsigned char); /* The following extra sections are only used for SOM. */ static GTY(()) section *som_readonly_data_section; @@ -213,6 +219,9 @@ /* Initialize the GCC target structure. */ +#undef TARGET_OPTION_OVERRIDE +#define TARGET_OPTION_OVERRIDE pa_option_override + #undef TARGET_ASM_ALIGNED_HI_OP #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t" #undef TARGET_ASM_ALIGNED_SI_OP @@ -235,6 +244,10 @@ #undef TARGET_FUNCTION_VALUE #define TARGET_FUNCTION_VALUE pa_function_value +#undef TARGET_LIBCALL_VALUE +#define TARGET_LIBCALL_VALUE pa_libcall_value +#undef TARGET_FUNCTION_VALUE_REGNO_P +#define TARGET_FUNCTION_VALUE_REGNO_P pa_function_value_regno_p #undef TARGET_LEGITIMIZE_ADDRESS #define TARGET_LEGITIMIZE_ADDRESS hppa_legitimize_address @@ -269,6 +282,9 @@ #define TARGET_ASM_FILE_END output_deferred_plabels #endif +#undef TARGET_PRINT_OPERAND_PUNCT_VALID_P +#define TARGET_PRINT_OPERAND_PUNCT_VALID_P pa_print_operand_punct_valid_p + #if !defined(USE_COLLECT2) #undef TARGET_ASM_CONSTRUCTOR #define TARGET_ASM_CONSTRUCTOR pa_asm_out_constructor @@ -284,6 +300,8 @@ #undef TARGET_INIT_BUILTINS #define TARGET_INIT_BUILTINS pa_init_builtins +#undef TARGET_REGISTER_MOVE_COST +#define TARGET_REGISTER_MOVE_COST hppa_register_move_cost #undef TARGET_RTX_COSTS #define TARGET_RTX_COSTS hppa_rtx_costs #undef TARGET_ADDRESS_COST @@ -487,8 +505,10 @@ } } -void -override_options (void) +/* Implement the TARGET_OPTION_OVERRIDE hook. */ + +static void +pa_option_override (void) { /* Unconditional branches in the delay slot are not compatible with dwarf2 call frame information. There is no benefit in using this optimization @@ -1297,6 +1317,32 @@ return orig; } +/* Implement the TARGET_REGISTER_MOVE_COST hook. + + Compute extra cost of moving data between one register class + and another. + + Make moves from SAR so expensive they should never happen. We used to + have 0xffff here, but that generates overflow in rare cases. + + Copies involving a FP register and a non-FP register are relatively + expensive because they must go through memory. + + Other copies are reasonably cheap. */ + +static int +hppa_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, + reg_class_t from, reg_class_t to) +{ + if (from == SHIFT_REGS) + return 0x100; + else if ((FP_REG_CLASS_P (from) && ! FP_REG_CLASS_P (to)) + || (FP_REG_CLASS_P (to) && ! FP_REG_CLASS_P (from))) + return 16; + else + return 2; +} + /* For the HPPA, REG and REG+CONST is cost 0 and addresses involving symbolic constants are cost 2. @@ -4801,6 +4847,20 @@ return 0; } +/* Implement the TARGET_PRINT_OPERAND_PUNCT_VALID_P hook. */ + +static bool +pa_print_operand_punct_valid_p (unsigned char code) +{ + if (code == '@' + || code == '#' + || code == '*' + || code == '^') + return true; + + return false; +} + /* Print operand X (an rtx) in assembler syntax to file FILE. CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. For `%' followed by punctuation, CODE is the punctuation and X is null. */ @@ -9235,7 +9295,7 @@ Small structures must be returned in a PARALLEL on PA64 in order to match the HP Compiler ABI. */ -rtx +static rtx pa_function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED, bool outgoing ATTRIBUTE_UNUSED) @@ -9296,6 +9356,31 @@ return gen_rtx_REG (valmode, 28); } +/* Implement the TARGET_LIBCALL_VALUE hook. */ + +static rtx +pa_libcall_value (enum machine_mode mode, + const_rtx fun ATTRIBUTE_UNUSED) +{ + if (! TARGET_SOFT_FLOAT + && (mode == SFmode || mode == DFmode)) + return gen_rtx_REG (mode, 32); + else + return gen_rtx_REG (mode, 28); +} + +/* Implement the TARGET_FUNCTION_VALUE_REGNO_P hook. */ + +static bool +pa_function_value_regno_p (const unsigned int regno) +{ + if (regno == 28 + || (! TARGET_SOFT_FLOAT && regno == 32)) + return true; + + return false; +} + /* Return the location of a parameter that is passed in a register or NULL if the parameter has any component that is passed in memory. Index: gcc/config/pa/pa.h =================================================================== --- gcc/config/pa/pa.h (revision 163384) +++ gcc/config/pa/pa.h (working copy) @@ -145,8 +145,6 @@ and the old mnemonics are dialect zero. */ #define ASSEMBLER_DIALECT (TARGET_PA_20 ? 1 : 0) -#define OVERRIDE_OPTIONS override_options () - /* Override some settings from dbxelf.h. */ /* We do not have to be compatible with dbx, so we enable gdb extensions @@ -554,20 +552,6 @@ ? (STACK_POINTER_OFFSET) \ : ((STACK_POINTER_OFFSET) - crtl->outgoing_args_size)) -/* Define how to find the value returned by a library function - assuming the value has mode MODE. */ - -#define LIBCALL_VALUE(MODE) \ - gen_rtx_REG (MODE, \ - (! TARGET_SOFT_FLOAT \ - && ((MODE) == SFmode || (MODE) == DFmode) ? 32 : 28)) - -/* 1 if N is a possible register number for a function value - as seen by the caller. */ - -#define FUNCTION_VALUE_REGNO_P(N) \ - ((N) == 28 || (! TARGET_SOFT_FLOAT && (N) == 32)) - /* Define a data type for recording info about an argument list during the scan of that argument list. This data type should @@ -1331,22 +1315,6 @@ few bits. */ #define SHIFT_COUNT_TRUNCATED 1 -/* Compute extra cost of moving data between one register class - and another. - - Make moves from SAR so expensive they should never happen. We used to - have 0xffff here, but that generates overflow in rare cases. - - Copies involving a FP register and a non-FP register are relatively - expensive because they must go through memory. - - Other copies are reasonably cheap. */ -#define REGISTER_MOVE_COST(MODE, CLASS1, CLASS2) \ - (CLASS1 == SHIFT_REGS ? 0x100 \ - : FP_REG_CLASS_P (CLASS1) && ! FP_REG_CLASS_P (CLASS2) ? 16 \ - : FP_REG_CLASS_P (CLASS2) && ! FP_REG_CLASS_P (CLASS1) ? 16 \ - : 2) - /* Adjust the cost of branches. */ #define BRANCH_COST(speed_p, predictable_p) (pa_cpu == PROCESSOR_8000 ? 2 : 1) @@ -1524,9 +1492,6 @@ /* All HP assemblers use "!" to separate logical lines. */ #define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == '!') -#define PRINT_OPERAND_PUNCT_VALID_P(CHAR) \ - ((CHAR) == '@' || (CHAR) == '#' || (CHAR) == '*' || (CHAR) == '^') - /* Print operand X (an rtx) in assembler syntax to file FILE. CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. For `%' followed by punctuation, CODE is the punctuation and X is null.