From patchwork Tue Feb 4 02:26:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 1233109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518836-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=Ql+X/dJJ; dkim-atps=neutral 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 48BTBn0cgkz9sX3 for ; Tue, 4 Feb 2020 13:28:16 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=bev0cSDjOfJUTXSSA09 Pu+oCKoWmgoTvaZtqXAPECxc+++ok4LqRyTWxjUQZorMTBpRxGeOgBa3zDDE8YW2 L5C5FzArQx7qQAKTojL6fumYrJezWcL3ifcaSWzCYKJ3dJOcEiNeeIzZEQXmSxw5 SfDAFVIXJAwGpSD662qKQvJI= 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:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; s=default; bh=j+WSsRIri6wo8Hz2YIyQaazT3 RU=; b=Ql+X/dJJoXHcaykJscWGjIg1evUDG/r+ApDkwzzTO9srMLhw8mxJvVH5R uo8kg/pUQbTytVJzz5p3RIyysSLO7XYzNsRfsp5XhbWm+yODdUA7Lu54Pj+9TEDX h19LR8fGNeav0f9e7g7wEOtOhSr/by77yIpdPyhyJ2bz5jsezE= Received: (qmail 67066 invoked by alias); 4 Feb 2020 02:27:25 -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 66997 invoked by uid 89); 4 Feb 2020 02:27:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0b-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0b-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Feb 2020 02:27:22 +0000 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0142R8iP042626; Mon, 3 Feb 2020 21:27:21 -0500 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 2xxp56fdbn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2020 21:27:20 -0500 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 0142Kp7o017009; Tue, 4 Feb 2020 02:27:19 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma02dal.us.ibm.com with ESMTP id 2xw0y6k937-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Feb 2020 02:27:19 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0142RI7918088230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Feb 2020 02:27:18 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 755E0C605B; Tue, 4 Feb 2020 02:27:18 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 50629C6055; Tue, 4 Feb 2020 02:27:18 +0000 (GMT) Received: from localhost (unknown [9.40.194.84]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 4 Feb 2020 02:27:18 +0000 (GMT) From: Bill Schmidt To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org Subject: [PATCH 07/14] Add main function with stub functions for parsing and output. Date: Mon, 3 Feb 2020 20:26:08 -0600 Message-Id: <3f4ff5b1d9c0164b94a256a646ed24491be4b28b.1580782131.git.wschmidt@linux.ibm.com> In-Reply-To: References: In-Reply-To: References: 2020-02-03 Bill Schmidt * config/rs6000/rs6000-genbif.c (rbtree.h): New include. (num_bif_stanzas): New filescope variable. (num_bifs): Likewise. (num_ovld_stanzas): Likewise. (num_ovlds): Likewise. (exit_codes): Add more enum values. (bif_rbt): New filescope variable. (ovld_rbt): Likewise. (fntype_rbt): Likewise. (parse_bif): New function stub. (parse_ovld): Likewise. (write_header_file): Likewise. (write_init_file): Likewise. (write_defines_file): Likewise. (main): New function. --- gcc/config/rs6000/rs6000-genbif.c | 185 ++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c index 7c1082fbe8f..38401224dce 100644 --- a/gcc/config/rs6000/rs6000-genbif.c +++ b/gcc/config/rs6000/rs6000-genbif.c @@ -122,6 +122,7 @@ along with GCC; see the file COPYING3. If not see #include #include #include +#include "rbtree.h" /* Used as a sentinel for range constraints on integer fields. No field can be 32 bits wide, so this is a safe sentinel value. */ @@ -155,6 +156,8 @@ enum void_status { VOID_OK }; +static int num_bif_stanzas; + /* Legal base types for an argument or return type. */ enum basetype { BT_CHAR, @@ -196,11 +199,33 @@ struct typeinfo { int val2; }; +static int num_bifs; +static int num_ovld_stanzas; +static int num_ovlds; + /* Exit codes for the shell. */ enum exit_codes { + EC_OK, + EC_BADARGS, + EC_NOBIF, + EC_NOOVLD, + EC_NOHDR, + EC_NOINIT, + EC_NODEFINES, + EC_PARSEBIF, + EC_PARSEOVLD, + EC_WRITEHDR, + EC_WRITEINIT, + EC_WRITEDEFINES, EC_INTERR }; +/* The red-black trees for built-in function identifiers, built-in + overload identifiers, and function type descriptors. */ +static rbt_strings bif_rbt; +static rbt_strings ovld_rbt; +static rbt_strings fntype_rbt; + /* Pointer to a diagnostic function. */ void (*diag) (const char *, ...) __attribute__ ((format (printf, 1, 2))) = NULL; @@ -721,3 +746,163 @@ match_type (typeinfo *typedata, int voidok) consume_whitespace (); return match_basetype (typedata); } + +/* Parse the built-in file. Return 1 for success, 5 for a parsing failure. */ +static int +parse_bif () +{ + return 1; +} + +/* Parse the overload file. Return 1 for success, 6 for a parsing error. */ +static int +parse_ovld () +{ + return 1; +} + +/* Write everything to the header file (rs6000-bif.h). */ +static int +write_header_file () +{ + return 1; +} + +/* Write everything to the initialization file (rs6000-bif.c). */ +static int +write_init_file () +{ + return 1; +} + +/* Write everything to the include file (rs6000-vecdefines.h). */ +static int +write_defines_file () +{ + return 1; +} + +/* Main program to convert flat files into built-in initialization code. */ +int +main (int argc, const char **argv) +{ + if (argc != 6) + { + fprintf (stderr, + "Five arguments required: two input file and three output" + "files.\n"); + exit (EC_BADARGS); + } + + pgm_path = argv[0]; + bif_path = argv[1]; + ovld_path = argv[2]; + header_path = argv[3]; + init_path = argv[4]; + defines_path = argv[5]; + + bif_file = fopen (bif_path, "r"); + if (!bif_file) + { + fprintf (stderr, "Cannot find input built-in file '%s'.\n", bif_path); + exit (EC_NOBIF); + } + ovld_file = fopen (ovld_path, "r"); + if (!ovld_file) + { + fprintf (stderr, "Cannot find input overload file '%s'.\n", ovld_path); + exit (EC_NOOVLD); + } + header_file = fopen (header_path, "w"); + if (!header_file) + { + fprintf (stderr, "Cannot open header file '%s' for output.\n", + header_path); + exit (EC_NOHDR); + } + init_file = fopen (init_path, "w"); + if (!init_file) + { + fprintf (stderr, "Cannot open init file '%s' for output.\n", init_path); + exit (EC_NOINIT); + } + defines_file = fopen (defines_path, "w"); + if (!defines_file) + { + fprintf (stderr, "Cannot open defines file '%s' for output.\n", + defines_path); + exit (EC_NODEFINES); + } + + /* Initialize the balanced trees containing built-in function ids, + overload function ids, and function type declaration ids. */ + bif_rbt.rbt_nil = (rbt_string_node *) malloc (sizeof (rbt_string_node)); + bif_rbt.rbt_nil->color = RBT_BLACK; + bif_rbt.rbt_root = bif_rbt.rbt_nil; + + ovld_rbt.rbt_nil = (rbt_string_node *) malloc (sizeof (rbt_string_node)); + ovld_rbt.rbt_nil->color = RBT_BLACK; + ovld_rbt.rbt_root = ovld_rbt.rbt_nil; + + fntype_rbt.rbt_nil = (rbt_string_node *) malloc (sizeof (rbt_string_node)); + fntype_rbt.rbt_nil->color = RBT_BLACK; + fntype_rbt.rbt_root = fntype_rbt.rbt_nil; + + /* Parse the built-in function file. */ + num_bif_stanzas = 0; + num_bifs = 0; + line = 0; + if (parse_bif () != 1) + { + fprintf (stderr, "Parsing of '%s' failed, aborting.\n", bif_path); + exit (EC_PARSEBIF); + } + fclose (bif_file); + +#ifdef DEBUG + fprintf (stderr, "\nFunction ID list:\n"); + rbt_dump (&bif_rbt, bif_rbt.rbt_root); + fprintf (stderr, "\n"); +#endif + + /* Parse the overload file. */ + num_ovld_stanzas = 0; + num_ovlds = 0; + line = 0; + if (parse_ovld () != 1) + { + fprintf (stderr, "Parsing of '%s' failed, aborting.\n", ovld_path); + exit (EC_PARSEOVLD); + } + fclose (ovld_file); + +#ifdef DEBUG + fprintf (stderr, "\nFunction type decl list:\n"); + rbt_dump (&fntype_rbt, fntype_rbt.rbt_root); + fprintf (stderr, "\n"); +#endif + + /* Write the header file and the file containing initialization code. */ + if (!write_header_file ()) + { + fprintf (stderr, "Output to '%s' failed, aborting.\n", header_path); + exit (EC_WRITEHDR); + } + fclose (header_file); + if (!write_init_file ()) + { + fprintf (stderr, "Output to '%s' failed, aborting.\n", init_path); + exit (EC_WRITEINIT); + } + fclose (init_file); + + /* Write the defines file to be included into altivec.h. */ + if (!write_defines_file ()) + { + fprintf (stderr, "Output to '%s' failed, aborting.\n", defines_path); + exit (EC_WRITEDEFINES); + } + fclose (defines_file); + + return EC_OK; +}