public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Andrew Fish" <afish@apple.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: Leif Lindholm <leif@nuviainc.com>
Subject: AArch64 assembly compatibility for Xcode and GCC
Date: Wed, 05 Jan 2022 12:36:27 -0800	[thread overview]
Message-ID: <962A1DA2-CB34-49F5-A721-AE7E5C82FA04@apple.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1793 bytes --]

I was playing around with getting Xcode to compile AArch64 code and I hit an interesting compatibility issue. The assembler line continuation token for GCC (;) is a comment for the Xcode clang assembler. For Xcode clang you need to use %%. Yikes [1]

I was wondering if any one else has hit this in another project and if there was any cool workaround?

The only thing I can think of is the “big hammer” on both (well you only need one) ends. We could replace ; with a #define that matches the assembler. It looks like this issue mostly hits in Code that is using C pre-processor macros so we could refactor the code. I’m a little concerned that the C pre processor is getting used since the macro languages of the assembler might also have some compatibility issues?

Looking for ideas and opinions on the best way to fix this if we want to add Xcode as an ARM compiler in the future. 


[1] https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S#L13

#define GPR_LAYOUT                         \
        REG_PAIR (x19, x20,  0);           \
        REG_PAIR (x21, x22, 16);           \
        REG_PAIR (x23, x24, 32);           \
        REG_PAIR (x25, x26, 48);           \
        REG_PAIR (x27, x28, 64);           \
        REG_PAIR (x29, x30, 80);/*FP, LR*/ \
        REG_ONE  (x16,      96) /*IP0*/

I had to change it to:

#define GPR_LAYOUT                         \
        REG_PAIR (x19, x20,  0)%%          \
        REG_PAIR (x21, x22, 16)%%          \
        REG_PAIR (x23, x24, 32)%%          \
        REG_PAIR (x25, x26, 48)%%          \
        REG_PAIR (x27, x28, 64)%%          \
        REG_PAIR (x29, x30, 80)%%/*FP, LR*/ \
        REG_ONE  (x16,      96) /*IP0*/

Thanks,

Andrew Fish


[-- Attachment #2: Type: text/html, Size: 23748 bytes --]

             reply	other threads:[~2022-01-05 20:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05 20:36 Andrew Fish [this message]
2022-01-05 23:31 ` [edk2-devel] AArch64 assembly compatibility for Xcode and GCC Pedro Falcato
2022-01-06 10:38   ` Akira Moroo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=962A1DA2-CB34-49F5-A721-AE7E5C82FA04@apple.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox