xref: /freebsd/contrib/llvm-project/clang/include/clang/CodeGen/BackendUtil.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
1 //===--- BackendUtil.h - LLVM Backend Utilities -----------------*- 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 #ifndef LLVM_CLANG_CODEGEN_BACKENDUTIL_H
10 #define LLVM_CLANG_CODEGEN_BACKENDUTIL_H
11 
12 #include "clang/Basic/LLVM.h"
13 #include "llvm/IR/ModuleSummaryIndex.h"
14 #include <memory>
15 
16 namespace llvm {
17   class BitcodeModule;
18   template <typename T> class Expected;
19   template <typename T> class IntrusiveRefCntPtr;
20   class Module;
21   class MemoryBufferRef;
22   namespace vfs {
23   class FileSystem;
24   } // namespace vfs
25 }
26 
27 namespace clang {
28   class DiagnosticsEngine;
29   class HeaderSearchOptions;
30   class CodeGenOptions;
31   class TargetOptions;
32   class LangOptions;
33   class BackendConsumer;
34 
35   enum BackendAction {
36     Backend_EmitAssembly,  ///< Emit native assembly files
37     Backend_EmitBC,        ///< Emit LLVM bitcode files
38     Backend_EmitLL,        ///< Emit human-readable LLVM assembly
39     Backend_EmitNothing,   ///< Don't emit anything (benchmarking mode)
40     Backend_EmitMCNull,    ///< Run CodeGen, but don't emit anything
41     Backend_EmitObj        ///< Emit native object files
42   };
43 
44   void EmitBackendOutput(DiagnosticsEngine &Diags, const HeaderSearchOptions &,
45                          const CodeGenOptions &CGOpts,
46                          const TargetOptions &TOpts, const LangOptions &LOpts,
47                          StringRef TDesc, llvm::Module *M, BackendAction Action,
48                          llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
49                          std::unique_ptr<raw_pwrite_stream> OS,
50                          BackendConsumer *BC = nullptr);
51 
52   void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts,
53                     llvm::MemoryBufferRef Buf);
54 
55   void EmbedObject(llvm::Module *M, const CodeGenOptions &CGOpts,
56                    DiagnosticsEngine &Diags);
57 }
58 
59 #endif
60