[PATCH] D112032: [RISCV] Use a lambda to avoid having the Support library depend on Option library.
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 , - std::vector ) const { +void RISCVISAInfo::toFeatures( +std::vector , +std::function StrAlloc) const { for (auto : 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 namespace llvm { -namespace opt { -class ArgList; -} struct RISCVExtensionInfo { std::string ExtName; unsigned MajorVersion; @@ -57,8 +54,8 @@ parseFeatures(unsigned XLen, const std::vector ); /// Convert RISCV ISA info to a feature vector. - void toFeatures(const llvm::opt::ArgList , - std::vector ) const; + void toFeatures(std::vector , + std::function StrAlloc) const; const OrderedExtensionMap () 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, [](const Twine ) { return Args.MakeArgString(Str); }); return true; } 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 , - std::vector ) const { +void RISCVISAInfo::toFeatures( +std::vector , +std::function StrAlloc) const { for (auto : 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 namespace llvm { -namespace opt { -class ArgList; -} struct RISCVExtensionInfo { std::string ExtName; unsigned MajorVersion; @@ -57,8 +54,8 @@ parseFeatures(unsigned XLen, const std::vector ); /// Convert RISCV ISA info to a feature vector. - void toFeatures(const llvm::opt::ArgList , - std::vector ) const; + void toFeatures(std::vector , + std::function StrAlloc) const; const OrderedExtensionMap () const { return Exts; }; Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp === --- clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++
[PATCH] D112032: [RISCV] Use a lambda to avoid having the Support library depend on Option library.
craig.topper created this revision. craig.topper added reviewers: jrtc27, kito-cheng, HsiangKai, khchen, arcbbb. Herald added subscribers: achieveartificialintelligence, StephenFan, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya. craig.topper requested review of this revision. Herald added a subscriber: MaskRay. Herald added projects: clang, LLVM. RISCVISAInfo::toFeatures needs to allocate strings using ArgList::MakeArgString, but toFeatures lives in Support and MakeArgString lives in Option. toFeature only has one caller, so the simple fix is to have that caller pass a lamdba that wraps MakeArgString to break the dependency. Repository: rG LLVM Github Monorepo 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 , - std::vector ) const { +void RISCVISAInfo::toFeatures( +std::vector , +std::function StrAlloc) const { for (auto : 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 namespace llvm { -namespace opt { -class ArgList; -} struct RISCVExtensionInfo { std::string ExtName; unsigned MajorVersion; @@ -57,8 +54,8 @@ parseFeatures(unsigned XLen, const std::vector ); /// Convert RISCV ISA info to a feature vector. - void toFeatures(const llvm::opt::ArgList , - std::vector ) const; + void toFeatures(std::vector , + std::function StrAlloc) const; const OrderedExtensionMap () 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, [](const Twine ) { return Args.MakeArgString(Str); }); return true; } 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 , - std::vector ) const { +void RISCVISAInfo::toFeatures( +std::vector , +std::function StrAlloc) const { for (auto : 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 namespace llvm { -namespace opt { -class ArgList; -} struct RISCVExtensionInfo { std::string ExtName; unsigned MajorVersion; @@ -57,8 +54,8 @@