Skip to content

Commit 321cd52

Browse files
committed
Update: [RISCV][MC] Add support for experimental zfa extension(FLI instruction not included)
1 parent 54c136e commit 321cd52

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

llvm/docs/RISCVUsage.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ The primary goal of experimental support is to assist in the process of ratifica
163163
``experimental-zvfh``
164164
LLVM implements `this draft text <https://github.com/riscv/riscv-v-spec/pull/780>`_.
165165

166+
``experimental-zfa``
167+
LLVM implements a subset of `0.1 draft specification <https://github.com/riscv/riscv-isa-manual/releases/download/draft-20221119-5234c63/riscv-spec.pdf>`_ (see Chapter 25). Load-immediate instructions (fli.s/fli.d/fli.h) haven't been implemented yet.
168+
166169
To use an experimental extension from `clang`, you must add `-menable-experimental-extensions` to the command line, and specify the exact version of the experimental extension you are using. To use an experimental extension with LLVM's internal developer tools (e.g. `llc`, `llvm-objdump`, `llvm-mc`), you must prefix the extension name with `experimental-`. Note that you don't need to specify the version with internal tools, and shouldn't include the `experimental-` prefix with `clang`.
167170

168171
Vendor Extensions

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
483483

484484
/// Return true if the operand is a valid floating point rounding mode.
485485
bool isFRMArg() const { return Kind == KindTy::FRM; }
486+
bool isRTZArg() const { return isFRMArg() && FRM.FRM == RISCVFPRndMode::RTZ; }
486487

487488
bool isImmXLenLI() const {
488489
int64_t Imm;
@@ -1253,6 +1254,10 @@ bool RISCVAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
12531254
SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc();
12541255
return Error(ErrorLoc, "operand must be a symbol with %tprel_add modifier");
12551256
}
1257+
case Match_InvalidRTZArg: {
1258+
SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc();
1259+
return Error(ErrorLoc, "operand must be 'rtz' floating-point rounding mode");
1260+
}
12561261
case Match_InvalidVTypeI: {
12571262
SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc();
12581263
return Error(

llvm/lib/Target/RISCV/RISCVFeatures.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ def HasStdExtZhinxOrZhinxmin
131131
"'Zhinx' (Half Float in Integer) or "
132132
"'Zhinxmin' (Half Float in Integer Minimal)">;
133133

134+
def FeatureStdExtZfa
135+
: SubtargetFeature<"experimental-zfa", "HasStdExtZfa", "true",
136+
"'Zfa' (Additional Floating-Point)",
137+
[FeatureStdExtF]>;
138+
def HasStdExtZfa : Predicate<"Subtarget->hasStdExtZfa()">,
139+
AssemblerPredicate<(all_of FeatureStdExtZfa),
140+
"'Zfa' (Additional Floating-Point)">;
141+
134142
def FeatureStdExtC
135143
: SubtargetFeature<"c", "HasStdExtC", "true",
136144
"'C' (Compressed Instructions)">;

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,7 @@ include "RISCVInstrInfoZb.td"
18831883
include "RISCVInstrInfoZc.td"
18841884
include "RISCVInstrInfoZk.td"
18851885
include "RISCVInstrInfoV.td"
1886+
include "RISCVInstrInfoZfa.td"
18861887
include "RISCVInstrInfoZfh.td"
18871888
include "RISCVInstrInfoZicbo.td"
18881889

0 commit comments

Comments
 (0)