Skip to content

Commit e024229

Browse files
asbtru
authored andcommitted
[lld][RISCV][test] Expand testing in riscv-attributes.s
This patch is related to the discussion in <https://discourse.llvm.org/t/rfc-resolving-issues-related-to-extension-versioning-in-risc-v/68472/1>. It slightly expands the coverage of behaviour for unrecognized extensions (there are slightly different forms of error for zfoo vs e.g. 'y'), and adds coverage for an extension with an unrecognized/unsupported version number. Use "unrecognized" terminology because the expectation is the error checking will be reduced in a follow-up patch posted for review. (cherry picked from commit 8b50048)
1 parent e3ce92b commit e024229

File tree

1 file changed

+36
-4
lines changed

1 file changed

+36
-4
lines changed

lld/test/ELF/riscv-attributes.s

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@
1414
# RUN: ld.lld a.o b.o c.o -o out2
1515
# RUN: llvm-readobj --arch-specific out2 | FileCheck %s --check-prefix=CHECK2
1616

17-
# RUN: llvm-mc -filetype=obj -triple=riscv64 invalid_ext.s -o invalid_ext.o
18-
# RUN: not ld.lld invalid_ext.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=INVALID_EXT --implicit-check-not=error:
19-
# INVALID_EXT: error: invalid_ext.o:(.riscv.attributes): rv64i2p0_y2p0: invalid standard user-level extension 'y'
17+
# RUN: llvm-mc -filetype=obj -triple=riscv64 unrecognized_ext1.s -o unrecognized_ext1.o
18+
# RUN: not ld.lld unrecognized_ext1.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNRECOGNIZED_EXT1 --implicit-check-not=error:
19+
# UNRECOGNIZED_EXT1: error: unrecognized_ext1.o:(.riscv.attributes): rv64i2p0_y2p0: invalid standard user-level extension 'y'
20+
21+
# RUN: llvm-mc -filetype=obj -triple=riscv64 unrecognized_ext2.s -o unrecognized_ext2.o
22+
# RUN: not ld.lld unrecognized_ext2.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNRECOGNIZED_EXT2 --implicit-check-not=error:
23+
# UNRECOGNIZED_EXT2: error: unrecognized_ext2.o:(.riscv.attributes): rv64i2p0_zmadeup1p0: unsupported version number 1.0 for extension 'zmadeup'
24+
25+
# RUN: llvm-mc -filetype=obj -triple=riscv64 unrecognized_version.s -o unrecognized_version.o
26+
# RUN: not ld.lld unrecognized_version.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNRECOGNIZED_VERSION --implicit-check-not=error:
27+
# UNRECOGNIZED_VERSION: error: unrecognized_version.o:(.riscv.attributes): rv64i99p0: unsupported version number 99.0 for extension 'i'
2028

2129
## A zero value attribute is not printed.
2230
# RUN: llvm-mc -filetype=obj -triple=riscv64 unaligned_access_0.s -o unaligned_access_0.o
@@ -127,7 +135,7 @@
127135
.attribute priv_spec, 2
128136
.attribute priv_spec_minor, 2
129137

130-
#--- invalid_ext.s
138+
#--- unrecognized_ext1.s
131139
.section .riscv.attributes,"",@0x70000003
132140
.byte 0x41
133141
.long .Lend-.riscv.attributes-1
@@ -139,6 +147,30 @@
139147
.asciz "rv64i2p0_y2p0"
140148
.Lend:
141149

150+
#--- unrecognized_ext2.s
151+
.section .riscv.attributes,"",@0x70000003
152+
.byte 0x41
153+
.long .Lend-.riscv.attributes-1
154+
.asciz "riscv" # vendor
155+
.Lbegin:
156+
.byte 1 # Tag_File
157+
.long .Lend-.Lbegin
158+
.byte 5 # Tag_RISCV_arch
159+
.asciz "rv64i2p0_zmadeup1p0"
160+
.Lend:
161+
162+
#--- unrecognized_version.s
163+
.section .riscv.attributes,"",@0x70000003
164+
.byte 0x41
165+
.long .Lend-.riscv.attributes-1
166+
.asciz "riscv" # vendor
167+
.Lbegin:
168+
.byte 1 # Tag_File
169+
.long .Lend-.Lbegin
170+
.byte 5 # Tag_RISCV_arch
171+
.asciz "rv64i99p0"
172+
.Lend:
173+
142174
#--- unaligned_access_0.s
143175
.attribute unaligned_access, 0
144176

0 commit comments

Comments
 (0)