brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 21b1d59 Raw
62 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file provides a way to combine bitcode files into one wasm10// file by compiling them using LLVM.11//12// If LTO is in use, your input files are not in regular wasm files13// but instead LLVM bitcode files. In that case, the linker has to14// convert bitcode files into the native format so that we can create15// a wasm file that contains native code. This file provides that16// functionality.17//18//===----------------------------------------------------------------------===//19 20#ifndef LLD_WASM_LTO_H21#define LLD_WASM_LTO_H22 23#include "Writer.h"24#include "lld/Common/LLVM.h"25#include "llvm/ADT/DenseSet.h"26#include "llvm/ADT/SmallString.h"27#include "llvm/Support/raw_ostream.h"28#include <memory>29#include <vector>30 31namespace llvm {32namespace lto {33class LTO;34}35} // namespace llvm36 37namespace lld::wasm {38 39class BitcodeFile;40class InputFile;41 42class BitcodeCompiler {43public:44  BitcodeCompiler();45  ~BitcodeCompiler();46 47  void add(BitcodeFile &f);48  SmallVector<InputFile *, 0> compile();49 50private:51  std::unique_ptr<llvm::lto::LTO> ltoObj;52  // An array of (module name, native relocatable file content) pairs.53  SmallVector<std::pair<std::string, SmallString<0>>, 0> buf;54  std::vector<std::unique_ptr<MemoryBuffer>> files;55  SmallVector<std::string, 0> filenames;56  std::unique_ptr<llvm::raw_fd_ostream> indexFile;57  llvm::DenseSet<StringRef> thinIndices;58};59} // namespace lld::wasm60 61#endif62