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 -- Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667
hi,> > define ptx_device i16 @t4_u16(i16 %x) { > ; CHECK: not.b16 rh0, rh1, rh2; > ; CHECK-NEXT: ret; > %z = xor i16 %x, 1it should be %z = xor i16 %x, 0xffff?> ret i16 %z > } >best regards ether
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 > >
Hi, Dan Someone on the irc suggest me using custom lowering to do the mapping correctly. But I am still trying to figure out how to do that. Regards, chenwj -- Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667
Reasonably Related Threads
- [LLVMdev] [LLVMDev] Add not instruction to PTX backend
- [LLVMdev] [LLVMDev] Add not instruction to PTX backend
- [LLVMdev] [LLVMDev] Add not instruction to PTX backend
- [LLVMdev] [LLVMDev] Add not instruction to PTX backend
- [LLVMdev] [LLVMDev] Add not instruction to PTX backend