LLVM 17.0.0git
MCCodeEmitter.h
Go to the documentation of this file.
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
9#ifndef LLVM_MC_MCCODEEMITTER_H
10#define LLVM_MC_MCCODEEMITTER_H
11
12namespace llvm {
13
14class MCFixup;
15class MCInst;
16class MCSubtargetInfo;
17class raw_ostream;
18template<typename T> class SmallVectorImpl;
19
20/// MCCodeEmitter - Generic instruction encoding interface.
22protected: // Can only create subclasses.
24
25 /// EncodeInstruction - Encode the given \p Inst to bytes on the output stream
26 /// \p OS. Allows for an implementation of encodeInstruction that uses streams
27 /// instead of a SmallVector.
28 virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS,
30 const MCSubtargetInfo &STI) const {}
31
32public:
33 MCCodeEmitter(const MCCodeEmitter &) = delete;
35 virtual ~MCCodeEmitter();
36
37 /// Lifetime management
38 virtual void reset() {}
39
40 /// Append the prefixes of given instruction to the code buffer.
41 ///
42 /// \param Inst a single low-level machine instruction.
43 /// \param CB code buffer
44 virtual void emitPrefix(const MCInst &Inst, SmallVectorImpl<char> &CB,
45 const MCSubtargetInfo &STI) const {}
46 /// EncodeInstruction - Encode the given \p Inst to bytes and append to \p CB.
47 virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl<char> &CB,
49 const MCSubtargetInfo &STI) const;
50};
51
52} // end namespace llvm
53
54#endif // LLVM_MC_MCCODEEMITTER_H
raw_pwrite_stream & OS
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:21
virtual void reset()
Lifetime management.
Definition: MCCodeEmitter.h:38
MCCodeEmitter & operator=(const MCCodeEmitter &)=delete
virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.
Definition: MCCodeEmitter.h:28
virtual ~MCCodeEmitter()
MCCodeEmitter(const MCCodeEmitter &)=delete
virtual void emitPrefix(const MCInst &Inst, SmallVectorImpl< char > &CB, const MCSubtargetInfo &STI) const
Append the prefixes of given instruction to the code buffer.
Definition: MCCodeEmitter.h:44
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
Generic base class for all target subtargets.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:577
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18