[LLVMdev] GCC assembler rejects native code generated by LLVM
Vyacheslav Akhmechet
coffeemug at gmail.com
Mon Mar 7 19:16:29 PST 2005
Ok, I just tried the patch with some modifications (added msvc target
and used WIN32 instead of __MINGW32__ for preprocessor) and everything
worked beautifully. Thanks for the help!
On Mon, 7 Mar 2005 20:45:40 -0500, Vyacheslav Akhmechet
<coffeemug at gmail.com> wrote:
> Reid,
>
> This patch won't work for me. I compile llvm toolset with MSVC Express
> (hence __MINGW32__ won't be defined for me at compile time). I only
> try to feed the generated assembly into gcc (pretty much gnu
> assembler, I suppose). I don't use mingw tools at the earlier stage.
> However it's obvious for me how to modify the code now (just add MSVC
> at that line), thanks! I'll try it as soon as I can.
>
> Thanks,
> - Vyacheslav.
>
>
> On Mon, 07 Mar 2005 17:32:00 -0800, Reid Spencer <reid at x10sys.com> wrote:
> > Vyacheslav,
> >
> > I've tracked down the change and I have a fix for you to test. The
> > attached patch should be applied to the CVS head (version 1.132) of
> > X86AsmPrinter.cpp in llvm/lib/Target/X86. The patch just includes MINGW
> > targets in the same set of choices that it makes for Cygwin. Could you
> > please try the patch and let me know if it solves your problem? If it
> > does, I'll commit the patch.
> >
> > Thanks,
> >
> > Reid.
> >
> >
> > On Mon, 2005-03-07 at 16:39, Vyacheslav Akhmechet wrote:
> > > Ok, I got home so I have more details. Here's the sample C program:
> > > ----------------- C program ---------------
> > > #include <stdio.h>
> > > int main() {
> > > printf("hello world\n");
> > > return 0;
> > > }
> > > ------------- end C program -------------
> > >
> > > This is compiled using llvm online demo into the following llvm code
> > > (target removed):
> > > ----------------- LLVM code --------------
> > > deplibs = [ "stdc++", "c", "crtend" ]
> > > %.str_1 = internal constant [13 x sbyte] c"hello world\0A\00"; <[13 x
> > > sbyte]*> [#uses=1]
> > >
> > > implementation ; Functions:
> > >
> > > declare int %printf(sbyte*, ...)
> > >
> > > int %main() {
> > > entry:
> > > call void %__main( )
> > > %tmp.0 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([13 x
> > > sbyte]* %.str_1, int 0, int 0) ); <int> [#uses=0]
> > > ret int 0
> > > }
> > >
> > > declare void %__main()
> > > ------------- End LLVM code -----------
> > >
> > > which in turn produces the following assembly code:
> > >
> > > ------------- Assembly code -------------
> > > .text
> > > .align 16
> > > .globl main
> > > .type main, @function
> > > main:
> > > subl $12, %esp
> > > fnstcw 10(%esp)
> > > movb $2, 11(%esp)
> > > fldcw 10(%esp)
> > > call __main
> > > movl $l1__2E_str_1, %eax
> > > movl %eax, (%esp)
> > > call printf
> > > movl $0, %eax
> > > #IMPLICIT_USE
> > > addl $12, %esp
> > > ret
> > >
> > >
> > > .data
> > > .align 1
> > > .type l1__2E_str_1, at object
> > > .size l1__2E_str_1,13
> > > l1__2E_str_1: # [13 x sbyte]* %.str_1 = c"hello world\0A\00"
> > > .ascii "hello world\n\000"
> > > ---------- End assembly code ----------
> > >
> > > When I try to assemble the above code using
> > > gcc hello.c.s -o hello.exe
> > > I get the following errors:
> > >
> > > hello.c.s: Assembler messages:
> > > hello.c.s:6: Warning: .type pseudo-op used outside of .def/.endef ignored.
> > > hello.c.s:6: Error: junk at end of line, first unrecognized character is `m'
> > > hello.c.s:24: Warning: .type pseudo-op used outside of .def/.endef ignored.
> > > hello.c.s:24: Error: junk at end of line, first unrecognized character is `l'
> > > hello.c.s:25: Warning: .size pseudo-op used outside of .def/.endef ignored.
> > > hello.c.s:25: Error: junk at end of line, first unrecognized character is `l'
> > >
> > > Sorry for the long email. I attach all relevant files for clarity.
> > >
> > > ______________________________________________________________________
> > > _______________________________________________
> > > LLVM Developers mailing list
> > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> > > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
> >
> >
> >
>
More information about the llvm-dev
mailing list