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

    <tr>
        <th>Summary</th>
        <td>
            [arm] Invalid instruction error when using '$' to mark an immediate in lsls instruction
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          jonathonpenix
      </td>
    </tr>
</table>

<pre>
    LLVM seems to inconsistently reject using '$' to mark an immediate operand in arm code.

A reproducer is below:

```
$ clang --version
clang version 19.0.0git (https://github.com/jonathonpenix/llvm-project.git 377a2767a9951659b5ec7309abb78da719a4f93b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/mnt/workspace/jpenix/toolchains/community/install/bin
Build config: +assertions
$ cat foo.s
foo:
  # We seem happy with the '$' here, no error
  subs r0, r0, $0x02
  # We produce an error on the '$' here though
  lsls  r0, r0, $0x02
$ clang --target=arm-none-eabi -c foo.s
foo.s:5:3: error: invalid instruction, any one of the following would fix this:
  lsls  r0, r0, $0x02
  ^
foo.s:5:16: note: operand must be an immediate in the range [0,31]
  lsls  r0, r0, $0x02
 ^
foo.s:5:16: note: operand must be a register in range [r0, r14]
  lsls  r0, r0, $0x02
                ^
foo.s:5:16: note: too many operands for instruction
  lsls  r0, r0, $0x02
 ^
```

Compiler explorer link: https://godbolt.org/z/v6x847nhb

GNU binutils seems happy with both instructions (and their docs generally mention that both '#' and '$' are supported IIUC, please see https://sourceware.org/binutils/docs-2.26/as/ARM_002dChars.html#ARM_002dChars).

This issue is easy to work around so probably isn't a huge priority, but might be nice to fix for compatibility with binutils/internal consistency.

Please also note that I'm not sure if this is limited to `lsls` or if there are other cases where this will happen--I only happened across this in the `lsls` instance.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVluP27gO_jXKC5HAlm_xQx7mcnIwQH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