[llvm] 0ae8f5a - [RISCV][test][llvm-objdump] Add test cases for objdump's handling of RISCV arch attributes

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 14 09:07:32 PDT 2023


Author: Alex Bradbury
Date: 2023-03-14T16:05:14Z
New Revision: 0ae8f5ac08ae61519e965808cf72f4f6ff09928d

URL: https://github.com/llvm/llvm-project/commit/0ae8f5ac08ae61519e965808cf72f4f6ff09928d
DIFF: https://github.com/llvm/llvm-project/commit/0ae8f5ac08ae61519e965808cf72f4f6ff09928d.diff

LOG: [RISCV][test][llvm-objdump] Add test cases for objdump's handling of RISCV arch attributes

In preparation for a follow-up patch to adjust the policy. The error for
an unrecognized version of the base ISA is particularly problematic, as
binaries produced from a current GCC are rejected.

The testing approach is modeled on the riscv-attributes.s file in
lld/test/ELF.

Added: 
    llvm/test/tools/llvm-objdump/ELF/RISCV/riscv-attributes.s

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-objdump/ELF/RISCV/riscv-attributes.s b/llvm/test/tools/llvm-objdump/ELF/RISCV/riscv-attributes.s
new file mode 100644
index 0000000000000..7c41b63dcbf86
--- /dev/null
+++ b/llvm/test/tools/llvm-objdump/ELF/RISCV/riscv-attributes.s
@@ -0,0 +1,91 @@
+# RUN: rm -rf %t && split-file %s %t && cd %t
+
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+m,+f,+d,+v noncanonicalized_arch.s -o noncanonicalized_arch.o
+# RUN: llvm-objdump -d noncanonicalized_arch.o | FileCheck %s --check-prefix=NONCANON
+
+# RUN: llvm-mc -filetype=obj -triple=riscv64 invalid_arch.s -o invalid_arch.o
+# RUN: not llvm-objdump -d invalid_arch.o 2>&1 | FileCheck %s --check-prefix=INVALID
+
+# RUN: llvm-mc -filetype=obj -triple=riscv32 unknown_i_version.s -o unknown_i_version.o
+# RUN: not llvm-objdump -d unknown_i_version.o 2>&1 | FileCheck %s --check-prefix=UNKNOWN-I-VERSION
+
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+zicbom unknown_ext_version.s -o unknown_ext_version.o
+# RUN: llvm-objdump -d unknown_ext_version.o 2>&1 | FileCheck %s --check-prefix=UNKNOWN-EXT-VERSION
+
+# RUN: llvm-mc -filetype=obj -triple=riscv64 unknown_ext_name.s -o unknown_ext_name.o
+# RUN: llvm-objdump -d unknown_ext_name.o 2>&1 | FileCheck %s --check-prefix=UNKNOWN-EXT-NAME
+
+#--- noncanonicalized_arch.s
+# NONCANON: vsetvli a3, a2, e8, m8, tu, mu
+vsetvli a3, a2, e8, m8, tu, mu
+
+.section .riscv.attributes,"", at 0x70000003
+.byte 0x41
+.long .Lend-.riscv.attributes-1
+.asciz "riscv"  # vendor
+.Lbegin:
+.byte 1  # Tag_File
+.long .Lend-.Lbegin
+.byte 5  # Tag_RISCV_arch
+.asciz "rv64gcv"
+.Lend:
+
+#--- invalid_arch.s
+# INVALID: string must begin with rv32{i,e,g} or rv64{i,g} 
+nop
+
+.section .riscv.attributes,"", at 0x70000003
+.byte 0x41
+.long .Lend-.riscv.attributes-1
+.asciz "riscv"  # vendor
+.Lbegin:
+.byte 1  # Tag_File
+.long .Lend-.Lbegin
+.byte 5  # Tag_RISCV_arch
+.asciz "nonsense"
+.Lend:
+
+#--- unknown_i_version.s
+# UNKNOWN-I-VERSION: unsupported version number 99.99 for extension 'i'
+nop
+
+.section .riscv.attributes,"", at 0x70000003
+.byte 0x41
+.long .Lend-.riscv.attributes-1
+.asciz "riscv"  # vendor
+.Lbegin:
+.byte 1  # Tag_File
+.long .Lend-.Lbegin
+.byte 5  # Tag_RISCV_arch
+.asciz "rv32i99p99"
+.Lend:
+
+#--- unknown_ext_version.s
+# UNKNOWN-EXT-VERSION: <unknown>
+cbo.clean (t0)
+
+.section .riscv.attributes,"", at 0x70000003
+.byte 0x41
+.long .Lend-.riscv.attributes-1
+.asciz "riscv"  # vendor
+.Lbegin:
+.byte 1  # Tag_File
+.long .Lend-.Lbegin
+.byte 5  # Tag_RISCV_arch
+.asciz "rv32i2p0_zicbom0p1"
+.Lend:
+
+#--- unknown_ext_name.s
+# UNKNOWN-EXT-NAME: nop
+nop
+
+.section .riscv.attributes,"", at 0x70000003
+.byte 0x41
+.long .Lend-.riscv.attributes-1
+.asciz "riscv"  # vendor
+.Lbegin:
+.byte 1  # Tag_File
+.long .Lend-.Lbegin
+.byte 5  # Tag_RISCV_arch
+.asciz "rv32i2p0_zmadeup1p0_smadeup1p0_xmadeup1p0_sxmadeup1p0"
+.Lend:


        


More information about the llvm-commits mailing list