Xiangyang Guo via llvm-dev
2016-Mar-21 23:33 UTC
[llvm-dev] define intrinsic function with pointer-typed parameter
Hi, If I define a intrinsic function with pointer-typed parameter, for example, def llvm_foo_ptr_ty : LLVMPointerType<llvm_i16_ty>; def int_foo_get : Intrinsic<[llvm_foo_ptr_ty], [llvm_foo_ptr_ty, llvm_i32_ty], [IntrReadArgMem]>; How to lower it for the backend? I'm not sure what kind of register (i16 or i32 or i32) is needed in this case? If the parameter is LLVMPointerType<llvm_i32_ty> instead of LLVMPointerType<llvm_i16_ty>, will this make difference for the backend? Suppose my backend has three types of register: i16, i32, i64. When I check the debug information, I can see LLVM tries to use i32 to lower the parameter to build SDAG. But why it chooses i32 instead of i64? Any input is appreciable. Regards, Xiangyang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160321/2778a8a1/attachment.html>
Philip Reames via llvm-dev
2016-Mar-22 20:50 UTC
[llvm-dev] define intrinsic function with pointer-typed parameter
It sounds like you're hitting the default case in SelectionDAGBuilder::visitIntrinsicCall and exercising the visitTargetIntrinsic code path. I haven't dug into the default handling there, but that's probably what you need to look at. Depending on your intrinsic, you might also consider adding custom handling in visitIntrinsicCall itself. On 03/21/2016 04:33 PM, Xiangyang Guo via llvm-dev wrote:> Hi, > > If I define a intrinsic function with pointer-typed parameter, for > example, > def llvm_foo_ptr_ty : LLVMPointerType<llvm_i16_ty>; > def int_foo_get : Intrinsic<[llvm_foo_ptr_ty], [llvm_foo_ptr_ty, > llvm_i32_ty], [IntrReadArgMem]>; > > How to lower it for the backend? I'm not sure what kind of register > (i16 or i32 or i32) is needed in this case? If the parameter is > LLVMPointerType<llvm_i32_ty> instead of LLVMPointerType<llvm_i16_ty>, > will this make difference for the backend? Suppose my backend has > three types of register: i16, i32, i64. > > When I check the debug information, I can see LLVM tries to use i32 to > lower the parameter to build SDAG. But why it chooses i32 instead of i64?This sounds like your target isn't telling the canonicalization logic i16 is a valid register type or that the cost of i32 register is much less than an i16. However, I'm no expert in the backend stuff, so take my comment with a grain of salt.> > Any input is appreciable. > > Regards, > > Xiangyang > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160322/19e47d67/attachment.html>
Reasonably Related Threads
- [LLVMdev] Creation of Intrinsics with Pointer Return Types
- [LLVMdev] Creation of Intrinsics with Pointer Return Types
- [LLVMdev] automatically generating intrinsic declarations
- [LLVMdev] Problems when refining type
- [LLVMdev] automatically generating intrinsic declarations