<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [ARMv7] ldrb.w syntax issue"
href="https://bugs.llvm.org/show_bug.cgi?id=43382">43382</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[ARMv7] ldrb.w syntax issue
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>9.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Tooling
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>eblot.ml@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>[foreword: I did not find the proper component for clang's integrated-as
component. I picked up "C" which is likely not the right sub-component, please
reassign to the proper component]
Using clang/llvm 9.0.0 final with an ARMv7-M (ELF) target, the following syntax
is not accepted by clang assembler:
ldrb.w r2, [r3], #1
Full example:
.text
.arch armv7
.thumb
.thumb_func
.align 1
.syntax unified
mov r3, r0
1: ldrb.w r2, [r3], #1
cmp r2, #0
bne 1b
subs r0, r3, r0
subs r0, #1
bx lr
Using "clang -target armv7em-none-eabi -mcpu=cortex-m4 -mfloat-abi=hard
-mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs -c strlen.S":
strlen.S:7:21: error: too many operands for instruction
1: ldrb.w r2, [r3], #1
>From ARMĀ®v7-M Architecture Reference Manual [ARM DDI 0403E.b], Section A7.7.45
LDRB (immediate), Encoding T2 ARMv7-M,
LDRB<c>.W <Rt>,[<Rn>{,#<imm12>}]
seems to be a valid syntax for the selected architecture.
If the opcode is changed to
ldrb r2, [r3], #1
clang does not complain anymore, and generate the .o output file
Now reading back this generated object file with llvm's objdump:
$ arm-none-eabi-objdump -S strlen.o
strlen.o: file format elf32-littlearm
Disassembly of section .text:
00000000 <.text>:
0: 4603 mov r3, r0
2: f813 2b01 ldrb.w r2, [r3], #1
6: 2a00 cmp r2, #0
8: d1fb bne.n 2 <.text+0x2>
a: 1a18 subs r0, r3, r0
c: 3801 subs r0, #1
e: 4770 bx lr
objdump decodes the ldrb instruction as ldrb.w, which is the syntax clang
rejects.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>