1c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===- MCSymbolWasm.h -  ----------------------------------------*- C++ -*-===//
2c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
3c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//                     The LLVM Compiler Infrastructure
4c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
5c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file is distributed under the University of Illinois Open Source
6c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// License. See LICENSE.TXT for details.
7c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
8c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
9c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#ifndef LLVM_MC_MCSYMBOLWASM_H
10c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define LLVM_MC_MCSYMBOLWASM_H
11c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
12c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/BinaryFormat/Wasm.h"
13c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/MC/MCSymbol.h"
14c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
15c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace llvm {
16c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
17c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MCSymbolWasm : public MCSymbol {
18c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate:
19c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool IsFunction = false;
20c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  std::string ModuleName;
21c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallVector<wasm::ValType, 1> Returns;
22c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  SmallVector<wasm::ValType, 4> Params;
23c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
24c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// An expression describing how to calculate the size of a symbol. If a
25c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// symbol has no size this field will be NULL.
26c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCExpr *SymbolSize = nullptr;
27c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
28c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
29c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // Use a module name of "env" for now, for compatibility with existing tools.
30c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  // This is temporary, and may change, as the ABI is not yet stable.
31c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MCSymbolWasm(const StringMapEntry<bool> *Name, bool isTemporary)
32c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot      : MCSymbol(SymbolKindWasm, Name, isTemporary),
33c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot        ModuleName("env") {}
34c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  static bool classof(const MCSymbol *S) { return S->isWasm(); }
35c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
36c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const MCExpr *getSize() const { return SymbolSize; }
37c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setSize(const MCExpr *SS) { SymbolSize = SS; }
38c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
39c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool isFunction() const { return IsFunction; }
40c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setIsFunction(bool isFunc) { IsFunction = isFunc; }
41c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
42c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const StringRef getModuleName() const { return ModuleName; }
43c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
44c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SmallVector<wasm::ValType, 1> &getReturns() const { return Returns; }
45c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
46c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setReturns(SmallVectorImpl<wasm::ValType> &&Rets) {
47c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Returns = std::move(Rets);
48c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
49c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
50c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  const SmallVector<wasm::ValType, 4> &getParams() const { return Params; }
51c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
52c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void setParams(SmallVectorImpl<wasm::ValType> &&Pars) {
53c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    Params = std::move(Pars);
54c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
55c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
56c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
57c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot}  // end namespace llvm
58c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
59c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#endif // LLVM_MC_MCSYMBOLWASM_H
60