Skip to content

Commit 11ab7e3

Browse files
committed
Avoid using nonstandard assembly syntax for NEON
While the original form of the example can't be assembled with Clang, the suggested replacement isn't ideal either. The original form of the example used a nonstandard way of referencing vector elements, by writing `V3.4H[0]`, while the standard form is to drop the total number of elements, writing only `V3.H[0]` - this is supported by both GNU assembler and Clang. The earlier replacement syntax, with instructions like `MUL.4H`, where the vector layout is specified as part of the instruction instead of as part of the register, is entirely nonstandard. (It is similar to how NEON instructions were written for AArch32 though.) This syntax is accepted by Clang, and is produced by LLVM tools when disassembling Mach-O file, but should not be recommended in new written code. Thus revert these instructions back to their original form and only apply the element specifier syntax fix, changing `V3.4H[0]` into `V3.H[0]`.
1 parent b8dbac1 commit 11ab7e3

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

Chapter 13/matrixmultneon.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ main:
3434
LDR D5, [X0]
3535

3636
.macro mulcol ccol bcol
37-
MUL.4H \ccol\(), V0, \bcol\()[0]
38-
MLA.4H \ccol\(), V1, \bcol\()[1]
39-
MLA.4H \ccol\(), V2, \bcol\()[2]
37+
MUL \ccol\().4H, V0.4H, \bcol\().H[0]
38+
MLA \ccol\().4H, V1.4H, \bcol\().H[1]
39+
MLA \ccol\().4H, V2.4H, \bcol\().H[2]
4040
.endm
4141

4242
mulcol V6, V3 // process first column

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -335,17 +335,11 @@ Like in Chapter 11, all the chages have been introduced already. Nothing new her
335335

336336
## Chapter 13: Neon Coprocessor
337337

338-
Once again, the Clang assembler wants a slightly different syntax: Where gcc accepts
339-
340-
```
341-
MUL V6.4H, V0.4H, V3.4H[0]
342-
```
343-
344-
the Clang assembler expects
345-
346-
```
347-
MUL.4H V6, V0, V3[0]
348-
```
338+
The example used a nonstandard syntax for referencing a single vector element,
339+
which GNU assembler accepts, but Clang doesn't.
340+
Where the example used `V3.4H[0]` for referencing the first 16 bit element,
341+
the correct, standard syntax is `V3.H[0]`, which is accepted both by GNU
342+
assembler and Clang.
349343

350344
All other changes to the code should be trivial at this point.
351345

0 commit comments

Comments
 (0)