The Kite Compiler: part 3 of many
Written by Mooneer Salem on Saturday 29th of May, 2010 in General
Since the last post, I’ve added binary operation support and the ability to have parameters in the method definition. As a result:
[Switching to process 68956] Running… Evaluates to: 42 ; ModuleID = 'test_module' %0 = type { void*, void* } %1 = type { i32 } define i32 @life_universe_everything(%0* %thd, i32 %param) { entry: %0 = alloca %1* ; <%1**> [#uses=1] store %1* null, %1** %0 %1 = add i32 32, %param ; <i32> [#uses=1] ret i32 %1 } Debugger stopped. Program exited with status value:0.
More updates soon! :)
The Kite Compiler: part 2 of many
Written by Mooneer Salem on Friday 14th of May, 2010 in General
This week, I worked some more on learning how LLVM works. I’ve created basic method and constant value classes to represent those values in the AST, and wrote a test app to ensure this works. I’m happy to tell you all that I have some initial success doing this. :)
Sample application:
using namespace kite::parse_tree; int main (int argc, char * const argv[]) { // TODO: kite compiler driver. InitializeNativeTarget(); llvm_start_multithreaded(); ConstantValue<double> *constant = new ConstantValue<double>(42.0); MethodValue *method = new MethodValue("life_universe_everything"); method->push_instruction(constant); CompilerState *state = new CompilerState(); LLVMContext &context = getGlobalContext(); state->push_module(new Module("test_module", context)); Value *v = method->codegen(state); Module *mod = state->pop_module(); ExecutionEngine *engine = EngineBuilder(mod).create(); void *fptr = engine->getPointerToFunction(static_cast<Function*>(v)); double (*FP)() = (double (*)())(intptr_t)fptr; std::cout << "Evaluates to: " << (*FP)() << std::endl; mod->dump(); return 0; }
Results:
[Session started at 2010-05-14 22:18:51 -0700.] GNU gdb 6.3.50-20050815 (Apple version gdb-1461.2) (Fri Mar 5 04:43:10 UTC 2010) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin".tty /dev/ttys000 Loading program into debugger… sharedlibrary apply-load-rules all Program loaded. run [Switching to process 19016] Running… Evaluates to: 42 ; ModuleID = 'test_module' define double @life_universe_everything() { entry: ret double 4.200000e+01 } Debugger stopped. Program exited with status value:0.
The Kite Compiler: part 1 of many
Written by Mooneer Salem on Monday 3rd of May, 2010 in General with 1 comment
I didn’t forget about Kite, don’t worry. :)
A compiler for Kite is a commonly requested feature. Kite 1.0 also has some major issues with regard to resource utilization and performance that won’t be resolved with the interpreter–only code. Enter LLVM, which promises the ability to write a compiler for any programming language.
Today, I’ve begun work on stripping out all of the interpreter–specific code from the parser and the lexer. This allows me to see what needs to be done to create an abstract syntax tree.
Because I’m going with LLVM for this, some of the Kite compiler will also be in C++. (the parser and lexer will definitely be in straight C, as will maybe some other portions that are undecided as of now). Basically, Kite can be written correctly this time. :)
That’s all for now. More later when more code’s been checked in. :D
Kite server hacked
Written by Mooneer Salem on Friday 17th of July, 2009 in General with 10 comments
Tonight, a rootkit was discovered on the VM hosting this Web site. As a result, we have moved SVN, Trac and the main Web site to a new machine earlier than we anticipated. If you see this, you are viewing the site on the new machine; the old VM has been taken down to contain the damage. Apologies for the inconvenience this has caused.
Please let us know if you see anything weird or broken on any of the sites. Thanks!
New VIM syntax file
Written by Mooneer Salem on Thursday 5th of February, 2009 in General with 1 comment
Jørgen P. Tjernø has written a preliminary vim syntax file for Kite.
- Download: http://svn.devsoft.no/kite/syntax/