MCSectionCOFF.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //===- MCSectionCOFF.h - COFF 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 MCSectionCOFF class.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCSECTIONCOFF_H
  14. #define LLVM_MC_MCSECTIONCOFF_H
  15. #include "llvm/ADT/StringRef.h"
  16. #include "llvm/MC/MCSection.h"
  17. #include "llvm/Support/COFF.h"
  18. namespace llvm {
  19. class MCSymbol;
  20. /// MCSectionCOFF - This represents a section on Windows
  21. class MCSectionCOFF : public MCSection {
  22. // The memory for this string is stored in the same MCContext as *this.
  23. StringRef SectionName;
  24. // FIXME: The following fields should not be mutable, but are for now so
  25. // the asm parser can honor the .linkonce directive.
  26. /// Characteristics - This is the Characteristics field of a section,
  27. /// drawn from the enums below.
  28. mutable unsigned Characteristics;
  29. /// The COMDAT symbol of this section. Only valid if this is a COMDAT
  30. /// section. Two COMDAT sections are merged if they have the same
  31. /// COMDAT symbol.
  32. MCSymbol *COMDATSymbol;
  33. /// Selection - This is the Selection field for the section symbol, if
  34. /// it is a COMDAT section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0
  35. mutable int Selection;
  36. private:
  37. friend class MCContext;
  38. MCSectionCOFF(StringRef Section, unsigned Characteristics,
  39. MCSymbol *COMDATSymbol, int Selection, SectionKind K,
  40. MCSymbol *Begin)
  41. : MCSection(SV_COFF, K, Begin), SectionName(Section),
  42. Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
  43. Selection(Selection) {
  44. assert ((Characteristics & 0x00F00000) == 0 &&
  45. "alignment must not be set upon section creation");
  46. }
  47. ~MCSectionCOFF() override;
  48. public:
  49. /// ShouldOmitSectionDirective - Decides whether a '.section' directive
  50. /// should be printed before the section name
  51. bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
  52. StringRef getSectionName() const { return SectionName; }
  53. unsigned getCharacteristics() const { return Characteristics; }
  54. MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; }
  55. int getSelection() const { return Selection; }
  56. void setSelection(int Selection) const;
  57. void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
  58. const MCExpr *Subsection) const override;
  59. bool UseCodeAlign() const override;
  60. bool isVirtualSection() const override;
  61. static bool classof(const MCSection *S) {
  62. return S->getVariant() == SV_COFF;
  63. }
  64. };
  65. } // end namespace llvm
  66. #endif