GaloisInc / dismantle

A library of assemblers and disassemblers derived from LLVM TableGen data
24 stars 5 forks source link

Fixes to the Thumb decoder #30

Closed travitch closed 3 years ago

travitch commented 3 years ago

The original implementation generated bit masks that were too permissive (and too large) that caused the decoder to improperly consume 16 extra bits with every T16 encoded instruction.

This (possibly misguided) attempt to fix it type-indexes all of the bitmasks to ensure that we get it right.

Note: it currently fails at TH time due to an error somewhere.

travitch commented 3 years ago

This seems to be good now. It makes instruction sizes explicit with a NatRepr. The change is plumbed through everywhere. The test suite covers some Thumb instructions now.

kquick commented 3 years ago

It's a big PR, but based on my note above, it looks like the core type change and NatRepr size tracking drive most of the changes here. This is assuredly better that what was there before, and thanks for giving me the opportunity to get familiar with it.

Also paraphrased from a separate conversation and left here for posterity: "Thumb-2 might not work yet, but this is still an improvement. It looks like negative patterns [in the trie usage] aren't being applied right for two byte instructions."