| 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/Compiler.h" |
| 20 | #include "llvm/Support/Error.h" |
| 21 | #include "llvm/Support/VersionTuple.h" |
| 22 | #include <memory> |
| 23 | #include <optional> |
| 24 | #include <string> |
| 25 | #include <vector> |
| 26 | |
| 27 | namespace llvm { |
| 28 | |
| 29 | class raw_ostream; |
| 30 | class Error; |
| 31 | class StringRef; |
| 32 | |
| 33 | namespace ifs { |
| 34 | |
| 35 | struct IFSStub; |
| 36 | |
| 37 | const VersionTuple IFSVersionCurrent(3, 0); |
| 38 | |
| 39 | /// Attempts to read an IFS interface file from a StringRef buffer. |
| 40 | LLVM_ABI Expected<std::unique_ptr<IFSStub>> readIFSFromBuffer(StringRef Buf); |
| 41 | |
| 42 | /// Attempts to write an IFS interface file to a raw_ostream. |
| 43 | LLVM_ABI Error writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub); |
| 44 | |
| 45 | /// Override the target platform inforation in the text stub. |
| 46 | LLVM_ABI Error |
| 47 | overrideIFSTarget(IFSStub &Stub, std::optional<IFSArch> OverrideArch, |
| 48 | std::optional<IFSEndiannessType> OverrideEndianness, |
| 49 | std::optional<IFSBitWidthType> OverrideBitWidth, |
| 50 | std::optional<std::string> OverrideTriple); |
| 51 | |
| 52 | /// Validate the target platform inforation in the text stub. |
| 53 | LLVM_ABI Error validateIFSTarget(IFSStub &Stub, bool ParseTriple); |
| 54 | |
| 55 | /// Strips target platform information from the text stub. |
| 56 | LLVM_ABI void stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch, |
| 57 | bool StripEndianness, bool StripBitWidth); |
| 58 | |
| 59 | LLVM_ABI Error filterIFSSyms(IFSStub &Stub, bool StripUndefined, |
| 60 | const std::vector<std::string> &Exclude = {}); |
| 61 | |
| 62 | /// Parse llvm triple string into a IFSTarget struct. |
| 63 | LLVM_ABI IFSTarget parseTriple(StringRef TripleStr); |
| 64 | |
| 65 | } // end namespace ifs |
| 66 | } // end namespace llvm |
| 67 | |
| 68 | #endif // LLVM_INTERFACESTUB_IFSHANDLER_H |
| 69 | |