LLVM  9.0.0svn
MCSymbolWasm.h
Go to the documentation of this file.
1 //===- MCSymbolWasm.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 #ifndef LLVM_MC_MCSYMBOLWASM_H
9 #define LLVM_MC_MCSYMBOLWASM_H
10 
11 #include "llvm/BinaryFormat/Wasm.h"
12 #include "llvm/MC/MCSymbol.h"
13 
14 namespace llvm {
15 
16 class MCSymbolWasm : public MCSymbol {
18  bool IsWeak = false;
19  bool IsHidden = false;
20  bool IsComdat = false;
21  Optional<std::string> ImportModule;
22  Optional<std::string> ImportName;
23  wasm::WasmSignature *Signature = nullptr;
26 
27  /// An expression describing how to calculate the size of a symbol. If a
28  /// symbol has no size this field will be NULL.
29  const MCExpr *SymbolSize = nullptr;
30 
31 public:
32  // Use a module name of "env" for now, for compatibility with existing tools.
33  // This is temporary, and may change, as the ABI is not yet stable.
35  : MCSymbol(SymbolKindWasm, Name, isTemporary) {}
36  static bool classof(const MCSymbol *S) { return S->isWasm(); }
37 
38  const MCExpr *getSize() const { return SymbolSize; }
39  void setSize(const MCExpr *SS) { SymbolSize = SS; }
40 
41  bool isFunction() const { return Type == wasm::WASM_SYMBOL_TYPE_FUNCTION; }
42  bool isData() const { return Type == wasm::WASM_SYMBOL_TYPE_DATA; }
43  bool isGlobal() const { return Type == wasm::WASM_SYMBOL_TYPE_GLOBAL; }
44  bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION; }
45  bool isEvent() const { return Type == wasm::WASM_SYMBOL_TYPE_EVENT; }
46  wasm::WasmSymbolType getType() const { return Type; }
47  void setType(wasm::WasmSymbolType type) { Type = type; }
48 
49  bool isExported() const {
51  }
52  void setExported() const {
54  }
55 
56  bool isWeak() const { return IsWeak; }
57  void setWeak(bool isWeak) { IsWeak = isWeak; }
58 
59  bool isHidden() const { return IsHidden; }
60  void setHidden(bool isHidden) { IsHidden = isHidden; }
61 
62  bool isComdat() const { return IsComdat; }
63  void setComdat(bool isComdat) { IsComdat = isComdat; }
64 
65  const StringRef getImportModule() const {
66  if (ImportModule.hasValue()) {
67  return ImportModule.getValue();
68  }
69  return "env";
70  }
71  void setImportModule(StringRef Name) { ImportModule = Name; }
72 
73  const StringRef getImportName() const {
74  if (ImportName.hasValue()) {
75  return ImportName.getValue();
76  }
77  return getName();
78  }
79  void setImportName(StringRef Name) { ImportName = Name; }
80 
81  const wasm::WasmSignature *getSignature() const { return Signature; }
82  void setSignature(wasm::WasmSignature *Sig) { Signature = Sig; }
83 
85  assert(GlobalType.hasValue());
86  return GlobalType.getValue();
87  }
88  void setGlobalType(wasm::WasmGlobalType GT) { GlobalType = GT; }
89 
91  assert(EventType.hasValue());
92  return EventType.getValue();
93  }
94  void setEventType(wasm::WasmEventType ET) { EventType = ET; }
95 };
96 
97 } // end namespace llvm
98 
99 #endif // LLVM_MC_MCSYMBOLWASM_H
bool isFunction() const
Definition: MCSymbolWasm.h:41
void setImportModule(StringRef Name)
Definition: MCSymbolWasm.h:71
WasmSymbolType
Definition: Wasm.h:271
bool isData() const
Definition: MCSymbolWasm.h:42
This class represents lattice values for constants.
Definition: AllocatorList.h:23
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMap.h:125
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
void setWeak(bool isWeak)
Definition: MCSymbolWasm.h:57
bool isWasm() const
Definition: MCSymbol.h:286
static bool classof(const MCSymbol *S)
Definition: MCSymbolWasm.h:36
void setGlobalType(wasm::WasmGlobalType GT)
Definition: MCSymbolWasm.h:88
void setImportName(StringRef Name)
Definition: MCSymbolWasm.h:79
const wasm::WasmGlobalType & getGlobalType() const
Definition: MCSymbolWasm.h:84
bool isWeak() const
Definition: MCSymbolWasm.h:56
const wasm::WasmEventType & getEventType() const
Definition: MCSymbolWasm.h:90
void setComdat(bool isComdat)
Definition: MCSymbolWasm.h:63
bool isSection() const
Definition: MCSymbolWasm.h:44
void setSize(const MCExpr *SS)
Definition: MCSymbolWasm.h:39
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
bool isGlobal() const
Definition: MCSymbolWasm.h:43
const wasm::WasmSignature * getSignature() const
Definition: MCSymbolWasm.h:81
const T & getValue() const LLVM_LVALUE_FUNCTION
Definition: Optional.h:162
void setHidden(bool isHidden)
Definition: MCSymbolWasm.h:60
void setEventType(wasm::WasmEventType ET)
Definition: MCSymbolWasm.h:94
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Definition: MCSymbol.h:219
const MCExpr * getSize() const
Definition: MCSymbolWasm.h:38
void setType(wasm::WasmSymbolType type)
Definition: MCSymbolWasm.h:47
const StringRef getImportModule() const
Definition: MCSymbolWasm.h:65
bool isComdat() const
Definition: MCSymbolWasm.h:62
MCSymbolWasm(const StringMapEntry< bool > *Name, bool isTemporary)
Definition: MCSymbolWasm.h:34
bool isExported() const
Definition: MCSymbolWasm.h:49
bool hasValue() const
Definition: Optional.h:166
void setExported() const
Definition: MCSymbolWasm.h:52
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:202
wasm::WasmSymbolType getType() const
Definition: MCSymbolWasm.h:46
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setSignature(wasm::WasmSignature *Sig)
Definition: MCSymbolWasm.h:82
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
const StringRef getImportName() const
Definition: MCSymbolWasm.h:73
const unsigned WASM_SYMBOL_EXPORTED
Definition: Wasm.h:293
bool isHidden() const
Definition: MCSymbolWasm.h:59
void modifyFlags(uint32_t Value, uint32_t Mask) const
Modify the flags via a mask.
Definition: MCSymbol.h:415
uint32_t getFlags() const
Get the (implementation defined) symbol flags.
Definition: MCSymbol.h:406
bool isEvent() const
Definition: MCSymbolWasm.h:45