[LLVMdev] Question on tablegen

Manjunath Kudlur keveman at gmail.com
Thu May 7 17:27:39 PDT 2009


Dan,

Thanks a lot. Using a modifier in the assembly string works for this
case. I am trying to solve a related problem. I am trying to print out
a set of "mov" ops for the vector_shuffle node. Since the source of
the "mov" is from one of the sources to vector_shuffle, depending on
the mask, I am not sure what assembly string to emit. For example, if
I have

d <- vector_shuffle s1, s2, <0,3>

I want to emit

mov d.x, s1.x
mov d.y, s2.y

For this, I need some thing like

"mov $d.x, <$src1 or $src2>.<something that depends on the mask>"

I can use the same modifier trick for which component of the source to
select, but I don't know how to select which of the sources to select
($src1 or $src2) depending on the mask. Do you have any suggestions?

Thanks,
Manjunath

On Wed, May 6, 2009 at 10:10 AM, Dan Gohman <gohman at apple.com> wrote:
> 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
>
> _______________________________________________
> 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