[LLVMdev] Beginners question
Chris Lattner
sabre at nondot.org
Tue Feb 24 08:48:01 PST 2004
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/
More information about the llvm-dev
mailing list