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 } // namespace llvm 26 27 namespace clang { 28 class CompilerInstance; 29 class DiagnosticsEngine; 30 class CodeGenOptions; 31 class BackendConsumer; 32 33 enum BackendAction { 34 Backend_EmitAssembly, ///< Emit native assembly files 35 Backend_EmitBC, ///< Emit LLVM bitcode files 36 Backend_EmitLL, ///< Emit human-readable LLVM assembly 37 Backend_EmitNothing, ///< Don't emit anything (benchmarking mode) 38 Backend_EmitMCNull, ///< Run CodeGen, but don't emit anything 39 Backend_EmitObj ///< Emit native object files 40 }; 41 42 void emitBackendOutput(CompilerInstance &CI, CodeGenOptions &CGOpts, 43 StringRef TDesc, llvm::Module *M, BackendAction Action, 44 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, 45 std::unique_ptr<raw_pwrite_stream> OS, 46 BackendConsumer *BC = nullptr); 47 48 void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts, 49 llvm::MemoryBufferRef Buf); 50 51 void EmbedObject(llvm::Module *M, const CodeGenOptions &CGOpts, 52 DiagnosticsEngine &Diags); 53 } // namespace clang 54 55 #endif 56