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