gpt4 book ai didi

ios - GAS 宏内的标签

转载 作者:行者123 更新时间:2023-11-28 23:27:28 31 4
gpt4 key购买 nike

我需要构建iOSOpenBLAS库。我选择构建它的 0.3.6 版本。我相信这是该库最新的稳定版本。

您可以在此处找到该库的版本 - https://github.com/xianyi/OpenBLAS/releases

我遇到下一个问题 - 似乎可以在 XCode 中找到的 clang 提供的汇编编译器似乎无法理解 .S 中的某些语法 文件库提供。

我有两个文件(nrm2.Sznrm2.S),它们导致了我所有的麻烦。这是nrm2.S。我不会提供其他文件,因为那里的错误完全相同。但如果你也想看一下,我会发布它,请告诉我:

/*******************************************************************************
Copyright (c) 2015, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#define ASSEMBLER
#include "common.h"

#define N x0
#define X x1
#define INC_X x2

#define I x3

#if !defined(DOUBLE)
#define SSQ s0
#define SCALE s1
#define REGZERO s5
#define REGONE s6
#else
#define SSQ d0
#define SCALE d1
#define REGZERO d5
#define REGONE d6
#endif

/*******************************************************************************
* Macro definitions
*******************************************************************************/

.macro KERNEL_F1
#if !defined(DOUBLE)
ldr s4, [X], #4
fcmp s4, REGZERO
beq KERNEL_F1_NEXT_\@
fabs s4, s4
fcmp SCALE, s4
bge KERNEL_F1_SCALE_GE_X_\@
fdiv s2, SCALE, s4
fmul s2, s2, s2
fmul s3, SSQ, s2
fadd SSQ, REGONE, s3
fmov SCALE, s4
b KERNEL_F1_NEXT_\@
KERNEL_F1_SCALE_GE_X_\@:
fdiv s2, s4, SCALE
fmla SSQ, s2, v2.s[0]
#else
ldr d4, [X], #8
fcmp d4, REGZERO
beq KERNEL_F1_NEXT_\@
fabs d4, d4
fcmp SCALE, d4
bge KERNEL_F1_SCALE_GE_X_\@
fdiv d2, SCALE, d4
fmul d2, d2, d2
fmul d3, SSQ, d2
fadd SSQ, REGONE, d3
fmov SCALE, d4
b KERNEL_F1_NEXT_\@
KERNEL_F1_SCALE_GE_X_\@:
fdiv d2, d4, SCALE
fmla SSQ, d2, v2.d[0]
#endif
KERNEL_F1_NEXT_\@:
.endm

.macro KERNEL_S1
#if !defined(DOUBLE)
ldr s4, [X]
fcmp s4, REGZERO
beq KERNEL_S1_NEXT
fabs s4, s4
fcmp SCALE, s4
bge KERNEL_S1_SCALE_GE_X
fdiv s2, SCALE, s4
fmul s2, s2, s2
fmul s3, SSQ, s2
fadd SSQ, REGONE, s3
fmov SCALE, s4
b KERNEL_S1_NEXT
KERNEL_S1_SCALE_GE_X:
fdiv s2, s4, SCALE
fmla SSQ, s2, v2.s[0]
#else
ldr d4, [X]
fcmp d4, REGZERO
beq KERNEL_S1_NEXT
fabs d4, d4
fcmp SCALE, d4
bge KERNEL_S1_SCALE_GE_X
fdiv d2, SCALE, d4
fmul d2, d2, d2
fmul d3, SSQ, d2
fadd SSQ, REGONE, d3
fmov SCALE, d4
b KERNEL_S1_NEXT
KERNEL_S1_SCALE_GE_X:
fdiv d2, d4, SCALE
fmla SSQ, d2, v2.d[0]
#endif
KERNEL_S1_NEXT:
add X, X, INC_X
.endm

.macro KERNEL_F8
KERNEL_F1
KERNEL_F1
KERNEL_F1
KERNEL_F1
KERNEL_F1
KERNEL_F1
KERNEL_F1
KERNEL_F1
.endm

.macro INIT_S
#if !defined(DOUBLE)
lsl INC_X, INC_X, #2 // INC_X * SIZE
#else
lsl INC_X, INC_X, #3 // INC_X * SIZE
#endif
.endm

.macro INIT
eor v1.16b, v1.16b, v1.16b // scale=0.0
fmov SSQ, #1.0
fmov REGONE, SSQ
fmov REGZERO, SCALE
.endm

/*******************************************************************************
* End of macro definitions
*******************************************************************************/

PROLOGUE

.align 5

INIT

cmp N, #0
ble .Lnrm2_kernel_L999

cmp INC_X, #0
beq .Lnrm2_kernel_L999


cmp INC_X, #1
bne .Lnrm2_kernel_S_BEGIN

.Lnrm2_kernel_F_BEGIN:

asr I, N, #3 // I = N / 8
cmp I, xzr
ble .Lnrm2_kernel_F1

.Lnrm2_kernel_F8:

KERNEL_F8

subs I, I, #1
bne .Lnrm2_kernel_F8

.Lnrm2_kernel_F1:

ands I, N, #7
ble .Lnrm2_kernel_L999


.Lnrm2_kernel_F10:

KERNEL_F1

subs I, I, #1
bne .Lnrm2_kernel_F10

b .Lnrm2_kernel_L999

.Lnrm2_kernel_S_BEGIN:

INIT_S

mov I, N

.align 5

.Lnrm2_kernel_S10:

KERNEL_S1

subs I, I, #1
bne .Lnrm2_kernel_S10


.Lnrm2_kernel_L999:
fsqrt SSQ, SSQ
fmul SSQ, SCALE, SSQ

ret

EPILOGUE

当编译器尝试处理该文件时,它会给出下一个错误:

<instantiation>:7:2: note: while in macro instantiation
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk -arch arm64 -miphoneos-version-min=10.0 -O2 -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DNO_LAPACK -DNO_LAPACKE -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=8 -DMAX_PARALLEL_NUMBER=1 -DVERSION=\"0.3.6\" -march=armv8-a -DASMNAME=_sgemm_oncopy -DASMFNAME=_sgemm_oncopy_ -DNAME=sgemm_oncopy_ -DCNAME=sgemm_oncopy -DCHAR_NAME=\"sgemm_oncopy_\" -DCHAR_CNAME=\"sgemm_oncopy\" -DNO_AFFINITY -I.. -UDOUBLE -UCOMPLEX -c -UDOUBLE -UCOMPLEX ../kernel/arm64/../generic/gemm_ncopy_4.c -o sgemm_oncopy.o
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:14:22: error: unknown token in expression
KERNEL_F1_SCALE_GE_X_\@:
^
<instantiation>:7:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:14:22: error: invalid operand
KERNEL_F1_SCALE_GE_X_\@:
^
<instantiation>:7:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
../kernel/arm64/nrm2.S:87:16: error: unknown token in expression
KERNEL_F1_NEXT_\@:
^
<instantiation>:7:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
../kernel/arm64/nrm2.S:87:16: error: invalid operand
KERNEL_F1_NEXT_\@:
^
<instantiation>:7:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:4:21: error: unexpected token in argument list
beq KERNEL_F1_NEXT_\@
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:7:27: error: unexpected token in argument list
bge KERNEL_F1_SCALE_GE_X_\@
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:13:19: error: unexpected token in argument list
b KERNEL_F1_NEXT_\@
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:14:22: error: unknown token in expression
KERNEL_F1_SCALE_GE_X_\@:
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:14:22: error: invalid operand
KERNEL_F1_SCALE_GE_X_\@:
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
../kernel/arm64/nrm2.S:87:16: error: unknown token in expression
KERNEL_F1_NEXT_\@:
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
../kernel/arm64/nrm2.S:87:16: error: invalid operand
KERNEL_F1_NEXT_\@:
^
<instantiation>:8:2: note: while in macro instantiation
KERNEL_F1
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:146:2: note: while in macro instantiation
KERNEL_F8
^
<instantiation>:4:21: error: unexpected token in argument list
beq KERNEL_F1_NEXT_\@
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
<instantiation>:7:27: error: unexpected token in argument list
bge KERNEL_F1_SCALE_GE_X_\@
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
<instantiation>:13:19: error: unexpected token in argument list
b KERNEL_F1_NEXT_\@
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
<instantiation>:14:22: error: unknown token in expression
KERNEL_F1_SCALE_GE_X_\@:
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
<instantiation>:14:22: error: invalid operand
KERNEL_F1_SCALE_GE_X_\@:
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
../kernel/arm64/nrm2.S:87:16: error: unknown token in expression
KERNEL_F1_NEXT_\@:
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1
^
../kernel/arm64/nrm2.S:87:16: error: invalid operand
KERNEL_F1_NEXT_\@:
^
/var/folders/xt/7v6bxk2n19zft1y3yzymdc580000gq/T/nrm2-bd3346.s:159:2: note: while in macro instantiation
KERNEL_F1

当我寻找问题的解释时,我发现了此链接 - https://www.avrfreaks.net/forum/labels-inside-macros .它让我了解到,有问题的 \@ 符号是一种标签计数器,它处理 GAS 宏内唯一标签名称的问题。

不幸的是,我对汇编器几乎一无所知,无法自行修复它。所以我想也许这里有组装专家愿意引导我穿过那片“黑暗森林”。

是否有可能 \@ 是相对较新的符号,而 Apple 的编译器还不知道它?我应该怎么做才能解决这个问题?

提前致谢!

最佳答案

这是因为 clang 使用集成的 LLVM 汇编器,它不具备 GNU 汇编器的所有功能。使用 -no-integrated-as 编译以改用 GNU 汇编程序。

关于ios - GAS 宏内的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58182880/

31 4 0