[llvm] c6a6944 - [M68k,MSP430,VE,Xtensa] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 6 21:02:57 PDT 2023
Author: Fangrui Song
Date: 2023-06-06T21:02:52-07:00
New Revision: c6a69446e152975c66594061ee542ca8e4e98b6f
URL: https://github.com/llvm/llvm-project/commit/c6a69446e152975c66594061ee542ca8e4e98b6f
DIFF: https://github.com/llvm/llvm-project/commit/c6a69446e152975c66594061ee542ca8e4e98b6f.diff
LOG: [M68k,MSP430,VE,Xtensa] Migrate to new encodeInstruction that uses SmallVectorImpl<char>. NFC
Added:
Modified:
llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp
llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp
llvm/lib/Target/VE/MCTargetDesc/VEMCCodeEmitter.cpp
llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp b/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp
index d4fc0510f9441..7fc5395671cfc 100644
--- a/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp
+++ b/llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp
@@ -65,7 +65,7 @@ class M68kMCCodeEmitter : public MCCodeEmitter {
~M68kMCCodeEmitter() override {}
- void encodeInstruction(const MCInst &MI, raw_ostream &OS,
+ void encodeInstruction(const MCInst &MI, SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const override;
};
@@ -199,7 +199,8 @@ void M68kMCCodeEmitter::getMachineOpValue(const MCInst &MI, const MCOperand &Op,
}
}
-void M68kMCCodeEmitter::encodeInstruction(const MCInst &MI, raw_ostream &OS,
+void M68kMCCodeEmitter::encodeInstruction(const MCInst &MI,
+ SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const {
unsigned Opcode = MI.getOpcode();
@@ -216,7 +217,7 @@ void M68kMCCodeEmitter::encodeInstruction(const MCInst &MI, raw_ostream &OS,
int64_t InstSize = EncodedInst.getBitWidth();
for (uint64_t Word : Data) {
for (int i = 0; i < 4 && InstSize > 0; ++i, InstSize -= 16) {
- support::endian::write<uint16_t>(OS, static_cast<uint16_t>(Word),
+ support::endian::write<uint16_t>(CB, static_cast<uint16_t>(Word),
support::big);
Word >>= 16;
}
diff --git a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp
index 2b16c6234a514..985906a353313 100644
--- a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp
+++ b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCCodeEmitter.cpp
@@ -74,12 +74,13 @@ class MSP430MCCodeEmitter : public MCCodeEmitter {
MSP430MCCodeEmitter(MCContext &ctx, MCInstrInfo const &MCII)
: Ctx(ctx), MCII(MCII) {}
- void encodeInstruction(const MCInst &MI, raw_ostream &OS,
+ void encodeInstruction(const MCInst &MI, SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const override;
};
-void MSP430MCCodeEmitter::encodeInstruction(const MCInst &MI, raw_ostream &OS,
+void MSP430MCCodeEmitter::encodeInstruction(const MCInst &MI,
+ SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const {
const MCInstrDesc &Desc = MCII.get(MI.getOpcode());
@@ -93,7 +94,7 @@ void MSP430MCCodeEmitter::encodeInstruction(const MCInst &MI, raw_ostream &OS,
size_t WordCount = Size / 2;
while (WordCount--) {
- support::endian::write(OS, (uint16_t)BinaryOpCode, support::little);
+ support::endian::write(CB, (uint16_t)BinaryOpCode, support::little);
BinaryOpCode >>= 16;
}
}
diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCCodeEmitter.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEMCCodeEmitter.cpp
index 45facd34f84ef..bb643d23e6183 100644
--- a/llvm/lib/Target/VE/MCTargetDesc/VEMCCodeEmitter.cpp
+++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCCodeEmitter.cpp
@@ -48,7 +48,7 @@ class VEMCCodeEmitter : public MCCodeEmitter {
VEMCCodeEmitter &operator=(const VEMCCodeEmitter &) = delete;
~VEMCCodeEmitter() override = default;
- void encodeInstruction(const MCInst &MI, raw_ostream &OS,
+ void encodeInstruction(const MCInst &MI, SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const override;
@@ -77,11 +77,12 @@ class VEMCCodeEmitter : public MCCodeEmitter {
} // end anonymous namespace
-void VEMCCodeEmitter::encodeInstruction(const MCInst &MI, raw_ostream &OS,
+void VEMCCodeEmitter::encodeInstruction(const MCInst &MI,
+ SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const {
uint64_t Bits = getBinaryCodeForInstr(MI, Fixups, STI);
- support::endian::write<uint64_t>(OS, Bits, support::little);
+ support::endian::write<uint64_t>(CB, Bits, support::little);
++MCNumEmitted; // Keep track of the # of mi's emitted.
}
diff --git a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
index 1ef5b110c927e..1afdbb38f9571 100644
--- a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
+++ b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
@@ -43,7 +43,7 @@ class XtensaMCCodeEmitter : public MCCodeEmitter {
~XtensaMCCodeEmitter() {}
// OVerride MCCodeEmitter.
- void encodeInstruction(const MCInst &MI, raw_ostream &OS,
+ void encodeInstruction(const MCInst &MI, SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const override;
@@ -122,7 +122,8 @@ MCCodeEmitter *llvm::createXtensaMCCodeEmitter(const MCInstrInfo &MCII,
return new XtensaMCCodeEmitter(MCII, Ctx, true);
}
-void XtensaMCCodeEmitter::encodeInstruction(const MCInst &MI, raw_ostream &OS,
+void XtensaMCCodeEmitter::encodeInstruction(const MCInst &MI,
+ SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const {
uint64_t Bits = getBinaryCodeForInstr(MI, Fixups, STI);
@@ -132,7 +133,7 @@ void XtensaMCCodeEmitter::encodeInstruction(const MCInst &MI, raw_ostream &OS,
// Little-endian insertion of Size bytes.
unsigned ShiftValue = 0;
for (unsigned I = 0; I != Size; ++I) {
- OS << uint8_t(Bits >> ShiftValue);
+ CB.push_back(char(Bits >> ShiftValue));
ShiftValue += 8;
}
} else {
More information about the llvm-commits
mailing list