From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1130) id 4DA2A385840F; Thu, 30 Mar 2023 10:11:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4DA2A385840F Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Richard Sandiford To: bfd-cvs@sourceware.org Subject: [binutils-gdb] aarch64: Use aarch64_operand_error more widely X-Act-Checkin: binutils-gdb X-Git-Author: Richard Sandiford X-Git-Refname: refs/heads/master X-Git-Oldrev: a5791d5814226054215b7aab9f87dec6b8e41664 X-Git-Newrev: 3e4525ca0b410b558207b2cdf62c44e3fc13b4f3 Message-Id: <20230330101104.4DA2A385840F@sourceware.org> Date: Thu, 30 Mar 2023 10:11:04 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Mar 2023 10:11:04 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3e4525ca0b41= 0b558207b2cdf62c44e3fc13b4f3 commit 3e4525ca0b410b558207b2cdf62c44e3fc13b4f3 Author: Richard Sandiford Date: Thu Mar 30 11:09:02 2023 +0100 aarch64: Use aarch64_operand_error more widely =20 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. Diff: --- 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_instruct= ion *); static inline void clear_error (void) { + memset (&inst.parsing_error, 0, sizeof (inst.parsing_error)); inst.parsing_error.kind =3D AARCH64_OPDE_NIL; - inst.parsing_error.error =3D NULL; } =20 static inline bool @@ -205,21 +201,11 @@ error_p (void) return inst.parsing_error.kind !=3D AARCH64_OPDE_NIL; } =20 -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 =3D -1; inst.parsing_error.kind =3D kind; inst.parsing_error.error =3D error; } @@ -7733,15 +7719,15 @@ parse_operands (char *str, const aarch64_opcode *op= code) =20 if (error_p ()) { + inst.parsing_error.index =3D 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