1 | //===- IFSHandler.h ---------------------------------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===-----------------------------------------------------------------------===/ |
8 | /// |
9 | /// \file |
10 | /// This file declares an interface for reading and writing .ifs (text-based |
11 | /// InterFace Stub) files. |
12 | /// |
13 | //===-----------------------------------------------------------------------===/ |
14 | |
15 | #ifndef LLVM_INTERFACESTUB_IFSHANDLER_H |
16 | #define LLVM_INTERFACESTUB_IFSHANDLER_H |
17 | |
18 | #include "IFSStub.h" |
19 | #include "llvm/Support/Error.h" |
20 | #include "llvm/Support/VersionTuple.h" |
21 | #include <memory> |
22 | #include <optional> |
23 | #include <string> |
24 | #include <vector> |
25 | |
26 | namespace llvm { |
27 | |
28 | class raw_ostream; |
29 | class Error; |
30 | class StringRef; |
31 | |
32 | namespace ifs { |
33 | |
34 | struct IFSStub; |
35 | |
36 | const VersionTuple IFSVersionCurrent(3, 0); |
37 | |
38 | /// Attempts to read an IFS interface file from a StringRef buffer. |
39 | Expected<std::unique_ptr<IFSStub>> readIFSFromBuffer(StringRef Buf); |
40 | |
41 | /// Attempts to write an IFS interface file to a raw_ostream. |
42 | Error writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub); |
43 | |
44 | /// Override the target platform inforation in the text stub. |
45 | Error overrideIFSTarget(IFSStub &Stub, std::optional<IFSArch> OverrideArch, |
46 | std::optional<IFSEndiannessType> OverrideEndianness, |
47 | std::optional<IFSBitWidthType> OverrideBitWidth, |
48 | std::optional<std::string> OverrideTriple); |
49 | |
50 | /// Validate the target platform inforation in the text stub. |
51 | Error validateIFSTarget(IFSStub &Stub, bool ParseTriple); |
52 | |
53 | /// Strips target platform information from the text stub. |
54 | void stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch, |
55 | bool StripEndianness, bool StripBitWidth); |
56 | |
57 | Error filterIFSSyms(IFSStub &Stub, bool StripUndefined, |
58 | const std::vector<std::string> &Exclude = {}); |
59 | |
60 | /// Parse llvm triple string into a IFSTarget struct. |
61 | IFSTarget parseTriple(StringRef TripleStr); |
62 | |
63 | } // end namespace ifs |
64 | } // end namespace llvm |
65 | |
66 | #endif // LLVM_INTERFACESTUB_IFSHANDLER_H |
67 | |