Skip to content

Commit c9bfdae

Browse files
authored
[RISCV] Use uint64_t for Insn in getInstruction32 and getInstruction16. NFC (#146619)
Insn is passed to decodeInstruction which is a template function based on the type of Insn. By using uint64_t we ensure only one version of decodeInstruction is created. This reduces the file size of RISCVDisassembler.cpp.o by ~25% in my local build.
1 parent f1a4bb6 commit c9bfdae

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,9 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
811811
}
812812
Size = 4;
813813

814-
uint32_t Insn = support::endian::read32le(Bytes.data());
814+
// Use uint64_t to match getInstruction48. decodeInstruction is templated
815+
// on the Insn type.
816+
uint64_t Insn = support::endian::read32le(Bytes.data());
815817

816818
for (const DecoderListEntry &Entry : DecoderList32) {
817819
if (!Entry.haveContainedFeatures(STI.getFeatureBits()))
@@ -857,7 +859,9 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
857859
}
858860
Size = 2;
859861

860-
uint32_t Insn = support::endian::read16le(Bytes.data());
862+
// Use uint64_t to match getInstruction48. decodeInstruction is templated
863+
// on the Insn type.
864+
uint64_t Insn = support::endian::read16le(Bytes.data());
861865

862866
for (const DecoderListEntry &Entry : DecoderList16) {
863867
if (!Entry.haveContainedFeatures(STI.getFeatureBits()))

0 commit comments

Comments
 (0)