2009-06-24 00:01:43 +02: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 08:31:49 +02:00
|
|
|
//
|
|
|
|
// This file declares the MCSection class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2009-06-24 00:01:43 +02:00
|
|
|
|
|
|
|
#ifndef LLVM_MC_MCSECTION_H
|
|
|
|
#define LLVM_MC_MCSECTION_H
|
|
|
|
|
2012-12-13 04:00:35 +01:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2009-08-01 23:30:49 +02:00
|
|
|
#include "llvm/MC/SectionKind.h"
|
2012-08-29 08:28:46 +02:00
|
|
|
#include "llvm/Support/Compiler.h"
|
2009-06-24 00:01:43 +02:00
|
|
|
|
2009-07-31 19:02:00 +02:00
|
|
|
namespace llvm {
|
2015-03-10 14:56:44 +01:00
|
|
|
class MCAsmInfo;
|
2015-03-23 22:22:04 +01:00
|
|
|
class MCContext;
|
2015-03-10 14:56:44 +01:00
|
|
|
class MCExpr;
|
2015-03-10 17:58:10 +01:00
|
|
|
class MCSymbol;
|
2015-03-10 14:56:44 +01:00
|
|
|
class raw_ostream;
|
2010-07-01 03:00:22 +02:00
|
|
|
|
2015-03-10 14:56:44 +01: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 23:54:26 +02:00
|
|
|
|
2015-03-10 14:56:44 +01:00
|
|
|
private:
|
|
|
|
MCSection(const MCSection &) = delete;
|
|
|
|
void operator=(const MCSection &) = delete;
|
2009-06-24 03:03:06 +02:00
|
|
|
|
2015-05-21 21:20:38 +02:00
|
|
|
MCSymbol *Begin;
|
2015-05-25 16:04:31 +02:00
|
|
|
MCSymbol *End = nullptr;
|
2015-05-21 21:20:38 +02:00
|
|
|
/// The alignment requirement of this section.
|
2015-05-25 16:04:31 +02:00
|
|
|
unsigned Alignment = 1;
|
2015-05-25 16:00:56 +02:00
|
|
|
/// The section index in the assemblers section list.
|
2015-05-25 16:18:24 +02:00
|
|
|
unsigned Ordinal = 0;
|
2015-05-25 16:25:28 +02:00
|
|
|
/// The index of this section in the layout order.
|
|
|
|
unsigned LayoutOrder;
|
2015-03-10 17:58:10 +01:00
|
|
|
|
2015-03-10 14:56:44 +01:00
|
|
|
protected:
|
2015-04-04 20:02:01 +02:00
|
|
|
MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
|
2015-05-25 16:04:31 +02:00
|
|
|
: Begin(Begin), Variant(V), Kind(K) {}
|
2015-03-10 14:56:44 +01:00
|
|
|
SectionVariant Variant;
|
|
|
|
SectionKind Kind;
|
2010-05-17 23:54:26 +02:00
|
|
|
|
2015-03-10 14:56:44 +01:00
|
|
|
public:
|
|
|
|
virtual ~MCSection();
|
2010-07-01 03:00:22 +02:00
|
|
|
|
2015-03-10 14:56:44 +01:00
|
|
|
SectionKind getKind() const { return Kind; }
|
2010-04-05 01:22:29 +02:00
|
|
|
|
2015-03-10 14:56:44 +01:00
|
|
|
SectionVariant getVariant() const { return Variant; }
|
2010-10-04 19:32:41 +02:00
|
|
|
|
2015-05-21 21:20:38 +02:00
|
|
|
MCSymbol *getBeginSymbol() { return Begin; }
|
|
|
|
const MCSymbol *getBeginSymbol() const {
|
|
|
|
return const_cast<MCSection *>(this)->getBeginSymbol();
|
|
|
|
}
|
|
|
|
void setBeginSymbol(MCSymbol *Sym) {
|
2015-05-21 18:52:32 +02:00
|
|
|
assert(!Begin);
|
|
|
|
Begin = Sym;
|
|
|
|
}
|
2015-05-21 21:20:38 +02:00
|
|
|
MCSymbol *getEndSymbol(MCContext &Ctx);
|
2015-03-23 22:22:04 +01:00
|
|
|
bool hasEnded() const;
|
2015-03-10 17:58:10 +01:00
|
|
|
|
2015-05-21 21:20:38 +02:00
|
|
|
unsigned getAlignment() const { return Alignment; }
|
|
|
|
void setAlignment(unsigned Value) { Alignment = Value; }
|
|
|
|
|
2015-05-25 16:00:56 +02:00
|
|
|
unsigned getOrdinal() const { return Ordinal; }
|
|
|
|
void setOrdinal(unsigned Value) { Ordinal = Value; }
|
|
|
|
|
2015-05-25 16:25:28 +02:00
|
|
|
unsigned getLayoutOrder() const { return LayoutOrder; }
|
|
|
|
void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
|
|
|
|
|
2015-03-10 14:56:44 +01: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 03:00:22 +02:00
|
|
|
|
2009-06-24 00:01:43 +02:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|