I found these lines in the BrainF example: //declare i32 @getchar() getchar_func = cast<Function>(module-> getOrInsertFunction("getchar", IntegerType::getInt32Ty(C), NULL)); //declare i32 @putchar(i32) putchar_func = cast<Function>(module-> getOrInsertFunction("putchar", IntegerType::getInt32Ty(C), IntegerType::getInt32Ty(C), NULL)); Since getchar and putchar are never defined, I'm assuming they are intrinsics, but they are not documented with the rest of the intrinsics. So are they intrinsics or something else? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110512/e80203f6/attachment.html>
Hi, Hans> Since getchar and putchar are never defined, I'm assuming they are > intrinsics, but they are not documented with the rest of the intrinsics. So > are they intrinsics or something else?I _guess_ standard functions like getchar/putchar are linked by default. Regards, chenwj -- Wei-Ren Chen (陳韋任) Computer Systems Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.) Tel:886-2-2788-3799 #1667
On 05/12/2011 11:08 PM, 陳韋任 wrote:> Hi, Hans > >> Since getchar and putchar are never defined, I'm assuming they are >> intrinsics, but they are not documented with the rest of the intrinsics. So >> are they intrinsics or something else? > > I _guess_ standard functions like getchar/putchar are linked by > default.Indeed, they're coming from libc. The JIT will find any visible functions in the program it's running in (it calls dlsym() actually), so it finds putchar() just like C code finds putchar(). You can even declare your own extern "C" functions and the JIT will find those too. Nick
Hi Hans,> I found these lines in the BrainF example: > > > //declare i32 @getchar() > getchar_func = cast<Function>(module-> > getOrInsertFunction("getchar", IntegerType::getInt32Ty(C), NULL)); > > //declare i32 @putchar(i32) > putchar_func = cast<Function>(module-> > getOrInsertFunction("putchar", IntegerType::getInt32Ty(C), > IntegerType::getInt32Ty(C), NULL)); > > > > > Since getchar and putchar are never defined, I'm assuming they are intrinsics,no, they are the C standard library functions putchar and getchar. Ciao, Duncan.