[LLVMdev] string input for the integrated assembler
rnk at google.com
Wed Mar 18 11:00:04 PDT 2015
To try to rephrase, these are the transformations to and from MC in LLVM:
assembly -> MCInsts
MachineInstrs -> MCInsts
MCInsts -> object file
MCInsts -> assembly
It sounds you're having trouble translating from MachineInstrs to MCInsts,
but printing assembly strings from MachineInstrs is easy for some reason.
I don't really see why we'd want to go back to the old way of printing
assembly strings from the compiler, and then reparsing them, even if it
were in-process. We did a lot of work to avoid that whole re-parsing step
to save on compile time.
I don't fully understand the challenges your target presents, but I'm not
convinced that they can't be overcome with some good engineering. Printing
asm strings and building MCInsts seem like equivalently difficult problems
that would leverage the same underlying logic.
On Tue, Mar 17, 2015 at 5:47 PM, Steve King <steve at metrokings.com> wrote:
> Short version: If the integrated assembler accepted assembly strings
> as input, more targets could take advantage of integrated assembly.
> The longer version:
> For a given assembly statement, my out-of-tree target has complex
> instruction selection logic -- more so than the in-tree targets. This
> target uses variable length instructions and a laborious hierarchy of
> tblgen AsmOperands to do the job. Assembly and disassembly with
> llvm-mc and llvm-objdump work fine.
> As a simplification, the compiler deals almost exclusively in pseudo
> instructions. By x86 analogy, using pseudos to unfold a TEST32rm into
> MOV32rm + TEST32rr means I can skip the complex operand fitting effort
> needed to pick specific machine instructions. There are many such
> examples where handling real instructions would become a gross
> One drawback of this approach is that the integrated assembler
> receives only unexpanded pseudos as input, which fails. So, my target
> must generate .s files and assemble as a separate step.
> If a target could pass an assembly string to the integrated assembler,
> the pseudo problem goes away. The string passed to the integrated
> assembler could come wrapped in a pseudo MCInst or whatever. Support
> for asm string parsing already exists in every target, so this doesn't
> seem like much of a stretch.
> Thanks for any comments on this idea.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev