LLVM API Documentation

MCSection.h
Go to the documentation of this file.
00001 //===- MCSection.h - 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 MCSection class.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #ifndef LLVM_MC_MCSECTION_H
00015 #define LLVM_MC_MCSECTION_H
00016 
00017 #include "llvm/ADT/StringRef.h"
00018 #include "llvm/MC/SectionKind.h"
00019 #include "llvm/Support/Compiler.h"
00020 
00021 namespace llvm {
00022   class MCAsmInfo;
00023   class MCExpr;
00024   class raw_ostream;
00025 
00026   /// MCSection - Instances of this class represent a uniqued identifier for a
00027   /// section in the current translation unit.  The MCContext class uniques and
00028   /// creates these.
00029   class MCSection {
00030   public:
00031     enum SectionVariant {
00032       SV_COFF = 0,
00033       SV_ELF,
00034       SV_MachO
00035     };
00036 
00037   private:
00038     MCSection(const MCSection&) LLVM_DELETED_FUNCTION;
00039     void operator=(const MCSection&) LLVM_DELETED_FUNCTION;
00040   protected:
00041     MCSection(SectionVariant V, SectionKind K) : Variant(V), Kind(K) {}
00042     SectionVariant Variant;
00043     SectionKind Kind;
00044   public:
00045     virtual ~MCSection();
00046 
00047     SectionKind getKind() const { return Kind; }
00048 
00049     SectionVariant getVariant() const { return Variant; }
00050 
00051     virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
00052                                       raw_ostream &OS,
00053                                       const MCExpr *Subsection) const = 0;
00054 
00055     // Convenience routines to get label names for the beginning/end of a
00056     // section.
00057     virtual std::string getLabelBeginName() const = 0;
00058     virtual std::string getLabelEndName() const = 0;
00059 
00060     /// isBaseAddressKnownZero - Return true if we know that this section will
00061     /// get a base address of zero.  In cases where we know that this is true we
00062     /// can emit section offsets as direct references to avoid a subtraction
00063     /// from the base of the section, saving a relocation.
00064     virtual bool isBaseAddressKnownZero() const {
00065       return false;
00066     }
00067 
00068     // UseCodeAlign - Return true if a .align directive should use
00069     // "optimized nops" to fill instead of 0s.
00070     virtual bool UseCodeAlign() const = 0;
00071 
00072     /// isVirtualSection - Check whether this section is "virtual", that is
00073     /// has no actual object file contents.
00074     virtual bool isVirtualSection() const = 0;
00075   };
00076 
00077 } // end namespace llvm
00078 
00079 #endif