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 <string>
00018 #include "llvm/ADT/StringRef.h"
00019 #include "llvm/MC/SectionKind.h"
00020 
00021 namespace llvm {
00022   class MCContext;
00023   class TargetAsmInfo;
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     MCSection(const MCSection&);      // DO NOT IMPLEMENT
00031     void operator=(const MCSection&); // DO NOT IMPLEMENT
00032   protected:
00033     MCSection(SectionKind K) : Kind(K) {}
00034     SectionKind Kind;
00035   public:
00036     virtual ~MCSection();
00037 
00038     SectionKind getKind() const { return Kind; }
00039     
00040     virtual void PrintSwitchToSection(const TargetAsmInfo &TAI,
00041                                       raw_ostream &OS) const = 0;
00042   };
00043 
00044   class MCSectionCOFF : public MCSection {
00045     std::string Name;
00046     
00047     /// IsDirective - This is true if the section name is a directive, not
00048     /// something that should be printed with ".section".
00049     ///
00050     /// FIXME: This is a hack.  Switch to a semantic view of the section instead
00051     /// of a syntactic one.
00052     bool IsDirective;
00053     
00054     MCSectionCOFF(const StringRef &name, bool isDirective, SectionKind K)
00055       : MCSection(K), Name(name), IsDirective(isDirective) {
00056     }
00057   public:
00058     
00059     static MCSectionCOFF *Create(const StringRef &Name, bool IsDirective, 
00060                                    SectionKind K, MCContext &Ctx);
00061 
00062     const std::string &getName() const { return Name; }
00063     bool isDirective() const { return IsDirective; }
00064     
00065     virtual void PrintSwitchToSection(const TargetAsmInfo &TAI,
00066                                       raw_ostream &OS) const;
00067   };
00068   
00069 } // end namespace llvm
00070 
00071 #endif