MCCodeEmitter.h 1.7 KB

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