From patchwork Sat Aug 7 17:53:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 61186 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 7AC59B6EEE for ; Sun, 8 Aug 2010 03:53:43 +1000 (EST) Received: (qmail 21990 invoked by alias); 7 Aug 2010 17:53:41 -0000 Received: (qmail 21979 invoked by uid 22791); 7 Aug 2010 17:53:41 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL, BAYES_00, TW_BX, TW_DB, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 07 Aug 2010 17:53:36 +0000 Received: (qmail 30397 invoked from network); 7 Aug 2010 17:53:34 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 7 Aug 2010 17:53:34 -0000 Date: Sat, 7 Aug 2010 10:53:34 -0700 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: dje.gcc@gmail.com, developer@sandoe-acoustics.co.uk Subject: [PATCH] convert rs6000.c:branch_island_list to a VEC Message-ID: <20100807175334.GH17362@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) 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 The patch below converts rs6000.c:branch_island_list to a VEC. We'll use slightly less space and warts like the int_cst bits go away as well. Unfortunately, I can't test the patch, as I don't have a PPC OS X machine available. Iain, could you please test the patch for me? OK to commit if testing looks good? -Nathan * config/rs6000/rs6000.c (branch_island): Define. Define a VEC of it. (branch_island_list): Delete. (branch_islands): Declare. (add_compiler_branch_island): Adjust for branch_islands instead of branch_island_list. (macho_branch_islands): Likewise. (no_previous_def): Likewise. (get_prev_label): Likewise. + const char *name = IDENTIFIER_POINTER (bi->function_name); char name_buf[512]; /* Cheap copy of the details from the Darwin ASM_OUTPUT_LABELREF(). */ if (name[0] == '*' || name[0] == '&') @@ -24552,7 +24553,7 @@ macho_branch_islands (void) strcat (tmp_buf, label); #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) - dbxout_stabd (N_SLINE, BRANCH_ISLAND_LINE_NUMBER (branch_island)); + dbxout_stabd (N_SLINE, bi->line_number); #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */ if (flag_pic) { @@ -24589,11 +24590,10 @@ macho_branch_islands (void) output_asm_insn (tmp_buf, 0); #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) - dbxout_stabd (N_SLINE, BRANCH_ISLAND_LINE_NUMBER (branch_island)); + dbxout_stabd (N_SLINE, bi->line_number); #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */ + VEC_pop (branch_island, branch_islands); } - - branch_island_list = 0; } /* NO_PREVIOUS_DEF checks in the link list whether the function name is @@ -24602,11 +24602,11 @@ macho_branch_islands (void) static int no_previous_def (tree function_name) { - tree branch_island; - for (branch_island = branch_island_list; - branch_island; - branch_island = TREE_CHAIN (branch_island)) - if (function_name == BRANCH_ISLAND_FUNCTION_NAME (branch_island)) + branch_island *bi; + unsigned ix; + + for (ix = 0; VEC_iterate (branch_island, branch_islands, ix, bi); ix++) + if (function_name == bi->function_name) return 0; return 1; } @@ -24617,13 +24617,13 @@ no_previous_def (tree function_name) static tree get_prev_label (tree function_name) { - tree branch_island; - for (branch_island = branch_island_list; - branch_island; - branch_island = TREE_CHAIN (branch_island)) - if (function_name == BRANCH_ISLAND_FUNCTION_NAME (branch_island)) - return BRANCH_ISLAND_LABEL_NAME (branch_island); - return 0; + branch_island *bi; + unsigned ix; + + for (ix = 0; VEC_iterate (branch_island, branch_islands, ix, bi); ix++) + if (function_name == bi->function_name) + return bi->label_name; + return NULL_TREE; } /* INSN is either a function call or a millicode call. It may have an diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 0f1f040..5d465b8 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -24499,7 +24499,16 @@ rs6000_fatal_bad_address (rtx op) #if TARGET_MACHO -static tree branch_island_list = 0; +typedef struct branch_island_d { + tree function_name; + tree label_name; + int line_number; +} branch_island; + +DEF_VEC_O(branch_island); +DEF_VEC_ALLOC_O(branch_island,gc); + +static VEC(branch_island,gc) *branch_islands; /* Remember to generate a branch island for far calls to the given function. */ @@ -24508,37 +24517,29 @@ static void add_compiler_branch_island (tree label_name, tree function_name, int line_number) { - tree branch_island = build_tree_list (function_name, label_name); - TREE_TYPE (branch_island) = build_int_cst (NULL_TREE, line_number); - TREE_CHAIN (branch_island) = branch_island_list; - branch_island_list = branch_island; -} + branch_island *bi = VEC_safe_push (branch_island, gc, branch_islands, NULL); -#define BRANCH_ISLAND_LABEL_NAME(BRANCH_ISLAND) TREE_VALUE (BRANCH_ISLAND) -#define BRANCH_ISLAND_FUNCTION_NAME(BRANCH_ISLAND) TREE_PURPOSE (BRANCH_ISLAND) -#define BRANCH_ISLAND_LINE_NUMBER(BRANCH_ISLAND) \ - TREE_INT_CST_LOW (TREE_TYPE (BRANCH_ISLAND)) + bi->function_name = function_name; + bi->label_name = label_name; + bi->line_number = line_number; +} -/* Generate far-jump branch islands for everything on the - branch_island_list. Invoked immediately after the last instruction - of the epilogue has been emitted; the branch-islands must be - appended to, and contiguous with, the function body. Mach-O stubs - are generated in machopic_output_stub(). */ +/* Generate far-jump branch islands for everything recorded in + branch_islands. Invoked immediately after the last instruction of + the epilogue has been emitted; the branch islands must be appended + to, and contiguous with, the function body. Mach-O stubs are + generated in machopic_output_stub(). */ static void macho_branch_islands (void) { char tmp_buf[512]; target-mips: add microMIPS exception handler support Unlike MIPS16, microMIPS lets you choose the ISA mode for your exception handlers.- tree branch_island; - for (branch_island = branch_island_list; - branch_island; - branch_island = TREE_CHAIN (branch_island)) + while (!VEC_empty (branch_island, branch_islands)) { - const char *label = - IDENTIFIER_POINTER (BRANCH_ISLAND_LABEL_NAME (branch_island)); - const char *name = - IDENTIFIER_POINTER (BRANCH_ISLAND_FUNCTION_NAME (branch_island)); + branch_island *bi = VEC_last (branch_island, branch_islands); + const char *label = IDENTIFIER_POINTER (bi->label_name);