LCOV - code coverage report
Current view: top level - include/llvm/MC - MCSectionWasm.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 6 11 54.5 %
Date: 2018-10-20 13:21:21 Functions: 1 8 12.5 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- MCSectionWasm.h - Wasm Machine Code Sections -------------*- 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             : //
      10             : // This file declares the MCSectionWasm class.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_MC_MCSECTIONWASM_H
      15             : #define LLVM_MC_MCSECTIONWASM_H
      16             : 
      17             : #include "llvm/ADT/Twine.h"
      18             : #include "llvm/MC/MCSection.h"
      19             : #include "llvm/MC/MCSymbolWasm.h"
      20             : #include "llvm/Support/Debug.h"
      21             : #include "llvm/Support/raw_ostream.h"
      22             : 
      23             : namespace llvm {
      24             : 
      25             : class MCSymbol;
      26             : 
      27             : /// This represents a section on wasm.
      28             : class MCSectionWasm final : public MCSection {
      29             :   /// This is the name of the section.  The referenced memory is owned by
      30             :   /// TargetLoweringObjectFileWasm's WasmUniqueMap.
      31             :   StringRef SectionName;
      32             : 
      33             :   unsigned UniqueID;
      34             : 
      35             :   const MCSymbolWasm *Group;
      36             : 
      37             :   // The offset of the MC function/data section in the wasm code/data section.
      38             :   // For data relocations the offset is relative to start of the data payload
      39             :   // itself and does not include the size of the section header.
      40             :   uint64_t SectionOffset = 0;
      41             : 
      42             :   // For data sections, this is the index of of the corresponding wasm data
      43             :   // segment
      44             :   uint32_t SegmentIndex = 0;
      45             : 
      46             :   friend class MCContext;
      47             :   MCSectionWasm(StringRef Section, SectionKind K, const MCSymbolWasm *group,
      48             :                 unsigned UniqueID, MCSymbol *Begin)
      49        8723 :       : MCSection(SV_Wasm, K, Begin), SectionName(Section), UniqueID(UniqueID),
      50        8723 :         Group(group) {}
      51             : 
      52             :   void setSectionName(StringRef Name) { SectionName = Name; }
      53             : 
      54             : public:
      55             :   ~MCSectionWasm();
      56             : 
      57             :   /// Decides whether a '.section' directive should be printed before the
      58             :   /// section name
      59             :   bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
      60             : 
      61           0 :   StringRef getSectionName() const { return SectionName; }
      62           0 :   const MCSymbolWasm *getGroup() const { return Group; }
      63             : 
      64             :   void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
      65             :                             raw_ostream &OS,
      66             :                             const MCExpr *Subsection) const override;
      67             :   bool UseCodeAlign() const override;
      68             :   bool isVirtualSection() const override;
      69             : 
      70         629 :   bool isWasmData() const {
      71         629 :     return Kind.isGlobalWriteableData() || Kind.isReadOnly();
      72             :   }
      73             : 
      74           0 :   bool isUnique() const { return UniqueID != ~0U; }
      75             :   unsigned getUniqueID() const { return UniqueID; }
      76             : 
      77           0 :   uint64_t getSectionOffset() const { return SectionOffset; }
      78         472 :   void setSectionOffset(uint64_t Offset) { SectionOffset = Offset; }
      79             : 
      80           0 :   uint32_t getSegmentIndex() const { return SegmentIndex; }
      81          83 :   void setSegmentIndex(uint32_t Index) { SegmentIndex = Index; }
      82             : 
      83             :   static bool classof(const MCSection *S) { return S->getVariant() == SV_Wasm; }
      84             : };
      85             : 
      86             : } // end namespace llvm
      87             : 
      88             : #endif

Generated by: LCOV version 1.13