Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Adept II

C-like replacement for CAL IL

Compiler under development (open source)

CAL IL is a low level IL by design. However if you dont want to make use of Brook+, then you need to write CAL IL to target ATI hardware.
I am writing a small compiler which takes a C-syntax tiny (and very low level) language which compiles to CAL IL.
Designed only as a replacement for IL, its a small C-like language without support for pointers, functions, structures or user defined arrays.
Basically think of it as IL but with type checked C-syntax with natural operators like +,*.
You still get access to arrays like g,i0,o0 etc but you can define local scalar variables. You cannot define any new arrays.
You will still need to write CAL API function calls .. the only difference is that instead of writing CAL IL you will write this C-syntax language and then compile it to CAL IL then use CAL compiler calls.

{int i; float4 sum; float4 g[]; sum.x = 0.0; sum.y = 0.0; sum.z = 0.0; sum.w = 0.0; for(i=0;i<100;i++){ sum = sum + g;} }
This will generate the expected IL code and will automatically allocate registers. If not enough registers are available, then error is generated and you need to modify you source code.

Here is preview of the compiler library. Its not intended for production use. Its a preview with lots of things broken or unimplemented. 
Its under Apache v2 license. I will issue regular updates and the development right now is very fast. In 1-2 weeks this will be very usable.
To compile, you will need to install antlr3 and libantlr3c (i.e. the C antlr3 runtime). I am developing on ubuntu 64-bit.
Note that I am not associated with AMD and this is an independant project.

Hosted at :

Checkout using svn.

2 Replies
Adept II

Much better version is now in SVN at

It is generating code for IL compute shader  though I am in the process of fixing it to give the option to generate either and to introduce more feature completeness. I am also fixing many more bugs.

Get revision 8 or later from SVN.



To build you will require :

1. Installation of antlr3

2. Installation of antlr3 C runtime.

Both can be downloaded from

Makefile is provided.