MCSectionWasm.h revision 317017
1317017Sdim//===- MCSectionWasm.h - Wasm Machine Code Sections -------------*- C++ -*-===// 2317017Sdim// 3317017Sdim// The LLVM Compiler Infrastructure 4317017Sdim// 5317017Sdim// This file is distributed under the University of Illinois Open Source 6317017Sdim// License. See LICENSE.TXT for details. 7317017Sdim// 8317017Sdim//===----------------------------------------------------------------------===// 9317017Sdim// 10317017Sdim// This file declares the MCSectionWasm class. 11317017Sdim// 12317017Sdim//===----------------------------------------------------------------------===// 13317017Sdim 14317017Sdim#ifndef LLVM_MC_MCSECTIONWASM_H 15317017Sdim#define LLVM_MC_MCSECTIONWASM_H 16317017Sdim 17317017Sdim#include "llvm/ADT/Twine.h" 18317017Sdim#include "llvm/MC/MCSection.h" 19317017Sdim#include "llvm/MC/MCSymbolWasm.h" 20317017Sdim#include "llvm/Support/Debug.h" 21317017Sdim#include "llvm/Support/raw_ostream.h" 22317017Sdim 23317017Sdimnamespace llvm { 24317017Sdim 25317017Sdimclass MCSymbol; 26317017Sdim 27317017Sdim/// This represents a section on wasm. 28317017Sdimclass MCSectionWasm final : public MCSection { 29317017Sdim /// This is the name of the section. The referenced memory is owned by 30317017Sdim /// TargetLoweringObjectFileWasm's WasmUniqueMap. 31317017Sdim StringRef SectionName; 32317017Sdim 33317017Sdim /// This is the sh_type field of a section, drawn from the enums below. 34317017Sdim unsigned Type; 35317017Sdim 36317017Sdim /// This is the sh_flags field of a section, drawn from the enums below. 37317017Sdim unsigned Flags; 38317017Sdim 39317017Sdim unsigned UniqueID; 40317017Sdim 41317017Sdim const MCSymbolWasm *Group; 42317017Sdim 43317017Sdim // The offset of the MC function section in the wasm code section. 44317017Sdim uint64_t SectionOffset; 45317017Sdim 46317017Sdimprivate: 47317017Sdim friend class MCContext; 48317017Sdim MCSectionWasm(StringRef Section, unsigned type, unsigned flags, SectionKind K, 49317017Sdim const MCSymbolWasm *group, unsigned UniqueID, MCSymbol *Begin) 50317017Sdim : MCSection(SV_Wasm, K, Begin), SectionName(Section), Type(type), 51317017Sdim Flags(flags), UniqueID(UniqueID), Group(group), SectionOffset(0) { 52317017Sdim } 53317017Sdim 54317017Sdim void setSectionName(StringRef Name) { SectionName = Name; } 55317017Sdim 56317017Sdimpublic: 57317017Sdim ~MCSectionWasm(); 58317017Sdim 59317017Sdim /// Decides whether a '.section' directive should be printed before the 60317017Sdim /// section name 61317017Sdim bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const; 62317017Sdim 63317017Sdim StringRef getSectionName() const { return SectionName; } 64317017Sdim unsigned getType() const { return Type; } 65317017Sdim unsigned getFlags() const { return Flags; } 66317017Sdim void setFlags(unsigned F) { Flags = F; } 67317017Sdim const MCSymbolWasm *getGroup() const { return Group; } 68317017Sdim 69317017Sdim void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, 70317017Sdim raw_ostream &OS, 71317017Sdim const MCExpr *Subsection) const override; 72317017Sdim bool UseCodeAlign() const override; 73317017Sdim bool isVirtualSection() const override; 74317017Sdim 75317017Sdim bool isUnique() const { return UniqueID != ~0U; } 76317017Sdim unsigned getUniqueID() const { return UniqueID; } 77317017Sdim 78317017Sdim uint64_t getSectionOffset() const { return SectionOffset; } 79317017Sdim void setSectionOffset(uint64_t Offset) { SectionOffset = Offset; } 80317017Sdim 81317017Sdim static bool classof(const MCSection *S) { return S->getVariant() == SV_Wasm; } 82317017Sdim}; 83317017Sdim 84317017Sdim} // end namespace llvm 85317017Sdim 86317017Sdim#endif 87