Skip to content

Commit 2222fdd

Browse files
authored
[MC,X86] De-virtualize emitPrefix
and remove x86-specific emitPrefix from the generic MCCodeEmitter. Pull Request: #97008
1 parent f65a52a commit 2222fdd

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

llvm/include/llvm/MC/MCCodeEmitter.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ class MCCodeEmitter {
3030
/// Lifetime management
3131
virtual void reset() {}
3232

33-
/// Append the prefixes of given instruction to the code buffer.
34-
///
35-
/// \param Inst a single low-level machine instruction.
36-
/// \param CB code buffer
37-
virtual void emitPrefix(const MCInst &Inst, SmallVectorImpl<char> &CB,
38-
const MCSubtargetInfo &STI) const {}
3933
/// Encode the given \p Inst to bytes and append to \p CB.
4034
virtual void encodeInstruction(const MCInst &Inst, SmallVectorImpl<char> &CB,
4135
SmallVectorImpl<MCFixup> &Fixups,

llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ bool X86AsmBackend::padInstructionViaPrefix(MCRelaxableFragment &RF,
788788
const unsigned MaxPossiblePad = std::min(15 - OldSize, RemainingSize);
789789
const unsigned RemainingPrefixSize = [&]() -> unsigned {
790790
SmallString<15> Code;
791-
Emitter.emitPrefix(RF.getInst(), Code, STI);
791+
X86_MC::emitPrefix(Emitter, RF.getInst(), Code, STI);
792792
assert(Code.size() < 15 && "The number of prefixes must be less than 15.");
793793

794794
// TODO: It turns out we need a decent amount of plumbing for the target

llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ class X86MCCodeEmitter : public MCCodeEmitter {
344344
~X86MCCodeEmitter() override = default;
345345

346346
void emitPrefix(const MCInst &MI, SmallVectorImpl<char> &CB,
347-
const MCSubtargetInfo &STI) const override;
347+
const MCSubtargetInfo &STI) const;
348348

349349
void encodeInstruction(const MCInst &MI, SmallVectorImpl<char> &CB,
350350
SmallVectorImpl<MCFixup> &Fixups,
@@ -1531,6 +1531,11 @@ void X86MCCodeEmitter::emitPrefix(const MCInst &MI, SmallVectorImpl<char> &CB,
15311531
emitPrefixImpl(CurOp, MI, STI, CB);
15321532
}
15331533

1534+
void X86_MC::emitPrefix(MCCodeEmitter &MCE, const MCInst &MI,
1535+
SmallVectorImpl<char> &CB, const MCSubtargetInfo &STI) {
1536+
static_cast<X86MCCodeEmitter &>(MCE).emitPrefix(MI, CB, STI);
1537+
}
1538+
15341539
void X86MCCodeEmitter::encodeInstruction(const MCInst &MI,
15351540
SmallVectorImpl<char> &CB,
15361541
SmallVectorImpl<MCFixup> &Fixups,

llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
1414
#define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
1515

16+
#include "llvm/ADT/SmallVector.h"
1617
#include <memory>
1718
#include <string>
1819

@@ -93,6 +94,9 @@ MCSubtargetInfo *createX86MCSubtargetInfo(const Triple &TT, StringRef CPU,
9394

9495
void emitInstruction(MCObjectStreamer &, const MCInst &Inst,
9596
const MCSubtargetInfo &STI);
97+
98+
void emitPrefix(MCCodeEmitter &MCE, const MCInst &MI, SmallVectorImpl<char> &CB,
99+
const MCSubtargetInfo &STI);
96100
}
97101

98102
MCCodeEmitter *createX86MCCodeEmitter(const MCInstrInfo &MCII,

0 commit comments

Comments
 (0)