Jez Ng | 21f8311 | 2020-10-27 02:18:29 | [diff] [blame] | 1 | //===- LTO.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 | |
| 9 | #ifndef LLD_MACHO_LTO_H |
| 10 | #define LLD_MACHO_LTO_H |
| 11 | |
Nico Weber | aa0883b | 2022-11-20 16:59:16 | [diff] [blame] | 12 | #include "lld/Common/LLVM.h" |
| 13 | #include "llvm/ADT/DenseSet.h" |
Jez Ng | 21f8311 | 2020-10-27 02:18:29 | [diff] [blame] | 14 | #include "llvm/ADT/SmallString.h" |
Leonard Grey | c931ff7 | 2021-07-15 16:56:13 | [diff] [blame] | 15 | #include "llvm/Support/MemoryBuffer.h" |
Nico Weber | aa0883b | 2022-11-20 16:59:16 | [diff] [blame] | 16 | #include "llvm/Support/raw_ostream.h" |
Jez Ng | 21f8311 | 2020-10-27 02:18:29 | [diff] [blame] | 17 | #include <memory> |
| 18 | #include <vector> |
| 19 | |
Nico Weber | bf20d43 | 2022-08-07 14:37:49 | [diff] [blame] | 20 | namespace llvm::lto { |
Jez Ng | 21f8311 | 2020-10-27 02:18:29 | [diff] [blame] | 21 | class LTO; |
Nico Weber | bf20d43 | 2022-08-07 14:37:49 | [diff] [blame] | 22 | } // namespace llvm::lto |
Jez Ng | 21f8311 | 2020-10-27 02:18:29 | [diff] [blame] | 23 | |
Nico Weber | bf20d43 | 2022-08-07 14:37:49 | [diff] [blame] | 24 | namespace lld::macho { |
Jez Ng | 21f8311 | 2020-10-27 02:18:29 | [diff] [blame] | 25 | |
| 26 | class BitcodeFile; |
| 27 | class ObjFile; |
| 28 | |
| 29 | class BitcodeCompiler { |
| 30 | public: |
| 31 | BitcodeCompiler(); |
| 32 | |
| 33 | void add(BitcodeFile &f); |
| 34 | std::vector<ObjFile *> compile(); |
| 35 | |
| 36 | private: |
| 37 | std::unique_ptr<llvm::lto::LTO> ltoObj; |
| 38 | std::vector<llvm::SmallString<0>> buf; |
Leonard Grey | c931ff7 | 2021-07-15 16:56:13 | [diff] [blame] | 39 | std::vector<std::unique_ptr<llvm::MemoryBuffer>> files; |
Nico Weber | aa0883b | 2022-11-20 16:59:16 | [diff] [blame] | 40 | std::unique_ptr<llvm::raw_fd_ostream> indexFile; |
| 41 | llvm::DenseSet<StringRef> thinIndices; |
Keith Smiley | a65678b | 2023-03-03 21:27:03 | [diff] [blame] | 42 | bool hasFiles = false; |
Jez Ng | 21f8311 | 2020-10-27 02:18:29 | [diff] [blame] | 43 | }; |
| 44 | |
Nico Weber | bf20d43 | 2022-08-07 14:37:49 | [diff] [blame] | 45 | } // namespace lld::macho |
Jez Ng | 21f8311 | 2020-10-27 02:18:29 | [diff] [blame] | 46 | |
| 47 | #endif |