From patchwork Tue Feb 4 02:26:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 1233112 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-518839-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=rcLoTcBt; 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 48BTCW72FFz9sX3 for ; Tue, 4 Feb 2020 13:28:55 +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=eVuLqIdsxIjheA7ykUm O4iQVyRr2s8pZnrPuK9DLSf9bOHJDm27eiWkmk6LDue0x4G/bbmF0Co/FuQPmVkc l7Z7K5Hhp5fDo/04wCGApwTp+qOQhreO3t6uIe48eVAEcMa0PPLZKr9dh6cgNcbq 2nJ/9r2WTZSwBBdgjCDWzx6A= 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=XjmlICiQ7l+D6CP/qNdIlLZCx VI=; b=rcLoTcBtX7hfpYOCgivSPuyoo8P7/zhUbFh9KtlD4hliadrvYXCQFgQfl lfs7KiKGW43NEFOgos//rlVOieJ5BFWQ06SmWokc+KPZLUeXko3SjNOl0Qv6UFgr 2G+xtPTjVzF9uVz2FX8wSGSyEANtd1HGHmOoRyZpZQlSIPtB9c= Received: (qmail 68340 invoked by alias); 4 Feb 2020 02:27:35 -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 68267 invoked by uid 89); 4 Feb 2020 02:27:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 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: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-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:32 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0142OrHA113654; Mon, 3 Feb 2020 21:27:30 -0500 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 2xxfrvg25s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 03 Feb 2020 21:27:30 -0500 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 0142Kqnh012270; Tue, 4 Feb 2020 02:27:29 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma03dal.us.ibm.com with ESMTP id 2xw0y7b8ma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 04 Feb 2020 02:27:29 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0142RSpl57082358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 4 Feb 2020 02:27:28 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 96ED9C6059; Tue, 4 Feb 2020 02:27:28 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72EDCC6055; Tue, 4 Feb 2020 02:27:28 +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:28 +0000 (GMT) From: Bill Schmidt To: gcc-patches@gcc.gnu.org Cc: segher@kernel.crashing.org Subject: [PATCH 10/14] Build function type identifiers and store them. Date: Mon, 3 Feb 2020 20:26:11 -0600 Message-Id: In-Reply-To: References: In-Reply-To: References: 2020-02-03 Bill Schmidt * config/rs6000/rs6000-genbif.c (complete_vector_type): New function. (complete_base_type): New function. (construct_fntype_id): New function. (parse_bif_entry): Call construct_fntype_id. (parse_ovld_entry): Likewise. --- gcc/config/rs6000/rs6000-genbif.c | 180 ++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) diff --git a/gcc/config/rs6000/rs6000-genbif.c b/gcc/config/rs6000/rs6000-genbif.c index 22b5b1df3b9..7bb7d2b24a4 100644 --- a/gcc/config/rs6000/rs6000-genbif.c +++ b/gcc/config/rs6000/rs6000-genbif.c @@ -999,6 +999,178 @@ htm = %d.\n", return 1; } +/* Convert a vector type into a mode string. */ +static void +complete_vector_type (typeinfo *typeptr, char *buf, int *bufi) +{ + buf[(*bufi)++] = 'v'; + if (typeptr->ispixel) + { + memcpy (&buf[*bufi], "p8hi", 4); + *bufi += 4; + } + else + { + if (typeptr->isbool) + buf[(*bufi)++] = 'b'; + switch (typeptr->base) + { + case BT_CHAR: + memcpy (&buf[*bufi], "16qi", 4); + *bufi += 4; + break; + case BT_SHORT: + memcpy (&buf[*bufi], "8hi", 3); + *bufi += 3; + break; + case BT_INT: + memcpy (&buf[*bufi], "4si", 3); + *bufi += 3; + break; + case BT_LONGLONG: + memcpy (&buf[*bufi], "2di", 3); + *bufi += 3; + break; + case BT_FLOAT: + memcpy (&buf[*bufi], "4sf", 3); + *bufi += 3; + break; + case BT_DOUBLE: + memcpy (&buf[*bufi], "2df", 3); + *bufi += 3; + break; + case BT_INT128: + memcpy (&buf[*bufi], "1ti", 3); + *bufi += 3; + break; + case BT_FLOAT128: + memcpy (&buf[*bufi], "1tf", 3); + *bufi += 3; + break; + default: + (*diag) ("unhandled basetype %d.\n", typeptr->base); + exit (EC_INTERR); + } + } +} + +/* Convert a base type into a mode string. */ +static void +complete_base_type (typeinfo *typeptr, char *buf, int *bufi) +{ + switch (typeptr->base) + { + case BT_CHAR: + memcpy (&buf[*bufi], "qi", 2); + break; + case BT_SHORT: + memcpy (&buf[*bufi], "hi", 2); + break; + case BT_INT: + memcpy (&buf[*bufi], "si", 2); + break; + case BT_LONGLONG: + memcpy (&buf[*bufi], "di", 2); + break; + case BT_FLOAT: + memcpy (&buf[*bufi], "sf", 2); + break; + case BT_DOUBLE: + memcpy (&buf[*bufi], "df", 2); + break; + case BT_INT128: + memcpy (&buf[*bufi], "ti", 2); + break; + case BT_FLOAT128: + memcpy (&buf[*bufi], "tf", 2); + break; + default: + (*diag) ("unhandled basetype %d.\n", typeptr->base); + exit (EC_INTERR); + } + + *bufi += 2; +} + +/* Build a function type descriptor identifier from the return type + and argument types, and store it if it does not already exist. + Return the identifier. */ +static char * +construct_fntype_id (prototype *protoptr) +{ + /* Determine the maximum space for a function type descriptor id. + Each type requires at most 8 characters (6 for the mode*, 1 for + the optional 'u' preceding the mode, and 1 for an underscore + following the mode). We also need 5 characters for the string + "ftype" that separates the return mode from the argument modes. + The last argument doesn't need a trailing underscore, but we + count that as the one trailing "ftype" instead. For the special + case of zero arguments, we need 8 for the return type and 7 + for "ftype_v". Finally, we need one character for the + terminating null. Thus for a function with N arguments, we + need at most 8N+14 characters for N>0, otherwise 16. + ---- + *Worst case is vb16qi for "vector bool char". */ + int len = protoptr->nargs ? (protoptr->nargs + 1) * 8 + 6 : 16; + char *buf = (char *) malloc (len); + int bufi = 0; + + if (protoptr->rettype.ispointer) + { + assert (protoptr->rettype.isvoid); + buf[bufi++] = 'p'; + } + if (protoptr->rettype.isvoid) + buf[bufi++] = 'v'; + else + { + if (protoptr->rettype.isunsigned) + buf[bufi++] = 'u'; + if (protoptr->rettype.isvector) + complete_vector_type (&protoptr->rettype, buf, &bufi); + else + complete_base_type (&protoptr->rettype, buf, &bufi); + } + + memcpy (&buf[bufi], "_ftype", 6); + bufi += 6; + + if (!protoptr->nargs) + { + memcpy (&buf[bufi], "_v", 2); + bufi += 2; + } + else + { + typelist *argptr = protoptr->args; + for (int i = 0; i < protoptr->nargs; i++) + { + assert (argptr); + buf[bufi++] = '_'; + if (argptr->info.isunsigned) + buf[bufi++] = 'u'; + if (argptr->info.ispointer) + { + buf[bufi++] = 'p'; + buf[bufi++] = 'v'; + } + else if (argptr->info.isvector) + complete_vector_type (&argptr->info, buf, &bufi); + else + complete_base_type (&argptr->info, buf, &bufi); + argptr = argptr->next; + } + assert (!argptr); + } + + buf[bufi] = '\0'; + + /* Ignore return value, as duplicates are expected. */ + (void) rbt_insert (&fntype_rbt, buf); + + return buf; +} + /* Parse a function prototype. This code is shared by the bif and overload file processing. Return 1 for success, 0 for failure. */ static int @@ -1111,6 +1283,10 @@ parse_bif_entry () if (!parse_prototype (&bifs[curr_bif].proto)) return 5; + /* Build a function type descriptor identifier from the return type + and argument types, and store it if it does not already exist. */ + bifs[curr_bif].fndecl = construct_fntype_id (&bifs[curr_bif].proto); + /* Now process line 2. First up is the builtin id. */ if (!advance_line (bif_file)) { @@ -1271,6 +1447,10 @@ parse_ovld_entry () if (!parse_prototype (&ovlds[curr_ovld].proto)) return 6; + /* Build a function type descriptor identifier from the return type + and argument types, and store it if it does not already exist. */ + ovlds[curr_ovld].fndecl = construct_fntype_id (&ovlds[curr_ovld].proto); + /* Now process line 2, which just contains the builtin id. */ if (!advance_line (ovld_file)) {