1 //===-- llvm/MC/MCCodeEmitter.h - Instruction Encoding ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_MC_MCCODEEMITTER_H
11 #define LLVM_MC_MCCODEEMITTER_H
13 #include "llvm/MC/MCFixup.h"
21 template<typename T> class SmallVectorImpl;
23 /// MCFixupKindInfo - Target independent information on a fixup kind.
24 struct MCFixupKindInfo {
26 /// Is this fixup kind PCrelative? This is used by the assembler backend to
27 /// evaluate fixup values in a target independent manner when possible.
28 FKF_IsPCRel = (1 << 0),
30 /// Should this fixup kind force a 4-byte aligned effective PC value?
31 FKF_IsAlignedDownTo32Bits = (1 << 1)
34 /// A target specific name for the fixup kind. The names will be unique for
35 /// distinct kinds on any given target.
38 /// The bit offset to write the relocation into.
40 // FIXME: These two fields are under-specified and not general enough, but it
41 // covers many things. It's enough to let the AsmStreamer pretty-print
43 unsigned TargetOffset;
45 /// The number of bits written by this fixup. The bits are assumed to be
49 /// Flags describing additional information on this fixup kind.
53 /// MCCodeEmitter - Generic instruction encoding interface.
56 MCCodeEmitter(const MCCodeEmitter &); // DO NOT IMPLEMENT
57 void operator=(const MCCodeEmitter &); // DO NOT IMPLEMENT
58 protected: // Can only create subclasses.
62 virtual ~MCCodeEmitter();
64 /// @name Target Independent Fixup Information
67 /// getNumFixupKinds - Get the number of target specific fixup kinds.
68 virtual unsigned getNumFixupKinds() const = 0;
70 /// getFixupKindInfo - Get information on a fixup kind.
71 virtual const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const;
75 /// EncodeInstruction - Encode the given \arg Inst to bytes on the output
77 virtual void EncodeInstruction(const MCInst &Inst, raw_ostream &OS,
78 SmallVectorImpl<MCFixup> &Fixups) const = 0;
81 } // End llvm namespace