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