obtaining IR for CellBE code

    I was trying to extract out the IR for some CELLBE code. However i
was not able to compile with llvm-gcc.
Has someone who has tried this shed some light on the changes required
to use llvm-gcc instead of gcc or xlc.
A simple replacement of gcc with llvm-gcc -emit-llvm -S or marking $CC
as llvm-gcc in the makefile did not work for me. I am using the
standard makefile format supplied with the example codes of CellSDK.
  Is there any alternate way / intrinsic which can be called to
introduce calls to the Cell C intrinsic functions??

Can you give a couple examples of error messages you're getting?


llvm-gcc -emit-llvm -S -W -Wall -Winline -Wno-main -I. -I
/opt/cell/sysroot/usr/spu/include -I
/opt/cell/sysroot/opt/cell/sdk/usr/spu/include -O3 -c simpleDMA_spu.c
simpleDMA_spu.c:42:23: error: spu_mfcio.h: No such file or directory
simpleDMA_spu.c: In function ‘main’:
simpleDMA_spu.c:60: warning: implicit declaration of function ‘mfc_tag_reserve’
simpleDMA_spu.c:60: error: ‘MFC_TAG_INVALID’ undeclared (first use in
this function)
simpleDMA_spu.c:60: error: (Each undeclared identifier is reported only once
simpleDMA_spu.c:60: error: for each function it appears in.)
simpleDMA_spu.c:74: warning: implicit declaration of function ‘mfc_get’
simpleDMA_spu.c:79: warning: implicit declaration of function
simpleDMA_spu.c:83: warning: implicit declaration of function

what is happening is llvm-gcc is not able to view the header files
even when the includes have been given


Sorry for the extremely low-level question, but did you compile
llvm-gcc as a cross-compiler targeting Cell? Assuming you did, I'm
not sure what the issue is; llvm-gcc should be providing that header.


Hi Kshitiz,

unfortunately it is not possible to build an spu-llvm-gcc yet, there
is a small number of issues (mainly support for integer divides and
some 128-bit related stuff) which prevent the LLVM SPU backend from
compiling libgcc successfully (the low level runtime library which is
built as part of llvm-gcc) and thus prevent a successful llvm-gcc
build. Please note that the Cell SPU backend is considered

Patches welcome though! :slight_smile:



Oh ok.. I think that is the problem. I was using the llvm-gcc x86 pre
compiled binary.
. I will compile llvm-gcc fromt end from the source code and try that.
Thanks a lot.. :slight_smile:


The llvm-gcc frontend will _not_ produce the IR. Specifically, the LLVM Cell BE (not "CELLBE") backend needs to capture and expand i32 multiplies. I'm sure there're other bugs that need to be fixed.

What you want to do, if you really, absolutely want to produce IR is use llvm-gcc for PowerPC or x86 to produce the bitcode file. Then, use llc to generate the assembly language output for the Cell. But... don't use stdio in your code (printf will not work!). There are other gotcha's, like using v2i32 vectors (i.e., non-standard vector sizes that aren't 128-bits long) and alignment, but so far, it's a strategy that's worked to test code locally when I've had a cycle or two to do development.

  (The Department Director Lives!)


The llvm-gcc frontend will _not_ produce the IR. Specifically, the LLVM Cell Be (not "CELLBE", or Peter Hofstee might get a tad upset) is alpha quality code. It needs 32 bit multiplication, among other things.

You're actually asking for Cell BE-specific IR. However, you can get fairly far using llvm-gcc for x86 so long as your code doesn't have stdio calls. If you are looking for Cell SDK intrinsics, you're out of luck.

Yes, I plan to get back to development at some point this summer, but in the meantime, I have a new job that I need to get under control.