LLVM  5.0.0
MCSectionWasm.h
Go to the documentation of this file.
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"
22 
23 namespace llvm {
24 
25 class MCSymbol;
26 
27 /// This represents a section on wasm.
28 class MCSectionWasm final : public MCSection {
29 private:
30  /// This is the name of the section. The referenced memory is owned by
31  /// TargetLoweringObjectFileWasm's WasmUniqueMap.
32  StringRef SectionName;
33 
34  /// This is the sh_type field of a section, drawn from the enums below.
35  unsigned Type;
36 
37  /// This is the sh_flags field of a section, drawn from the enums below.
38  unsigned Flags;
39 
40  unsigned UniqueID;
41 
42  const MCSymbolWasm *Group;
43 
44  // The offset of the MC function/data section in the wasm code/data section.
45  // For data relocations the offset is relative to start of the data payload
46  // itself and does not include the size of the section header.
47  uint64_t SectionOffset;
48 
49  friend class MCContext;
50  MCSectionWasm(StringRef Section, unsigned type, unsigned flags, SectionKind K,
51  const MCSymbolWasm *group, unsigned UniqueID, MCSymbol *Begin)
52  : MCSection(SV_Wasm, K, Begin), SectionName(Section), Type(type),
53  Flags(flags), UniqueID(UniqueID), Group(group), SectionOffset(0) {
54  }
55 
56  void setSectionName(StringRef Name) { SectionName = Name; }
57 
58 public:
60 
61  /// Decides whether a '.section' directive should be printed before the
62  /// section name
63  bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
64 
65  StringRef getSectionName() const { return SectionName; }
66  unsigned getType() const { return Type; }
67  unsigned getFlags() const { return Flags; }
68  void setFlags(unsigned F) { Flags = F; }
69  const MCSymbolWasm *getGroup() const { return Group; }
70 
71  void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
72  raw_ostream &OS,
73  const MCExpr *Subsection) const override;
74  bool UseCodeAlign() const override;
75  bool isVirtualSection() const override;
76 
77  bool isUnique() const { return UniqueID != ~0U; }
78  unsigned getUniqueID() const { return UniqueID; }
79 
80  uint64_t getSectionOffset() const { return SectionOffset; }
81  void setSectionOffset(uint64_t Offset) { SectionOffset = Offset; }
82 
83  static bool classof(const MCSection *S) { return S->getVariant() == SV_Wasm; }
84 };
85 
86 } // end namespace llvm
87 
88 #endif
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
SectionVariant getVariant() const
Definition: MCSection.h:104
static bool classof(const MCSection *S)
Definition: MCSectionWasm.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
unsigned getType() const
Definition: MCSectionWasm.h:66
uint64_t getSectionOffset() const
Definition: MCSectionWasm.h:80
Context object for machine code objects.
Definition: MCContext.h:59
#define F(x, y, z)
Definition: MD5.cpp:55
StringRef getSectionName() const
Definition: MCSectionWasm.h:65
bool UseCodeAlign() const override
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
const char * Name
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
unsigned getFlags() const
Definition: MCSectionWasm.h:67
This represents a section on wasm.
Definition: MCSectionWasm.h:28
void setSectionOffset(uint64_t Offset)
Definition: MCSectionWasm.h:81
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:23
bool isUnique() const
Definition: MCSectionWasm.h:77
void setFlags(unsigned F)
Definition: MCSectionWasm.h:68
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const
Decides whether a '.section' directive should be printed before the section name. ...
unsigned getUniqueID() const
Definition: MCSectionWasm.h:78
void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, const MCExpr *Subsection) const override
const MCSymbolWasm * getGroup() const
Definition: MCSectionWasm.h:69
static std::vector< std::string > Flags
Definition: FlagsTest.cpp:8
const char SectionName[]
Definition: AMDGPUPTNote.h:24
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
bool isVirtualSection() const override
Check whether this section is "virtual", that is has no actual object file contents.