[PATCH] D112032: [RISCV] Use a lambda to avoid having the Support library depend on Option library.

Craig Topper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 18 13:44:12 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1053e0b27ce1: [RISCV] Use a lambda to avoid having the Support library depend on Option… (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112032/new/

https://reviews.llvm.org/D112032

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp


Index: llvm/lib/Support/RISCVISAInfo.cpp
===================================================================
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -11,7 +11,6 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Option/ArgList.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_ostream.h"
@@ -252,8 +251,9 @@
   return LHS < RHS;
 }
 
-void RISCVISAInfo::toFeatures(const llvm::opt::ArgList &Args,
-                              std::vector<StringRef> &Features) const {
+void RISCVISAInfo::toFeatures(
+    std::vector<StringRef> &Features,
+    std::function<StringRef(const Twine &)> StrAlloc) const {
   for (auto &Ext : Exts) {
     StringRef ExtName = Ext.first;
 
@@ -268,9 +268,9 @@
       Features.push_back("+experimental-zvlsseg");
       Features.push_back("+experimental-zvamo");
     } else if (isExperimentalExtension(ExtName)) {
-      Features.push_back(Args.MakeArgString("+experimental-" + ExtName));
+      Features.push_back(StrAlloc("+experimental-" + ExtName));
     } else {
-      Features.push_back(Args.MakeArgString("+" + ExtName));
+      Features.push_back(StrAlloc("+" + ExtName));
     }
   }
 }
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===================================================================
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -19,9 +19,6 @@
 #include <vector>
 
 namespace llvm {
-namespace opt {
-class ArgList;
-}
 struct RISCVExtensionInfo {
   std::string ExtName;
   unsigned MajorVersion;
@@ -57,8 +54,8 @@
   parseFeatures(unsigned XLen, const std::vector<std::string> &Features);
 
   /// Convert RISCV ISA info to a feature vector.
-  void toFeatures(const llvm::opt::ArgList &Args,
-                  std::vector<StringRef> &Features) const;
+  void toFeatures(std::vector<StringRef> &Features,
+                  std::function<StringRef(const Twine &)> StrAlloc) const;
 
   const OrderedExtensionMap &getExtensions() const { return Exts; };
 
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -41,7 +41,8 @@
     return false;
   }
 
-  (*ISAInfo)->toFeatures(Args, Features);
+  (*ISAInfo)->toFeatures(
+      Features, [&Args](const Twine &Str) { return Args.MakeArgString(Str); });
   return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112032.380513.patch
Type: text/x-patch
Size: 2548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211018/21a8b1fd/attachment.bin>


More information about the cfe-commits mailing list