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-05-25 15:04:26 +00:00
|
|
|
/// \brief Express the state of bundle locked groups while emitting code.
|
|
|
|
enum BundleLockStateType {
|
|
|
|
NotBundleLocked,
|
|
|
|
BundleLocked,
|
|
|
|
BundleLockedAlignToEnd
|
|
|
|
};
|
|
|
|
|
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-05-21 19:20:38 +00:00
|
|
|
MCSymbol *Begin;
|
2015-05-25 14:04:31 +00:00
|
|
|
MCSymbol *End = nullptr;
|
2015-05-21 19:20:38 +00:00
|
|
|
/// The alignment requirement of this section.
|
2015-05-25 14:04:31 +00:00
|
|
|
unsigned Alignment = 1;
|
2015-05-25 14:00:56 +00:00
|
|
|
/// The section index in the assemblers section list.
|
2015-05-25 14:18:24 +00:00
|
|
|
unsigned Ordinal = 0;
|
2015-05-25 14:25:28 +00:00
|
|
|
/// The index of this section in the layout order.
|
|
|
|
unsigned LayoutOrder;
|
2015-03-10 16:58:10 +00:00
|
|
|
|
2015-05-25 15:04:26 +00:00
|
|
|
/// \brief Keeping track of bundle-locked state.
|
|
|
|
BundleLockStateType BundleLockState = NotBundleLocked;
|
|
|
|
|
|
|
|
/// \brief Current nesting depth of bundle_lock directives.
|
|
|
|
unsigned BundleLockNestingDepth = 0;
|
|
|
|
|
|
|
|
/// \brief We've seen a bundle_lock directive but not its first instruction
|
|
|
|
/// yet.
|
|
|
|
bool BundleGroupBeforeFirstInst = false;
|
|
|
|
|
2015-03-10 13:56:44 +00:00
|
|
|
protected:
|
2015-04-04 18:02:01 +00:00
|
|
|
MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
|
2015-05-25 14:04:31 +00:00
|
|
|
: Begin(Begin), 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-05-21 19:20:38 +00:00
|
|
|
MCSymbol *getBeginSymbol() { return Begin; }
|
|
|
|
const MCSymbol *getBeginSymbol() const {
|
|
|
|
return const_cast<MCSection *>(this)->getBeginSymbol();
|
|
|
|
}
|
|
|
|
void setBeginSymbol(MCSymbol *Sym) {
|
2015-05-21 16:52:32 +00:00
|
|
|
assert(!Begin);
|
|
|
|
Begin = Sym;
|
|
|
|
}
|
2015-05-21 19:20:38 +00:00
|
|
|
MCSymbol *getEndSymbol(MCContext &Ctx);
|
2015-03-23 21:22:04 +00:00
|
|
|
bool hasEnded() const;
|
2015-03-10 16:58:10 +00:00
|
|
|
|
2015-05-21 19:20:38 +00:00
|
|
|
unsigned getAlignment() const { return Alignment; }
|
|
|
|
void setAlignment(unsigned Value) { Alignment = Value; }
|
|
|
|
|
2015-05-25 14:00:56 +00:00
|
|
|
unsigned getOrdinal() const { return Ordinal; }
|
|
|
|
void setOrdinal(unsigned Value) { Ordinal = Value; }
|
|
|
|
|
2015-05-25 14:25:28 +00:00
|
|
|
unsigned getLayoutOrder() const { return LayoutOrder; }
|
|
|
|
void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
|
|
|
|
|
2015-05-25 15:04:26 +00:00
|
|
|
BundleLockStateType getBundleLockState() const { return BundleLockState; }
|
|
|
|
void setBundleLockState(BundleLockStateType NewState);
|
|
|
|
bool isBundleLocked() const { return BundleLockState != NotBundleLocked; }
|
|
|
|
|
|
|
|
bool isBundleGroupBeforeFirstInst() const {
|
|
|
|
return BundleGroupBeforeFirstInst;
|
|
|
|
}
|
|
|
|
void setBundleGroupBeforeFirstInst(bool IsFirst) {
|
|
|
|
BundleGroupBeforeFirstInst = IsFirst;
|
|
|
|
}
|
|
|
|
|
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
|