LCOV - code coverage report
Current view: top level - include/llvm/MC - MCSymbolWasm.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 13 23 56.5 %
Date: 2018-09-23 13:06:45 Functions: 2 14 14.3 %
Legend: Lines: hit not hit

          Line data    Source code
       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 {
      18             :   wasm::WasmSymbolType Type = wasm::WASM_SYMBOL_TYPE_DATA;
      19             :   bool IsWeak = false;
      20             :   bool IsHidden = false;
      21             :   bool IsComdat = false;
      22             :   std::string ModuleName;
      23             :   SmallVector<wasm::ValType, 1> Returns;
      24             :   SmallVector<wasm::ValType, 4> Params;
      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.
      37       15247 :   MCSymbolWasm(const StringMapEntry<bool> *Name, bool isTemporary)
      38       29898 :       : MCSymbol(SymbolKindWasm, Name, isTemporary), ModuleName("env") {}
      39             :   static bool classof(const MCSymbol *S) { return S->isWasm(); }
      40             : 
      41           0 :   const MCExpr *getSize() const { return SymbolSize; }
      42         436 :   void setSize(const MCExpr *SS) { SymbolSize = SS; }
      43             : 
      44         410 :   bool isFunction() const { return Type == wasm::WASM_SYMBOL_TYPE_FUNCTION; }
      45           0 :   bool isData() const { return Type == wasm::WASM_SYMBOL_TYPE_DATA; }
      46           0 :   bool isGlobal() const { return Type == wasm::WASM_SYMBOL_TYPE_GLOBAL; }
      47           0 :   bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION; }
      48           0 :   wasm::WasmSymbolType getType() const { return Type; }
      49        9370 :   void setType(wasm::WasmSymbolType type) { Type = type; }
      50             : 
      51           0 :   bool isWeak() const { return IsWeak; }
      52          34 :   void setWeak(bool isWeak) { IsWeak = isWeak; }
      53             : 
      54           0 :   bool isHidden() const { return IsHidden; }
      55         102 :   void setHidden(bool isHidden) { IsHidden = isHidden; }
      56             : 
      57           0 :   bool isComdat() const { return IsComdat; }
      58           9 :   void setComdat(bool isComdat) { IsComdat = isComdat; }
      59             : 
      60             :   const StringRef getModuleName() const { return ModuleName; }
      61           2 :   void setModuleName(StringRef Name) { ModuleName = Name; }
      62             : 
      63             :   const SmallVector<wasm::ValType, 1> &getReturns() const {
      64             :     assert(ReturnsSet);
      65             :     return Returns;
      66             :   }
      67             : 
      68             :   void setReturns(SmallVectorImpl<wasm::ValType> &&Rets) {
      69         962 :     ReturnsSet = true;
      70             :     Returns = std::move(Rets);
      71             :   }
      72             : 
      73             :   const SmallVector<wasm::ValType, 4> &getParams() const {
      74             :     assert(ParamsSet);
      75             :     return Params;
      76             :   }
      77             : 
      78             :   void setParams(SmallVectorImpl<wasm::ValType> &&Pars) {
      79         962 :     ParamsSet = true;
      80             :     Params = std::move(Pars);
      81             :   }
      82             : 
      83             :   const wasm::WasmGlobalType &getGlobalType() const {
      84             :     assert(GlobalTypeSet);
      85             :     return GlobalType;
      86             :   }
      87             : 
      88           0 :   void setGlobalType(wasm::WasmGlobalType GT) {
      89         248 :     GlobalTypeSet = true;
      90         248 :     GlobalType = GT;
      91           0 :   }
      92             : };
      93             : 
      94             : } // end namespace llvm
      95             : 
      96             : #endif // LLVM_MC_MCSYMBOLWASM_H

Generated by: LCOV version 1.13