Skip to content

Commit c3b160b

Browse files
authored
[RISCV] Remove -mattr=+no-rvc-hints (#145138)
As far as I know binutils does not have a similar option and I don't know of a reason we shouldn't accept the RVC hint instructions. The wording in the spec in the past suggested that maybe these weren't valid instruction names, but that's been modified recently.
1 parent 2dfcc30 commit c3b160b

File tree

8 files changed

+10
-92
lines changed

8 files changed

+10
-92
lines changed

llvm/docs/ReleaseNotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Changes to the RISC-V Backend
212212
* `-mtune=andes-45-series` was added.
213213
* Adds assembler support for the Andes `XAndesvbfhcvt` (Andes Vector BFLOAT16 Conversion extension).
214214
* `-mcpu=andes-ax45mpv` was added.
215+
* Removed -mattr=+no-rvc-hints that could be used to disable parsing and generation of RVC hints.
215216

216217
Changes to the WebAssembly Backend
217218
----------------------------------

llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void RISCVAsmPrinter::emitNTLHint(const MachineInstr *MI) {
292292
NontemporalMode += 0b10;
293293

294294
MCInst Hint;
295-
if (STI->hasStdExtZca() && STI->enableRVCHintInstrs())
295+
if (STI->hasStdExtZca())
296296
Hint.setOpcode(RISCV::C_ADD_HINT);
297297
else
298298
Hint.setOpcode(RISCV::ADD);

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,6 @@ def HasStdExtZhinx : Predicate<"Subtarget->hasStdExtZhinx()">,
373373
def NoStdExtZhinx : Predicate<"!Subtarget->hasStdExtZhinx()">;
374374

375375
// Compressed Extensions
376-
def FeatureNoRVCHints
377-
: SubtargetFeature<"no-rvc-hints", "EnableRVCHintInstrs", "false",
378-
"Disable RVC Hint Instructions.">;
379-
def HasRVCHints : Predicate<"Subtarget->enableRVCHintInstrs()">,
380-
AssemblerPredicate<(all_of(not FeatureNoRVCHints)),
381-
"RVC Hint Instructions">;
382-
383376
def FeatureStdExtZca
384377
: RISCVExtension<1, 0,
385378
"part of the C extension, excluding compressed "

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ unsigned RISCVInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
17261726
if (!MI.memoperands_empty()) {
17271727
MachineMemOperand *MMO = *(MI.memoperands_begin());
17281728
if (STI.hasStdExtZihintntl() && MMO->isNonTemporal()) {
1729-
if (STI.hasStdExtZca() && STI.enableRVCHintInstrs()) {
1729+
if (STI.hasStdExtZca()) {
17301730
if (isCompressibleInst(MI, STI))
17311731
return 4; // c.ntl.all + c.load/c.store
17321732
return 6; // c.ntl.all + load/store

llvm/lib/Target/RISCV/RISCVInstrInfoC.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ def C_UNIMP : RVInst16<(outs), (ins), "c.unimp", "", [], InstFormatOther>,
608608
// HINT Instructions
609609
//===----------------------------------------------------------------------===//
610610

611-
let Predicates = [HasStdExtZca, HasRVCHints], hasSideEffects = 0, mayLoad = 0,
611+
let Predicates = [HasStdExtZca], hasSideEffects = 0, mayLoad = 0,
612612
mayStore = 0 in {
613613

614614
def C_NOP_HINT : RVInst16CI<0b000, 0b01, (outs), (ins simm6nonzero:$imm),
@@ -691,24 +691,24 @@ def C_SRAI64_HINT : RVInst16CB<0b100, 0b01, (outs GPRC:$rd),
691691
let Inst{12} = 0;
692692
}
693693

694-
} // Predicates = [HasStdExtZca, HasRVCHints], hasSideEffects = 0, mayLoad = 0,
694+
} // Predicates = [HasStdExtZca], hasSideEffects = 0, mayLoad = 0,
695695
// mayStore = 0
696696

697697
//===----------------------------------------------------------------------===//
698698
// Assembler Pseudo Instructions
699699
//===----------------------------------------------------------------------===//
700700

701-
let Predicates = [HasStdExtZca, HasRVCHints] in {
701+
let Predicates = [HasStdExtZca] in {
702702
// Just a different syntax for the c.nop hint: c.addi x0, simm6 vs c.nop simm6.
703703
def : InstAlias<"c.addi x0, $imm", (C_NOP_HINT simm6nonzero:$imm), 0>;
704704
}
705705

706-
let Predicates = [HasStdExtC, HasRVCHints, HasStdExtZihintntl] in {
706+
let Predicates = [HasStdExtC, HasStdExtZihintntl] in {
707707
def : InstAlias<"c.ntl.p1", (C_ADD_HINT X0, X2)>;
708708
def : InstAlias<"c.ntl.pall", (C_ADD_HINT X0, X3)>;
709709
def : InstAlias<"c.ntl.s1", (C_ADD_HINT X0, X4)>;
710710
def : InstAlias<"c.ntl.all", (C_ADD_HINT X0, X5)>;
711-
} // Predicates = [HasStdExtC, HasRVCHints, HasStdExtZihintntl]
711+
} // Predicates = [HasStdExtC, HasStdExtZihintntl]
712712

713713
let EmitPriority = 0 in {
714714
let Predicates = [HasStdExtZca] in {

llvm/test/CodeGen/RISCV/features-info.ll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
; CHECK-NEXT: m - 'M' (Integer Multiplication and Division).
6262
; CHECK-NEXT: mips-p8700 - MIPS p8700 processor.
6363
; CHECK-NEXT: no-default-unroll - Disable default unroll preference..
64-
; CHECK-NEXT: no-rvc-hints - Disable RVC Hint Instructions..
6564
; CHECK-NEXT: no-sink-splat-operands - Disable sink splat operands to enable .vx, .vf,.wx, and .wf instructions.
6665
; CHECK-NEXT: no-trailing-seq-cst-fence - Disable trailing fence for seq-cst store..
6766
; CHECK-NEXT: optimized-nf2-segment-load-store - vlseg2eN.v and vsseg2eN.v are implemented as a wide memory op and shuffle.

llvm/test/MC/Disassembler/RISCV/c_lui_disasm.txt

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,265 +10,197 @@
1010
# RUN: llvm-mc --disassemble -triple=riscv32 -mattr=+c -mattr=+Zcmop \
1111
# RUN: -M no-aliases --show-encoding < %s | \
1212
# RUN: FileCheck --check-prefixes=GOOD,MOP %s
13-
#
14-
# RUN: llvm-mc --disassemble -triple=riscv32 -mattr=+c -mattr=+no-rvc-hints \
15-
# RUN: -M no-aliases --show-encoding < %s 2>&1 | \
16-
# RUN: FileCheck --check-prefix=NOHINTS %s
1713

1814
# BAD: invalid instruction encoding
19-
# NOHINTS: invalid instruction encoding
2015
0x01 0x60
2116

2217
# GOOD: c.lui zero, 1
23-
# NOHINTS: invalid instruction encoding
2418
0x05 0x60
2519

2620
# GOOD: c.lui zero, 2
27-
# NOHINTS: invalid instruction encoding
2821
0x09 0x60
2922

3023
# GOOD: c.lui zero, 3
31-
# NOHINTS: invalid instruction encoding
3224
0x0D 0x60
3325

3426
# GOOD: c.lui zero, 4
35-
# NOHINTS: invalid instruction encoding
3627
0x11 0x060
3728

3829
# GOOD: c.lui zero, 5
39-
# NOHINTS: invalid instruction encoding
4030
0x15 0x60
4131

4232
# GOOD: c.lui zero, 6
43-
# NOHINTS: invalid instruction encoding
4433
0x19 0x60
4534

4635
# GOOD: c.lui zero, 7
47-
# NOHINTS: invalid instruction encoding
4836
0x1D 0x60
4937

5038
# GOOD: c.lui zero, 8
51-
# NOHINTS: invalid instruction encoding
5239
0x21 0x60
5340

5441
# GOOD: c.lui zero, 9
55-
# NOHINTS: invalid instruction encoding
5642
0x25 0x60
5743

5844
# GOOD: c.lui zero, 10
59-
# NOHINTS: invalid instruction encoding
6045
0x29 0x60
6146

6247
# GOOD: c.lui zero, 11
63-
# NOHINTS: invalid instruction encoding
6448
0x2D 0x60
6549

6650
# GOOD: c.lui zero, 12
67-
# NOHINTS: invalid instruction encoding
6851
0x31 0x60
6952

7053
# GOOD: c.lui zero, 13
71-
# NOHINTS: invalid instruction encoding
7254
0x35 0x60
7355

7456
# GOOD: c.lui zero, 14
75-
# NOHINTS: invalid instruction encoding
7657
0x39 0x60
7758

7859
# GOOD: c.lui zero, 15
79-
# NOHINTS: invalid instruction encoding
8060
0x3D 0x60
8161

8262
# GOOD: c.lui zero, 16
83-
# NOHINTS: invalid instruction encoding
8463
0x41 0x60
8564

8665
# GOOD: c.lui zero, 17
87-
# NOHINTS: invalid instruction encoding
8866
0x45 0x60
8967

9068
# GOOD: c.lui zero, 18
91-
# NOHINTS: invalid instruction encoding
9269
0x49 0x60
9370

9471
# GOOD: c.lui zero, 19
95-
# NOHINTS: invalid instruction encoding
9672
0x4D 0x60
9773

9874
# GOOD: c.lui zero, 20
99-
# NOHINTS: invalid instruction encoding
10075
0x51 0x60
10176

10277
# GOOD: c.lui zero, 21
103-
# NOHINTS: invalid instruction encoding
10478
0x55 0x60
10579

10680
# GOOD: c.lui zero, 22
107-
# NOHINTS: invalid instruction encoding
10881
0x59 0x60
10982

11083
# GOOD: c.lui zero, 23
111-
# NOHINTS: invalid instruction encoding
11284
0x5D 0x60
11385

11486
# GOOD: c.lui zero, 24
115-
# NOHINTS: invalid instruction encoding
11687
0x61 0x60
11788

11889
# GOOD: c.lui zero, 25
119-
# NOHINTS: invalid instruction encoding
12090
0x65 0x60
12191

12292
# GOOD: c.lui zero, 26
123-
# NOHINTS: invalid instruction encoding
12493
0x69 0x60
12594

12695
# GOOD: c.lui zero, 27
127-
# NOHINTS: invalid instruction encoding
12896
0x6D 0x60
12997

13098
# GOOD: c.lui zero, 28
131-
# NOHINTS: invalid instruction encoding
13299
0x71 0x60
133100

134101
# GOOD: c.lui zero, 29
135-
# NOHINTS: invalid instruction encoding
136102
0x75 0x60
137103

138104
# GOOD: c.lui zero, 30
139-
# NOHINTS: invalid instruction encoding
140105
0x79 0x60
141106

142107
# GOOD: c.lui zero, 31
143-
# NOHINTS: invalid instruction encoding
144108
0x7D 0x60
145109

146110
# GOOD: c.lui zero, 1048544
147-
# NOHINTS: invalid instruction encoding
148111
0x01 0x70
149112

150113
# GOOD: c.lui zero, 1048545
151-
# NOHINTS: invalid instruction encoding
152114
0x05 0x70
153115

154116
# GOOD: c.lui zero, 1048546
155-
# NOHINTS: invalid instruction encoding
156117
0x09 0x70
157118

158119
# GOOD: c.lui zero, 1048547
159-
# NOHINTS: invalid instruction encoding
160120
0x0D 0x70
161121

162122
# GOOD: c.lui zero, 1048548
163-
# NOHINTS: invalid instruction encoding
164123
0x11 0x70
165124

166125
# GOOD: c.lui zero, 1048549
167-
# NOHINTS: invalid instruction encoding
168126
0x15 0x70
169127

170128
# GOOD: c.lui zero, 1048550
171-
# NOHINTS: invalid instruction encoding
172129
0x19 0x70
173130

174131
# GOOD: c.lui zero, 1048551
175-
# NOHINTS: invalid instruction encoding
176132
0x1D 0x70
177133

178134
# GOOD: c.lui zero, 1048552
179-
# NOHINTS: invalid instruction encoding
180135
0x21 0x70
181136

182137
# GOOD: c.lui zero, 1048553
183-
# NOHINTS: invalid instruction encoding
184138
0x25 0x70
185139

186140
# GOOD: c.lui zero, 1048554
187-
# NOHINTS: invalid instruction encoding
188141
0x29 0x70
189142

190143
# GOOD: c.lui zero, 1048555
191-
# NOHINTS: invalid instruction encoding
192144
0x2D 0x70
193145

194146
# GOOD: c.lui zero, 1048556
195-
# NOHINTS: invalid instruction encoding
196147
0x31 0x70
197148

198149
# GOOD: c.lui zero, 1048557
199-
# NOHINTS: invalid instruction encoding
200150
0x35 0x70
201151

202152
# GOOD: c.lui zero, 1048558
203-
# NOHINTS: invalid instruction encoding
204153
0x39 0x70
205154

206155
# GOOD: c.lui zero, 1048559
207-
# NOHINTS: invalid instruction encoding
208156
0x3D 0x70
209157

210158
# GOOD: c.lui zero, 1048560
211-
# NOHINTS: invalid instruction encoding
212159
0x41 0x70
213160

214161
# GOOD: c.lui zero, 1048561
215-
# NOHINTS: invalid instruction encoding
216162
0x45 0x70
217163

218164
# GOOD: c.lui zero, 1048562
219-
# NOHINTS: invalid instruction encoding
220165
0x49 0x70
221166

222167
# GOOD: c.lui zero, 1048563
223-
# NOHINTS: invalid instruction encoding
224168
0x4D 0x70
225169

226170
# GOOD: c.lui zero, 1048564
227-
# NOHINTS: invalid instruction encoding
228171
0x51 0x70
229172

230173
# GOOD: c.lui zero, 1048565
231-
# NOHINTS: invalid instruction encoding
232174
0x55 0x70
233175

234176
# GOOD: c.lui zero, 1048566
235-
# NOHINTS: invalid instruction encoding
236177
0x59 0x70
237178

238179
# GOOD: c.lui zero, 1048567
239-
# NOHINTS: invalid instruction encoding
240180
0x5D 0x70
241181

242182
# GOOD: c.lui zero, 1048568
243-
# NOHINTS: invalid instruction encoding
244183
0x61 0x70
245184

246185
# GOOD: c.lui zero, 1048569
247-
# NOHINTS: invalid instruction encoding
248186
0x65 0x70
249187

250188
# GOOD: c.lui zero, 1048570
251-
# NOHINTS: invalid instruction encoding
252189
0x69 0x70
253190

254191
# GOOD: c.lui zero, 1048571
255-
# NOHINTS: invalid instruction encoding
256192
0x6D 0x70
257193

258194
# GOOD: c.lui zero, 1048572
259-
# NOHINTS: invalid instruction encoding
260195
0x71 0x70
261196

262197
# GOOD: c.lui zero, 1048573
263-
# NOHINTS: invalid instruction encoding
264198
0x75 0x70
265199

266200
# GOOD: c.lui zero, 1048574
267-
# NOHINTS: invalid instruction encoding
268201
0x79 0x70
269202

270203
# GOOD: c.lui zero, 1048575
271-
# NOHINTS: invalid instruction encoding
272204
0x7D 0x70
273205

274206
# BAD: invalid instruction encoding

llvm/test/MC/RISCV/rv32c-invalid.s

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# RUN: not llvm-mc -triple=riscv32 -mattr=+c -mattr=+no-rvc-hints < %s 2>&1 \
1+
# RUN: not llvm-mc -triple=riscv32 -mattr=+c < %s 2>&1 \
22
# RUN: | FileCheck %s
3-
# RUN: not llvm-mc -triple=riscv32 -mattr=+zca -mattr=+no-rvc-hints < %s 2>&1 \
3+
# RUN: not llvm-mc -triple=riscv32 -mattr=+zca < %s 2>&1 \
44
# RUN: | FileCheck %s
55

66
## GPRC
@@ -23,16 +23,10 @@ c.lwsp x0, 4(sp) # CHECK: :[[@LINE]]:9: error: register must be a GPR excluding
2323
c.lwsp zero, 4(sp) # CHECK: :[[@LINE]]:9: error: register must be a GPR excluding zero (x0)
2424
c.jr x0 # CHECK: :[[@LINE]]:7: error: register must be a GPR excluding zero (x0)
2525
c.jalr zero # CHECK: :[[@LINE]]:9: error: register must be a GPR excluding zero (x0)
26-
c.addi x0, x0, 1 # CHECK: :[[@LINE]]:13: error: immediate must be zero
27-
c.li zero, 2 # CHECK: :[[@LINE]]:1: error: instruction requires the following: RVC Hint Instructions{{$}}
28-
c.slli zero, zero, 4 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
29-
c.mv zero, s0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: RVC Hint Instructions{{$}}
3026
c.mv ra, x0 # CHECK: :[[@LINE]]:11: error: register must be a GPR excluding zero (x0)
3127
c.add ra, ra, x0 # CHECK: :[[@LINE]]:16: error: invalid operand for instruction
32-
c.add zero, zero, sp # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
3328

3429
## GPRNoX0X2
35-
c.lui x0, 4 # CHECK: :[[@LINE]]:1: error: instruction requires the following: RVC Hint Instructions{{$}}
3630
c.lui x2, 4 # CHECK: :[[@LINE]]:7: error: register must be a GPR excluding zero (x0) and sp (x2){{$}}
3731

3832
## SP
@@ -57,7 +51,6 @@ c.andi a0, %lo(foo) # CHECK: :[[@LINE]]:12: error: immediate must be an integer
5751
c.andi a0, %hi(foo) # CHECK: :[[@LINE]]:12: error: immediate must be an integer in the range [-32, 31]
5852

5953
## simm6nonzero
60-
c.addi t0, 0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: RVC Hint Instructions{{$}}
6154
c.addi t0, -33 # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31]
6255
c.addi t0, 32 # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31]
6356
c.addi t0, foo # CHECK: :[[@LINE]]:12: error: immediate must be non-zero in the range [-32, 31]

0 commit comments

Comments
 (0)