forked from OSchip/llvm-project
[RISCV] Use a lambda to avoid having the Support library depend on Option library.
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. Differential Revision: https://reviews.llvm.org/D112032
This commit is contained in:
parent
431a5d8411
commit
1053e0b27c
|
@ -41,7 +41,8 @@ static bool getArchFeatures(const Driver &D, StringRef Arch,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*ISAInfo)->toFeatures(Args, Features);
|
(*ISAInfo)->toFeatures(
|
||||||
|
Features, [&Args](const Twine &Str) { return Args.MakeArgString(Str); });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
namespace opt {
|
|
||||||
class ArgList;
|
|
||||||
}
|
|
||||||
struct RISCVExtensionInfo {
|
struct RISCVExtensionInfo {
|
||||||
std::string ExtName;
|
std::string ExtName;
|
||||||
unsigned MajorVersion;
|
unsigned MajorVersion;
|
||||||
|
@ -57,8 +54,8 @@ public:
|
||||||
parseFeatures(unsigned XLen, const std::vector<std::string> &Features);
|
parseFeatures(unsigned XLen, const std::vector<std::string> &Features);
|
||||||
|
|
||||||
/// Convert RISCV ISA info to a feature vector.
|
/// Convert RISCV ISA info to a feature vector.
|
||||||
void toFeatures(const llvm::opt::ArgList &Args,
|
void toFeatures(std::vector<StringRef> &Features,
|
||||||
std::vector<StringRef> &Features) const;
|
std::function<StringRef(const Twine &)> StrAlloc) const;
|
||||||
|
|
||||||
const OrderedExtensionMap &getExtensions() const { return Exts; };
|
const OrderedExtensionMap &getExtensions() const { return Exts; };
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "llvm/ADT/STLExtras.h"
|
#include "llvm/ADT/STLExtras.h"
|
||||||
#include "llvm/ADT/StringExtras.h"
|
#include "llvm/ADT/StringExtras.h"
|
||||||
#include "llvm/ADT/StringRef.h"
|
#include "llvm/ADT/StringRef.h"
|
||||||
#include "llvm/Option/ArgList.h"
|
|
||||||
#include "llvm/Support/Errc.h"
|
#include "llvm/Support/Errc.h"
|
||||||
#include "llvm/Support/Error.h"
|
#include "llvm/Support/Error.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
@ -252,8 +251,9 @@ bool RISCVISAInfo::compareExtension(const std::string &LHS,
|
||||||
return LHS < RHS;
|
return LHS < RHS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RISCVISAInfo::toFeatures(const llvm::opt::ArgList &Args,
|
void RISCVISAInfo::toFeatures(
|
||||||
std::vector<StringRef> &Features) const {
|
std::vector<StringRef> &Features,
|
||||||
|
std::function<StringRef(const Twine &)> StrAlloc) const {
|
||||||
for (auto &Ext : Exts) {
|
for (auto &Ext : Exts) {
|
||||||
StringRef ExtName = Ext.first;
|
StringRef ExtName = Ext.first;
|
||||||
|
|
||||||
|
@ -268,9 +268,9 @@ void RISCVISAInfo::toFeatures(const llvm::opt::ArgList &Args,
|
||||||
Features.push_back("+experimental-zvlsseg");
|
Features.push_back("+experimental-zvlsseg");
|
||||||
Features.push_back("+experimental-zvamo");
|
Features.push_back("+experimental-zvamo");
|
||||||
} else if (isExperimentalExtension(ExtName)) {
|
} else if (isExperimentalExtension(ExtName)) {
|
||||||
Features.push_back(Args.MakeArgString("+experimental-" + ExtName));
|
Features.push_back(StrAlloc("+experimental-" + ExtName));
|
||||||
} else {
|
} else {
|
||||||
Features.push_back(Args.MakeArgString("+" + ExtName));
|
Features.push_back(StrAlloc("+" + ExtName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue