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