66 return "Unsupported endianness";
95 return "Unsupported bit width";
124 if (!Symbol.Size || *Symbol.Size)
170 if (Line.starts_with(
"Target:")) {
171 if (Line ==
"Target:" || Line.contains(
"{")) {
185 YamlIn >> *
static_cast<IFSStub *
>(Stub.get());
187 if (std::error_code Err = YamlIn.
error()) {
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 for (
const auto &Item : Stub->Symbols) {
207 std::make_error_code(std::errc::invalid_argument),
208 "IFS symbol type for symbol '" + Item.Name +
"' is unsupported");
210 return std::move(Stub);
215 std::unique_ptr<IFSStubTriple> CopyStub(
new IFSStubTriple(Stub));
217 CopyStub->Target.ArchString =
222 if (CopyStub->Target.Triple ||
223 (!CopyStub->Target.ArchString && !CopyStub->Target.Endianness &&
224 !CopyStub->Target.BitWidth))
225 YamlOut << *CopyStub;
227 YamlOut << *static_cast<IFSStub *>(CopyStub.get());
232 IFSStub &Stub, std::optional<IFSArch> OverrideArch,
233 std::optional<IFSEndiannessType> OverrideEndianness,
234 std::optional<IFSBitWidthType> OverrideBitWidth,
235 std::optional<std::string> OverrideTriple) {
236 std::error_code OverrideEC(1, std::generic_category());
240 "Supplied Arch conflicts with the text stub", OverrideEC);
244 if (OverrideEndianness) {
248 "Supplied Endianness conflicts with the text stub", OverrideEC);
252 if (OverrideBitWidth) {
255 "Supplied BitWidth conflicts with the text stub", OverrideEC);
259 if (OverrideTriple) {
262 "Supplied Triple conflicts with the text stub", OverrideEC);
270 std::error_code ValidationEC(1, std::generic_category());
275 "Target triple cannot be used simultaneously with ELF target format",
298 "Endianness is not defined in the text stub", ValidationEC);
305 Triple IFSTriple(TripleStr);
310 RetTarget.
Arch = TripleArch;
320 bool StripEndianness,
bool StripBitWidth) {
321 if (StripTriple || StripArch) {
325 if (StripTriple || StripEndianness) {
328 if (StripTriple || StripBitWidth) {
340 const std::vector<std::string> &Exclude) {
345 if (StripUndefined) {
347 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)
Utility for declaring that a std::vector of a particular type should be considered a YAML sequence.
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 LLVM_ABI Expected< GlobPattern > create(StringRef Pat, std::optional< size_t > MaxSubPatterns={})
LLVM_ABI_FOR_TEST 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.
StringRef trim(char Char) const
Return string with consecutive Char characters starting from the left and right removed.
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.
LLVM_ABI bool isLittleEndian() const
Tests whether the target triple is little endian.
ArchType getArch() const
Get the parsed architecture type of this triple.
LLVM_ABI 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.
void mapOptional(const char *Key, T &Val)
virtual bool outputting() const =0
virtual bool mapTag(StringRef Tag, bool Default=false)=0
void mapRequired(const char *Key, T &Val)
virtual void setError(const Twine &)=0
virtual bool matchEnumFallback()=0
void enumCase(T &Val, const char *Str, const T ConstVal)
The Output class is used to generate a yaml document from in-memory structs and vectors.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI uint16_t convertTripleArchTypeToEMachine(Triple::ArchType ArchType)
LLVM_ABI uint16_t convertArchNameToEMachine(StringRef Arch)
Convert an architecture name into ELF's e_machine value.
LLVM_ABI StringRef convertEMachineToArchName(uint16_t EMachine)
Convert an ELF's e_machine value into an architecture name.
LLVM_ABI void stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch, bool StripEndianness, bool StripBitWidth)
Strips target platform information from the text stub.
LLVM_ABI Expected< std::unique_ptr< IFSStub > > readIFSFromBuffer(StringRef Buf)
Attempts to read an IFS interface file from a StringRef buffer.
LLVM_ABI Error validateIFSTarget(IFSStub &Stub, bool ParseTriple)
Validate the target platform inforation in the text stub.
LLVM_ABI IFSTarget parseTriple(StringRef TripleStr)
Parse llvm triple string into a IFSTarget struct.
LLVM_ABI Error writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub)
Attempts to write an IFS interface file to a raw_ostream.
const VersionTuple IFSVersionCurrent(3, 0)
LLVM_ABI Error filterIFSSyms(IFSStub &Stub, bool StripUndefined, const std::vector< std::string > &Exclude={})
LLVM_ABI 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.
QuotingType
Describe which type of quotes should be used when quoting is necessary.
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.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
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)
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
static void enumeration(IO &IO, IFSSymbolType &SymbolType)
This class should be specialized by any integral type that converts to/from a YAML scalar where there...
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)
This class should be specialized by type that requires custom conversion to/from a yaml scalar.