From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by sourceware.org (Postfix) with ESMTPS id E69393851C25 for ; Wed, 24 Aug 2022 11:42:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E69393851C25 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-ot1-x344.google.com with SMTP id o15-20020a9d718f000000b00638c1348012so11639694otj.2 for ; Wed, 24 Aug 2022 04:42:28 -0700 (PDT) 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; bh=PI/Gi87V8KGjA01f6AwR050QOyWaXUf5lOgD9d6vYyY=; b=Z9eHvJS5lC5QpT5JFE5817gycDRPAxhv54AHPaCEdAec8sMTQR8RotI6DKuZli7dfi fZXd15Eir7zgajAxG27HnXJN2d/BIlMZ9nRuaCRe9ku36hP1Ha9JRgnFKYg38K7PB2q1 P+blYZ0DkOunpgkYYayVkIAfP3rG32Sgoz06gnZmkZzmVyELQLxgbJ2u+u9i4FMgHDPq 07pQVTT6msR9J68jpgBp1HzcU2SfJcWoLy3yg/D6v6IKXUFbwJ19L+C2wVDDvYvSyzt8 TIhc5+YzrrCTqCq4iTHJc1QJXJG6YbslpAc7u+JE8bsnH4nJ21kZ/Bgn+i7hT6J3NcFf RGFQ== 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; bh=PI/Gi87V8KGjA01f6AwR050QOyWaXUf5lOgD9d6vYyY=; b=gvgBqKagXhosjGZ4yw7w2cL1kvahDl6ckmoXxb3mQanxM5l6OM9QjIXH8eZ6SLxlQW Uhs1PxYTp6G3Fsh789NkIKO9re4pzLiO3kxEZWRIFK5S8fO4FT6e6AhIO6iZWQ/RgdCL 9WAQ9vdOoGRJsc8v2cAh5+CUW02T+bXOY0Z1LTuIDzs74dMvToiAAMycAf98rnu5pJZU sPxZrS87wjHKhf/s+yRv5DtM7vt5rlI0gyK8ga30835P2TM1HqCDavIQyMYZRXX1qK8A 4BSLEkb8a8QIKKedWqceN3bGG2AWV42RX+UkqRzVztBSnZgIP6K+2I1R0LjN31EZj9Ll 8IVw== X-Gm-Message-State: ACgBeo2SwDLUfR4v2Iu6VMRsIJkZZ3HoZICv+czfvvl4Qd90yFgRXJ5F HueObTa54r1mcj+ROKsNOebFw1vke+VkFaPBdbtHyg== X-Google-Smtp-Source: AA6agR5PIJedtgCaNQaZkMr5CONBiMiZE5Fix84TKMaBId2MQp9oKN55jnxaDYW8AsjntX8ZPNp+lc/VWvVEAklJXTQ= X-Received: by 2002:a05:6830:25c2:b0:638:ca5c:bc66 with SMTP id d2-20020a05683025c200b00638ca5cbc66mr10947292otu.208.1661341348190; Wed, 24 Aug 2022 04:42:28 -0700 (PDT) MIME-Version: 1.0 References: <6f3879108a1b8702eba6cdd5a10283b502c83456.1661304407.git.research_trasio@irq.a4lg.com> In-Reply-To: <6f3879108a1b8702eba6cdd5a10283b502c83456.1661304407.git.research_trasio@irq.a4lg.com> From: Nelson Chu Date: Wed, 24 Aug 2022 19:42:17 +0800 Message-ID: Subject: Re: [PATCH v7 4/5] RISC-V: Add address printer tests on disassembler To: Tsukasa OI Cc: "H . Peter Anvin" , Palmer Dabbelt , Andrew Waterman , Jim Wilson , Nelson Chu , binutils@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,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 List-Id: On Wed, Aug 24, 2022 at 9:29 AM Tsukasa OI via Binutils wrote: > > This commit adds address printer tests on the disassembler focusing on > various path to/on maybe_print_address. It also tests whether the address > adjustment on RV32 (fix to PR29342) works as expected, whether the highest > address is printed with a symbol and JALR address computation is fixed. > > gas/ChangeLog: > > * testsuite/gas/riscv/dis-addr-1.s: Rename from auipc-x0.s. > * testsuite/gas/riscv/dis-addr-1.d: Rename from auipc-x0.d. I think the test case is for another purpose, it is not only for the PR29342, so just keep it as before. > * testsuite/gas/riscv/dis-addr-2.s: New address printer tests > on the disassembler. > * testsuite/gas/riscv/dis-addr-2-32.d: Likewise. > * testsuite/gas/riscv/dis-addr-2-64.d: Likewise. > * testsuite/gas/riscv/dis-addr-3.s: New address printer tests > on the disassembler if `gp' is the highest address. > * testsuite/gas/riscv/dis-addr-3-32.d: Likewise. > * testsuite/gas/riscv/dis-addr-3-64.d: Likewise. OK, looks good. Just moving them to the corresponding patches should be enough. > --- > .../gas/riscv/{auipc-x0.d => dis-addr-1.d} | 0 > .../gas/riscv/{auipc-x0.s => dis-addr-1.s} | 0 > gas/testsuite/gas/riscv/dis-addr-2-32.d | 31 ++++++++ > gas/testsuite/gas/riscv/dis-addr-2-64.d | 35 +++++++++ > gas/testsuite/gas/riscv/dis-addr-2.s | 74 +++++++++++++++++++ > gas/testsuite/gas/riscv/dis-addr-3-32.d | 12 +++ > gas/testsuite/gas/riscv/dis-addr-3-64.d | 12 +++ > gas/testsuite/gas/riscv/dis-addr-3.s | 15 ++++ > 8 files changed, 179 insertions(+) > rename gas/testsuite/gas/riscv/{auipc-x0.d => dis-addr-1.d} (100%) > rename gas/testsuite/gas/riscv/{auipc-x0.s => dis-addr-1.s} (100%) > create mode 100644 gas/testsuite/gas/riscv/dis-addr-2-32.d > create mode 100644 gas/testsuite/gas/riscv/dis-addr-2-64.d > create mode 100644 gas/testsuite/gas/riscv/dis-addr-2.s > create mode 100644 gas/testsuite/gas/riscv/dis-addr-3-32.d > create mode 100644 gas/testsuite/gas/riscv/dis-addr-3-64.d > create mode 100644 gas/testsuite/gas/riscv/dis-addr-3.s > > diff --git a/gas/testsuite/gas/riscv/auipc-x0.d b/gas/testsuite/gas/riscv/dis-addr-1.d > similarity index 100% > rename from gas/testsuite/gas/riscv/auipc-x0.d > rename to gas/testsuite/gas/riscv/dis-addr-1.d > diff --git a/gas/testsuite/gas/riscv/auipc-x0.s b/gas/testsuite/gas/riscv/dis-addr-1.s > similarity index 100% > rename from gas/testsuite/gas/riscv/auipc-x0.s > rename to gas/testsuite/gas/riscv/dis-addr-1.s > diff --git a/gas/testsuite/gas/riscv/dis-addr-2-32.d b/gas/testsuite/gas/riscv/dis-addr-2-32.d > new file mode 100644 > index 00000000000..5117c3d8a0c > --- /dev/null > +++ b/gas/testsuite/gas/riscv/dis-addr-2-32.d > @@ -0,0 +1,31 @@ > +#as: -march=rv32ic > +#source: dis-addr-2.s > +#objdump: -d > + > +.*: file format elf32-(little|big)riscv > + > + > +Disassembly of section .text: > + > +0+000 : > +[ ]+[0-9a-f]+:[ ]+fffff2b7[ ]+lui[ ]+t0,0xfffff > +[ ]+[0-9a-f]+:[ ]+ffc2a903[ ]+lw[ ]+s2,-4\(t0\) # ffffeffc > +[ ]+[0-9a-f]+:[ ]+ffffe337[ ]+lui[ ]+t1,0xffffe > +[ ]+[0-9a-f]+:[ ]+ff332c23[ ]+sw[ ]+s3,-8\(t1\) # ffffdff8 > +[ ]+[0-9a-f]+:[ ]+ffffd3b7[ ]+lui[ ]+t2,0xffffd > +[ ]+[0-9a-f]+:[ ]+000380e7[ ]+jalr[ ]+t2 # ffffd000 > +[ ]+[0-9a-f]+:[ ]+ffffce37[ ]+lui[ ]+t3,0xffffc > +[ ]+[0-9a-f]+:[ ]+ff4e00e7[ ]+jalr[ ]+-12\(t3\) # ffffbff4 > +[ ]+[0-9a-f]+:[ ]+ffffbeb7[ ]+lui[ ]+t4,0xffffb > +[ ]+[0-9a-f]+:[ ]+000e8a67[ ]+jalr[ ]+s4,t4 # ffffb000 > +[ ]+[0-9a-f]+:[ ]+ffffaf37[ ]+lui[ ]+t5,0xffffa > +[ ]+[0-9a-f]+:[ ]+ff0f0a93[ ]+addi[ ]+s5,t5,-16 # ffff9ff0 > +[ ]+[0-9a-f]+:[ ]+ffff9fb7[ ]+lui[ ]+t6,0xffff9 > +[ ]+[0-9a-f]+:[ ]+1fb1[ ]+addi[ ]+t6,t6,-20 # ffff8fec > +[ ]+[0-9a-f]+:[ ]+4001a283[ ]+lw[ ]+t0,1024\(gp\) # 600 > +[ ]+[0-9a-f]+:[ ]+c001a303[ ]+lw[ ]+t1,-1024\(gp\) # fffffe00 > +[ ]+[0-9a-f]+:[ ]+10002383[ ]+lw[ ]+t2,256\(zero\) # 100 > +[ ]+[0-9a-f]+:[ ]+80002e03[ ]+lw[ ]+t3,-2048\(zero\) # fffff800 > +[ ]+[0-9a-f]+:[ ]+10400ee7[ ]+jalr[ ]+t4,260\(zero\) # 104 > +[ ]+[0-9a-f]+:[ ]+80400f67[ ]+jalr[ ]+t5,-2044\(zero\) # fffff804 > +[ ]+[0-9a-f]+:[ ]+fff00f83[ ]+lb[ ]+t6,-1\(zero\) # ffffffff > diff --git a/gas/testsuite/gas/riscv/dis-addr-2-64.d b/gas/testsuite/gas/riscv/dis-addr-2-64.d > new file mode 100644 > index 00000000000..d806bad25b4 > --- /dev/null > +++ b/gas/testsuite/gas/riscv/dis-addr-2-64.d > @@ -0,0 +1,35 @@ > +#as: -march=rv64ic -defsym rv64=1 > +#source: dis-addr-2.s > +#objdump: -d > + > +.*: file format elf64-(little|big)riscv > + > + > +Disassembly of section .text: > + > +0+000 : > +[ ]+[0-9a-f]+:[ ]+fffff2b7[ ]+lui[ ]+t0,0xfffff > +[ ]+[0-9a-f]+:[ ]+ffc2a903[ ]+lw[ ]+s2,-4\(t0\) # ffffffffffffeffc > +[ ]+[0-9a-f]+:[ ]+ffffe337[ ]+lui[ ]+t1,0xffffe > +[ ]+[0-9a-f]+:[ ]+ff332c23[ ]+sw[ ]+s3,-8\(t1\) # ffffffffffffdff8 > +[ ]+[0-9a-f]+:[ ]+ffffd3b7[ ]+lui[ ]+t2,0xffffd > +[ ]+[0-9a-f]+:[ ]+000380e7[ ]+jalr[ ]+t2 # ffffffffffffd000 > +[ ]+[0-9a-f]+:[ ]+ffffce37[ ]+lui[ ]+t3,0xffffc > +[ ]+[0-9a-f]+:[ ]+ff4e00e7[ ]+jalr[ ]+-12\(t3\) # ffffffffffffbff4 > +[ ]+[0-9a-f]+:[ ]+ffffbeb7[ ]+lui[ ]+t4,0xffffb > +[ ]+[0-9a-f]+:[ ]+000e8a67[ ]+jalr[ ]+s4,t4 # ffffffffffffb000 > +[ ]+[0-9a-f]+:[ ]+ffffaf37[ ]+lui[ ]+t5,0xffffa > +[ ]+[0-9a-f]+:[ ]+ff0f0a93[ ]+addi[ ]+s5,t5,-16 # ffffffffffff9ff0 > +[ ]+[0-9a-f]+:[ ]+ffff9fb7[ ]+lui[ ]+t6,0xffff9 > +[ ]+[0-9a-f]+:[ ]+1fb1[ ]+addi[ ]+t6,t6,-20 # ffffffffffff8fec > +[ ]+[0-9a-f]+:[ ]+ffff8b37[ ]+lui[ ]+s6,0xffff8 > +[ ]+[0-9a-f]+:[ ]+fe8b0b9b[ ]+addiw[ ]+s7,s6,-24 # ffffffffffff7fe8 > +[ ]+[0-9a-f]+:[ ]+ffff7c37[ ]+lui[ ]+s8,0xffff7 > +[ ]+[0-9a-f]+:[ ]+3c11[ ]+addiw[ ]+s8,s8,-28 # ffffffffffff6fe4 > +[ ]+[0-9a-f]+:[ ]+4001a283[ ]+lw[ ]+t0,1024\(gp\) # 600 > +[ ]+[0-9a-f]+:[ ]+c001a303[ ]+lw[ ]+t1,-1024\(gp\) # fffffffffffffe00 > +[ ]+[0-9a-f]+:[ ]+10002383[ ]+lw[ ]+t2,256\(zero\) # 100 > +[ ]+[0-9a-f]+:[ ]+80002e03[ ]+lw[ ]+t3,-2048\(zero\) # fffffffffffff800 > +[ ]+[0-9a-f]+:[ ]+10400ee7[ ]+jalr[ ]+t4,260\(zero\) # 104 > +[ ]+[0-9a-f]+:[ ]+80400f67[ ]+jalr[ ]+t5,-2044\(zero\) # fffffffffffff804 > +[ ]+[0-9a-f]+:[ ]+fff00f83[ ]+lb[ ]+t6,-1\(zero\) # ffffffffffffffff > diff --git a/gas/testsuite/gas/riscv/dis-addr-2.s b/gas/testsuite/gas/riscv/dis-addr-2.s > new file mode 100644 > index 00000000000..cb7f0cd9dc2 > --- /dev/null > +++ b/gas/testsuite/gas/riscv/dis-addr-2.s > @@ -0,0 +1,74 @@ > +.set __global_pointer$, 0x00000200 > + > +.ifdef rv64 > +topbase = 0xffffffff00000000 > +.else > +topbase = 0 > +.endif > + > +.set addr_load, topbase + 0xffffeffc # -0x1000 -4 > +.set addr_store, topbase + 0xffffdff8 # -0x2000 -8 > +.set addr_jalr_1, topbase + 0xffffd000 # -0x3000 > +.set addr_jalr_2, topbase + 0xffffbff4 # -0x4000 -12 > +.set addr_jalr_3, topbase + 0xffffb000 # -0x5000 > +.set addr_loadaddr, topbase + 0xffff9ff0 # -0x6000 -16 > +.set addr_loadaddr_c, topbase + 0xffff8fec # -0x7000 -20 > +.set addr_loadaddr_w, topbase + 0xffff7fe8 # -0x8000 -24 > +.set addr_loadaddr_w_c, topbase + 0xffff6fe4 # -0x9000 -28 > +.set addr_rel_gp_pos, 0x00000600 # __global_pointer$ + 0x400 > +.set addr_rel_gp_neg, topbase + 0xfffffe00 # __global_pointer$ - 0x400 > +.set addr_rel_zero_pos, 0x00000100 > +.set addr_rel_zero_neg, topbase + 0xfffff800 # -0x800 > +.set addr_jalr_rel_zero_pos, 0x00000104 # 0x104 > +.set addr_jalr_rel_zero_neg, topbase + 0xfffff804 # -0x7fc > +.set addr_top, topbase + 0xffffffff # -1 > + > +target: > + .option push > + .option arch, -c > + ## Use hi_addr > + # Load > + lui t0, 0xfffff > + lw s2, -4(t0) > + # Store > + lui t1, 0xffffe > + sw s3, -8(t1) > + # JALR (implicit destination, no offset) > + lui t2, 0xffffd > + jalr t2 > + # JALR (implicit destination, with offset) > + lui t3, 0xffffc > + jalr -12(t3) > + # JALR (explicit destination, no offset) > + lui t4, 0xffffb > + jalr s4, t4 > + # ADDI (not compressed) > + lui t5, 0xffffa > + addi s5, t5, -16 > + # C.ADDI > + lui t6, 0xffff9 > + .option pop > + c.addi t6, -20 > +.ifdef rv64 > + .option push > + .option arch, -c > + # ADDIW (not compressed) > + lui s6, 0xffff8 > + addiw s7, s6, -24 > + # C.ADDIW > + lui s8, 0xffff7 > + .option pop > + c.addiw s8, -28 > +.endif > + > + # Use addresses relative to gp > + lw t0, 0x400(gp) > + lw t1, -0x400(gp) > + # Use addresses relative to zero > + lw t2, 0x100(zero) > + lw t3, -0x800(zero) > + jalr t4, 0x104(zero) > + jalr t5, -0x7fc(zero) > + > + # Access to the highest address > + lb t6, -1(zero) > diff --git a/gas/testsuite/gas/riscv/dis-addr-3-32.d b/gas/testsuite/gas/riscv/dis-addr-3-32.d > new file mode 100644 > index 00000000000..42ca89850ac > --- /dev/null > +++ b/gas/testsuite/gas/riscv/dis-addr-3-32.d > @@ -0,0 +1,12 @@ > +#as: -march=rv32i > +#source: dis-addr-3.s > +#objdump: -d > + > +.*: file format elf32-(little|big)riscv > + > + > +Disassembly of section .text: > + > +0+000 : > +[ ]+[0-9a-f]+:[ ]+0051a283[ ]+lw[ ]+t0,5\(gp\) # 4 > +[ ]+[0-9a-f]+:[ ]+ffd1a303[ ]+lw[ ]+t1,-3\(gp\) # fffffffc > diff --git a/gas/testsuite/gas/riscv/dis-addr-3-64.d b/gas/testsuite/gas/riscv/dis-addr-3-64.d > new file mode 100644 > index 00000000000..394c58fac96 > --- /dev/null > +++ b/gas/testsuite/gas/riscv/dis-addr-3-64.d > @@ -0,0 +1,12 @@ > +#as: -march=rv64i -defsym rv64=1 > +#source: dis-addr-3.s > +#objdump: -d > + > +.*: file format elf64-(little|big)riscv > + > + > +Disassembly of section .text: > + > +0+000 : > +[ ]+[0-9a-f]+:[ ]+0051a283[ ]+lw[ ]+t0,5\(gp\) # 4 > +[ ]+[0-9a-f]+:[ ]+ffd1a303[ ]+lw[ ]+t1,-3\(gp\) # fffffffffffffffc > diff --git a/gas/testsuite/gas/riscv/dis-addr-3.s b/gas/testsuite/gas/riscv/dis-addr-3.s > new file mode 100644 > index 00000000000..6ba9fc7a39d > --- /dev/null > +++ b/gas/testsuite/gas/riscv/dis-addr-3.s > @@ -0,0 +1,15 @@ > +.ifdef rv64 > +topbase = 0xffffffff00000000 > +.else > +topbase = 0 > +.endif > + > +.set __global_pointer$, topbase + 0xffffffff # -1 > +.set addr_rel_gp_pos, 0x00000004 # +4 > +.set addr_rel_gp_neg, topbase + 0xfffffffc # -4 > + > +target: > + # Use addresses relative to gp > + # (gp is the highest address) > + lw t0, +5(gp) > + lw t1, -3(gp) > -- > 2.34.1 >