Frage

I am working on a project where I have to a write code for converting LLVM-IR into a C-like language. This language has constructs very similar to C. After doing a little survey, I found that upto version 3.0 of LLVM there existed a file named CBackend.cpp responsible for conversion of LLVM-IR into C code. What I want to check is run this CBackend.cpp file on my input file of LLVM-IR and generate C code.

The command for this is: llc -march=c -o code.c code.ll

where the code.ll file is the input file containing the input llvm-ir and code.c is the output file containing the resultant C code.

What I am facing is, I have LLVM version 3.4svn installed on my ubuntu system and there is no CBackend.cpp file in this version as the file has been upgraded to CppBackend.cpp (which converts LLVM-IR to C++). Which command can I use to run this CBackend.cpp file on my LLVM-IR input file to get the corresponding C code in version 3.4svn of LLVM ?

Thanks in advance.

War es hilfreich?

Lösung

The C backend was dropped in release 3.1 because it was not maintained and started developing code rot, becoming a burden. Since no maintainer stepped up, it was removed from the tree. From the release notes of 3.1:

The C backend has been removed. It had numerous problems, to the point of not being able to compile any nontrivial program.

In August 2012 a thread on llvmdev discussed reviving the C backend, but I don't think it ended up anywhere useful.

You can still download LLVM version 3.0 (from the releases page), build it and see the C backend in action, study its code, etc. For your specific purpose - looking at the code and figuring out how it works, the 3.0 C backend should be good enough.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top