4

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.

  • This thread indicates it may have been broken - http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-April/049124.html . If you still want it, why not download an older version from here - http://llvm.org/releases/download.html ? – Leeor Oct 16 '13 at 19:08
  • 1
    @Leeor: Actually I din't upgrade my llvm. I have version 3.4svn installed from the beginning and it does not have the CBackend file. They seem to remove it from the versions which came after 3.0 . So, I want the command to run this file on my version. – Surbhi Chauhan Oct 16 '13 at 19:25
  • 1
    @Leeor: I have that CBackend.cpp file with me. I just want the command to run this file on my version. As installing a lower version is just not the right solution for me now. – Surbhi Chauhan Oct 16 '13 at 19:41

1 Answers1

7

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.

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412