LLVM  7.0.0
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  std::string ModuleName;
25  wasm::WasmGlobalType GlobalType;
26  bool ParamsSet = false;
27  bool ReturnsSet = false;
28  bool GlobalTypeSet = false;
29 
30  /// An expression describing how to calculate the size of a symbol. If a
31  /// symbol has no size this field will be NULL.
32  const MCExpr *SymbolSize = nullptr;
33 
34 public:
35  // Use a module name of "env" for now, for compatibility with existing tools.
36  // This is temporary, and may change, as the ABI is not yet stable.
38  : MCSymbol(SymbolKindWasm, Name, isTemporary),
39  ModuleName("env") {}
40  static bool classof(const MCSymbol *S) { return S->isWasm(); }
41 
42  const MCExpr *getSize() const { return SymbolSize; }
43  void setSize(const MCExpr *SS) { SymbolSize = SS; }
44 
45  bool isFunction() const { return Type == wasm::WASM_SYMBOL_TYPE_FUNCTION; }
46  bool isData() const { return Type == wasm::WASM_SYMBOL_TYPE_DATA; }
47  bool isGlobal() const { return Type == wasm::WASM_SYMBOL_TYPE_GLOBAL; }
48  bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION; }
49  wasm::WasmSymbolType getType() const { return Type; }
50  void setType(wasm::WasmSymbolType type) { Type = type; }
51 
52  bool isWeak() const { return IsWeak; }
53  void setWeak(bool isWeak) { IsWeak = isWeak; }
54 
55  bool isHidden() const { return IsHidden; }
56  void setHidden(bool isHidden) { IsHidden = isHidden; }
57 
58  bool isComdat() const { return IsComdat; }
59  void setComdat(bool isComdat) { IsComdat = isComdat; }
60 
61  const StringRef getModuleName() const { return ModuleName; }
62  void setModuleName(StringRef Name) { ModuleName = Name; }
63 
65  assert(ReturnsSet);
66  return Returns;
67  }
68 
70  ReturnsSet = true;
71  Returns = std::move(Rets);
72  }
73 
75  assert(ParamsSet);
76  return Params;
77  }
78 
80  ParamsSet = true;
81  Params = std::move(Pars);
82  }
83 
85  assert(GlobalTypeSet);
86  return GlobalType;
87  }
88 
90  GlobalTypeSet = true;
91  GlobalType = GT;
92  }
93 };
94 
95 } // end namespace llvm
96 
97 #endif // LLVM_MC_MCSYMBOLWASM_H
bool isFunction() const
Definition: MCSymbolWasm.h:45
WasmSymbolType
Definition: Wasm.h:252
bool isData() const
Definition: MCSymbolWasm.h:46
void setModuleName(StringRef Name)
Definition: MCSymbolWasm.h:62
Compute iterated dominance frontiers using a linear time algorithm.
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:53
bool isWasm() const
Definition: MCSymbol.h:287
static bool classof(const MCSymbol *S)
Definition: MCSymbolWasm.h:40
void setGlobalType(wasm::WasmGlobalType GT)
Definition: MCSymbolWasm.h:89
const StringRef getModuleName() const
Definition: MCSymbolWasm.h:61
void setParams(SmallVectorImpl< wasm::ValType > &&Pars)
Definition: MCSymbolWasm.h:79
const wasm::WasmGlobalType & getGlobalType() const
Definition: MCSymbolWasm.h:84
bool isWeak() const
Definition: MCSymbolWasm.h:52
void setComdat(bool isComdat)
Definition: MCSymbolWasm.h:59
bool isSection() const
Definition: MCSymbolWasm.h:48
void setSize(const MCExpr *SS)
Definition: MCSymbolWasm.h:43
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
bool isGlobal() const
Definition: MCSymbolWasm.h:47
void setHidden(bool isHidden)
Definition: MCSymbolWasm.h:56
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
void setReturns(SmallVectorImpl< wasm::ValType > &&Rets)
Definition: MCSymbolWasm.h:69
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Definition: MCSymbol.h:220
const SmallVector< wasm::ValType, 1 > & getReturns() const
Definition: MCSymbolWasm.h:64
const MCExpr * getSize() const
Definition: MCSymbolWasm.h:42
void setType(wasm::WasmSymbolType type)
Definition: MCSymbolWasm.h:50
bool isComdat() const
Definition: MCSymbolWasm.h:58
MCSymbolWasm(const StringMapEntry< bool > *Name, bool isTemporary)
Definition: MCSymbolWasm.h:37
const SmallVector< wasm::ValType, 4 > & getParams() const
Definition: MCSymbolWasm.h:74
wasm::WasmSymbolType getType() const
Definition: MCSymbolWasm.h:49
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
bool isHidden() const
Definition: MCSymbolWasm.h:55