On Tue, 11 Nov 2008, Peter Shugalev wrote:> Hi, > > Anton Korobeynikov wrote: >>> I thought llvm-gcc isn't meant to compile for specific target (at least >>> with -emit-llvm flag I'm using). >> No, it is not. C language is highly target-specific, thus LLVM IR >> obtained from such sources also has the same nice 'property' > > I can see only one reason for such dependence: inclusion of system > headers in /usr/include. If I compile llvm-gcc with predefined set of > Linux headers (the way cross-compilers are usually made) will the IR > output be the same no matter which platform is used for compilation?I had trouble with this too -- I still haven't entirely figured it out. Try browsing through http://www.gaisler.com/doc/sparc-abi.pdf which is the SPARC ABI. It explains things like structure padding and stack layout/function calling. llvm-gcc has to make lots of decisions dependent on this ABI when converting C/C++ to IR. I imagine that every platform has its own rules. The SPARC rules actually seem relatively straightforward. -Luke
On Nov 11, 2008, at 10:48 AM, Luke K. Dalessandro wrote:> On Tue, 11 Nov 2008, Peter Shugalev wrote: > >> Hi, >> >> Anton Korobeynikov wrote: >>>> I thought llvm-gcc isn't meant to compile for specific target (at >>>> least >>>> with -emit-llvm flag I'm using). >>> No, it is not. C language is highly target-specific, thus LLVM IR >>> obtained from such sources also has the same nice 'property' >> >> I can see only one reason for such dependence: inclusion of system >> headers in /usr/include. If I compile llvm-gcc with predefined set of >> Linux headers (the way cross-compilers are usually made) will the IR >> output be the same no matter which platform is used for compilation? > > I had trouble with this too -- I still haven't entirely figured it > out. > Try browsing through http://www.gaisler.com/doc/sparc-abi.pdf which is > the SPARC ABI. It explains things like structure padding and stack > layout/function calling. llvm-gcc has to make lots of decisions > dependent > on this ABI when converting C/C++ to IR. I imagine that every > platform has > its own rules. > > The SPARC rules actually seem relatively straightforward.I'd expect llvm-gcc to get the structure layout rules "for free". You could write some testcases to verify this. The case that requires a bit of work are the various parameter passing cases if there is weirdness. When I was working on the sparc backend, just about everything was passing in llvm-test, so I think it is pretty close to good. -Chris
Chris Lattner dixit:>When I was working on the sparc backend, just about everything was >passing in llvm-test, so I think it is pretty close to good.So, if I patch llvm-gcc with MirBSD/sparc rules in gcc/config.gcc and gcc/config/sparc/ like I did with i386, chances are it would work (in a limited fashion)? Or is sparc support in llvm specific to Solaris? bye, //mirabilos -- Sometimes they [people] care too much: pretty printers [and syntax highligh- ting, d.A.] mechanically produce pretty output that accentuates irrelevant detail in the program, which is as sensible as putting all the prepositions in English text in bold font. -- Rob Pike in "Notes on Programming in C"