Anders,
It will be interesting to hear how your project goes. To generalize
Chris's answer a bit, for any language, you have to implement the
standard libraries and runtime system (if any) somehow. LLVM is just a
compiler infrastructure, i.e. it is mainly intended to implement the
compiler system (language-to-LLVM-to-target). The standard libraries
and runtime system can either be compiled to the target language
directly, or can be compiled to LLVM. In either case, they get linked
into the code generated by the compiler, either by the system linker or
by the LLVM linker.
--Vikram
http://www.cs.uiuc.edu/~vadve
http://llvm.cs.uiuc.edu/
On Feb 24, 2004, at 8:49 AM, Chris Lattner wrote:
> On Tue, 24 Feb 2004, Anders Alexandersson wrote:
>> I am doing some pre-studies for my masters thesis, which (hopefully)
>> will result in a compiler prototype for Ruby to LLVM, and I have a
>> question:
>
> Cool! :)
>
>> 1. When reading the reference manual, I do not understand how e.g.
>> simple I/O operations as printf() can be implemented in LLVM. Are
>> there
>> any external functions available, or how do I proceed?
>
> Basically, LLVM relies on the operating system for this. printf is
> part
> of the "standard I/O" library provided by libc on most unix-like
> systems.
> After adding a layer of buffering, libc ends up turning stdio calls
> into
> low-level system calls like read() and write().
>
> If you want _direct_ access to the OS, you could do similar things.
>
> On the other hand, if you're working on a Ruby backend for LLVM, it
> might
> make most sense to define a Ruby/LLVM runtime library that includes
> more-or-less direct implementations of things like the ruby 'print'
> message for various types. This runtime library could be written in C,
> C++, Ruby, or for that matter, LLVM directly. When compiling a user
> program, the Ruby front-end would emit calls to these runtime library
> routines.
>
> Let me know if this doesn't make any sense and I can supply an example.
> :)
>
> -Chris
>
> --
> http://llvm.cs.uiuc.edu/
> http://www.nondot.org/~sabre/Projects/
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 2328 bytes
Desc: not available
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20040224/18eabe8e/attachment.bin>