[llvm] [RISCV] Introduce a new tune feature string syntax and its parser (PR #168160)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 20 22:58:03 PST 2025


================
@@ -47,13 +48,32 @@ struct CPUInfo {
   bool is64Bit() const { return DefaultMarch.starts_with("rv64"); }
 };
 
+/// Fatal errors encountered during parsing.
+struct ParserError : public ErrorInfo<ParserError, StringError> {
+  using ErrorInfo<ParserError, StringError>::ErrorInfo;
+  explicit ParserError(const Twine &S)
+      : ErrorInfo(S, inconvertibleErrorCode()) {}
+  static char ID;
+};
+
+/// Warnings encountered during parsing.
+struct ParserWarning : public ErrorInfo<ParserWarning, StringError> {
+  using ErrorInfo<ParserWarning, StringError>::ErrorInfo;
+  explicit ParserWarning(const Twine &S)
+      : ErrorInfo(S, inconvertibleErrorCode()) {}
+  static char ID;
+};
+
 // We use 64 bits as the known part in the scalable vector types.
 static constexpr unsigned RVVBitsPerBlock = 64;
 static constexpr unsigned RVVBytesPerBlock = RVVBitsPerBlock / 8;
 
 LLVM_ABI void getFeaturesForCPU(StringRef CPU,
                                 SmallVectorImpl<std::string> &EnabledFeatures,
                                 bool NeedPlus = false);
+LLVM_ABI void getAllTuneFeatures(SmallVectorImpl<StringRef> &TuneFeatures);
----------------
lenary wrote:

We might want to hook this up to a clang option, eventually. Right now, `clang --target=riscv32 -mtune=help` just prints a list of known CPUs. This can be a follow-up.

We might also want something akin to clang's `clang --target=riscv64 --print-enabled-extensions`, which is focussed on architecture extensions rather than tuning parameters. 

https://github.com/llvm/llvm-project/pull/168160


More information about the llvm-commits mailing list