LLVM API Documentation
00001 //===- MCSectionCOFF.h - COFF Machine Code Sections -------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file declares the MCSectionCOFF class. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_MC_MCSECTIONCOFF_H 00015 #define LLVM_MC_MCSECTIONCOFF_H 00016 00017 #include "llvm/ADT/StringRef.h" 00018 #include "llvm/MC/MCSection.h" 00019 #include "llvm/Support/COFF.h" 00020 00021 namespace llvm { 00022 class MCSymbol; 00023 00024 /// MCSectionCOFF - This represents a section on Windows 00025 class MCSectionCOFF : public MCSection { 00026 // The memory for this string is stored in the same MCContext as *this. 00027 StringRef SectionName; 00028 00029 // FIXME: The following fields should not be mutable, but are for now so 00030 // the asm parser can honor the .linkonce directive. 00031 00032 /// Characteristics - This is the Characteristics field of a section, 00033 /// drawn from the enums below. 00034 mutable unsigned Characteristics; 00035 00036 /// The COMDAT symbol of this section. Only valid if this is a COMDAT 00037 /// section. Two COMDAT sections are merged if they have the same 00038 /// COMDAT symbol. 00039 MCSymbol *COMDATSymbol; 00040 00041 /// Selection - This is the Selection field for the section symbol, if 00042 /// it is a COMDAT section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0 00043 mutable int Selection; 00044 00045 private: 00046 friend class MCContext; 00047 MCSectionCOFF(StringRef Section, unsigned Characteristics, 00048 MCSymbol *COMDATSymbol, int Selection, SectionKind K) 00049 : MCSection(SV_COFF, K), SectionName(Section), 00050 Characteristics(Characteristics), COMDATSymbol(COMDATSymbol), 00051 Selection(Selection) { 00052 assert ((Characteristics & 0x00F00000) == 0 && 00053 "alignment must not be set upon section creation"); 00054 } 00055 ~MCSectionCOFF(); 00056 00057 public: 00058 /// ShouldOmitSectionDirective - Decides whether a '.section' directive 00059 /// should be printed before the section name 00060 bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const; 00061 00062 StringRef getSectionName() const { return SectionName; } 00063 std::string getLabelBeginName() const override { 00064 return SectionName.str() + "_begin"; 00065 } 00066 std::string getLabelEndName() const override { 00067 return SectionName.str() + "_end"; 00068 } 00069 unsigned getCharacteristics() const { return Characteristics; } 00070 MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; } 00071 int getSelection() const { return Selection; } 00072 00073 void setSelection(int Selection) const; 00074 00075 void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS, 00076 const MCExpr *Subsection) const override; 00077 bool UseCodeAlign() const override; 00078 bool isVirtualSection() const override; 00079 00080 static bool classof(const MCSection *S) { 00081 return S->getVariant() == SV_COFF; 00082 } 00083 }; 00084 00085 } // end namespace llvm 00086 00087 #endif