Home

Awesome

the llvm-ir ca compiler with no defined function support

This branch support compile source code into llvm ir aims: include ll file, native object file (.o), native assembly file (.s) and jit running with gcc debug support and optimization.

This branch support functions.

The llvm-ir or rename it into ca contains the llvm code generation, can compiled into many objectives: llvm IR, native as assembly language (.s), native object file (.o elf64) and can run with jit with or without optimization.

Usage

./llvm-ir
Usage: ca [-ll] | [-S] | [-native] | [-c] | [-jit] [-O] | [-g] <input> [<output>]
Options:
         -ll:      compile into IR assembly file: .ll (llvm)
         -S:       compile into native (as) assembly file: .s
         -native:  compile into native execute file: ELF file on linux, PE file on windows (default value)
         -c:       compile into native object file: .o
         -jit:     interpret using jit (llvm)
         -O:       do optimization
         -g:       do not do any optimization (default value)

Compile

debug & optimization

-g

Add debug information into the object file, and can use gdb to debug the code

-O

Add optimization pass for the llvm (optimization) pass

-g -O

Add debug information into the object file and add llvm optimization pass

An code example

x = 0;
print x;
y = 0;
while (x < 10) {
	print x;
	x = x * 2 + 4 / y;
	y = y + 1;
	z = z + 1;
	i = i + 1;
	j = i + 1;
}

print y;

Features

link multiple object

ca -c -g test/extern_call2.ca extern_call2.o
ca -c -g -nomain test/extern_call2_assist.ca extern_call2_assist.o
clang test/extern_call2.ca test/extern_call2_assist.ca -o call2
# or
ld -dynamic-linker /lib64/ld-linux-x86-64.so.2 cruntime/*.o -o call2 extern_call2.o extern_call2_assist.o -lc

TODO list

Debugging

Grammar

Makefile

Optimization

System

self-defined machine

is scopeline the real skip function start for debugging? try it

NEXT TODO:

License

See LICENSE file in this directory, for license in directory cruntime see cruntime/README.md