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