LLVM  10.0.0svn
MCSectionWasm.h
Go to the documentation of this file.
1 //===- MCSectionWasm.h - Wasm Machine Code Sections -------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the MCSectionWasm class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_MC_MCSECTIONWASM_H
14 #define LLVM_MC_MCSECTIONWASM_H
15 
16 #include "llvm/ADT/Twine.h"
17 #include "llvm/MC/MCSection.h"
18 #include "llvm/MC/MCSymbolWasm.h"
19 #include "llvm/Support/Debug.h"
21 
22 namespace llvm {
23 
24 class MCSymbol;
25 
26 /// This represents a section on wasm.
27 class MCSectionWasm final : public MCSection {
28  /// This is the name of the section. The referenced memory is owned by
29  /// TargetLoweringObjectFileWasm's WasmUniqueMap.
31 
32  unsigned UniqueID;
33 
34  const MCSymbolWasm *Group;
35 
36  // The offset of the MC function/data section in the wasm code/data section.
37  // For data relocations the offset is relative to start of the data payload
38  // itself and does not include the size of the section header.
39  uint64_t SectionOffset = 0;
40 
41  // For data sections, this is the index of of the corresponding wasm data
42  // segment
43  uint32_t SegmentIndex = 0;
44 
45  // Whether this data segment is passive
46  bool IsPassive = false;
47 
48  friend class MCContext;
50  unsigned UniqueID, MCSymbol *Begin)
51  : MCSection(SV_Wasm, K, Begin), SectionName(Section), UniqueID(UniqueID),
52  Group(group) {}
53 
54 public:
55  /// Decides whether a '.section' directive should be printed before the
56  /// section name
57  bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
58 
59  StringRef getSectionName() const { return SectionName; }
60  const MCSymbolWasm *getGroup() const { return Group; }
61 
62  void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
63  raw_ostream &OS,
64  const MCExpr *Subsection) const override;
65  bool UseCodeAlign() const override;
66  bool isVirtualSection() const override;
67 
68  bool isWasmData() const {
69  return Kind.isGlobalWriteableData() || Kind.isReadOnly() ||
71  }
72 
73  bool isUnique() const { return UniqueID != ~0U; }
74  unsigned getUniqueID() const { return UniqueID; }
75 
76  uint64_t getSectionOffset() const { return SectionOffset; }
77  void setSectionOffset(uint64_t Offset) { SectionOffset = Offset; }
78 
79  uint32_t getSegmentIndex() const { return SegmentIndex; }
80  void setSegmentIndex(uint32_t Index) { SegmentIndex = Index; }
81 
82  bool getPassive() const {
83  assert(isWasmData());
84  return IsPassive;
85  }
86  void setPassive(bool V = true) {
87  assert(isWasmData());
88  IsPassive = V;
89  }
90  static bool classof(const MCSection *S) { return S->getVariant() == SV_Wasm; }
91 };
92 
93 } // end namespace llvm
94 
95 #endif
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
This class represents lattice values for constants.
Definition: AllocatorList.h:23
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
StringRef getSectionName() const
Definition: MCSectionWasm.h:59
static bool classof(const MCSection *S)
Definition: MCSectionWasm.h:90
const MCSymbolWasm * getGroup() const
Definition: MCSectionWasm.h:60
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
bool isGlobalWriteableData() const
Definition: SectionKind.h:155
Context object for machine code objects.
Definition: MCContext.h:65
void setPassive(bool V=true)
Definition: MCSectionWasm.h:86
bool UseCodeAlign() const override
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
This represents a section on wasm.
Definition: MCSectionWasm.h:27
void setSectionOffset(uint64_t Offset)
Definition: MCSectionWasm.h:77
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
SectionVariant getVariant() const
Definition: MCSection.h:108
bool isUnique() const
Definition: MCSectionWasm.h:73
unsigned getUniqueID() const
Definition: MCSectionWasm.h:74
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
bool getPassive() const
Definition: MCSectionWasm.h:82
uint64_t getSectionOffset() const
Definition: MCSectionWasm.h:76
void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, const MCExpr *Subsection) const override
bool isWasmData() const
Definition: MCSectionWasm.h:68
bool isReadOnly() const
Definition: SectionKind.h:122
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isThreadLocal() const
Definition: SectionKind.h:148
uint32_t getSegmentIndex() const
Definition: MCSectionWasm.h:79
const char SectionName[]
Definition: AMDGPUPTNote.h:23
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const
Decides whether a '.section' directive should be printed before the section name. ...
bool isVirtualSection() const override
Check whether this section is "virtual", that is has no actual object file contents.
SectionKind Kind
Definition: MCSection.h:97
void setSegmentIndex(uint32_t Index)
Definition: MCSectionWasm.h:80