As explained in the previous post, I have the last released version of LLVM installed in my machine.
At the beggining a big confussion with the headers under the "llvm-c" dir. Those headers are the C API, the ones I'm using here are the C++ API.
Imagine IR as a language that finds a perfect balance between high-level and low-level languages. It's a language as general as possible, able to adapt quite well to all programming languages. If a code optimizer is written for that language, the result is that we can reuse a backend
The truth is that it is not 100% machine independent, there are times when the code generated by the optimizer has instructions that depend on the backend. This is because there are certain instructions from the machine that can help you optimize certain code. Machines that do not have such instructions are not able to optimize that code as well.
This is how the CMakeLists.txt
looks like.
This is the code of the main.cpp
file:
And this one is the expected output.

You cannot compile this code, you need a main
function.
Full code in GitHub
Check out the repository with the code from this post.
All the code of this post is tagged with post02
.