1 //===--- yaml2obj.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 /// \file 9 /// Common declarations for yaml2obj 10 //===----------------------------------------------------------------------===// 11 #ifndef LLVM_OBJECTYAML_YAML2OBJ_H 12 #define LLVM_OBJECTYAML_YAML2OBJ_H 13 14 #include "llvm/ADT/STLExtras.h" 15 #include "llvm/Support/Compiler.h" 16 #include <memory> 17 18 namespace llvm { 19 class raw_ostream; 20 template <typename T> class SmallVectorImpl; 21 class StringRef; 22 class Twine; 23 24 namespace object { 25 class ObjectFile; 26 } 27 28 namespace COFFYAML { 29 struct Object; 30 } 31 32 namespace ELFYAML { 33 struct Object; 34 } 35 36 namespace GOFFYAML { 37 struct Object; 38 } 39 40 namespace MinidumpYAML { 41 struct Object; 42 } 43 44 namespace OffloadYAML { 45 struct Binary; 46 } 47 48 namespace WasmYAML { 49 struct Object; 50 } 51 52 namespace XCOFFYAML { 53 struct Object; 54 } 55 56 namespace ArchYAML { 57 struct Archive; 58 } 59 60 namespace DXContainerYAML { 61 struct Object; 62 } // namespace DXContainerYAML 63 64 namespace yaml { 65 class Input; 66 struct YamlObjectFile; 67 68 using ErrorHandler = llvm::function_ref<void(const Twine &Msg)>; 69 70 LLVM_ABI bool yaml2archive(ArchYAML::Archive &Doc, raw_ostream &Out, 71 ErrorHandler EH); 72 LLVM_ABI bool yaml2coff(COFFYAML::Object &Doc, raw_ostream &Out, 73 ErrorHandler EH); 74 LLVM_ABI bool yaml2goff(GOFFYAML::Object &Doc, raw_ostream &Out, 75 ErrorHandler EH); 76 LLVM_ABI bool yaml2elf(ELFYAML::Object &Doc, raw_ostream &Out, ErrorHandler EH, 77 uint64_t MaxSize); 78 LLVM_ABI bool yaml2macho(YamlObjectFile &Doc, raw_ostream &Out, 79 ErrorHandler EH); 80 LLVM_ABI bool yaml2minidump(MinidumpYAML::Object &Doc, raw_ostream &Out, 81 ErrorHandler EH); 82 LLVM_ABI bool yaml2offload(OffloadYAML::Binary &Doc, raw_ostream &Out, 83 ErrorHandler EH); 84 LLVM_ABI bool yaml2wasm(WasmYAML::Object &Doc, raw_ostream &Out, 85 ErrorHandler EH); 86 LLVM_ABI bool yaml2xcoff(XCOFFYAML::Object &Doc, raw_ostream &Out, 87 ErrorHandler EH); 88 LLVM_ABI bool yaml2dxcontainer(DXContainerYAML::Object &Doc, raw_ostream &Out, 89 ErrorHandler EH); 90 91 LLVM_ABI bool convertYAML(Input &YIn, raw_ostream &Out, ErrorHandler ErrHandler, 92 unsigned DocNum = 1, uint64_t MaxSize = UINT64_MAX); 93 94 /// Convenience function for tests. 95 LLVM_ABI std::unique_ptr<object::ObjectFile> 96 yaml2ObjectFile(SmallVectorImpl<char> &Storage, StringRef Yaml, 97 ErrorHandler ErrHandler); 98 99 } // namespace yaml 100 } // namespace llvm 101 102 #endif 103