Hello everyone, I have some questions about the possibilities with the LLVM but I'm not sure where to gather the information. 1.) Can I teach the LLVM new platform depended intrinsics? Like I provide assembly code and want to create a custom intrinsic for it. 2.) Does the IR language have some kind of template support? I'm not sure if this even possible - but I thought about having a template function and when jitting the IR it could instantiate that template with the now known data - okay writing this already sounds weird and I'm not sure if I could explain what I wanted. 3.) Can I implement my own custom calling convention? Like my own "__planschiCall" or something? When these things are possible - are there any documentation or tutorials for this? And how does Clang learn about all these custom things? Kind regards Björn Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180409/80ede173/attachment.html>
Also a newbie myself. However afaik: 1&3 should be possible , as for the 2nd, I have no idea what do you mean Zhang> On 9 Apr 2018, at 09:43, via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hello everyone, > > I have some questions about the possibilities with the LLVM but I'm not sure where to gather the information. > > 1.) Can I teach the LLVM new platform depended intrinsics? > Like I provide assembly code and want to create a custom intrinsic for it. > > 2.) Does the IR language have some kind of template support? > I'm not sure if this even possible - but I thought about having a template function and when jitting the IR it could instantiate that template with the now known data - okay writing this already sounds weird and I'm not sure if I could explain what I wanted. > > 3.) Can I implement my own custom calling convention? Like my own "__planschiCall" or something? > > When these things are possible - are there any documentation or tutorials for this? And how does Clang learn about all these custom things? > > Kind regards > Björn > > Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 > Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima. > > _______________________________________________ > 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/20180409/ebf5acf6/attachment.html>
Hi Björn, On 9 April 2018 at 09:43, via llvm-dev <llvm-dev at lists.llvm.org> wrote:> 1.) Can I teach the LLVM new platform depended intrinsics? > Like I provide assembly code and want to create a custom intrinsic for it.Yes. You'd add a declaration to include/llvm/IR/IntrinsicsXYZ.td (where XYZ is your target), and then you can select them with a normal pattern in your target's .td files. On the Clang side you'd add it to include/clang/Basic/BuiltinsXYZ.def and lib/CodeGen/CGBuiltin.cpp. Possibly lib/Sema/SemaChecking.cpp too if it has strange validity requirements.> 2.) Does the IR language have some kind of template support? > I'm not sure if this even possible - but I thought about having a template > function and when jitting the IR it could instantiate that template with the > now known data - okay writing this already sounds weird and I'm not sure if > I could explain what I wanted.No template support, I'm afraid. That would be handled by a language's front-end.> 3.) Can I implement my own custom calling convention? Like my own > "__planschiCall" or something?Yes. The easiest way would be to use a simple numbered calling convention "cc N" in the LLVM IR. Then you just have to add support to lib/Target/XYZ/XYZISelLowering.cpp and the corresponding calling convention .td file (the name varies a bit). ISelLowering usually just involves a switch based on the call or definition that selects the right implementation from the .td file. Grep for CCAssignFnForCall to see the kind of thing you'll be changing. Clang side, you'll be changing lib/Targets/XYZ.cpp to either make it the default or support it via __attribute__((pcs("whatever"))). See ARM.cpp for an example, it already uses both methods. Cheers. Tim.
Hello Tim, thank you for the response! Are there tutorials for the points 1 and 3 available? I'm still a cub with the LLVM... Kind regards Björn From: Tim Northover <t.p.northover at gmail.com> To: bjoern.gaier at horiba.com Cc: LLVM Developers Mailing List <llvm-dev at lists.llvm.org> Date: 09.04.2018 12:09 Subject: Re: [llvm-dev] Possibilities with LLVM Hi Björn, On 9 April 2018 at 09:43, via llvm-dev <llvm-dev at lists.llvm.org> wrote:> 1.) Can I teach the LLVM new platform depended intrinsics? > Like I provide assembly code and want to create a custom intrinsic forit. Yes. You'd add a declaration to include/llvm/IR/IntrinsicsXYZ.td (where XYZ is your target), and then you can select them with a normal pattern in your target's .td files. On the Clang side you'd add it to include/clang/Basic/BuiltinsXYZ.def and lib/CodeGen/CGBuiltin.cpp. Possibly lib/Sema/SemaChecking.cpp too if it has strange validity requirements.> 2.) Does the IR language have some kind of template support? > I'm not sure if this even possible - but I thought about having atemplate> function and when jitting the IR it could instantiate that template withthe> now known data - okay writing this already sounds weird and I'm not sureif> I could explain what I wanted.No template support, I'm afraid. That would be handled by a language's front-end.> 3.) Can I implement my own custom calling convention? Like my own > "__planschiCall" or something?Yes. The easiest way would be to use a simple numbered calling convention "cc N" in the LLVM IR. Then you just have to add support to lib/Target/XYZ/XYZISelLowering.cpp and the corresponding calling convention .td file (the name varies a bit). ISelLowering usually just involves a switch based on the call or definition that selects the right implementation from the .td file. Grep for CCAssignFnForCall to see the kind of thing you'll be changing. Clang side, you'll be changing lib/Targets/XYZ.cpp to either make it the default or support it via __attribute__((pcs("whatever"))). See ARM.cpp for an example, it already uses both methods. Cheers. Tim. Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180409/2fc8da17/attachment.html>