2009-08-27 00:51:57 +00:00
|
|
|
//===-- llvm/MC/MCCodeEmitter.h - Instruction Encoding ----------*- 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_MCCODEEMITTER_H
|
|
|
|
#define LLVM_MC_MCCODEEMITTER_H
|
|
|
|
|
2010-02-09 22:59:55 +00:00
|
|
|
#include "llvm/MC/MCFixup.h"
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
2009-08-27 00:51:57 +00:00
|
|
|
namespace llvm {
|
2010-02-09 22:59:55 +00:00
|
|
|
class MCExpr;
|
2009-08-27 01:15:54 +00:00
|
|
|
class MCInst;
|
|
|
|
class raw_ostream;
|
2010-02-09 22:59:55 +00:00
|
|
|
template<typename T> class SmallVectorImpl;
|
|
|
|
|
|
|
|
/// MCFixupKindInfo - Target independent information on a fixup kind.
|
|
|
|
struct MCFixupKindInfo {
|
2010-03-19 10:43:23 +00:00
|
|
|
enum FixupKindFlags {
|
2010-10-12 18:11:41 +00:00
|
|
|
/// Is this fixup kind PCrelative? This is used by the assembler backend to
|
2010-03-19 10:43:23 +00:00
|
|
|
/// evaluate fixup values in a target independent manner when possible.
|
|
|
|
FKF_IsPCRel = (1 << 0)
|
|
|
|
};
|
|
|
|
|
2010-02-09 22:59:55 +00:00
|
|
|
/// A target specific name for the fixup kind. The names will be unique for
|
|
|
|
/// distinct kinds on any given target.
|
|
|
|
const char *Name;
|
|
|
|
|
|
|
|
/// The bit offset to write the relocation into.
|
|
|
|
//
|
|
|
|
// FIXME: These two fields are under-specified and not general enough, but it
|
2010-10-12 18:11:41 +00:00
|
|
|
// covers many things. It's enough to let the AsmStreamer pretty-print
|
2010-02-09 22:59:55 +00:00
|
|
|
// the encoding.
|
|
|
|
unsigned TargetOffset;
|
|
|
|
|
|
|
|
/// The number of bits written by this fixup. The bits are assumed to be
|
|
|
|
/// contiguous.
|
|
|
|
unsigned TargetSize;
|
2010-03-19 10:43:23 +00:00
|
|
|
|
|
|
|
/// Flags describing additional information on this fixup kind.
|
|
|
|
unsigned Flags;
|
2010-02-09 22:59:55 +00:00
|
|
|
};
|
2009-08-27 00:51:57 +00:00
|
|
|
|
|
|
|
/// MCCodeEmitter - Generic instruction encoding interface.
|
|
|
|
class MCCodeEmitter {
|
2010-02-09 22:59:55 +00:00
|
|
|
private:
|
2009-08-27 00:51:57 +00:00
|
|
|
MCCodeEmitter(const MCCodeEmitter &); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const MCCodeEmitter &); // DO NOT IMPLEMENT
|
|
|
|
protected: // Can only create subclasses.
|
|
|
|
MCCodeEmitter();
|
2010-02-09 22:59:55 +00:00
|
|
|
|
2009-08-27 00:51:57 +00:00
|
|
|
public:
|
|
|
|
virtual ~MCCodeEmitter();
|
|
|
|
|
2010-02-09 22:59:55 +00:00
|
|
|
/// @name Target Independent Fixup Information
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/// getNumFixupKinds - Get the number of target specific fixup kinds.
|
|
|
|
virtual unsigned getNumFixupKinds() const = 0;
|
|
|
|
|
|
|
|
/// getFixupKindInfo - Get information on a fixup kind.
|
2010-02-11 21:27:18 +00:00
|
|
|
virtual const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const;
|
2010-02-09 22:59:55 +00:00
|
|
|
|
|
|
|
/// @}
|
|
|
|
|
2009-08-27 00:51:57 +00:00
|
|
|
/// EncodeInstruction - Encode the given \arg Inst to bytes on the output
|
|
|
|
/// stream \arg OS.
|
2010-02-09 22:59:55 +00:00
|
|
|
virtual void EncodeInstruction(const MCInst &Inst, raw_ostream &OS,
|
|
|
|
SmallVectorImpl<MCFixup> &Fixups) const = 0;
|
2009-08-27 00:51:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|