34 IO.enumCase(
SymbolType,
"NoType", IFSSymbolType::NoType);
35 IO.enumCase(
SymbolType,
"Func", IFSSymbolType::Func);
36 IO.enumCase(
SymbolType,
"Object", IFSSymbolType::Object);
37 IO.enumCase(
SymbolType,
"TLS", IFSSymbolType::TLS);
38 IO.enumCase(
SymbolType,
"Unknown", IFSSymbolType::Unknown);
40 if (!IO.outputting() && IO.matchEnumFallback())
49 case IFSEndiannessType::Big:
52 case IFSEndiannessType::Little:
62 .
Case(
"big", IFSEndiannessType::Big)
63 .
Case(
"little", IFSEndiannessType::Little)
64 .
Default(IFSEndiannessType::Unknown);
65 if (
Value == IFSEndiannessType::Unknown) {
66 return "Unsupported endianness";
78 case IFSBitWidthType::IFS32:
81 case IFSBitWidthType::IFS64:
91 .
Case(
"32", IFSBitWidthType::IFS32)
92 .
Case(
"64", IFSBitWidthType::IFS64)
93 .
Default(IFSBitWidthType::Unknown);
94 if (
Value == IFSBitWidthType::Unknown) {
95 return "Unsupported bit width";
105 IO.mapOptional(
"ObjectFormat",
Target.ObjectFormat);
106 IO.mapOptional(
"Arch",
Target.ArchString);
107 IO.mapOptional(
"Endianness",
Target.Endianness);
108 IO.mapOptional(
"BitWidth",
Target.BitWidth);
112 static const bool flow =
true;
118 IO.mapRequired(
"Name", Symbol.Name);
119 IO.mapRequired(
"Type", Symbol.Type);
121 if (Symbol.Type == IFSSymbolType::NoType) {
124 if (!Symbol.Size || *Symbol.Size)
125 IO.mapOptional(
"Size", Symbol.Size);
126 }
else if (Symbol.Type != IFSSymbolType::Func) {
127 IO.mapOptional(
"Size", Symbol.Size);
129 IO.mapOptional(
"Undefined", Symbol.Undefined,
false);
130 IO.mapOptional(
"Weak", Symbol.Weak,
false);
131 IO.mapOptional(
"Warning", Symbol.Warning);
135 static const bool flow =
true;
141 if (!IO.mapTag(
"!ifs-v1",
true))
142 IO.setError(
"Not a .tbe YAML file.");
143 IO.mapRequired(
"IfsVersion", Stub.
IfsVersion);
144 IO.mapOptional(
"SoName", Stub.
SoName);
145 IO.mapOptional(
"Target", Stub.
Target);
146 IO.mapOptional(
"NeededLibs", Stub.
NeededLibs);
147 IO.mapRequired(
"Symbols", Stub.
Symbols);
154 if (!IO.mapTag(
"!ifs-v1",
true))
155 IO.setError(
"Not a .tbe YAML file.");
156 IO.mapRequired(
"IfsVersion", Stub.
IfsVersion);
157 IO.mapOptional(
"SoName", Stub.
SoName);
159 IO.mapOptional(
"NeededLibs", Stub.
NeededLibs);
160 IO.mapRequired(
"Symbols", Stub.
Symbols);
170 if (Line.startswith(
"Target:")) {
171 if (Line ==
"Target:" || Line.contains(
"{")) {
180 yaml::Input YamlIn(Buf);
185 YamlIn >> *
static_cast<IFSStub *
>(Stub.get());
187 if (std::error_code Err = YamlIn.error()) {
192 return make_error<StringError>(
193 "IFS version " + Stub->IfsVersion.getAsString() +
" is unsupported.",
194 std::make_error_code(std::errc::invalid_argument));
195 if (Stub->Target.ArchString) {
199 return std::move(Stub);
203 yaml::Output YamlOut(
OS,
nullptr, 0);
204 std::unique_ptr<IFSStubTriple> CopyStub(
new IFSStubTriple(Stub));
206 CopyStub->Target.ArchString =
211 if (CopyStub->Target.Triple ||
212 (!CopyStub->Target.ArchString && !CopyStub->Target.Endianness &&
213 !CopyStub->Target.BitWidth))
214 YamlOut << *CopyStub;
216 YamlOut << *static_cast<IFSStub *>(CopyStub.get());
221 IFSStub &Stub, std::optional<IFSArch> OverrideArch,
222 std::optional<IFSEndiannessType> OverrideEndianness,
223 std::optional<IFSBitWidthType> OverrideBitWidth,
224 std::optional<std::string> OverrideTriple) {
225 std::error_code OverrideEC(1, std::generic_category());
228 return make_error<StringError>(
229 "Supplied Arch conflicts with the text stub", OverrideEC);
233 if (OverrideEndianness) {
236 return make_error<StringError>(
237 "Supplied Endianness conflicts with the text stub", OverrideEC);
241 if (OverrideBitWidth) {
243 return make_error<StringError>(
244 "Supplied BitWidth conflicts with the text stub", OverrideEC);
248 if (OverrideTriple) {
250 return make_error<StringError>(
251 "Supplied Triple conflicts with the text stub", OverrideEC);
259 std::error_code ValidationEC(1, std::generic_category());
263 return make_error<StringError>(
264 "Target triple cannot be used simultaneously with ELF target format",
278 return make_error<StringError>(
"Arch is not defined in the text stub",
282 return make_error<StringError>(
"BitWidth is not defined in the text stub",
286 return make_error<StringError>(
287 "Endianness is not defined in the text stub", ValidationEC);
294 Triple IFSTriple(TripleStr);
298 case Triple::ArchType::aarch64:
301 case Triple::ArchType::x86_64:
304 case Triple::ArchType::riscv64:
311 : IFSEndiannessType::Big;
313 IFSTriple.
isArch64Bit() ? IFSBitWidthType::IFS64 : IFSBitWidthType::IFS32;
318 bool StripEndianness,
bool StripBitWidth) {
319 if (StripTriple || StripArch) {
323 if (StripTriple || StripEndianness) {
326 if (StripTriple || StripBitWidth) {
338 const std::vector<std::string> &Exclude) {
343 if (StripUndefined) {
345 return Sym.Undefined ||
Filter(Sym);
bool usesTriple(StringRef Buf)
Attempt to determine if a Text stub uses target triple.
This file declares an interface for reading and writing .ifs (text-based InterFace Stub) files.
This file defines an internal representation of an InterFace Stub.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
static Expected< GlobPattern > create(StringRef Pat)
MatchResult match(StringRef Buffer, const SourceMgr &SM) const
Matches the pattern string against the input buffer Buffer.
StringRef - Represent a constant reference to a string, i.e.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
bool isLittleEndian() const
Tests whether the target triple is little endian.
ArchType getArch() const
Get the parsed architecture type of this triple.
bool isArch64Bit() const
Test whether the architecture is 64-bit.
LLVM Value Representation.
A forward iterator which reads text lines from a buffer.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
uint16_t convertArchNameToEMachine(StringRef Arch)
Convert an architecture name into ELF's e_machine value.
StringRef convertEMachineToArchName(uint16_t EMachine)
Convert an ELF's e_machine value into an architecture name.
void stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch, bool StripEndianness, bool StripBitWidth)
Strips target platform information from the text stub.
Expected< std::unique_ptr< IFSStub > > readIFSFromBuffer(StringRef Buf)
Attempts to read an IFS interface file from a StringRef buffer.
Error validateIFSTarget(IFSStub &Stub, bool ParseTriple)
Validate the target platform inforation in the text stub.
IFSTarget parseTriple(StringRef TripleStr)
Parse llvm triple string into a IFSTarget struct.
Error writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub)
Attempts to write an IFS interface file to a raw_ostream.
const VersionTuple IFSVersionCurrent(3, 0)
Error filterIFSSyms(IFSStub &Stub, bool StripUndefined, const std::vector< std::string > &Exclude={})
Error overrideIFSTarget(IFSStub &Stub, std::optional< IFSArch > OverrideArch, std::optional< IFSEndiannessType > OverrideEndianness, std::optional< IFSBitWidthType > OverrideBitWidth, std::optional< std::string > OverrideTriple)
Override the target platform inforation in the text stub.
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
std::vector< IFSSymbol > Symbols
std::optional< std::string > SoName
std::vector< std::string > NeededLibs
std::optional< std::string > ArchString
std::optional< std::string > Triple
std::optional< IFSEndiannessType > Endianness
std::optional< IFSBitWidthType > BitWidth
std::optional< std::string > ObjectFormat
std::optional< IFSArch > Arch
static void mapping(IO &IO, IFSStubTriple &Stub)
static void mapping(IO &IO, IFSStub &Stub)
static void mapping(IO &IO, IFSSymbol &Symbol)
static void mapping(IO &IO, IFSTarget &Target)
static void enumeration(IO &IO, IFSSymbolType &SymbolType)
static StringRef input(StringRef Scalar, void *, IFSBitWidthType &Value)
static void output(const IFSBitWidthType &Value, void *, llvm::raw_ostream &Out)
static QuotingType mustQuote(StringRef)
static StringRef input(StringRef Scalar, void *, IFSEndiannessType &Value)
static QuotingType mustQuote(StringRef)
static void output(const IFSEndiannessType &Value, void *, llvm::raw_ostream &Out)