Skip to content

Commit 1f995b5

Browse files
authored
[M68k] Remove use of APInt::getRawData(). NFC (llvm#103529)
getRawData exposes some internal details of APInt. The code was iterating over the uint64_t pieces and then iterating breaking them into 4 uint16_t pieces. This patch changes the code to extract 16-bit pieces directly from the APInt without using getRawData.
1 parent cba9166 commit 1f995b5

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

llvm/lib/Target/M68k/MCTargetDesc/M68kMCCodeEmitter.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,11 @@ void M68kMCCodeEmitter::encodeInstruction(const MCInst &MI,
236236
APInt Scratch(64, 0U); // One APInt word is enough.
237237
getBinaryCodeForInstr(MI, Fixups, EncodedInst, Scratch, STI);
238238

239-
ArrayRef<uint64_t> Data(EncodedInst.getRawData(), EncodedInst.getNumWords());
240-
int64_t InstSize = EncodedInst.getBitWidth();
241-
for (uint64_t Word : Data) {
242-
for (int i = 0; i < 4 && InstSize > 0; ++i, InstSize -= 16) {
243-
support::endian::write<uint16_t>(CB, static_cast<uint16_t>(Word),
244-
llvm::endianness::big);
245-
Word >>= 16;
246-
}
247-
}
239+
unsigned InstSize = EncodedInst.getBitWidth();
240+
for (unsigned i = 0; i != InstSize; i += 16)
241+
support::endian::write<uint16_t>(
242+
CB, static_cast<uint16_t>(EncodedInst.extractBitsAsZExtValue(16, i)),
243+
llvm::endianness::big);
248244
}
249245

250246
MCCodeEmitter *llvm::createM68kMCCodeEmitter(const MCInstrInfo &MCII,

0 commit comments

Comments
 (0)