From patchwork Wed Feb 14 10:49:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shahab Vahedi X-Patchwork-Id: 200900 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1124621dyb; Wed, 14 Feb 2024 02:50:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWrN+F9Snx18CoAJhe1/LmuN5pqBoFu1780Nd2IvKa88i77pB1nJZ7Vi9Lf+8CPL05GFSBCyyP/4Uj/AZE8j6cmJrNzzA== X-Google-Smtp-Source: AGHT+IFoFEXZKAjoBE3ZeJKR6iSoFIHIjFkXAXrsJSvJLqPXpuIr4w3SEYjfSM9nscsEP275pyIv X-Received: by 2002:ac8:5809:0:b0:42c:7f9f:dabd with SMTP id g9-20020ac85809000000b0042c7f9fdabdmr2452487qtg.14.1707907809002; Wed, 14 Feb 2024 02:50:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707907808; cv=pass; d=google.com; s=arc-20160816; b=yKEneuQlV4y9eJTQAt3KQ6OYMCoaBpcdDcVNmE6fyhHQmr2gjxSLGlcRWNOgn0mM5P UXSivWMJ6ElvRkpri8SBHrV4LgoCH/CL7+/RR8txrIm9uOzqjkNfUK35ikTWbbfLJ3FJ 9c4lrsct1GiDnJ/bKNpFopxjRrZ/f+nYJxoO7fJLHE2G43ayZjUAXQIifqKqFHPH1zoo 3Ws78eZEmOdt6wumcFrGmPpiQTKwDhQp+9Rf6uIE6SL+NG4YLy0BwAhOgtccgZvXT4k4 cvzR6PwgKHBPfsTBFC4i/9gYWwISUmuKz/pp1Jm7oVS2H3rKWExFhBkt2LYXsT0OnlZm DSEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to: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 :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=wm/v/npOg++dXFflFM4gIPlaPcXiN3LNKCZpGFitcAY=; fh=OYmpEmJuMMnIg967arTGwU0twA60323hQbr3SDzf0x0=; b=amRgzW+7UnmxvH/PkzoHbSMYIGZJDjuERvQiA2UyhKsuwXlkyAXJoPk1RLOVnftLoO vscKK9dCzW1ZvnF51Y6gtzMo/fwEdNIw8IYPH0mN92AHRqDarph/4v8vZzx5Vyyo5Pmd zQuGzEAboekmjnS1L0sPbPQcTB13ZiQSd3j68+9eU4EfqXKMW9EKPDz6ZKVh89jmAbih QHaAZHGQJD6Oinpfy6q1VvbFqOTe6zjm7dhkSGRd5EkEyiNDcFIkma4p/VccK2lIIs4P /F4uVQ0T8qNeyEJeEojep7lcE0+ezx5igFF2Nhonijm3oUDksOjai7/OtiHDulw5EVnZ 1+NA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vahedi.org header.s=key1 header.b=PcSRoHrJ; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vahedi.org X-Forwarded-Encrypted: i=2; AJvYcCVcKpHUG3A5BSgidCevtB5/pBLVKmbbo+Ku8/BSFxalXo7WHKqmfGo9em4e+3qVuzMEXAYuY+z0vOgP3vj5WIewMZIZjg== Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c21-20020a05622a025500b0042c78a54983si5594613qtx.134.2024.02.14.02.50.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 02:50:08 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@vahedi.org header.s=key1 header.b=PcSRoHrJ; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vahedi.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AD03C385DC1A for ; Wed, 14 Feb 2024 10:50:08 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [IPv6:2001:41d0:1004:224b::ae]) by sourceware.org (Postfix) with ESMTPS id 4F0273857011 for ; Wed, 14 Feb 2024 10:49:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F0273857011 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=vahedi.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vahedi.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4F0273857011 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:41d0:1004:224b::ae ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707907801; cv=none; b=kZkIQcbrjdI377EIIorawfWQsmBFlv63+ZshZ1Q0BM4IrZJ9RhXrhILKDx3iIkAES67CYUOlAcY1lYh8VNt5xIN/Y6tBpVhtCiemg8sh4dFrgGiL6AL1ZCV3XRLYvsN1O1Ohp3VEMjit8Sk6De/jhbON6xrWJboINoik6pYSMkI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707907801; c=relaxed/simple; bh=El8ewA6G8fl5vcZPTyMsY2DnIhlYQuF4aMdqNbxgtpY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=hmny5FJWALg+/Zv0+WVrdxqnuzzxQsZBIvCLr4OFx0WF6LkcFQs051bLwKqiwh/X354Z1vF+ofEvw0IRX+/LtR4B+uyhZytHulDPXrKintnWKdXaG0VsQyZ1ZaYWGOGD5QvKLd0Wq7YbvVJIL/fV1EbD9d1EjNF01kg8qr5rtJ0= ARC-Authentication-Results: i=1; server2.sourceware.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vahedi.org; s=key1; t=1707907798; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wm/v/npOg++dXFflFM4gIPlaPcXiN3LNKCZpGFitcAY=; b=PcSRoHrJItGk+a1mFcCPXb5+sH0XYemqzB5P7b+dm5Cm0qjlj7XXdNZd+Zxic4B3N3XE1L sECe8OmRFoQ2R7j0mMBmdNirGTJ86yMqjDRwIjMNFDZpIJa2fJ6E35KhJBD2F3AJDhIk2t 1bWrWLPzXzVtj0RPZV9zZ/RSLLYohgudH4AvQRVqrn+chevSObr1/QR2jql8fsoUPERCAg hZO92GJLAjR9sX61LbDpUpVcNGiFb6edmK4lpJfA+h5kz9b+nW1CZ9/lAs/WFFLGjAx0Wu DI13BXARYN0nT5/NkeAhoDe/mEEqeTj2LxrlQh5s1GDFjmOOlUMFlnTUHTXKbw== From: Shahab Vahedi To: binutils@sourceware.org Cc: Yuriy Kolerov , Claudiu Zissulescu Ianculescu , Shahab Vahedi , Yuriy Kolerov Subject: [PUSHED] arc: Put DBNZ instruction to a separate class Date: Wed, 14 Feb 2024 11:49:54 +0100 Message-Id: <20240214104954.40036-1-list+bin@vahedi.org> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790431825597133869 X-GMAIL-MSGID: 1790871138879682930 From: Yuriy Kolerov DBNZ instruction decrements its source register operand, and if the result is non-zero it branches to the location defined by a signed half-word displacement operand. DBNZ instruction is in BRANCH class as other branch instrucitons like B, Bcc, etc. However, DBNZ is the only branch instruction that stores a branch offset in the second operand. Thus it must be placed in a distinct class and treated differently. For example, current logic of arc_insn_get_branch_target in GDB assumes that a branch offset is always stored in the first operand for BRANCH class and it's wrong for DBNZ. include/ChangeLog: 2024-02-14 Yuriy Kolerov * opcode/arc.h (enum insn_class_t): Add DBNZ class. opcodes/ChangeLog: 2024-02-14 Yuriy Kolerov * arc-tbl.h (dbnz): Use "DBNZ" class. * arc-dis.c (arc_opcode_to_insn_type): Handle "DBNZ" class. gas/ChangeLog: 2024-02-14 Yuriy Kolerov * config/tc-arc.c (is_br_jmp_insn_p): Add check against "DBNZ". --- gas/ChangeLog | 4 ++++ gas/config/tc-arc.c | 1 + include/ChangeLog | 4 ++++ include/opcode/arc.h | 1 + opcodes/ChangeLog | 5 +++++ opcodes/arc-dis.c | 1 + opcodes/arc-tbl.h | 2 +- 7 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index b1c8d09bf1b..b277f47b05d 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,7 @@ +2024-02-14 Yuriy Kolerov + + * config/tc-arc.c (is_br_jmp_insn_p): Add check against "DBNZ". + 2024-01-29 Jose E. Marchesi * doc/c-bpf.texi (BPF Instructions): There is no indirect 64-bit diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c index 69de96e43fc..f7d8e8938ce 100644 --- a/gas/config/tc-arc.c +++ b/gas/config/tc-arc.c @@ -109,6 +109,7 @@ enum arc_rlx_types || (op)->insn_class == BBIT0 \ || (op)->insn_class == BBIT1 \ || (op)->insn_class == BI \ + || (op)->insn_class == DBNZ \ || (op)->insn_class == EI \ || (op)->insn_class == ENTER \ || (op)->insn_class == JLI \ diff --git a/include/ChangeLog b/include/ChangeLog index 11c4b321a49..db5c258cbdf 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2024-02-14 Yuriy Kolerov + + * opcode/arc.h (enum insn_class_t): Add DBNZ class. + 2024-02-12 Frederic Cambus * elf/common.h (PT_OPENBSD_SYSCALLS): Define. diff --git a/include/opcode/arc.h b/include/opcode/arc.h index df2be17d839..c16e1298b89 100644 --- a/include/opcode/arc.h +++ b/include/opcode/arc.h @@ -52,6 +52,7 @@ typedef enum BRANCH, BRCC, CONTROL, + DBNZ, DIVREM, DMA, DPI, diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 4bc815780fd..4fb2d0de207 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,8 @@ +2024-02-14 Yuriy Kolerov + + * arc-tbl.h (dbnz): Use "DBNZ" class. + * arc-dis.c (arc_opcode_to_insn_type): Handle "DBNZ" class. + 2024-01-29 Jose E. Marchesi * bpf-opc.c (bpf_opcodes): Remove BPF_INSN_LDINDDW and diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c index c75e4406046..16fbc8ab007 100644 --- a/opcodes/arc-dis.c +++ b/opcodes/arc-dis.c @@ -894,6 +894,7 @@ arc_opcode_to_insn_type (const struct arc_opcode *opcode) case BI: case BIH: case BRCC: + case DBNZ: case EI: case JLI: case JUMP: diff --git a/opcodes/arc-tbl.h b/opcodes/arc-tbl.h index e0415c8021d..4572f7d6590 100644 --- a/opcodes/arc-tbl.h +++ b/opcodes/arc-tbl.h @@ -3656,7 +3656,7 @@ { "daddh22", 0x36F77F80, 0xFFFF7FE0, ARC_OPCODE_ARCv2EM, FLOAT, DPA, { ZA, LIMM, LIMMdup }, { C_F, C_CC }}, /* dbnz<.d> b,s13 00100bbb1000110N0BBBssssssSSSSSS. */ -{ "dbnz", 0x208C0000, 0xF8FE8000, ARC_OPCODE_ARCv2EM | ARC_OPCODE_ARCv2HS, BRANCH, NONE, { RB, SIMM13_A16_20}, { C_DNZ_D }}, +{ "dbnz", 0x208C0000, 0xF8FE8000, ARC_OPCODE_ARCv2EM | ARC_OPCODE_ARCv2HS, DBNZ, NONE, { RB, SIMM13_A16_20}, { C_DNZ_D }}, /* dexcl1<.f> a,b,c 00110bbb00011000FBBBCCCCCCAAAAAA. */ { "dexcl1", 0x30180000, 0xF8FF0000, ARC_OPCODE_ARC700 | ARC_OPCODE_ARCv2EM, FLOAT, DPX, { RA, RB, RC }, { C_F }},