From patchwork Thu Jun 17 15:18:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 1493611 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=MnKFDztF; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G5QwZ4C3Cz9sSs for ; Fri, 18 Jun 2021 01:30:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 53D4A3857402 for ; Thu, 17 Jun 2021 15:30:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53D4A3857402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1623943804; bh=SuZWhXml6W2iNeJDZsF94jp+maA/HWbQUcEjV9F1z9A=; h=To:Subject:Date:In-Reply-To:References:In-Reply-To:References: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=MnKFDztFWjPD3kr8ApMQ67C2zZ4tczLeoLzpvcVQ3x+RNNgLUxUvvXun8nkstxEm2 J3trPuia3sjnZjkw8h0RptwIXPCsdDivQtCEgEnon5GTYQB10Li0P9eQ4i82oVt6ls /AnAOQ8mqGWJ23sz3UnMMnxaCDnPvN78TAGoTqkE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 747E4396AC09 for ; Thu, 17 Jun 2021 15:20:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 747E4396AC09 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15HF4EgQ158761; Thu, 17 Jun 2021 11:20:50 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 3988eqs30r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Jun 2021 11:20:49 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15HFBOam028783; Thu, 17 Jun 2021 15:20:48 GMT Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by ppma05wdc.us.ibm.com with ESMTP id 3954gknduu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 17 Jun 2021 15:20:48 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15HFKlsd9831130 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Jun 2021 15:20:48 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DFCC86E054; Thu, 17 Jun 2021 15:20:47 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C5EF36E04E; Thu, 17 Jun 2021 15:20:47 +0000 (GMT) Received: from localhost (unknown [9.40.194.84]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 17 Jun 2021 15:20:47 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 08/55] rs6000: Add functions for matching types, part 3 of 3 Date: Thu, 17 Jun 2021 10:18:52 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: dUXPBehG5BEip4HVk3XeY3l_EFNuWjQ9 X-Proofpoint-GUID: dUXPBehG5BEip4HVk3XeY3l_EFNuWjQ9 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-17_13:2021-06-15, 2021-06-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 malwarescore=0 bulkscore=0 phishscore=0 mlxlogscore=999 spamscore=0 adultscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106170096 X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bill Schmidt via Gcc-patches From: Bill Schmidt Reply-To: Bill Schmidt Cc: segher@kernel.crashing.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 2021-06-07 Bill Schmidt gcc/ * config/rs6000/rs6000-gen-builtins.c (restriction): New enum. (typeinfo): Add restr field. (match_bracketed_pair): New function. (match_const_restriction): Implement. --- gcc/config/rs6000/rs6000-gen-builtins.c | 115 +++++++++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-) diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index f850ea86a39..b964dc2298f 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -216,6 +216,22 @@ enum basetype BT_VQUAD }; +/* Ways in which a const int value can be restricted. RES_BITS indicates + that the integer is restricted to val1 bits, interpreted as an unsigned + number. RES_RANGE indicates that the integer is restricted to values + between val1 and val2, inclusive. RES_VAR_RANGE is like RES_RANGE, but + the argument may be variable, so it can only be checked if it is constant. + RES_VALUES indicates that the integer must have one of the values val1 + or val2. */ +enum restriction +{ + RES_NONE, + RES_BITS, + RES_RANGE, + RES_VAR_RANGE, + RES_VALUES +}; + /* Type modifiers for an argument or return type. */ struct typeinfo { @@ -228,6 +244,7 @@ struct typeinfo char ispixel; char ispointer; basetype base; + restriction restr; char *val1; char *val2; }; @@ -453,6 +470,53 @@ match_basetype (typeinfo *typedata) return 1; } +/* Helper routine for match_const_restriction. */ +static int +match_bracketed_pair (typeinfo *typedata, char open, char close, + restriction restr) +{ + if (linebuf[pos] == open) + { + safe_inc_pos (); + int oldpos = pos; + char *x = match_integer (); + if (x == NULL) + { + (*diag) ("malformed integer at column %d.\n", oldpos + 1); + return 0; + } + consume_whitespace (); + if (linebuf[pos] != ',') + { + (*diag) ("missing comma at column %d.\n", pos + 1); + return 0; + } + safe_inc_pos (); + consume_whitespace (); + oldpos = pos; + char *y = match_integer (); + if (y == NULL) + { + (*diag) ("malformed integer at column %d.\n", oldpos + 1); + return 0; + } + typedata->restr = restr; + typedata->val1 = x; + typedata->val2 = y; + + consume_whitespace (); + if (linebuf[pos] != close) + { + (*diag) ("malformed restriction at column %d.\n", pos + 1); + return 0; + } + safe_inc_pos (); + return 1; + } + + return 0; +} + /* A const int argument may be restricted to certain values. This is indicated by one of the following occurring after the "int' token: @@ -470,7 +534,56 @@ match_basetype (typeinfo *typedata) static int match_const_restriction (typeinfo *typedata) { - return 1; + int oldpos = pos; + if (linebuf[pos] == '<') + { + safe_inc_pos (); + oldpos = pos; + char *x = match_integer (); + if (x == NULL) + { + (*diag) ("malformed integer at column %d.\n", oldpos + 1); + return 0; + } + consume_whitespace (); + if (linebuf[pos] == '>') + { + typedata->restr = RES_BITS; + typedata->val1 = x; + safe_inc_pos (); + return 1; + } + else if (linebuf[pos] != ',') + { + (*diag) ("malformed restriction at column %d.\n", pos + 1); + return 0; + } + safe_inc_pos (); + oldpos = pos; + char *y = match_integer (); + if (y == NULL) + { + (*diag) ("malformed integer at column %d.\n", oldpos + 1); + return 0; + } + typedata->restr = RES_RANGE; + typedata->val1 = x; + typedata->val2 = y; + + consume_whitespace (); + if (linebuf[pos] != '>') + { + (*diag) ("malformed restriction at column %d.\n", pos + 1); + return 0; + } + safe_inc_pos (); + return 1; + } + else if (match_bracketed_pair (typedata, '{', '}', RES_VALUES) + || match_bracketed_pair (typedata, '[', ']', RES_VAR_RANGE)) + return 1; + + return 0; } /* Look for a type, which can be terminated by a token that is not part of