[LLVMdev] Question on tablegen

Dan Gohman gohman at apple.com
Wed May 6 10:10:24 PDT 2009


One way to do this is to handle this in the AsmPrinter, with
operand modifiers.

For example, on x86 there are instructions with ${dst:call} in
their asm string. The "call" part is interpreted as an operand
modifier. The assembly printer looks for the "call" modifier
on MachineOperand::MO_Immediate operands
(in X86ATTAsmPrinter::printOperand), which lets it perform custom
printing for that type of operand. You could use a modifier which
tells the AsmPrinter to print an immediate as the appropriate
letter.

Dan


On May 5, 2009, at 10:23 PM, Manjunath Kudlur wrote:

> Hello,
>
> I am trying to create a machine instruction for "extractelement". I
> want to translate
> r <- extractelement v, 0
> to
> mov r, v.x
>
> I was looking at the dag I can use and I found vector_extract. The
> inputs for this SDnode are a register and a iPtr constant. With that,
> I need to create 4 separate def's to extract element 0, 1, 2, and 3
> and translate to v.x, v.y, v.z, and v.w. I was wondering if I can use
> the dag's 2nd input as an index into a list of strings and form the
> assembly instruction, something like !strconcat("mov $dst, v.",
> elemnames[$input]). I am still trying to learn the tablegen syntax and
> semantics, so how to do this is not clear to me. I will appreciate any
> suggestions on how to do this, or pointers to other places where
> similar things are done.
>
> Thanks,
> Manjunath
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list