[LLVMdev] [LLVMDev] Add not instruction to PTX backend
Dan Bailey
drb at dneg.com
Thu May 12 08:06:10 PDT 2011
Hi,
Hope you've got this to work. LLVM IR is pretty low-level, much more so
than PTX. As there are quite a few different ways to achieve the same
thing in PTX, it's likely that we won't need to handle all of the
different instructions for PTX as the IR will only support a subset of them.
In the future, I would suggest putting together the test case first and
only when the backend is incapable of lowering a particular IR
instruction then look to add support to the backend. Your suggested
implementation looks completely valid, it's just that it may not
actually be needed! (Note I haven't investigated whether or not that's
the case here though.) :-)
Dan
陳韋任 wrote:
> Hi, Dan
>
> I add "not" instruction support in PTXInstrInfo.td as
> you suggested before.
>
> multiclass PTX_LOGIC_2OP<string opcstr,PatFrag opnode> {
> ...
> }
>
> Now I am trying to write test case for logic and shift
> operations. But I have a trouble in mapping LLVM IR to PTX
> IR for "not" instruction. The test case I wrote is,
>
> define ptx_device i16 @t4_u16(i16 %x) {
> ; CHECK: not.b16 rh0, rh1, rh2;
> ; CHECK-NEXT: ret;
> %z = xor i16 %x, 1
> ret i16 %z
> }
>
> Since LLVM IR doesn't support logical not directly, I use "xor i16 %x, 1"
> to represent logical not in LLVM IR. It turns out the IR is mapped to
> PTX "xor" not PTX "not". Any idea on how to get the mapping correct?
>
> Thanks.
>
> Regards,
> chenwj
>
>
More information about the llvm-dev
mailing list