LLVM: lib/InterfaceStub/IFSHandler.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

20#include

21#include

22

23using namespace llvm;

25

27

28namespace llvm {

29namespace yaml {

30

31

44

50 Out << "big";

51 break;

53 Out << "little";

54 break;

55 default:

57 }

58 }

59

66 return "Unsupported endianness";

67 }

69 }

70

72};

73

79 Out << "32";

80 break;

82 Out << "64";

83 break;

84 default:

86 }

87 }

88

95 return "Unsupported bit width";

96 }

98 }

99

101};

102

110

111

112 static const bool flow = true;

113};

114

115

120

122

123

124 if (!Symbol.Size || *Symbol.Size)

128 }

129 IO.mapOptional("Undefined", Symbol.Undefined, false);

132 }

133

134

135 static const bool flow = true;

136};

137

138

150

151

163}

164}

165

166

170 if (Line.starts_with("Target:")) {

171 if (Line == "Target:" || Line.contains("{")) {

172 return false;

173 }

174 }

175 }

176 return true;

177}

178

181 std::unique_ptr Stub(new IFSStubTriple());

183 YamlIn >> *Stub;

184 } else {

185 YamlIn >> *static_cast<IFSStub *>(Stub.get());

186 }

187 if (std::error_code Err = YamlIn.error()) {

189 }

190

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;

203 }

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");

209 }

210 return std::move(Stub);

211}

212

214 yaml::Output YamlOut(OS, nullptr, 0);

215 std::unique_ptr CopyStub(new IFSStubTriple(Stub));

217 CopyStub->Target.ArchString =

219 }

221

222 if (CopyStub->Target.Triple ||

223 (!CopyStub->Target.ArchString && !CopyStub->Target.Endianness &&

224 !CopyStub->Target.BitWidth))

225 YamlOut << *CopyStub;

226 else

227 YamlOut << *static_cast<IFSStub *>(CopyStub.get());

229}

230

232 IFSStub &Stub, std::optional OverrideArch,

233 std::optional OverrideEndianness,

234 std::optional OverrideBitWidth,

235 std::optionalstd::string OverrideTriple) {

236 std::error_code OverrideEC(1, std::generic_category());

237 if (OverrideArch) {

240 "Supplied Arch conflicts with the text stub", OverrideEC);

241 }

243 }

244 if (OverrideEndianness) {

248 "Supplied Endianness conflicts with the text stub", OverrideEC);

249 }

251 }

252 if (OverrideBitWidth) {

255 "Supplied BitWidth conflicts with the text stub", OverrideEC);

256 }

258 }

259 if (OverrideTriple) {

262 "Supplied Triple conflicts with the text stub", OverrideEC);

263 }

265 }

267}

268

270 std::error_code ValidationEC(1, std::generic_category());

275 "Target triple cannot be used simultaneously with ELF target format",

276 ValidationEC);

277 }

278 if (ParseTriple) {

283 }

285 }

287

290 ValidationEC);

291 }

294 ValidationEC);

295 }

298 "Endianness is not defined in the text stub", ValidationEC);

299 }

300 }

302}

303

305 Triple IFSTriple(TripleStr);

310 RetTarget.Arch = TripleArch;

311 }

316 return RetTarget;

317}

318

320 bool StripEndianness, bool StripBitWidth) {

321 if (StripTriple || StripArch) {

324 }

325 if (StripTriple || StripEndianness) {

327 }

328 if (StripTriple || StripBitWidth) {

330 }

331 if (StripTriple) {

333 }

336 }

337}

338

340 const std::vectorstd::string &Exclude) {

342 return false;

343 };

344

345 if (StripUndefined) {

347 return Sym.Undefined || Filter(Sym);

348 };

349 }

350

353 if (!PatternOrErr)

357 };

358 }

359

361

363}

bool usesTriple(StringRef Buf)

Attempt to determine if a Text stub uses target triple.

Definition IFSHandler.cpp:167

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.

virtual bool outputting() const =0

virtual bool mapTag(StringRef Tag, bool Default=false)=0

void enumCase(T &Val, StringRef Str, const T ConstVal)

void mapOptional(StringRef Key, T &Val)

virtual void setError(const Twine &)=0

void mapRequired(StringRef Key, T &Val)

virtual bool matchEnumFallback()=0

The Input class is used to parse a yaml document into in-memory structs and vectors.

std::error_code error() override

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.

Definition IFSHandler.cpp:319

LLVM_ABI Expected< std::unique_ptr< IFSStub > > readIFSFromBuffer(StringRef Buf)

Attempts to read an IFS interface file from a StringRef buffer.

Definition IFSHandler.cpp:179

LLVM_ABI Error validateIFSTarget(IFSStub &Stub, bool ParseTriple)

Validate the target platform inforation in the text stub.

Definition IFSHandler.cpp:269

LLVM_ABI IFSTarget parseTriple(StringRef TripleStr)

Parse llvm triple string into a IFSTarget struct.

Definition IFSHandler.cpp:304

LLVM_ABI Error writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub)

Attempts to write an IFS interface file to a raw_ostream.

Definition IFSHandler.cpp:213

const VersionTuple IFSVersionCurrent(3, 0)

LLVM_ABI Error filterIFSSyms(IFSStub &Stub, bool StripUndefined, const std::vector< std::string > &Exclude={})

Definition IFSHandler.cpp:339

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.

Definition IFSHandler.cpp:231

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)

Definition IFSHandler.cpp:153

static void mapping(IO &IO, IFSStub &Stub)

Definition IFSHandler.cpp:140

static void mapping(IO &IO, IFSSymbol &Symbol)

Definition IFSHandler.cpp:117

static const bool flow

Definition IFSHandler.cpp:135

static const bool flow

Definition IFSHandler.cpp:112

static void mapping(IO &IO, IFSTarget &Target)

Definition IFSHandler.cpp:104

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)

Definition IFSHandler.cpp:33

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)

Definition IFSHandler.cpp:89

static void output(const IFSBitWidthType &Value, void *, llvm::raw_ostream &Out)

Definition IFSHandler.cpp:75

static QuotingType mustQuote(StringRef)

Definition IFSHandler.cpp:100

static StringRef input(StringRef Scalar, void *, IFSEndiannessType &Value)

Definition IFSHandler.cpp:60

static QuotingType mustQuote(StringRef)

Definition IFSHandler.cpp:71

static void output(const IFSEndiannessType &Value, void *, llvm::raw_ostream &Out)

Definition IFSHandler.cpp:46

This class should be specialized by type that requires custom conversion to/from a yaml scalar.