2011-07-26 01:24:55 +02:00
|
|
|
//===-- llvm/MC/MCAsmBack.h - MC Asm Backend --------------------*- C++ -*-===//
|
2010-02-21 22:53:53 +01:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-07-26 01:24:55 +02:00
|
|
|
#ifndef LLVM_MC_MCASMBACKEND_H
|
|
|
|
#define LLVM_MC_MCASMBACKEND_H
|
2010-02-21 22:53:53 +01:00
|
|
|
|
2010-12-08 02:16:55 +01:00
|
|
|
#include "llvm/MC/MCDirectives.h"
|
2010-12-16 04:20:06 +01:00
|
|
|
#include "llvm/MC/MCFixup.h"
|
|
|
|
#include "llvm/MC/MCFixupKindInfo.h"
|
2010-11-29 19:16:10 +01:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2010-03-19 10:28:12 +01:00
|
|
|
|
2010-02-21 22:53:53 +01:00
|
|
|
namespace llvm {
|
2011-03-09 19:44:41 +01:00
|
|
|
class MCELFObjectTargetWriter;
|
2010-05-26 17:18:56 +02:00
|
|
|
class MCFixup;
|
2010-03-23 02:39:09 +01:00
|
|
|
class MCInst;
|
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-03-19 11:43:26 +01:00
|
|
|
class raw_ostream;
|
2010-02-21 22:53:53 +01:00
|
|
|
|
2011-07-26 01:24:55 +02:00
|
|
|
/// MCAsmBackend - Generic interface to target specific assembler backends.
|
|
|
|
class MCAsmBackend {
|
|
|
|
MCAsmBackend(const MCAsmBackend &); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const MCAsmBackend &); // DO NOT IMPLEMENT
|
2010-02-21 22:53:53 +01:00
|
|
|
protected: // Can only create subclasses.
|
2011-07-26 01:24:55 +02:00
|
|
|
MCAsmBackend();
|
2010-02-21 22:53:53 +01:00
|
|
|
|
2010-03-18 01:58:53 +01:00
|
|
|
unsigned HasReliableSymbolDifference : 1;
|
|
|
|
|
2010-02-21 22:53:53 +01:00
|
|
|
public:
|
2011-07-26 01:24:55 +02:00
|
|
|
virtual ~MCAsmBackend();
|
2010-02-21 22:53:53 +01:00
|
|
|
|
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;
|
|
|
|
|
2011-03-09 19:44:41 +01:00
|
|
|
/// createELFObjectTargetWriter - Create a new ELFObjectTargetWriter to enable
|
|
|
|
/// non-standard ELFObjectWriters.
|
|
|
|
virtual MCELFObjectTargetWriter *createELFObjectTargetWriter() const {
|
|
|
|
assert(0 && "createELFObjectTargetWriter is not supported by asm backend");
|
|
|
|
return 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
|
|
|
|
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-12-16 04:20:06 +01:00
|
|
|
/// @name Target Fixup Interfaces
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/// getNumFixupKinds - Get the number of target specific fixup kinds.
|
|
|
|
virtual unsigned getNumFixupKinds() const = 0;
|
|
|
|
|
|
|
|
/// getFixupKindInfo - Get information on a fixup kind.
|
|
|
|
virtual const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const;
|
|
|
|
|
|
|
|
/// @}
|
|
|
|
|
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-12-06 20:08:48 +01:00
|
|
|
virtual void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
2010-03-19 10:28:12 +01:00
|
|
|
uint64_t Value) const = 0;
|
2010-03-23 02:39:09 +01:00
|
|
|
|
2010-12-16 04:20:06 +01:00
|
|
|
/// @}
|
|
|
|
|
|
|
|
/// @name Target Relaxation Interfaces
|
|
|
|
/// @{
|
|
|
|
|
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
|
|
|
|
2010-12-16 04:20:06 +01:00
|
|
|
/// @}
|
|
|
|
|
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-12-08 02:16:55 +01:00
|
|
|
|
|
|
|
/// HandleAssemblerFlag - Handle any target-specific assembler flags.
|
|
|
|
/// By default, do nothing.
|
|
|
|
virtual void HandleAssemblerFlag(MCAssemblerFlag Flag) {}
|
2010-02-21 22:53:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|