Skip to content

Commit 0d65307

Browse files
committed
[AVR][NFC] Merge AVRMCCodeEmitter::emitInstruction into AVRMCCodeEmitter::encodeInstruction.
The reasons are: 1, `AVRMCCodeEmitter::emitInstruction` has only one use which is `AVRMCCodeEmitter::encodeInstruction`, and the parameter `STI` is not used in this function. I think it might be copied from other target. 2, We do have `AVRAsmPrinter::emitInstruction`, and it would invoke `AVRMCCodeEmitter::encodeInstruction` in its calling chain, so if we call `AVRMCCodeEmitter::emitInstruction` in `AVRMCCodeEmitter::encodeInstruction`, it would be confusing. Reviewed By: benshi001 Differential Revision: https://reviews.llvm.org/D155426
1 parent 9c2f792 commit 0d65307

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,17 +270,6 @@ unsigned AVRMCCodeEmitter::getMachineOpValue(const MCInst &MI,
270270
return getExprOpValue(MO.getExpr(), Fixups, STI);
271271
}
272272

273-
void AVRMCCodeEmitter::emitInstruction(uint64_t Val, unsigned Size,
274-
const MCSubtargetInfo &STI,
275-
SmallVectorImpl<char> &CB) const {
276-
size_t WordCount = Size / 2;
277-
278-
for (int64_t i = WordCount - 1; i >= 0; --i) {
279-
uint16_t Word = (Val >> (i * 16)) & 0xFFFF;
280-
support::endian::write(CB, Word, support::endianness::little);
281-
}
282-
}
283-
284273
void AVRMCCodeEmitter::encodeInstruction(const MCInst &MI,
285274
SmallVectorImpl<char> &CB,
286275
SmallVectorImpl<MCFixup> &Fixups,
@@ -293,7 +282,11 @@ void AVRMCCodeEmitter::encodeInstruction(const MCInst &MI,
293282
assert(Size > 0 && "Instruction size cannot be zero");
294283

295284
uint64_t BinaryOpCode = getBinaryCodeForInstr(MI, Fixups, STI);
296-
emitInstruction(BinaryOpCode, Size, STI, CB);
285+
286+
for (int64_t i = Size / 2 - 1; i >= 0; --i) {
287+
uint16_t Word = (BinaryOpCode >> (i * 16)) & 0xFFFF;
288+
support::endian::write(CB, Word, support::endianness::little);
289+
}
297290
}
298291

299292
MCCodeEmitter *createAVRMCCodeEmitter(const MCInstrInfo &MCII,

llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ class AVRMCCodeEmitter : public MCCodeEmitter {
9595
SmallVectorImpl<MCFixup> &Fixups,
9696
const MCSubtargetInfo &STI) const;
9797

98-
void emitInstruction(uint64_t Val, unsigned Size, const MCSubtargetInfo &STI,
99-
SmallVectorImpl<char> &CB) const;
100-
10198
void encodeInstruction(const MCInst &MI, SmallVectorImpl<char> &CB,
10299
SmallVectorImpl<MCFixup> &Fixups,
103100
const MCSubtargetInfo &STI) const override;

0 commit comments

Comments
 (0)