2017-02-22 02:23:18 +01:00
|
|
|
//===- MCSymbolWasm.h - ----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-02-22 02:23:18 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_MC_MCSYMBOLWASM_H
|
|
|
|
#define LLVM_MC_MCSYMBOLWASM_H
|
|
|
|
|
2017-06-07 05:48:56 +02:00
|
|
|
#include "llvm/BinaryFormat/Wasm.h"
|
2017-02-22 02:23:18 +01:00
|
|
|
#include "llvm/MC/MCSymbol.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
2017-06-13 20:51:50 +02:00
|
|
|
|
2017-02-22 02:23:18 +01:00
|
|
|
class MCSymbolWasm : public MCSymbol {
|
2018-02-23 06:08:34 +01:00
|
|
|
wasm::WasmSymbolType Type = wasm::WASM_SYMBOL_TYPE_DATA;
|
2017-06-20 06:04:59 +02:00
|
|
|
bool IsWeak = false;
|
2017-12-03 02:19:23 +01:00
|
|
|
bool IsHidden = false;
|
2018-01-11 21:35:17 +01:00
|
|
|
bool IsComdat = false;
|
2017-02-25 00:18:00 +01:00
|
|
|
std::string ModuleName;
|
2018-10-04 00:22:48 +02:00
|
|
|
wasm::WasmSignature *Signature = nullptr;
|
2018-11-14 03:46:21 +01:00
|
|
|
Optional<wasm::WasmGlobalType> GlobalType;
|
|
|
|
Optional<wasm::WasmEventType> EventType;
|
2017-02-25 00:18:00 +01:00
|
|
|
|
|
|
|
/// An expression describing how to calculate the size of a symbol. If a
|
|
|
|
/// symbol has no size this field will be NULL.
|
|
|
|
const MCExpr *SymbolSize = nullptr;
|
|
|
|
|
2017-02-22 02:23:18 +01:00
|
|
|
public:
|
2017-02-25 00:18:00 +01:00
|
|
|
// Use a module name of "env" for now, for compatibility with existing tools.
|
|
|
|
// This is temporary, and may change, as the ABI is not yet stable.
|
2017-02-22 02:23:18 +01:00
|
|
|
MCSymbolWasm(const StringMapEntry<bool> *Name, bool isTemporary)
|
2018-09-05 03:27:38 +02:00
|
|
|
: MCSymbol(SymbolKindWasm, Name, isTemporary), ModuleName("env") {}
|
2017-02-22 02:23:18 +01:00
|
|
|
static bool classof(const MCSymbol *S) { return S->isWasm(); }
|
2017-02-25 00:18:00 +01:00
|
|
|
|
|
|
|
const MCExpr *getSize() const { return SymbolSize; }
|
|
|
|
void setSize(const MCExpr *SS) { SymbolSize = SS; }
|
|
|
|
|
2018-02-23 06:08:34 +01:00
|
|
|
bool isFunction() const { return Type == wasm::WASM_SYMBOL_TYPE_FUNCTION; }
|
|
|
|
bool isData() const { return Type == wasm::WASM_SYMBOL_TYPE_DATA; }
|
|
|
|
bool isGlobal() const { return Type == wasm::WASM_SYMBOL_TYPE_GLOBAL; }
|
2018-04-30 21:40:57 +02:00
|
|
|
bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION; }
|
2018-11-14 03:46:21 +01:00
|
|
|
bool isEvent() const { return Type == wasm::WASM_SYMBOL_TYPE_EVENT; }
|
2018-02-23 06:08:34 +01:00
|
|
|
wasm::WasmSymbolType getType() const { return Type; }
|
|
|
|
void setType(wasm::WasmSymbolType type) { Type = type; }
|
2017-02-25 00:18:00 +01:00
|
|
|
|
2017-06-20 06:04:59 +02:00
|
|
|
bool isWeak() const { return IsWeak; }
|
|
|
|
void setWeak(bool isWeak) { IsWeak = isWeak; }
|
|
|
|
|
2017-12-03 02:19:23 +01:00
|
|
|
bool isHidden() const { return IsHidden; }
|
|
|
|
void setHidden(bool isHidden) { IsHidden = isHidden; }
|
|
|
|
|
2018-01-11 21:35:17 +01:00
|
|
|
bool isComdat() const { return IsComdat; }
|
|
|
|
void setComdat(bool isComdat) { IsComdat = isComdat; }
|
|
|
|
|
2017-02-25 00:18:00 +01:00
|
|
|
const StringRef getModuleName() const { return ModuleName; }
|
2018-02-10 00:13:22 +01:00
|
|
|
void setModuleName(StringRef Name) { ModuleName = Name; }
|
2017-02-25 00:18:00 +01:00
|
|
|
|
2018-10-04 00:22:48 +02:00
|
|
|
const wasm::WasmSignature *getSignature() const { return Signature; }
|
|
|
|
void setSignature(wasm::WasmSignature *Sig) { Signature = Sig; }
|
2018-02-23 06:08:34 +01:00
|
|
|
|
|
|
|
const wasm::WasmGlobalType &getGlobalType() const {
|
2018-11-14 03:46:21 +01:00
|
|
|
assert(GlobalType.hasValue());
|
|
|
|
return GlobalType.getValue();
|
2018-02-23 06:08:34 +01:00
|
|
|
}
|
2018-11-14 03:46:21 +01:00
|
|
|
void setGlobalType(wasm::WasmGlobalType GT) { GlobalType = GT; }
|
2018-02-23 06:08:34 +01:00
|
|
|
|
2018-11-14 03:46:21 +01:00
|
|
|
const wasm::WasmEventType &getEventType() const {
|
|
|
|
assert(EventType.hasValue());
|
|
|
|
return EventType.getValue();
|
2018-02-23 06:08:34 +01:00
|
|
|
}
|
2018-11-14 03:46:21 +01:00
|
|
|
void setEventType(wasm::WasmEventType ET) { EventType = ET; }
|
2017-02-22 02:23:18 +01:00
|
|
|
};
|
|
|
|
|
2018-09-05 03:27:38 +02:00
|
|
|
} // end namespace llvm
|
2017-06-13 20:51:50 +02:00
|
|
|
|
|
|
|
#endif // LLVM_MC_MCSYMBOLWASM_H
|