[cfe-dev] How to add new target?

Artur Pietrek pietreka at gmail.com
Tue Mar 30 05:25:47 PDT 2010


On Thu, Mar 25, 2010 at 4:21 PM, Daniel Dunbar <daniel at zuster.org> wrote:

> On Thu, Mar 25, 2010 at 5:33 AM, Artur Pietrek <pietreka at gmail.com> wrote:
> >> Hi Artur,
> >
> > Hi Daniel
> >
> >>
> >> > Hi all,
> >> > so after "greping" the code I was able to do (more or less) everything
> I
> >> > wanted to do.
> >>
> >> As you have discovered, this stuff isn't very well documented yet. Do
> >> you feel like writing up a blurb we could add to our Internals Manual
> >> describing what you have discovered?
> >
> > I'll try when I'll make it work correct ;)
> >
> > BTW I've noticed strange behaviour. When I switched from llvm-gcc to
> clang,
> > my benchmarks stopped working. When I compile simple code:
> >
> > char array[] =
> > "+0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
> >
> > int main() {
> >   return array[31];
> > }
> >
> > like this:
> > clang -ccc-host-triple mycpu -O0 -S hello.c -o hello.s
> >
> > The code is wrong, to be precise in one instruction I get
> > lbs $r16 = 0[$r17] instead of lbs $r16 = 31[$r17]
> >
> > but the code is correct when I do it like this:
> > clang -ccc-host-triple mycpu -O0 hello.c -c -emit-llvm -o hello.bc
> > llc -march=mycpu hello.bc -o hello.s
> >
> >
> > Am I missing something? Shouldn't these two be equivalent?
>
> Unfortunately, no. The driver sets a variety of options in the LLVM
> backend that you would need to pass to llc by hand. Try running
> $ clang -ccc-host-triple mycpu -O0 hello.c -c -emit-llvm -o hello.bc -###
> to see how clang is calling the compiler (clang -cc1), and look for -m
> arguments. For example, -mcpu sets the CPU to target, and other -m
> options do things like disable use of a frame pointer.
>
>  - Daniel
>

Thanks for advice, there was a bug in relocation in my backend and indeed
clang was triggering it by passing different options than llc.

Now I'm trying to find another bug. I don't know why I'm ending up with reg
to reg copy from 64bit to 32bit register class but only using clang and
turned on optimization (when i compile with llvm-gcc or again with clang to
bitcode and then using llc the problem does not occur).
I've tried to change options given to compiler, but this changes nothing.
The code I try to compile has castings from i8* to i64*.
Any ideas what could trigger that?
Is there a way to force clang to dump debug information similar to "llc
-debug"?

Once more, thanks for your help!
Artur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100330/57db7dc4/attachment.html>


More information about the cfe-dev mailing list