MCCodeEmitter.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //===- llvm/MC/MCCodeEmitter.h - Instruction Encoding -----------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_MC_MCCODEEMITTER_H
  9. #define LLVM_MC_MCCODEEMITTER_H
  10. namespace llvm {
  11. class MCFixup;
  12. class MCInst;
  13. class MCSubtargetInfo;
  14. class raw_ostream;
  15. template<typename T> class SmallVectorImpl;
  16. /// MCCodeEmitter - Generic instruction encoding interface.
  17. class MCCodeEmitter {
  18. protected: // Can only create subclasses.
  19. MCCodeEmitter();
  20. public:
  21. MCCodeEmitter(const MCCodeEmitter &) = delete;
  22. MCCodeEmitter &operator=(const MCCodeEmitter &) = delete;
  23. virtual ~MCCodeEmitter();
  24. /// Lifetime management
  25. virtual void reset() {}
  26. /// Emit the prefixes of given instruction on the output stream.
  27. ///
  28. /// \param Inst a single low-level machine instruction.
  29. /// \param OS output stream.
  30. virtual void emitPrefix(const MCInst &Inst, raw_ostream &OS,
  31. const MCSubtargetInfo &STI) const {}
  32. /// EncodeInstruction - Encode the given \p Inst to bytes on the output
  33. /// stream \p OS.
  34. virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS,
  35. SmallVectorImpl<MCFixup> &Fixups,
  36. const MCSubtargetInfo &STI) const = 0;
  37. };
  38. } // end namespace llvm
  39. #endif // LLVM_MC_MCCODEEMITTER_H