From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mx.groups.io with SMTP id smtpd.web09.7063.1641465515346522744 for ; Thu, 06 Jan 2022 02:38:35 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=VrNZJn2F; spf=pass (domain: gmail.com, ip: 209.85.214.181, mailfrom: retrage01@gmail.com) Received: by mail-pl1-f181.google.com with SMTP id z3so2207881plg.8 for ; Thu, 06 Jan 2022 02:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=cpv1VDCPGfSyDtQqtNmrWNgXCbS9kinwJinFHcrlDcA=; b=VrNZJn2Fc6ikxzagr7vkFs4jz76mIYGS7Oo/H0ngCMqc2Q4+gsi1b8nfj/ZuQ5/VgD xXsL+oZV5SlnZI6Z8I7IeZI8pjpVB3Ab0iXFnuX5RQhM/Mm9ufLr30nLfCBFn8zNW1Do JGTeObd5YeD2uYKpoHC1wGQT23Wt1N69QyoRmIqWLPncCJmxBS5XBB19KlHSAZq7Atz6 Vo2JJMKWaCfKdrmZtL8AMjjRBZmL2NSLLqWpLwj0FFI+mS4FT8u9hXG2Jq0++tkI+zt2 962vdXeL5JTahCFME98VkBCdR32asXRd8P68t4aLRbFLm2e6Tzvm1mSwBvzwWd3ZNIn4 jaeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=cpv1VDCPGfSyDtQqtNmrWNgXCbS9kinwJinFHcrlDcA=; b=yEk+HuYB3aZ4F73tUfTamQERJraTx3s4ASXuz6qjeLj/bfxAfNEhf2uYAxoBW/f5O9 lsCNuyOJqa2V8untIvvcbbVXlnkuVNRklB66ccOxMbgXd/ayevMqtn2hrhunHBs1OVFQ Q8lKUQ3TzcIU+WXPruj++hZRvyh0HJtZ1GMl6Upn/IV5AoQCDCSzEamPOLrkNQUZ1+9q +CN/nrUL+hox19/+8QHsfY6E2ySAJ3Hdlr7Kk8PGyTI58X4tILkkWCFatDBmjCcJUq7l 0zP9Pk8bXRbUskAQze32oGJ/VkXU6pxpqRIvDBPEUTeu000uAZ4/v5Jdy99mC4nRmg6m 1U4w== X-Gm-Message-State: AOAM530qT/hUoJQTUXeUkeA8cT9LKlkmpd2n39x457F50wtRP0TyMbMx y+GjtFzK2pLsE2h8ZDx8OL3LsbKABjJX X-Google-Smtp-Source: ABdhPJxZ+PeL8YJyaaNgCcl5dgFEh79R0Y85LSUrbeSJ1qfFt3uvvzJ+ThS3opzSXcia62RChgXdow== X-Received: by 2002:a17:902:be17:b0:149:8663:483a with SMTP id r23-20020a170902be1700b001498663483amr44794161pls.60.1641465514868; Thu, 06 Jan 2022 02:38:34 -0800 (PST) Return-Path: Received: from smtpclient.apple ([240d:1a:ada:4400:80f6:9130:d86:2f2f]) by smtp.gmail.com with ESMTPSA id t21sm1657205pgn.28.2022.01.06.02.38.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jan 2022 02:38:34 -0800 (PST) Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: [edk2-devel] AArch64 assembly compatibility for Xcode and GCC From: "Akira Moroo" In-Reply-To: Date: Thu, 6 Jan 2022 19:38:31 +0900 Cc: Leif Lindholm Message-Id: <554BF0E3-656B-4FA7-A6E3-509344023851@gmail.com> References: <962A1DA2-CB34-49F5-A721-AE7E5C82FA04@apple.com> To: devel@edk2.groups.io, pedro.falcato@gmail.com, Andrew Fish X-Mailer: Apple Mail (2.3654.120.0.1.13) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, I tried to add support AArch64 XCODE5 about three months ago, too. I had th= e same compatibility issue in the other code. I just ended up adding ugly #= ifdef as a workaround [1]. I think there are other compatibility issues in = the current EDK2 code base. I=E2=80=99m not sure if the GAS macro and Apple= Clang Assembler are compatible, but the C standard guarantees C preprocess= or macro compatibility. [1] https://github.com/retrage/edk2/commit/89b166758b9f858373bb20eb8e006914= f7f13373 Best regards, Akira Moroo > On Jan 6, 2022, at 8:31, Pedro Falcato wrote: >=20 > Hi, >=20 > GNU Assembler and the clang assembler support more complex macros nativel= y (using the .macro and.endm directives), without the need for the C prepro= cessor. > This completely sidesteps the need for explicit ";" as the GAS macros res= pect newlines inside the macro. >=20 > See https://godbolt.org/z/6zzqoeKE4 for a very simple example. > Of course, you can also pass arguments, see https://sourceware.org/binuti= ls/docs/as/Macro.html for the full documentation. >=20 > Best regards, > Pedro >=20 > On Wed, Jan 5, 2022 at 8:36 PM Andrew Fish via groups.io wrote: > 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] >=20 > I was wondering if any one else has hit this in another project and if th= ere was any cool workaround? >=20 > The only thing I can think of is the =E2=80=9Cbig hammer=E2=80=9D on both= (well you only need one) ends. We could replace ; with a #define that matc= hes the assembler. It looks like this issue mostly hits in Code that is usi= ng C pre-processor macros so we could refactor the code. I=E2=80=99m a litt= le concerned that the C pre processor is getting used since the macro langu= ages of the assembler might also have some compatibility issues? >=20 > 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.=20 >=20 >=20 > [1] https://github.com/tianocore/edk2/blob/master/MdePkg/Library/BaseLib/= AArch64/SetJumpLongJump.S#L13 >=20 > #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*/ >=20 > I had to change it to: >=20 > #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*/ >=20 > Thanks, >=20 > Andrew Fish >=20 >=20 >=20 >=20 >=20 > --=20 > Pedro Falcato >=20