summaryrefslogtreecommitdiffstats
path: root/lld/wasm/InputFunction.h
blob: a660d62bb691257b4f4732daf92afea2d6cf4eb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//===- InpuFunction.h -------------------------------------------*- C++ -*-===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Represents a WebAssembly function in an input file which could also be
// assigned a function index in the output.
//
//===----------------------------------------------------------------------===//

#ifndef LLD_WASM_INPUT_FUNCTION_H
#define LLD_WASM_INPUT_FUNCTION_H

#include "WriterUtils.h"
#include "llvm/Object/Wasm.h"

using llvm::wasm::WasmRelocation;
using llvm::wasm::WasmFunction;

namespace lld {
namespace wasm {

class ObjFile;

class InputFunction {
public:
  InputFunction(const WasmSignature &S, const WasmFunction &Func,
                const ObjFile &F)
      : Signature(S), Function(Func), File(F) {}

  uint32_t getOutputIndex() const { return OutputIndex.getValue(); };
  bool hasOutputIndex() const { return OutputIndex.hasValue(); };

  void setOutputIndex(uint32_t Index) {
    assert(!hasOutputIndex());
    OutputIndex = Index;
  };

  const WasmSignature &Signature;
  const WasmFunction &Function;
  int32_t OutputOffset = 0;
  std::vector<WasmRelocation> Relocations;
  std::vector<OutputRelocation> OutRelocations;
  const ObjFile &File;

protected:
  llvm::Optional<uint32_t> OutputIndex;
};

} // namespace wasm
} // namespace lld

#endif // LLD_WASM_INPUT_FUNCTION_H
OpenPOWER on IntegriCloud