Dis-assembler

Hi,

I would like to make a disassembler for my target that reads .s files into a MachineFunction with MachineInstrs. Is this possible?

Jonas

Nope.

-eric

Could you please expand a bit?

Why are not the MCInstr and MachineInstr classes compatible? Is this not a long term goal, even?

Could I make optimization passes in the MC layer with a disassembler as in a MachineFunction?

Thanks,

Jonas

Could you please expand a bit?

Why are not the MCInstr and MachineInstr classes compatible? Is this not a long term goal, even?

It's not that the MCInst and MachineInstr classes are incompatible, it's that decomposing generic assembly/machine code into functions and global variables is a very non-trivial task. Since MCInsts already give you pretty much everything that MachineInstr would (the only major things I see missing, from perusing documentation, is register def-use chains and pseudo-instructions, neither of which are terribly definable when MCInsts are used), there's not much of a reason to write a class to translate MCInst back into MachineInstr.

Could I make optimization passes in the MC layer with a disassembler as in a MachineFunction?

The MC layer is a lower-level layer, where the notion of functions and definable control flow are a lot weaker and also where things like "delete this instruction" can very easily break things (e.g., a branch can no longer be done since it was a short jump and the target moved out of range). Optimizations at this layer would, to me at least, fall under the category of "you really don't want to do this". Given that many people neither expect nor desire optimizations to be done on explicit assembly code, I would recommend that you rather find a different approach to do what you are trying to do.