2010-02-21 22:53:53 +01:00
|
|
|
//===-- llvm/Target/TargetAsmBackend.h - Target Asm Backend -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TARGET_TARGETASMBACKEND_H
|
|
|
|
#define LLVM_TARGET_TARGETASMBACKEND_H
|
|
|
|
|
2010-03-19 10:28:12 +01:00
|
|
|
#include "llvm/System/DataTypes.h"
|
|
|
|
|
2010-02-21 22:53:53 +01:00
|
|
|
namespace llvm {
|
2010-03-19 10:28:12 +01:00
|
|
|
class MCDataFragment;
|
2010-05-26 17:18:56 +02:00
|
|
|
class MCFixup;
|
2010-03-23 02:39:09 +01:00
|
|
|
class MCInst;
|
2010-10-16 20:23:53 +02:00
|
|
|
class MCObjectFormat;
|
2010-03-19 11:43:26 +01:00
|
|
|
class MCObjectWriter;
|
2010-03-15 22:56:50 +01:00
|
|
|
class MCSection;
|
2010-03-23 04:13:05 +01:00
|
|
|
template<typename T>
|
|
|
|
class SmallVectorImpl;
|
2010-02-21 22:53:53 +01:00
|
|
|
class Target;
|
2010-03-19 11:43:26 +01:00
|
|
|
class raw_ostream;
|
2010-02-21 22:53:53 +01:00
|
|
|
|
|
|
|
/// TargetAsmBackend - Generic interface to target specific assembler backends.
|
|
|
|
class TargetAsmBackend {
|
|
|
|
TargetAsmBackend(const TargetAsmBackend &); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const TargetAsmBackend &); // DO NOT IMPLEMENT
|
|
|
|
protected: // Can only create subclasses.
|
|
|
|
TargetAsmBackend(const Target &);
|
|
|
|
|
|
|
|
/// TheTarget - The Target that this machine was created for.
|
|
|
|
const Target &TheTarget;
|
|
|
|
|
2010-03-18 01:58:53 +01:00
|
|
|
unsigned HasReliableSymbolDifference : 1;
|
|
|
|
unsigned HasScatteredSymbols : 1;
|
|
|
|
|
2010-02-21 22:53:53 +01:00
|
|
|
public:
|
|
|
|
virtual ~TargetAsmBackend();
|
|
|
|
|
|
|
|
const Target &getTarget() const { return TheTarget; }
|
|
|
|
|
2010-10-16 20:23:53 +02:00
|
|
|
virtual const MCObjectFormat &getObjectFormat() const = 0;
|
|
|
|
|
2010-03-19 11:43:26 +01:00
|
|
|
/// createObjectWriter - Create a new MCObjectWriter instance for use by the
|
|
|
|
/// assembler backend to emit the final object file.
|
|
|
|
virtual MCObjectWriter *createObjectWriter(raw_ostream &OS) const = 0;
|
|
|
|
|
2010-03-18 01:58:53 +01:00
|
|
|
/// hasReliableSymbolDifference - Check whether this target implements
|
|
|
|
/// accurate relocations for differences between symbols. If not, differences
|
|
|
|
/// between symbols will always be relocatable expressions and any references
|
|
|
|
/// to temporary symbols will be assumed to be in the same atom, unless they
|
|
|
|
/// reside in a different section.
|
|
|
|
///
|
|
|
|
/// This should always be true (since it results in fewer relocations with no
|
|
|
|
/// loss of functionality), but is currently supported as a way to maintain
|
|
|
|
/// exact object compatibility with Darwin 'as' (on non-x86_64). It should
|
2010-10-16 20:23:53 +02:00
|
|
|
/// eventually should be eliminated.
|
2010-03-18 01:58:53 +01:00
|
|
|
bool hasReliableSymbolDifference() const {
|
|
|
|
return HasReliableSymbolDifference;
|
|
|
|
}
|
2010-03-11 02:34:21 +01:00
|
|
|
|
|
|
|
/// hasScatteredSymbols - Check whether this target supports scattered
|
|
|
|
/// symbols. If so, the assembler should assume that atoms can be scattered by
|
|
|
|
/// the linker. In particular, this means that the offsets between symbols
|
|
|
|
/// which are in distinct atoms is not known at link time, and the assembler
|
|
|
|
/// must generate fixups and relocations appropriately.
|
|
|
|
///
|
|
|
|
/// Note that the assembler currently does not reason about atoms, instead it
|
|
|
|
/// assumes all temporary symbols reside in the "current atom".
|
2010-03-18 01:58:53 +01:00
|
|
|
bool hasScatteredSymbols() const { return HasScatteredSymbols; }
|
2010-03-15 22:56:50 +01:00
|
|
|
|
|
|
|
/// doesSectionRequireSymbols - Check whether the given section requires that
|
|
|
|
/// all symbols (even temporaries) have symbol table entries.
|
|
|
|
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
|
|
|
|
return false;
|
|
|
|
}
|
2010-03-19 10:28:12 +01:00
|
|
|
|
2010-05-12 02:38:17 +02:00
|
|
|
/// isSectionAtomizable - Check whether the given section can be split into
|
|
|
|
/// atoms.
|
|
|
|
///
|
|
|
|
/// \see MCAssembler::isSymbolLinkerVisible().
|
|
|
|
virtual bool isSectionAtomizable(const MCSection &Section) const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-03-19 10:29:03 +01:00
|
|
|
/// isVirtualSection - Check whether the given section is "virtual", that is
|
|
|
|
/// has no actual object file contents.
|
|
|
|
virtual bool isVirtualSection(const MCSection &Section) const = 0;
|
|
|
|
|
2010-09-30 18:38:07 +02:00
|
|
|
/// getPointerSize - Get the pointer size in bytes.
|
|
|
|
virtual unsigned getPointerSize() const = 0;
|
|
|
|
|
2010-03-19 10:28:12 +01:00
|
|
|
/// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided
|
|
|
|
/// data fragment, at the offset specified by the fixup and following the
|
|
|
|
/// fixup kind as appropriate.
|
2010-05-26 17:18:56 +02:00
|
|
|
virtual void ApplyFixup(const MCFixup &Fixup, MCDataFragment &Fragment,
|
2010-03-19 10:28:12 +01:00
|
|
|
uint64_t Value) const = 0;
|
2010-03-23 02:39:09 +01:00
|
|
|
|
2010-03-23 04:13:05 +01:00
|
|
|
/// MayNeedRelaxation - Check whether the given instruction may need
|
|
|
|
/// relaxation.
|
|
|
|
///
|
2010-05-26 20:15:06 +02:00
|
|
|
/// \param Inst - The instruction to test.
|
2010-05-26 19:45:29 +02:00
|
|
|
virtual bool MayNeedRelaxation(const MCInst &Inst) const = 0;
|
2010-03-23 04:13:05 +01:00
|
|
|
|
2010-03-23 02:39:09 +01:00
|
|
|
/// RelaxInstruction - Relax the instruction in the given fragment to the next
|
|
|
|
/// wider instruction.
|
2010-05-26 20:15:06 +02:00
|
|
|
///
|
|
|
|
/// \param Inst - The instruction to relax, which may be the same as the
|
|
|
|
/// output.
|
|
|
|
/// \parm Res [output] - On return, the relaxed instruction.
|
|
|
|
virtual void RelaxInstruction(const MCInst &Inst, MCInst &Res) const = 0;
|
2010-03-23 03:36:58 +01:00
|
|
|
|
|
|
|
/// WriteNopData - Write an (optimal) nop sequence of Count bytes to the given
|
|
|
|
/// output. If the target cannot generate such a sequence, it should return an
|
|
|
|
/// error.
|
|
|
|
///
|
|
|
|
/// \return - True on success.
|
|
|
|
virtual bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const = 0;
|
2010-02-21 22:53:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|