• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: clang assembler macro expansion failing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: clang assembler macro expansion failing


  • Subject: Re: clang assembler macro expansion failing
  • From: Jim Grosbach <email@hidden>
  • Date: Tue, 11 Dec 2012 11:04:32 -0800

Hi Arun,

This is a bug in clang's integrated assembler. Specifically, the presence of the argument names is ignored by the old system assembler, but indicates to clang's integrated assembler that named arguments rather than positional arguments are being used, so the "$n" values aren't expanded as they should be. Please file a bug report at bugreport.apple.com. In the meantime you can work around the problem by either removing the argument names from the .macro directive (i.e., ".macro test_macro" rather than ".macro test_macro zero, one, two") or pass the -no-integrated-as command line option to clang.

The problem reproduces without the C preprocessor, as well:

enkidu: ~/tmp $ cat x.s
.globl _return_value

.macro test_macro zero, one, two
        .if ($1==0)
                mov $1, êx
        .else
                mov $2, êx
        .endif
        ret
.endm

_return_value:
        test_macro 0, 1, 2

enkidu: ~/tmp $ clang -c x.s
enkidu: ~/tmp $ otool -vt x.o
x.o:
(__TEXT,__text) section
_return_value:
0000000000000000	movl	$1, êx
0000000000000005	movl	$2, êx
000000000000000a	ret

Regards,
  Jim

> Hi All
>
> I have a small assembly code "test.S" as below.
>
> .globl _return_value
>
> #define IF_LAST .if ($1==0)
> #define ELSE    .else
> #define ENDIF   .endif
>
> .macro test_macro zero, one, two
>         IF_LAST
>                 mov $1, êx
>         ELSE
>                 mov $2, êx
>         ENDIF
>         ret
> .endm
>
>
> _return_value:
>         test_macro 0, 1, 2
>
> When i use LLVM compiler "clang" and produce a object file using the command "clang -c test.S", and disassemble the object file using "otool", i see the below output.
>
> otool -tV test.o
> test.o:
> (__TEXT,__text) section
> _return_value:
> 0000000000000000    movl    $0x00000001,êx
> 0000000000000005    movl    $0x00000002,êx
> 000000000000000a    ret
>
>
>
> When i use GCC compiler "gcc" and produce a object file using the command "gcc -c test.S", and disassemble the object file using "otool", i see the below output.
>
> otool -tV test.o
> test.o:
> (__TEXT,__text) section
> _return_value:
> 0000000000000000    movl    0x00000002,êx
> 0000000000000007    ret
>
>
> Looks like the object code generated by the GCC is correct and as expected. But in case of clang, the assembler macro expansion is not proper.
>
> Can anyone help me with clangs macro expansion here?
>
> Thanks in advance
> Arun KA


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >clang assembler macro expansion failing (From: Arun <email@hidden>)

  • Prev by Date: Re: Still no diff for model version in Xcode 4?
  • Next by Date: Link Fails
  • Previous by thread: clang assembler macro expansion failing
  • Next by thread: Link Fails
  • Index(es):
    • Date
    • Thread