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) {
200 std::make_error_code(std::errc::invalid_argument),
201 "IFS arch '" + *Stub->Target.ArchString +
"' is unsupported");
202 Stub->Target.Arch = eMachine;
204 return std::move(Stub);
208 yaml::Output YamlOut(
OS,
nullptr, 0);
209 std::unique_ptr<IFSStubTriple> CopyStub(
new IFSStubTriple(Stub));
211 CopyStub->Target.ArchString =
216 if (CopyStub->Target.Triple ||
217 (!CopyStub->Target.ArchString && !CopyStub->Target.Endianness &&
218 !CopyStub->Target.BitWidth))
219 YamlOut << *CopyStub;
221 YamlOut << *static_cast<IFSStub *>(CopyStub.get());
226 IFSStub &Stub, std::optional<IFSArch> OverrideArch,
227 std::optional<IFSEndiannessType> OverrideEndianness,
228 std::optional<IFSBitWidthType> OverrideBitWidth,
229 std::optional<std::string> OverrideTriple) {
230 std::error_code OverrideEC(1, std::generic_category());
233 return make_error<StringError>(
234 "Supplied Arch conflicts with the text stub", OverrideEC);
238 if (OverrideEndianness) {
241 return make_error<StringError>(
242 "Supplied Endianness conflicts with the text stub", OverrideEC);
246 if (OverrideBitWidth) {
248 return make_error<StringError>(
249 "Supplied BitWidth conflicts with the text stub", OverrideEC);
253 if (OverrideTriple) {
255 return make_error<StringError>(
256 "Supplied Triple conflicts with the text stub", OverrideEC);
264 std::error_code ValidationEC(1, std::generic_category());
268 return make_error<StringError>(
269 "Target triple cannot be used simultaneously with ELF target format",
283 return make_error<StringError>(
"Arch is not defined in the text stub",
287 return make_error<StringError>(
"BitWidth is not defined in the text stub",
291 return make_error<StringError>(
292 "Endianness is not defined in the text stub", ValidationEC);
299 Triple IFSTriple(TripleStr);
303 case Triple::ArchType::aarch64:
306 case Triple::ArchType::x86_64:
309 case Triple::ArchType::riscv64:
316 : IFSEndiannessType::Big;
318 IFSTriple.
isArch64Bit() ? IFSBitWidthType::IFS64 : IFSBitWidthType::IFS32;
323 bool StripEndianness,
bool StripBitWidth) {
324 if (StripTriple || StripArch) {
328 if (StripTriple || StripEndianness) {
331 if (StripTriple || StripBitWidth) {
343 const std::vector<std::string> &Exclude) {
348 if (StripUndefined) {
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, std::optional< size_t > MaxSubPatterns={})
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)