A Question about LLVM-backend

Hello, all.

I want to manipulate LLVM-backend to emit other compiler’s IR, in this case, VPO’s IR.
So, what i want to know is… Is there a project to be referred? (For example, “Do LLVM-backend → GIMPLE” project exist?)
Or, how can I manipulate it easily?

Thanks,
Cho Yeong-pil

Hi 조영필,

> I want to manipulate LLVM-backend to emit other compiler's IR, in this case,

VPO's IR.
So, what i want to know is.. Is there a project to be referred? (For example,
"Do LLVM-backend -> GIMPLE" project exist?)

as far as I know there is no LLVM IR -> gimple pass. LLVM used to have a C
backend that turned LLVM IR into C. I think it was removed in 3.1 already,
because it was buggy and unmaintained, but you can find it in older versions
of LLVM and it may give you some ideas.

Or, how can I manipulate it easily?

You can write a module pass that iterates over all objects in the module
(global variables, functions etc) and squirts out IR for your other compiler.
That's basically what the C backend did.

Ciao, Duncan.

Hi 조영필,

  > I want to manipulate LLVM-backend to emit other compiler's IR, in this case,

VPO's IR.
So, what i want to know is.. Is there a project to be referred? (For example,
"Do LLVM-backend -> GIMPLE" project exist?)

as far as I know there is no LLVM IR -> gimple pass. LLVM used to have a C
backend that turned LLVM IR into C. I think it was removed in 3.1 already,
because it was buggy and unmaintained, but you can find it in older versions
of LLVM and it may give you some ideas.

For those that are interested, I can provide a patch to the current trunk which provides a working version of the C backend. So far this patch just takes the parts that were removed and updates them to the current infrastructure.

Hi Roel,

For those wondering about the C backend, a patch(set) to current trunk is available but too large to send through the LLVM mailinglist. I can send the patch(es) directly if people are interested.

Cheers,
  Roel

That *is* interesting. I suppose you could use any of the number of
free file/snippet/paste upload services online and just post a link?
This way many interested people will be able to download it without
bugging you.

Eli

I think that this should fix the attachement problem for now:

http://www.es.ele.tue.nl/~rjordans/llvm-cbe-patches/

When anyone notices that these patches are outdated, please give me a ping.

Roel