1195098Sed//===- MCSection.h - Machine Code Sections ----------------------*- C++ -*-===// 2195098Sed// 3195098Sed// The LLVM Compiler Infrastructure 4195098Sed// 5195098Sed// This file is distributed under the University of Illinois Open Source 6195098Sed// License. See LICENSE.TXT for details. 7195098Sed// 8195098Sed//===----------------------------------------------------------------------===// 9195340Sed// 10195340Sed// This file declares the MCSection class. 11195340Sed// 12195340Sed//===----------------------------------------------------------------------===// 13195098Sed 14195098Sed#ifndef LLVM_MC_MCSECTION_H 15195098Sed#define LLVM_MC_MCSECTION_H 16195098Sed 17252723Sdim#include "llvm/ADT/StringRef.h" 18198090Srdivacky#include "llvm/MC/SectionKind.h" 19245431Sdim#include "llvm/Support/Compiler.h" 20195098Sed 21195098Sednamespace llvm { 22198090Srdivacky class MCAsmInfo; 23252723Sdim class MCExpr; 24198090Srdivacky class raw_ostream; 25210299Sed 26195340Sed /// MCSection - Instances of this class represent a uniqued identifier for a 27195340Sed /// section in the current translation unit. The MCContext class uniques and 28195340Sed /// creates these. 29195098Sed class MCSection { 30208599Srdivacky public: 31208599Srdivacky enum SectionVariant { 32208599Srdivacky SV_COFF = 0, 33208599Srdivacky SV_ELF, 34218893Sdim SV_MachO 35208599Srdivacky }; 36208599Srdivacky 37208599Srdivacky private: 38245431Sdim MCSection(const MCSection&) LLVM_DELETED_FUNCTION; 39245431Sdim void operator=(const MCSection&) LLVM_DELETED_FUNCTION; 40198090Srdivacky protected: 41208599Srdivacky MCSection(SectionVariant V, SectionKind K) : Variant(V), Kind(K) {} 42208599Srdivacky SectionVariant Variant; 43198090Srdivacky SectionKind Kind; 44195098Sed public: 45198090Srdivacky virtual ~MCSection(); 46195098Sed 47198090Srdivacky SectionKind getKind() const { return Kind; } 48208599Srdivacky 49208599Srdivacky SectionVariant getVariant() const { return Variant; } 50210299Sed 51198090Srdivacky virtual void PrintSwitchToSection(const MCAsmInfo &MAI, 52252723Sdim raw_ostream &OS, 53252723Sdim const MCExpr *Subsection) const = 0; 54206274Srdivacky 55252723Sdim // Convenience routines to get label names for the beginning/end of a 56252723Sdim // section. 57252723Sdim virtual std::string getLabelBeginName() const = 0; 58252723Sdim virtual std::string getLabelEndName() const = 0; 59252723Sdim 60206274Srdivacky /// isBaseAddressKnownZero - Return true if we know that this section will 61206274Srdivacky /// get a base address of zero. In cases where we know that this is true we 62206274Srdivacky /// can emit section offsets as direct references to avoid a subtraction 63206274Srdivacky /// from the base of the section, saving a relocation. 64206274Srdivacky virtual bool isBaseAddressKnownZero() const { 65206274Srdivacky return false; 66206274Srdivacky } 67198090Srdivacky 68218893Sdim // UseCodeAlign - Return true if a .align directive should use 69218893Sdim // "optimized nops" to fill instead of 0s. 70218893Sdim virtual bool UseCodeAlign() const = 0; 71218893Sdim 72218893Sdim /// isVirtualSection - Check whether this section is "virtual", that is 73218893Sdim /// has no actual object file contents. 74218893Sdim virtual bool isVirtualSection() const = 0; 75195098Sed }; 76210299Sed 77195098Sed} // end namespace llvm 78195098Sed 79195098Sed#endif 80