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
|
|
|
|
|
|
|
|
#include <string>
|
2009-07-27 21:22:30 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2009-08-01 21:30:49 +00:00
|
|
|
#include "llvm/MC/SectionKind.h"
|
2009-06-23 22:01:43 +00:00
|
|
|
|
2009-07-31 17:02:00 +00:00
|
|
|
namespace llvm {
|
|
|
|
class MCContext;
|
2009-08-22 20:48:53 +00:00
|
|
|
class MCAsmInfo;
|
2009-08-08 22:41:53 +00:00
|
|
|
class raw_ostream;
|
2009-07-31 17:02:00 +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 {
|
2009-07-01 06:31:49 +00:00
|
|
|
MCSection(const MCSection&); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const MCSection&); // DO NOT IMPLEMENT
|
2009-07-31 17:02:00 +00:00
|
|
|
protected:
|
2009-08-08 23:39:42 +00:00
|
|
|
MCSection(SectionKind K) : Kind(K) {}
|
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; }
|
2009-08-08 22:41:53 +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
|
|
|
|
|
|
|
/// 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;
|
|
|
|
}
|
2009-06-23 22:01:43 +00:00
|
|
|
};
|
|
|
|
|
2009-08-08 20:52:13 +00:00
|
|
|
class MCSectionCOFF : public MCSection {
|
2010-03-22 23:26:12 +00:00
|
|
|
// The memory for this string is stored in the same MCContext as *this.
|
|
|
|
StringRef Name;
|
2009-08-08 23:39:42 +00:00
|
|
|
|
|
|
|
/// IsDirective - This is true if the section name is a directive, not
|
|
|
|
/// something that should be printed with ".section".
|
|
|
|
///
|
|
|
|
/// FIXME: This is a hack. Switch to a semantic view of the section instead
|
|
|
|
/// of a syntactic one.
|
|
|
|
bool IsDirective;
|
|
|
|
|
2009-11-06 10:58:06 +00:00
|
|
|
MCSectionCOFF(StringRef name, bool isDirective, SectionKind K)
|
2009-08-13 00:37:15 +00:00
|
|
|
: MCSection(K), Name(name), IsDirective(isDirective) {
|
|
|
|
}
|
2009-08-08 20:50:49 +00:00
|
|
|
public:
|
|
|
|
|
2009-11-06 10:58:06 +00:00
|
|
|
static MCSectionCOFF *Create(StringRef Name, bool IsDirective,
|
|
|
|
SectionKind K, MCContext &Ctx);
|
2009-08-08 23:39:42 +00:00
|
|
|
|
2010-03-22 23:26:12 +00:00
|
|
|
StringRef getName() const { return Name; }
|
2009-08-08 23:39:42 +00:00
|
|
|
bool isDirective() const { return IsDirective; }
|
2009-08-08 22:41:53 +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;
|
2009-08-08 20:50:49 +00:00
|
|
|
};
|
2009-07-31 18:48:30 +00:00
|
|
|
|
2009-06-23 22:01:43 +00:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|