[LLVMdev] Dis-assembler

Joshua Cranmer pidgeot18 at gmail.com
Mon Feb 20 10:45:25 PST 2012


On 2/20/2012 3:27 AM, Jonas Paulsson wrote:
> 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.

-- 
Joshua Cranmer
News submodule owner
DXR coauthor




More information about the llvm-dev mailing list