From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id E21AE3856955 for ; Fri, 29 Jul 2022 13:11:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E21AE3856955 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 3937D30008A; Fri, 29 Jul 2022 13:11:27 +0000 (UTC) From: Tsukasa OI To: Tsukasa OI , "H . Peter Anvin" , Nelson Chu , Kito Cheng , Palmer Dabbelt Cc: binutils@sourceware.org Subject: [PATCH 3/3] RISC-V: Add address printer tests on disassembler Date: Fri, 29 Jul 2022 22:10:36 +0900 Message-Id: In-Reply-To: References: Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2022 13:11:30 -0000 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 and whether the highest address is printed with a symbol. gas/ChangeLog: * testsuite/gas/riscv/dis-addr-1.s: New address printer tests on the disassembler. * testsuite/gas/riscv/dis-addr-1-32.d: Likewise. * testsuite/gas/riscv/dis-addr-1-64.d: Likewise. --- gas/testsuite/gas/riscv/dis-addr-1-32.d | 29 ++++++++++ gas/testsuite/gas/riscv/dis-addr-1-64.d | 33 ++++++++++++ gas/testsuite/gas/riscv/dis-addr-1.s | 70 +++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 gas/testsuite/gas/riscv/dis-addr-1-32.d create mode 100644 gas/testsuite/gas/riscv/dis-addr-1-64.d create mode 100644 gas/testsuite/gas/riscv/dis-addr-1.s diff --git a/gas/testsuite/gas/riscv/dis-addr-1-32.d b/gas/testsuite/gas/riscv/dis-addr-1-32.d new file mode 100644 index 00000000000..457e6e12600 --- /dev/null +++ b/gas/testsuite/gas/riscv/dis-addr-1-32.d @@ -0,0 +1,29 @@ +#as: -march=rv32ic +#source: dis-addr-1.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]+:[ ]+fff00e83[ ]+lb[ ]+t4,-1\(zero\) # ffffffff diff --git a/gas/testsuite/gas/riscv/dis-addr-1-64.d b/gas/testsuite/gas/riscv/dis-addr-1-64.d new file mode 100644 index 00000000000..78b03575c8c --- /dev/null +++ b/gas/testsuite/gas/riscv/dis-addr-1-64.d @@ -0,0 +1,33 @@ +#as: -march=rv64ic -defsym rv64=1 +#source: dis-addr-1.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]+:[ ]+fff00e83[ ]+lb[ ]+t4,-1\(zero\) # ffffffffffffffff diff --git a/gas/testsuite/gas/riscv/dis-addr-1.s b/gas/testsuite/gas/riscv/dis-addr-1.s new file mode 100644 index 00000000000..492573be9bf --- /dev/null +++ b/gas/testsuite/gas/riscv/dis-addr-1.s @@ -0,0 +1,70 @@ +.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_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) + + # Access the highest address + lb t4, -1(zero) -- 2.34.1