[llvm-dev] constant folding-like optimization at compile time

Pranav Kuber via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 17 14:33:53 PDT 2016


Hi everyone!

I am new to llvm and excuse me if this is a wrong question for this forum.

I am trying to design a front end for my own programming language using the
LLVM infrastructure for a personal project. It's a very simple procedural
language for now; no object oriented business.

I am playing around with a simple concept and was wondering if it's
possible to implement it in the LLVM environment.

Consider I have a simple declaration statement.

float array a[sqrt(9)];

Is it possible to evaluate "sqrt(9)" before generating LLVM IR by calling
some math library function? This is still compile time and way before the
JIT kicks in, so I won't be able to take advantage of the JIT. In other
words, the LLVM IRBuilder would probably see something like -- "float array
a[3];", and won't even know that "sqrt(9)" existed. Only my parser would be
aware of its existence.

Let me know if this is possible.

Thanks,
Pranav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160317/c7f596ba/attachment.html>


More information about the llvm-dev mailing list