I have created a compiler that produces an intermediate code. I do not have the time to write the backend for my project.
Is there any software I could use to evaluate the intermediate code produced? Where could I download this software?
The output looks something like this :
t1 = 0.67596e-7
sum = t1
t1 = 2
t2 = 3
t3 = t2 + t1
i = t3
L0:
t1 = sum
t2 = 20
t3 = compare(t1 <= t2)
t4 = sum
t5 = 12
t6 = compare(t4 ~= t5)
t7 = t3 | t6
t8 = sum
t9 = 20
t10 = compare(t8 > t9)
t11 = t7 & t10
if t11 true then goto L1 else goto L2
L1:
t1 = 2
t2 = sum
t3 = t2 + t1
sum = t3
t1 = 1
t2 = i
t3 = t2 + t1
i = t3
goto L0
L2:
Thanks for reading.
Code generation is my business :-)
Comments on a few options:
CLR:
LLVM:
C--
C as target language
Summary: anything except C is a reasonable choice. For the best combination of flexibility, quality, and expected longevity, I'd probably recommend LLVM. But your example code is very close to C--, so that may be an advantage.
Full disclosure: I am affiliated with the C-- project.
Have a look at the llvm compiler infrastructure project. It is used in a lot of real world projects. The LLVM is a low level virtual machine, easy to create code for and easy to translate to native code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With