From patchwork Thu Mar 30 10:23:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 77046 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1026777vqo; Thu, 30 Mar 2023 03:37:18 -0700 (PDT) X-Google-Smtp-Source: AKy350YiFkd+98nNX3jDTLDz6Eq6V66Kkd3P03ctuCy68QFeZK3qFYTOAPe0e8vfubXvZ4vx3Ohv X-Received: by 2002:a05:6402:1390:b0:502:2382:5c24 with SMTP id b16-20020a056402139000b0050223825c24mr20465067edv.39.1680172638536; Thu, 30 Mar 2023 03:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680172638; cv=none; d=google.com; s=arc-20160816; b=FeE8i446ewYI8XwXdUxwGLb5Kh49FvNi1510l7EiQip5/P0t9Fm8ju+LQudchLgggb BTmxW9t+YmBiRg97rtQaHYjQi3xquyrI8Tg2tq1qCzshssPXkgsI6DMlsXDXWA77utvo VKt9yqlyHjtbbH8dBnw4+U9zDju69F5P7Q009mOOimi7aZRBboGPvWOV3a7jcCkI9Z3x rT4EfNfRlidAO/wgZyZYKs/Z55MGd9TVhCztIC8q4hatALUpRN32pTt6ioBSh+0hsz+1 ZVYGS26D4SyMaZL/eiOh6w5F1ZbFflkGGDYlP96LX4yF12XYRvPZpu3cUv2muCB8GufB gzxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=8qXu588Qc1zoMF7V+XIjJmaWmZFnBsZsEtIHNARQq4A=; b=x9hSt0QQlZK7TU+I85kyTJhCcuNm/N78vsmCYRM1gOZ5sHGEMPmPwPqGCFt8dXkWyN 7XP2rm0UX0mxnNmHwHrBi6Y3mKnnNyQZnxauq36BnnXIYN6plgulQK/dHsWA10KgqWDQ H38FjRSXhNYWjqqOIWWyOLwm7kUq5/HqiL+TL0GDYqg424v8i3fElOoGz7MzRAzfvVss S6aLh6FrG2AfgnD8f/QlXnOlVOEZGFrKIFuJWRZeo/5hdhgVAhUUSoGxq3sMZzA0tbCF oQDhujSl9t08Nw6HwnO4pjdIeNzZXlh1ZzkHcekPgN6NBD9K2sZDi+quwE4X/yLW8cle aijA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=EF8Dhl8A; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w17-20020a17090652d100b008da1e19114fsi33045275ejn.322.2023.03.30.03.37.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 03:37:18 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=EF8Dhl8A; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC5EF3959C53 for ; Thu, 30 Mar 2023 10:30:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC5EF3959C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680172232; bh=8qXu588Qc1zoMF7V+XIjJmaWmZFnBsZsEtIHNARQq4A=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=EF8Dhl8A00/7SiY85ge0LZyUE6Q2PKDHNiQ+BKmJReeaese+/UoFsudh6MzhYMbD2 94ZDvaefDuPjjoD290YBT33apD4PfzAW5sBmvK9mWYdiTaboV1gnefKhN5ILzdu9KU CIG2SE8ZJqktzZuIXBuunor3j2mnAhcUX1/o0Wx4= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 710373858033 for ; Thu, 30 Mar 2023 10:24:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 710373858033 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A99F112FC; Thu, 30 Mar 2023 03:25:11 -0700 (PDT) Received: from e121540-lin.manchester.arm.com (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E0BD73F663; Thu, 30 Mar 2023 03:24:26 -0700 (PDT) To: binutils@sourceware.org Cc: Richard Sandiford Subject: [PATCH 18/43] aarch64: Commonise index parsing Date: Thu, 30 Mar 2023 11:23:34 +0100 Message-Id: <20230330102359.3327695-19-richard.sandiford@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230330102359.3327695-1-richard.sandiford@arm.com> References: <20230330102359.3327695-1-richard.sandiford@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-33.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Sandiford via Binutils From: Richard Sandiford Reply-To: Richard Sandiford Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761788704387420479?= X-GMAIL-MSGID: =?utf-8?q?1761788704387420479?= Just a minor clean-up to factor out the index parsing, partly to ensure that the error handling remains consistent. No behavioural change intended. --- gas/config/tc-aarch64.c | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index e5185353013..dafd5bc296c 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -1022,6 +1022,23 @@ aarch64_valid_suffix_char_p (aarch64_reg_type type, char ch) } } +/* Parse an index expression at *STR, storing it in *IMM on success. */ + +static bool +parse_index_expression (char **str, int64_t *imm) +{ + expressionS exp; + + aarch64_get_expression (&exp, str, GE_NO_PREFIX, REJECT_ABSENT); + if (exp.X_op != O_constant) + { + first_error (_("constant expression required")); + return false; + } + *imm = exp.X_add_number; + return true; +} + /* Parse a register of the type TYPE. Return null if the string pointed to by *CCP is not a valid register @@ -1116,8 +1133,6 @@ parse_typed_reg (char **ccp, aarch64_reg_type type, if (!(flags & PTR_FULL_REG) && skip_past_char (&str, '[')) { - expressionS exp; - /* Reject Sn[index] syntax. */ if (!is_typed_vecreg) { @@ -1133,18 +1148,11 @@ parse_typed_reg (char **ccp, aarch64_reg_type type, atype.defined |= NTA_HASINDEX; - aarch64_get_expression (&exp, &str, GE_NO_PREFIX, REJECT_ABSENT); - - if (exp.X_op != O_constant) - { - first_error (_("constant expression required")); - return NULL; - } + if (!parse_index_expression (&str, &atype.index)) + return NULL; if (! skip_past_char (&str, ']')) return NULL; - - atype.index = exp.X_add_number; } else if (!(flags & PTR_IN_REGLIST) && (atype.defined & NTA_HASINDEX) != 0) { @@ -1318,18 +1326,10 @@ parse_vector_reg_list (char **ccp, aarch64_reg_type type, { if (skip_past_char (&str, '[')) { - expressionS exp; - - aarch64_get_expression (&exp, &str, GE_NO_PREFIX, REJECT_ABSENT); - if (exp.X_op != O_constant) - { - set_first_syntax_error (_("constant expression required.")); - error = true; - } + if (!parse_index_expression (&str, &typeinfo_first.index)) + error = true; if (! skip_past_char (&str, ']')) error = true; - else - typeinfo_first.index = exp.X_add_number; } else {