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 {
|
2009-08-22 20:48:53 +00:00
|
|
|
class MCAsmInfo;
|
2009-08-08 22:41:53 +00:00
|
|
|
class raw_ostream;
|
2010-07-01 01:00:22 +00:00
|
|
|
|
2009-07-01 06:31:49 +00:00
|
|
|
/// MCSection - Instances of this class represent a uniqued identifier for a
|
|
|
|
/// section in the current translation unit. The MCContext class uniques and
|
|
|
|
/// creates these.
|
2009-06-23 22:01:43 +00:00
|
|
|
class MCSection {
|
2010-05-17 21:54:26 +00:00
|
|
|
public:
|
|
|
|
enum SectionVariant {
|
|
|
|
SV_COFF = 0,
|
|
|
|
SV_ELF,
|
2010-10-11 05:44:40 +00:00
|
|
|
SV_MachO
|
2010-05-17 21:54:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2012-08-29 06:28:46 +00:00
|
|
|
MCSection(const MCSection&) LLVM_DELETED_FUNCTION;
|
|
|
|
void operator=(const MCSection&) LLVM_DELETED_FUNCTION;
|
2009-07-31 17:02:00 +00:00
|
|
|
protected:
|
2010-05-17 21:54:26 +00:00
|
|
|
MCSection(SectionVariant V, SectionKind K) : Variant(V), Kind(K) {}
|
|
|
|
SectionVariant Variant;
|
2009-07-31 18:48:30 +00:00
|
|
|
SectionKind Kind;
|
2009-07-01 06:31:49 +00:00
|
|
|
public:
|
2009-07-31 17:02:00 +00:00
|
|
|
virtual ~MCSection();
|
2009-06-24 01:03:06 +00:00
|
|
|
|
2009-07-31 18:48:30 +00:00
|
|
|
SectionKind getKind() const { return Kind; }
|
2010-05-17 21:54:26 +00:00
|
|
|
|
|
|
|
SectionVariant getVariant() const { return Variant; }
|
2010-07-01 01:00:22 +00:00
|
|
|
|
2009-08-22 21:43:10 +00:00
|
|
|
virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
|
2009-08-08 22:41:53 +00:00
|
|
|
raw_ostream &OS) const = 0;
|
2010-04-04 23:22:29 +00:00
|
|
|
|
2012-12-13 03:00:35 +00:00
|
|
|
// Convenience routines to get label names for the beginning/end of a
|
|
|
|
// section.
|
|
|
|
virtual std::string getLabelBeginName() const = 0;
|
|
|
|
virtual std::string getLabelEndName() const = 0;
|
|
|
|
|
2011-03-12 13:07:37 +00:00
|
|
|
/// isBaseAddressKnownZero - Return true if we know that this section will
|
|
|
|
/// get a base address of zero. In cases where we know that this is true we
|
|
|
|
/// can emit section offsets as direct references to avoid a subtraction
|
|
|
|
/// from the base of the section, saving a relocation.
|
|
|
|
virtual bool isBaseAddressKnownZero() const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-10-04 17:32:41 +00:00
|
|
|
// UseCodeAlign - Return true if a .align directive should use
|
|
|
|
// "optimized nops" to fill instead of 0s.
|
|
|
|
virtual bool UseCodeAlign() const = 0;
|
|
|
|
|
2010-11-17 20:03:54 +00:00
|
|
|
/// isVirtualSection - Check whether this section is "virtual", that is
|
|
|
|
/// has no actual object file contents.
|
|
|
|
virtual bool isVirtualSection() const = 0;
|
2009-06-23 22:01:43 +00:00
|
|
|
};
|
2010-07-01 01:00:22 +00:00
|
|
|
|
2009-06-23 22:01:43 +00:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|