From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by sourceware.org (Postfix) with ESMTPS id 10E813858D32 for ; Mon, 30 Jan 2023 01:40:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10E813858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-16332831ed0so13350127fac.10 for ; Sun, 29 Jan 2023 17:40:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=EB67Cgkh18f4A2MaxSsPqr86lDBwYdZd5xLRbj2d7NI=; b=fKTrANQOZXuSRk/L33SeqQQvrX+Z2RS44Y+fpU/a6A9q9liiAiyUrLKCeIeN/Tcct3 vcLVwMK+dySQMTWp7tQD/QQlKsceSNz4bgrWjVg4niG7zM0ZQaO7tiYsnbzs7HRSL0n8 gg91bEAkshzo6qVaJNHPZMSfe5t7ccDh8uiC1LQAURyvs9DZgapa73W72sZkzBQ9HUOC Lv+TZa3+EEMTCI7NiKkPp/+zaHN81nSxAL9ivxpJxxG0OZPee0UAHFMn3auaWDgacqZv UiI1df7zXfMLFM1qF9x1HZWUeiaMkR39BgWcMcRDKTf/M6FeyUkuS7rx56NZ9AcBaz66 PxaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EB67Cgkh18f4A2MaxSsPqr86lDBwYdZd5xLRbj2d7NI=; b=70F/dGtYVIcw2Ng3O1pkZe06AqGt9cnWvf78hyNVd3uO0z79RhVf5wCj1WWA4B5UJF I64QCRl9Diz0KSaDDzqSu/hBFmGXuoG8Zx/XdJ4P6Kl3B+SJYxwlnauNSCCsCA9fU2Hb gIHhbBnQpOYy53k0mBxvOBX2EbSHjnG8r6oXRQ4HKi4VHpVA6Od8UaeW43cdjkHShMtR gXl5VKODvp1ljB1KA9L8bZUOHBzVOeMzs0vb1Gk91/ldRV/YqyAdvUalr2DdIUkIacEi IKx29P3pbqt6ixB7VcxF7Xi72sqKFwttmeZpe08IX56E49hwwU7Wl2bJZybMDcxiZhsS t0rQ== X-Gm-Message-State: AO0yUKXY5WIlITwDYG5jifzzhtzpiDanST57hcKwU5xmpK0VMkv9Y+bx oAEEgs9Or3zrw8nfnadkTT6kHs/3fcP0VvpJ2F3owA== X-Google-Smtp-Source: AK7set8O2H32zkHdv+nYdPbR3O40Sa5WySP1XwjJE7XUYOuJ4SAN46I+La2Jrm2OJZfuCSJIQer0TFmcn8OYQtyqj2k= X-Received: by 2002:a05:6870:f593:b0:163:aadd:a457 with SMTP id eh19-20020a056870f59300b00163aadda457mr284734oab.201.1675042847062; Sun, 29 Jan 2023 17:40:47 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Nelson Chu Date: Mon, 30 Jan 2023 09:40:36 +0800 Message-ID: Subject: Re: [PATCH] RISC-V: don't disassemble unrecognized insns as .byte To: Jan Beulich Cc: Binutils , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Kito Cheng Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: On Fri, Jan 27, 2023 at 9:14 PM Jan Beulich wrote: > > Insn width granularity being 16 bits, produce 16 bits of data per output > element for the non-special-cased insn widths. Besides being slightly > more natural (in particular having the first element carry everything > that's needed for determining insn length), this is also slightly more > compact. Sounds reasonable and good, so please commit, thanks. > --- > I think output would be even more neat if .byte were suppressed when > generic code already prints the raw insn (or maybe something like > was printed instead). > > As to the special case code for 2-, 4-, and 8-byte insns: Any thoughts > towards zero-padding the numbers there as well? That would make yet more > noticable what the insn width is; in particular - see e.g. ".8byte 0x3f" > in full disassembly of the testcases modified here - it would avoid the > value looking like it was for a more narrow one. > > Taking it yet one step further - how about printing unknown insns as > ".insn ...", matching what gas would consume? I don't remember how long ago, Kito did discuss this idea with me, but since we haven't supported mapping symbols at that time, it's been forgotten until this patch. Anyway, I vote to dump the unrecognized instructions into .insn directives, so if there is no objection, please go ahead. Also cc Kito, he should have almost forgotten about this :-) Thanks Nelson > > --- a/gas/testsuite/gas/riscv/insn-na.d > +++ b/gas/testsuite/gas/riscv/insn-na.d > @@ -76,11 +76,11 @@ Disassembly of section .text: > [^:]+:[ ]+007f 0000 0000 0000 0000[ ]+[._a-z].* > [^:]+:[ ]+0000107f 00000000 00000000[ ]+[._a-z].* > [^:]+:[ ]+607f 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000[ ]+[._a-z].* > -[^:]+:[ ]+007f 0000 0000 0000 8000[ ]+\.byte[ ]+0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 > -[^:]+:[ ]+007f 0000 0000 0000 8000[ ]+\.byte[ ]+0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 > -[^:]+:[ ]+607f 89ab 4567 0123 3210 7654 ba98 fedc 0000 0000 0000[ ]+\.byte[ ]+0x7f, 0x60, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 > -[^:]+:[ ]+607f 89ab 4567 0123 3210 7654 ba98 fedc 0000 0000 0000[ ]+\.byte[ ]+0x7f, 0x60, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 > -[^:]+:[ ]+607f 33cc 55aa cdef 89ab 4567 0123 3210 7654 ba98 00dc[ ]+\.byte[ ]+0x7f, 0x60, 0xcc, 0x33, 0xaa, 0x55, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0x00 > -[^:]+:[ ]+607f 33cc 55aa cdef 89ab 4567 0123 3210 7654 ba98 00dc[ ]+\.byte[ ]+0x7f, 0x60, 0xcc, 0x33, 0xaa, 0x55, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0x00 > -[^:]+:[ ]+607f 33cc 55aa cdef 89ab 4567 0123 3210 7654 ba98 fedc[ ]+\.byte[ ]+0x7f, 0x60, 0xcc, 0x33, 0xaa, 0x55, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe > -[^:]+:[ ]+607f 33cc 55aa cdef 89ab 4567 0123 3210 7654 ba98 fedc[ ]+\.byte[ ]+0x7f, 0x60, 0xcc, 0x33, 0xaa, 0x55, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe > +[^:]+:[ ]+007f 0000 0000 0000 8000[ ]+\.2byte[ ]+0x007f, 0x0000, 0x0000, 0x0000, 0x8000 > +[^:]+:[ ]+007f 0000 0000 0000 8000[ ]+\.2byte[ ]+0x007f, 0x0000, 0x0000, 0x0000, 0x8000 > +[^:]+:[ ]+607f 89ab 4567 0123 3210 7654 ba98 fedc 0000 0000 0000[ ]+\.2byte[ ]+0x607f, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0xfedc, 0x0000, 0x0000, 0x0000 > +[^:]+:[ ]+607f 89ab 4567 0123 3210 7654 ba98 fedc 0000 0000 0000[ ]+\.2byte[ ]+0x607f, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0xfedc, 0x0000, 0x0000, 0x0000 > +[^:]+:[ ]+607f 33cc 55aa cdef 89ab 4567 0123 3210 7654 ba98 00dc[ ]+\.2byte[ ]+0x607f, 0x33cc, 0x55aa, 0xcdef, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0x00dc > +[^:]+:[ ]+607f 33cc 55aa cdef 89ab 4567 0123 3210 7654 ba98 00dc[ ]+\.2byte[ ]+0x607f, 0x33cc, 0x55aa, 0xcdef, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0x00dc > +[^:]+:[ ]+607f 33cc 55aa cdef 89ab 4567 0123 3210 7654 ba98 fedc[ ]+\.2byte[ ]+0x607f, 0x33cc, 0x55aa, 0xcdef, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0xfedc > +[^:]+:[ ]+607f 33cc 55aa cdef 89ab 4567 0123 3210 7654 ba98 fedc[ ]+\.2byte[ ]+0x607f, 0x33cc, 0x55aa, 0xcdef, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0xfedc > --- a/gas/testsuite/gas/riscv/insn.d > +++ b/gas/testsuite/gas/riscv/insn.d > @@ -95,25 +95,25 @@ Disassembly of section .text: > [^:]+:[ ]+607f 0000 0000 0000[ ]+[._a-z].* > [^:]+:[ ]+0000 0000 0000 0000 ? > [^:]+:[ ]+0000 0000 0000 ? > -[^:]+:[ ]+007f 0000 0000 0000[ ]+\.byte[ ]+0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 > +[^:]+:[ ]+007f 0000 0000 0000[ ]+\.2byte[ ]+0x007f, 0x0000, 0x0000, 0x0000, 0x8000 > [^:]+:[ ]+8000 ? > -[^:]+:[ ]+007f 0000 0000 0000[ ]+\.byte[ ]+0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 > +[^:]+:[ ]+007f 0000 0000 0000[ ]+\.2byte[ ]+0x007f, 0x0000, 0x0000, 0x0000, 0x8000 > [^:]+:[ ]+8000 ? > -[^:]+:[ ]+607f 89ab 4567 0123[ ]+\.byte[ ]+0x7f, 0x60, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 > +[^:]+:[ ]+607f 89ab 4567 0123[ ]+\.2byte[ ]+0x607f, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0xfedc, 0x0000, 0x0000, 0x0000 > [^:]+:[ ]+3210 7654 ba98 fedc ? > [^:]+:[ ]+0000 0000 0000 ? > -[^:]+:[ ]+607f 89ab 4567 0123[ ]+\.byte[ ]+0x7f, 0x60, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 > +[^:]+:[ ]+607f 89ab 4567 0123[ ]+\.2byte[ ]+0x607f, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0xfedc, 0x0000, 0x0000, 0x0000 > [^:]+:[ ]+3210 7654 ba98 fedc ? > [^:]+:[ ]+0000 0000 0000 ? > -[^:]+:[ ]+607f 33cc 55aa cdef[ ]+\.byte[ ]+0x7f, 0x60, 0xcc, 0x33, 0xaa, 0x55, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0x00 > +[^:]+:[ ]+607f 33cc 55aa cdef[ ]+\.2byte[ ]+0x607f, 0x33cc, 0x55aa, 0xcdef, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0x00dc > [^:]+:[ ]+89ab 4567 0123 3210 ? > [^:]+:[ ]+7654 ba98 00dc ? > -[^:]+:[ ]+607f 33cc 55aa cdef[ ]+\.byte[ ]+0x7f, 0x60, 0xcc, 0x33, 0xaa, 0x55, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0x00 > +[^:]+:[ ]+607f 33cc 55aa cdef[ ]+\.2byte[ ]+0x607f, 0x33cc, 0x55aa, 0xcdef, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0x00dc > [^:]+:[ ]+89ab 4567 0123 3210 ? > [^:]+:[ ]+7654 ba98 00dc ? > -[^:]+:[ ]+607f 33cc 55aa cdef[ ]+\.byte[ ]+0x7f, 0x60, 0xcc, 0x33, 0xaa, 0x55, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe > +[^:]+:[ ]+607f 33cc 55aa cdef[ ]+\.2byte[ ]+0x607f, 0x33cc, 0x55aa, 0xcdef, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0xfedc > [^:]+:[ ]+89ab 4567 0123 3210 ? > [^:]+:[ ]+7654 ba98 fedc ? > -[^:]+:[ ]+607f 33cc 55aa cdef[ ]+\.byte[ ]+0x7f, 0x60, 0xcc, 0x33, 0xaa, 0x55, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe > +[^:]+:[ ]+607f 33cc 55aa cdef[ ]+\.2byte[ ]+0x607f, 0x33cc, 0x55aa, 0xcdef, 0x89ab, 0x4567, 0x0123, 0x3210, 0x7654, 0xba98, 0xfedc > [^:]+:[ ]+89ab 4567 0123 3210 ? > [^:]+:[ ]+7654 ba98 fedc ? > --- a/opcodes/riscv-dis.c > +++ b/opcodes/riscv-dis.c > @@ -800,16 +800,16 @@ riscv_disassemble_insn (bfd_vma memaddr, > { > int i; > (*info->fprintf_styled_func) > - (info->stream, dis_style_assembler_directive, ".byte"); > + (info->stream, dis_style_assembler_directive, ".2byte"); > (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t"); > - for (i = 0; i < insnlen; ++i) > + for (i = 0; i < insnlen; i += 2) > { > if (i > 0) > (*info->fprintf_styled_func) (info->stream, dis_style_text, > ", "); > + word = bfd_get_bits (packet + i, 16, false); > (*info->fprintf_styled_func) (info->stream, dis_style_immediate, > - "0x%02x", > - (unsigned int) (*packet++)); > + "0x%04x", (unsigned int) word); > } > } > break;