Home | History | Annotate | Download | only in MC
      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/MC/MCSymbol.h"
     13 #include "llvm/Support/Wasm.h"
     14 
     15 namespace llvm {
     16 class MCSymbolWasm : public MCSymbol {
     17 private:
     18   bool IsFunction = false;
     19   std::string ModuleName;
     20   SmallVector<wasm::ValType, 1> Returns;
     21   SmallVector<wasm::ValType, 4> Params;
     22 
     23   /// An expression describing how to calculate the size of a symbol. If a
     24   /// symbol has no size this field will be NULL.
     25   const MCExpr *SymbolSize = nullptr;
     26 
     27 public:
     28   // Use a module name of "env" for now, for compatibility with existing tools.
     29   // This is temporary, and may change, as the ABI is not yet stable.
     30   MCSymbolWasm(const StringMapEntry<bool> *Name, bool isTemporary)
     31       : MCSymbol(SymbolKindWasm, Name, isTemporary),
     32         ModuleName("env") {}
     33   static bool classof(const MCSymbol *S) { return S->isWasm(); }
     34 
     35   const MCExpr *getSize() const { return SymbolSize; }
     36   void setSize(const MCExpr *SS) { SymbolSize = SS; }
     37 
     38   bool isFunction() const { return IsFunction; }
     39   void setIsFunction(bool isFunc) { IsFunction = isFunc; }
     40 
     41   const StringRef getModuleName() const { return ModuleName; }
     42 
     43   const SmallVector<wasm::ValType, 1> &getReturns() const { return Returns; }
     44 
     45   void setReturns(SmallVectorImpl<wasm::ValType> &&Rets) {
     46     Returns = std::move(Rets);
     47   }
     48 
     49   const SmallVector<wasm::ValType, 4> &getParams() const { return Params; }
     50 
     51   void setParams(SmallVectorImpl<wasm::ValType> &&Pars) {
     52     Params = std::move(Pars);
     53   }
     54 };
     55 }
     56 
     57 #endif
     58