[LLVMdev] LLVM and GMP

Albert Graef Dr.Graef at t-online.de
Sun Mar 29 00:51:28 PDT 2009


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



More information about the llvm-dev mailing list