Print the Binary Form of an Instruction

Hi all,

I have defined an instruction in the and files. I also wrote a CodeEmitter class for that, and now I have a .inc file after compilation that seems like it might be correct, BUT, I would like to see what will be generated when the assembly code is converted to the binary machine code!

Is there any command in TableGen or a test class to do so?




If you have an AsmParser implemented, you could put an instruction into
a file and then run it through llvm-mc with the -show-encoding option.
For example:

  llvm-mc -triple=foo -show-encoding test.s

Hope this helps.

Hello all,
Hello Simon,

Thank you very much for your tutorial “Howto: Implementing LLVM Integrated Assembler”. It was indeed very helpful for me.

I am having a little bit difficulties with the AsmParser which I would like to postpone for the moment.

I have the LLVM IR for a simple add that I want to see its emitted binary. Do you think it’s possible/doable to give this internal representation to the CodeEmitter and see the binary representation instead of going through writing the assembly code, then parsing it, and then run it with the show-encoding option?

Thanks a lot.