froofyJIT 0.21 review
DownloadfroofyJIT is a C++ 'syntactic sugar' front-end for Paolo Bonzini's GNU lightning library for dynamic native code generation
|
|
froofyJIT is a C++ 'syntactic sugar' front-end for Paolo Bonzini's GNU lightning library for dynamic native code generation. froofyJIT program uses C++'s powerful language facilities to allow GNU lightning instructions to be expressed in a more concise way that approximates a 'real' assembly language.
Below is a program which uses froofyJIT to compute a Fibonacci number (directly translated from tests/fib.c in GNU lightning):
#include < cstdlib >
#include < iostream >
#include "froofy/jit.h"
static jit_insn codeBuffer[1024];
typedef int (*pifi)(int);
int main()
{
pifi nfibs;
int in;
{
using namespace froofy::jit;
label< > basis;
nfibs/ !org, codeBuffer;
prolog, 1;
!arg< ui > in;
getarg< ui > v0, in;
blti< ui > basis, v0, 2;
subi< ui > v1, v0, 1;
subi< ui > v2, v0, 2;
prepare< i > 1;
pusharg< ui > v1;
finish, nfibs;
retval< i > v1;
prepare< i > 1;
pusharg< ui > v2;
finish, nfibs;
retval< i > v2;
addi< ui > v1, v1, 1;
addr< ui > rr, v1, v2;
ret --;
basis/ movi< i > rr, 1;
ret --;
!end, codeBuffer;
}
std::cout
froofyJIT 0.21 keywords