<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/119963>119963</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang doesn't accept udiv with 2 operands when assembling for Cortex-M3
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mateusz-banaszek
      </td>
    </tr>
</table>

<pre>
    When using clang to assemble for ARM Cortex-M3, it doesn't accept an `udiv` instruction with 2 operands, for example:

```asm
.syntax unified

udiv r10, r5
```

An attempt to assemble that using clang v19.1.5:

```
clang -nodefaultlibs -mcpu=cortex-m3 --target=armv7m-none-eabi ./example.s
```

results in an error:

```
./example.s:3:15: error: too few operands for instruction
udiv   r10, r5
              ^
```

However, *Arm v7-M Architecture Reference Manual* says that the assembler syntax is `UDIV<c><q> {<Rd>,} <Rn>, <Rm>` where *"`<Rd>` Specifies the destination register. If `<Rd>` is omitted, this register is the same as `<Rn>`."* As a result, I expect clang to assemble that into:
```
fbba faf5   udiv r10, r10, r5
```
GCC assembles it correctly: https://godbolt.org/z/oh8TnW99T.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0lE2TozYQhn-NuHRBgWRgOHBg7XEyh7lMNtmzEI1RAhKRGs_Hr08JPM54ZtdFlflQv9396FVL7_XJINYs_8byQyQXGqyrJ0m4-Le4lUb6N_wnam33Wv8Y0MDitTmBGqU5AVmQ3uPUjgi9ddA8PcLeOsKX-FEwvgdN0Fn0hvGSQCqFM4E0wIp06fSZFSlo48ktirQ18KxpAA52RidN54NAUMUXOc0jMtGwdL2KdLukn1jaJP7VkHyBxeheY7etCfLgsjRouPxj0Pa9MSCJcJrppgkaJN10eM6qJEvyr7lZ2mwrYmM77OUy0qhbD_Gk5oWJg9owTALimKQ7ITFxkG46l1NsrMEYZashYfx4aS_xX6t06JeRPGgTqKFz1v20klsZ0QgmmiwUfY0BshZ6fL7CXcl-gP_ODG6owc2P5fdfa_zdPuMZXQhhvGncBOcyfoTGqUETKlocwhP26NAohEdpFjky3oCXr37jTQNed8DBZTe1Dy758_DwFxN7xcQ9E_t_mbgHVn5jYv_UhVd8z8oDhEezPa73U7gvUnge0GEoinEeyn2PKlL4Y0YV3OLX5B160kauHnR40p7QJfDQw6co7cFOmgi7kIoG7a_Lw7cg5eUUmnmPNFtkEirgDTQeJGybGhQeAF9mVPST07SC0YbsZb8_MO_bVkIv-xwAbmz-C7f_tt9fdX04kco6h4rG1-CLgWgOlmH8yPjxZLvWjpRYd2L8-Mb40Q53382PqvqeRF0tukpUMsI6K8UuK8siy6KhzvOix6zq2mIn70pUZZ71CqtcVnd8J0QZ6ZqnfJfxbJfxNM3SpG1FkbZ3vSrK7i6XO7ZLcZJ6TMbxPIXkkfZ-wTrLqqoQ0ShbHP06ojhfWQWe-SFydQiI2-Xk2S4dtSf_vwRpGrHer2i_DKEV3Kd5Ewxj3lGFERCOyHWcRYsb60-0NA1Lmyg7MX4MeS9_8ezs36iI8ePah2f8eGnlXPP_AgAA__85rqyR">