[PATCH] D120960: [M68k][Disassembler] Adopt the new variable length decoder
Sheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 2 12:14:12 PDT 2022
0x59616e updated this revision to Diff 426481.
0x59616e marked 2 inline comments as done.
0x59616e added a comment.
address feedback:
- use llvm::alignTo
- construct `APInt` directly with constructor instead of assignment copy constructor
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D120960/new/
https://reviews.llvm.org/D120960
Files:
llvm/lib/Target/M68k/Disassembler/M68kDisassembler.cpp
Index: llvm/lib/Target/M68k/Disassembler/M68kDisassembler.cpp
===================================================================
--- llvm/lib/Target/M68k/Disassembler/M68kDisassembler.cpp
+++ llvm/lib/Target/M68k/Disassembler/M68kDisassembler.cpp
@@ -118,15 +118,15 @@
raw_ostream &CStream) const {
DecodeStatus Result;
auto MakeUp = [&](APInt &Insn, unsigned InstrBits) {
- unsigned i = Insn.getBitWidth();
- unsigned RoundUp = ((InstrBits + 0xf) & ~0xf);
+ unsigned Idx = Insn.getBitWidth() >> 3;
+ unsigned RoundUp = alignTo(InstrBits, Align(16));
Insn = Insn.zextOrSelf(RoundUp);
RoundUp = RoundUp >> 3;
- for (i = i >> 3; i < RoundUp; i += 2) {
- Insn.insertBits(support::endian::read16be(&Bytes[i]), i * 8, 16);
+ for (; Idx < RoundUp; Idx += 2) {
+ Insn.insertBits(support::endian::read16be(&Bytes[Idx]), Idx * 8, 16);
}
};
- APInt Insn = APInt(16, support::endian::read16be(Bytes.data()));
+ APInt Insn(16, support::endian::read16be(Bytes.data()));
Result = decodeInstruction(DecoderTable80, Instr, Insn, Address, this, STI,
MakeUp);
if (Result == DecodeStatus::Success)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120960.426481.patch
Type: text/x-patch
Size: 1217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220502/51a7f0d9/attachment.bin>
More information about the llvm-commits
mailing list