xref: /freebsd/contrib/llvm-project/clang/include/clang/CodeGen/BackendUtil.h (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
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 
34   enum BackendAction {
35     Backend_EmitAssembly,  ///< Emit native assembly files
36     Backend_EmitBC,        ///< Emit LLVM bitcode files
37     Backend_EmitLL,        ///< Emit human-readable LLVM assembly
38     Backend_EmitNothing,   ///< Don't emit anything (benchmarking mode)
39     Backend_EmitMCNull,    ///< Run CodeGen, but don't emit anything
40     Backend_EmitObj        ///< Emit native object files
41   };
42 
43   void EmitBackendOutput(DiagnosticsEngine &Diags, const HeaderSearchOptions &,
44                          const CodeGenOptions &CGOpts,
45                          const TargetOptions &TOpts, const LangOptions &LOpts,
46                          StringRef TDesc, llvm::Module *M, BackendAction Action,
47                          llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS,
48                          std::unique_ptr<raw_pwrite_stream> OS);
49 
50   void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts,
51                     llvm::MemoryBufferRef Buf);
52 
53   void EmbedObject(llvm::Module *M, const CodeGenOptions &CGOpts,
54                    DiagnosticsEngine &Diags);
55 }
56 
57 #endif
58