2009-06-23 22:01:43 +00:00
|
|
|
//===- MCSection.h - Machine Code Sections ----------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-07-01 06:31:49 +00:00
|
|
|
//
|
|
|
|
// This file declares the MCSection class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-23 22:01:43 +00:00
|
|
|
|
|
|
|
#ifndef LLVM_MC_MCSECTION_H
|
|
|
|
#define LLVM_MC_MCSECTION_H
|
|
|
|
|
2012-12-13 03:00:35 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2009-08-01 21:30:49 +00:00
|
|
|
#include "llvm/MC/SectionKind.h"
|
2012-08-29 06:28:46 +00:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2009-06-23 22:01:43 +00:00
|
|
|
|
2009-07-31 17:02:00 +00:00
|
|
|
namespace llvm {
|
2015-03-10 13:56:44 +00:00
|
|
|
class MCAsmInfo;
|
2015-03-23 21:22:04 +00:00
|
|
|
class MCContext;
|
2015-03-10 13:56:44 +00:00
|
|
|
class MCExpr;
|
2015-03-10 16:58:10 +00:00
|
|
|
class MCSymbol;
|
2015-03-10 13:56:44 +00:00
|
|
|
class raw_ostream;
|
2010-07-01 01:00:22 +00:00
|
|
|
|
2015-03-10 13:56:44 +00:00
|
|
|
/// Instances of this class represent a uniqued identifier for a section in the
|
|
|
|
/// current translation unit. The MCContext class uniques and creates these.
|
|
|
|
class MCSection {
|
|
|
|
public:
|
|
|
|
enum SectionVariant { SV_COFF = 0, SV_ELF, SV_MachO };
|
2010-05-17 21:54:26 +00:00
|
|
|
|
2015-03-10 13:56:44 +00:00
|
|
|
private:
|
|
|
|
MCSection(const MCSection &) = delete;
|
|
|
|
void operator=(const MCSection &) = delete;
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2015-03-10 22:00:25 +00:00
|
|
|
MCSymbol *Begin;
|
2015-03-23 21:22:04 +00:00
|
|
|
mutable MCSymbol *End;
|
2015-03-10 16:58:10 +00:00
|
|
|
|
2015-03-10 13:56:44 +00:00
|
|
|
protected:
|
2015-04-04 18:02:01 +00:00
|
|
|
MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
|
|
|
|
: Begin(Begin), End(nullptr), Variant(V), Kind(K) {}
|
2015-03-10 13:56:44 +00:00
|
|
|
SectionVariant Variant;
|
|
|
|
SectionKind Kind;
|
2010-05-17 21:54:26 +00:00
|
|
|
|
2015-03-10 13:56:44 +00:00
|
|
|
public:
|
|
|
|
virtual ~MCSection();
|
2010-07-01 01:00:22 +00:00
|
|
|
|
2015-03-10 13:56:44 +00:00
|
|
|
SectionKind getKind() const { return Kind; }
|
2010-04-04 23:22:29 +00:00
|
|
|
|
2015-03-10 13:56:44 +00:00
|
|
|
SectionVariant getVariant() const { return Variant; }
|
2010-10-04 17:32:41 +00:00
|
|
|
|
2015-03-10 22:00:25 +00:00
|
|
|
MCSymbol *getBeginSymbol() const { return Begin; }
|
2015-03-23 21:22:04 +00:00
|
|
|
MCSymbol *getEndSymbol(MCContext &Ctx) const;
|
|
|
|
bool hasEnded() const;
|
2015-03-10 16:58:10 +00:00
|
|
|
|
2015-03-10 13:56:44 +00:00
|
|
|
virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
|
|
|
|
const MCExpr *Subsection) const = 0;
|
|
|
|
|
|
|
|
/// Return true if a .align directive should use "optimized nops" to fill
|
|
|
|
/// instead of 0s.
|
|
|
|
virtual bool UseCodeAlign() const = 0;
|
|
|
|
|
|
|
|
/// Check whether this section is "virtual", that is has no actual object
|
|
|
|
/// file contents.
|
|
|
|
virtual bool isVirtualSection() const = 0;
|
|
|
|
};
|
2010-07-01 01:00:22 +00:00
|
|
|
|
2009-06-23 22:01:43 +00:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|