From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 6EFCB3858428 for ; Thu, 30 Mar 2023 10:24:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6EFCB3858428 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com 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 8CFE11595; Thu, 30 Mar 2023 03:25:02 -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 C40283F663; Thu, 30 Mar 2023 03:24:17 -0700 (PDT) From: Richard Sandiford To: binutils@sourceware.org Cc: Richard Sandiford Subject: [PATCH 05/43] aarch64: Use aarch64_operand_error more widely Date: Thu, 30 Mar 2023 11:23:21 +0100 Message-Id: <20230330102359.3327695-6-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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-33.4 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 List-Id: GAS's aarch64_instruction had its own cut-down error record, but it's better for later patches if it reuses the binutils-wide aarch64_operand_error instead. The main difference is that aarch64_operand_error can store arguments to the error while aarch64_instruction couldn't. --- gas/config/tc-aarch64.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 67b0e61a7ff..4e75946c684 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -155,11 +155,7 @@ struct aarch64_instruction /* libopcodes structure for instruction intermediate representation. */ aarch64_inst base; /* Record assembly errors found during the parsing. */ - struct - { - enum aarch64_operand_error_kind kind; - const char *error; - } parsing_error; + aarch64_operand_error parsing_error; /* The condition that appears in the assembly line. */ int cond; /* Relocation information (including the GAS internal fixup). */ @@ -195,8 +191,8 @@ static bool programmer_friendly_fixup (aarch64_instruction *); static inline void clear_error (void) { + memset (&inst.parsing_error, 0, sizeof (inst.parsing_error)); inst.parsing_error.kind = AARCH64_OPDE_NIL; - inst.parsing_error.error = NULL; } static inline bool @@ -205,21 +201,11 @@ error_p (void) return inst.parsing_error.kind != AARCH64_OPDE_NIL; } -static inline const char * -get_error_message (void) -{ - return inst.parsing_error.error; -} - -static inline enum aarch64_operand_error_kind -get_error_kind (void) -{ - return inst.parsing_error.kind; -} - static inline void set_error (enum aarch64_operand_error_kind kind, const char *error) { + memset (&inst.parsing_error, 0, sizeof (inst.parsing_error)); + inst.parsing_error.index = -1; inst.parsing_error.kind = kind; inst.parsing_error.error = error; } @@ -7733,15 +7719,15 @@ parse_operands (char *str, const aarch64_opcode *opcode) if (error_p ()) { + inst.parsing_error.index = i; DEBUG_TRACE ("parsing FAIL: %s - %s", - operand_mismatch_kind_names[get_error_kind ()], - get_error_message ()); + operand_mismatch_kind_names[inst.parsing_error.kind], + inst.parsing_error.error); /* Record the operand error properly; this is useful when there are multiple instruction templates for a mnemonic name, so that later on, we can select the error that most closely describes the problem. */ - record_operand_error (opcode, i, get_error_kind (), - get_error_message ()); + record_operand_error_info (opcode, &inst.parsing_error); return false; } else -- 2.25.1