10b57cec5SDimitry Andric //===- llvm/MC/MCCodeEmitter.h - Instruction Encoding -----------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #ifndef LLVM_MC_MCCODEEMITTER_H
100b57cec5SDimitry Andric #define LLVM_MC_MCCODEEMITTER_H
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric namespace llvm {
130b57cec5SDimitry Andric 
140b57cec5SDimitry Andric class MCFixup;
150b57cec5SDimitry Andric class MCInst;
160b57cec5SDimitry Andric class MCSubtargetInfo;
170b57cec5SDimitry Andric class raw_ostream;
180b57cec5SDimitry Andric template<typename T> class SmallVectorImpl;
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric /// MCCodeEmitter - Generic instruction encoding interface.
210b57cec5SDimitry Andric class MCCodeEmitter {
220b57cec5SDimitry Andric protected: // Can only create subclasses.
230b57cec5SDimitry Andric   MCCodeEmitter();
240b57cec5SDimitry Andric 
250b57cec5SDimitry Andric public:
260b57cec5SDimitry Andric   MCCodeEmitter(const MCCodeEmitter &) = delete;
270b57cec5SDimitry Andric   MCCodeEmitter &operator=(const MCCodeEmitter &) = delete;
280b57cec5SDimitry Andric   virtual ~MCCodeEmitter();
290b57cec5SDimitry Andric 
300b57cec5SDimitry Andric   /// Lifetime management
reset()310b57cec5SDimitry Andric   virtual void reset() {}
320b57cec5SDimitry Andric 
3306c3fb27SDimitry Andric   /// Append the prefixes of given instruction to the code buffer.
34480093f4SDimitry Andric   ///
35480093f4SDimitry Andric   /// \param Inst a single low-level machine instruction.
3606c3fb27SDimitry Andric   /// \param CB code buffer
emitPrefix(const MCInst & Inst,SmallVectorImpl<char> & CB,const MCSubtargetInfo & STI)3706c3fb27SDimitry Andric   virtual void emitPrefix(const MCInst &Inst, SmallVectorImpl<char> &CB,
38480093f4SDimitry Andric                           const MCSubtargetInfo &STI) const {}
395f757f3fSDimitry Andric   /// Encode the given \p Inst to bytes and append to \p CB.
4006c3fb27SDimitry Andric   virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl<char> &CB,
410b57cec5SDimitry Andric                                  SmallVectorImpl<MCFixup> &Fixups,
425f757f3fSDimitry Andric                                  const MCSubtargetInfo &STI) const = 0;
430b57cec5SDimitry Andric };
440b57cec5SDimitry Andric 
450b57cec5SDimitry Andric } // end namespace llvm
460b57cec5SDimitry Andric 
470b57cec5SDimitry Andric #endif // LLVM_MC_MCCODEEMITTER_H
48