[llvm] 0d65307 - [AVR][NFC] Merge AVRMCCodeEmitter::emitInstruction into AVRMCCodeEmitter::encodeInstruction.
Jianjian GUAN via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 17 19:57:51 PDT 2023
Author: Jianjian GUAN
Date: 2023-07-18T10:57:38+08:00
New Revision: 0d6530728ff202849a5d30d0db4e1fdb5b11ce7b
URL: https://github.com/llvm/llvm-project/commit/0d6530728ff202849a5d30d0db4e1fdb5b11ce7b
DIFF: https://github.com/llvm/llvm-project/commit/0d6530728ff202849a5d30d0db4e1fdb5b11ce7b.diff
LOG: [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
Added:
Modified:
llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
index d71ec083b2aff8..c08e293d04378d 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.cpp
@@ -270,17 +270,6 @@ unsigned AVRMCCodeEmitter::getMachineOpValue(const MCInst &MI,
return getExprOpValue(MO.getExpr(), Fixups, STI);
}
-void AVRMCCodeEmitter::emitInstruction(uint64_t Val, unsigned Size,
- const MCSubtargetInfo &STI,
- SmallVectorImpl<char> &CB) const {
- size_t WordCount = Size / 2;
-
- for (int64_t i = WordCount - 1; i >= 0; --i) {
- uint16_t Word = (Val >> (i * 16)) & 0xFFFF;
- support::endian::write(CB, Word, support::endianness::little);
- }
-}
-
void AVRMCCodeEmitter::encodeInstruction(const MCInst &MI,
SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
@@ -293,7 +282,11 @@ void AVRMCCodeEmitter::encodeInstruction(const MCInst &MI,
assert(Size > 0 && "Instruction size cannot be zero");
uint64_t BinaryOpCode = getBinaryCodeForInstr(MI, Fixups, STI);
- emitInstruction(BinaryOpCode, Size, STI, CB);
+
+ for (int64_t i = Size / 2 - 1; i >= 0; --i) {
+ uint16_t Word = (BinaryOpCode >> (i * 16)) & 0xFFFF;
+ support::endian::write(CB, Word, support::endianness::little);
+ }
}
MCCodeEmitter *createAVRMCCodeEmitter(const MCInstrInfo &MCII,
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h
index 47bdf48d1faad8..a00bbb9ae498bb 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCCodeEmitter.h
@@ -95,9 +95,6 @@ class AVRMCCodeEmitter : public MCCodeEmitter {
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const;
- void emitInstruction(uint64_t Val, unsigned Size, const MCSubtargetInfo &STI,
- SmallVectorImpl<char> &CB) const;
-
void encodeInstruction(const MCInst &MI, SmallVectorImpl<char> &CB,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const override;
More information about the llvm-commits
mailing list