Hello I've been looking to LLVM, in order to develop a compiler for a cryptography oriented language. I started by following the tutorials on Kaleidoscope, and I must say they were very usefull. Now I need to use GMP, so i can add Big Integer support. I am trying to change Kaleidoscope to support BigIntegers instead of doubles, but I don't really know how to do that. I'd really appreciate some help in this. Thanks in advance Paulo Matias
I could be wrong, but I think that you may need to add a 'big-integer' intrinsic type to llvm. On Wed, Mar 25, 2009 at 4:32 AM, Paulo Matias <paulomatias0 at gmail.com> wrote:> Hello > > I've been looking to LLVM, in order to develop a compiler for a > cryptography oriented language. I started by following the tutorials on > Kaleidoscope, and I must say they were very usefull. Now I need to use > GMP, so i can add Big Integer support. I am trying to change > Kaleidoscope to support BigIntegers instead of doubles, but I don't > really know how to do that. I'd really appreciate some help in this. > > Thanks in advance > Paulo Matias > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
On Mar 24, 2009, at 11:20 PM, someguy wrote:> I could be wrong, but I think that you may need to add a 'big-integer' > intrinsic type to llvm.No, please don't. GMP is just another library like libc, your front- end should just generate calls into it like any other library. This is similar to how we handle threading and many other "language features". -Chris
Hi Paulo, Paulo Matias wrote:> I've been looking to LLVM, in order to develop a compiler for a > cryptography oriented language. I started by following the tutorials on > Kaleidoscope, and I must say they were very usefull. Now I need to use > GMP, so i can add Big Integer support. I am trying to change > Kaleidoscope to support BigIntegers instead of doubles, but I don't > really know how to do that. I'd really appreciate some help in this.If you don't mind using an existing LLVM-based language, "Pure" has GMP bigints built into it, and rational numbers (and complex rationals) as well. And you have a full-featured language to boot, which can also do symbolic algebraic manipulations (it's based on term rewriting). Being dynamically typed, Pure isn't quite as fast as compiled Haskell or ML, but it does LLVM JIT compilation and in the latest version you can also create standalone executables. Interfacing to your own C code is as easy as pie: using "lib:my_c_stuff.so"; extern char *foo(mpz_t *x); If nothing else, the Pure interpreter also provides you with a bunch of C++ code using LLVM which goes well beyond Kaleidoscope. I hear that people are already using it that way, as well as for testing their LLVM ports and packages. ;-) You can find Pure here: http://pure-lang.googlecode.com/ Cheers, Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr.Graef at t-online.de, ag at muwiinfa.geschichte.uni-mainz.de WWW: http://www.musikinformatik.uni-mainz.de/ag