//===- MCAssembler.h - Object File Generation -------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_MC_MCASSEMBLER_H
#define LLVM_MC_MCASSEMBLER_H
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCInst.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/ilist.h"
#include "llvm/ADT/ilist_node.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/DataTypes.h"
#include <vector> // FIXME: Shouldn't be needed.
namespace llvm {
class raw_ostream;
class MCAsmLayout;
class MCAssembler;
class MCContext;
class MCCodeEmitter;
class MCExpr;
class MCFragment;
class MCObjectWriter;
class MCSection;
class MCSectionData;
class MCSymbol;
class MCSymbolData;
class MCValue;
class MCAsmBackend;
class MCFragment : public ilist_node<MCFragment> {
friend class MCAsmLayout;
MCFragment(const MCFragment&); // DO NOT IMPLEMENT
void operator=(const MCFragment&); // DO NOT IMPLEMENT
public:
enum FragmentType {
FT_Align,
FT_Data,
FT_Fill,
FT_Inst,
FT_Org,
FT_Dwarf,
FT_DwarfFrame,
FT_LEB,
FT_Tiny // @LOCALMOD
};
// @LOCALMOD-BEGIN
enum BundleAlignType {
BundleAlignNone = 0,
BundleAlignStart = 1,
BundleAlignEnd = 2
};
// @LOCALMOD-END
private:
// @LOCALMOD-BEGIN
// Try to compress the layout of MCFragment by:
// 1) Making Kind, the bundling flags, and BundlePadding fit in 32 bits.
// 2) Move LayoutOrder to fit in the hole left by aligning for 64 bits.
FragmentType Kind : 4;
BundleAlignType BundleAlign : 2;
bool BundleGroupStart : 1;
bool BundleGroupEnd : 1;
/// BundlePadding - The computed padding for this fragment. This is ~0
/// until initialized.
uint8_t BundlePadding;
/// LayoutOrder - The layout order of this fragment.
unsigned LayoutOrder;
// @LOCALMOD-END
/// Parent - The data for the section this fragment is in.
MCSectionData *Parent;
/// Atom - The atom this fragment is in, as represented by it's defining
/// symbol. Atom's are only used by backends which set
/// \see MCAsmBackend::hasReliableSymbolDifference().
MCSymbolData *Atom;
/// @name Assembler Backend Data
/// @{
//
// FIXME: This could all be kept private to the assembler implementation.
/// Offset - The offset of this fragment in its section. This is ~0 until
/// initialized.
uint64_t Offset;
/// @}
protected:
MCFragment(FragmentType _Kind, MCSectionData *_Parent = 0);
public:
// Only for sentinel.
MCFragment();
virtual ~MCFragment();
FragmentType getKind() const { return Kind; }
MCSectionData *getParent() const { return Parent; }
void setParent(MCSectionData *Value) { Parent = Value; }
MCSymbolData *getAtom() const { return Atom; }
void setAtom(MCSymbolData *Value) { Atom = Value; }
unsigned getLayoutOrder() const { return LayoutOrder; }
void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
// @LOCALMOD-BEGIN
bool isBundleGroupStart() const { return BundleGroupStart; }
void setBundleGroupStart(bool Value) { BundleGroupStart = Value; }
bool isBundleGroupEnd() const { return BundleGroupEnd; }
void setBundleGroupEnd(bool Value) { BundleGroupEnd = Value; }
BundleAlignType getBundleAlign() const { return BundleAlign; }
void setBundleAlign(BundleAlignType Value) { BundleAlign = Value; }
// @LOCALMOD-END
static bool classof(const MCFragment *O) { return true; }
void dump();
};
// @LOCALMOD-BEGIN
// This is just a tiny data fragment with no fixups.
// (To help with memory usage)
class MCTinyFragment : public MCFragment {
private:
SmallString<6> Contents;
public:
MCTinyFragment(MCSectionData *SD = 0) : MCFragment(FT_Tiny, SD) {}
SmallString<6> &getContents() { return Contents; }
const