[llvm-dev] Possibilities with LLVM

via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 9 07:31:15 PDT 2018


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 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.



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>


More information about the llvm-dev mailing list