This adds new option --mnemonic-hist to print a histogram of all (static) instructions/mnemonics. For example:
$ llvm-objdump --triple=thumbv7 -d --mnemonic-hist .. Instruction histogram: ldr: 120 (27.3973%) mov: 96 (21.9178%) blx: 56 (12.7854%) bl: 31 (7.07763%) str: 26 (5.93607%) add: 18 (4.10959%) b: 12 (2.73973%) sub: 10 (2.28311%) cmp: 9 (2.05479%) ..
I am probably interested in printing more information, like the encoding width, but this seems a good first step.
If you're going to pad the names to make them all line up then you should test something that isn't 3 characters. Also, and this makes the test bigger but check that the number padding works. Maybe just make one appear 10 times, unless you can figure out a macro to emit 100 of something.
Also do you expect an ordering between the 2 instructions that both have 1? As in should it be alphabetical between those 2 or is it going to depend on order of appearance in the object file.
Edit: Putting them in a std::map sorts them so you would always see mul then sub even if sub appears first in the object, correct?
Can you comment in the test file what things it's looking for.