<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Daniel,<br>
<br>
Thanks for the reply. If I understand correctly, your suggestion is to
have the backend call a library that handles the built-in functions.
Would the calls need to be lowered and redirected (e.g. by a big switch
statement or a jump table) to the corresponding function in the library?<br>
<br>
Thanks,<br>
Javier<br>
<br>
On 7/20/2009 12:11 AM, Daniel Dunbar wrote:
<blockquote
 cite="mid:6a8523d60907200011wa53fcfbt24c5043f792d907c@mail.gmail.com"
 type="cite">
  <pre wrap="">Hi Javier,

I'm not the right person to answer your question, but since no one
else took it: I believe this is a situation where the backend would
typically emit a call the the compiler's runtime library (e.g.,
libgcc).

While it isn't currently completely wired up, we do have our own
compiler runtime library available under the compiler-rt project in
the LLVM repo.

 - Daniel

On Thu, Jul 16, 2009 at 2:07 AM, Javier Martinez<a class="moz-txt-link-rfc2396E" href="mailto:javier@jmartinez.org"><javier@jmartinez.org></a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hi,

I'm trying to add support in my back end for certain functions that are
seen as built-in by the target. Some of these functions can be
implemented in a) LLVM, and some in b) the native target language.

My approach to case a) is to write the built-in function implementation
in C, compile it to LLVM using Clang, link it to the module that uses it
and finally add a pass to inline it. The last two steps can be made
inside a ModulePass. The definition of TargetMachine allows for any pass
manager deriving form BasicPass to be passed to AddPassesToEmitFile.
However, I see that llc uses a FunctionPassManager for all the passes. A
(module)PassManager is used only if the target implements
AddPassesToEmitWholeFile but the comments on the base class discourage
this path. Am I approaching the problem the wrong way?

I haven't worked much on case b) but my idea was to use a similar
approach but instead of writing the built-in function implementation in
straight C an asm block would be used to insert the code. Does this make
sense?

Thanks,
Javier


_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>

    </pre>
  </blockquote>
  <pre wrap=""><!---->
_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
  </pre>
</blockquote>
</body>
</html>