<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 - The assembly parser eats trailing 'h' chars from macro arguments that start with a number"
   href="https://bugs.llvm.org/show_bug.cgi?id=32973">32973</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The assembly parser eats trailing 'h' chars from macro arguments that start with a number
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>MC
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>martin@martin.st
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When macro arguments start with a number, a 'h' after the number gets eaten
before the macro gets expanded.

E.g. this aarch64 snippet fails to assemble with clang/LLVM while it assembles
fine with gnu binutils:


.macro do_add sz
        add     v0.\sz, v0.\sz, v0.\sz
.endm

do_add 8h


With clang/llvm, this fails to assemble like this:

$ clang -target aarch64-linux-gnu -c test.s -o test.o
<instantiation>:1:9: error: invalid vector kind qualifier
add     v0.8, v0.8, v0.8
        ^
test.s:5:1: note: while in macro instantiation
do_add 8h
^

If the same snippet is written differently, to include the dot in the macro
argument, it assembles fine:

.macro do_add sz
        add     v0\sz, v0\sz, v0\sz
.endm

do_add .8h

Likewise, the original do_add macro succeeds with other lane sizes like 4s, 8b,
16b etc.



The same phenomenon can be observed with this rather pathological test case:

.macro def_string param
        .ascii  "\param"
.endm

.data
def_string 1hello

When assembled, objdump shows:

$ aarch64-linux-gnu-objdump -s test.o

test.o:     file format elf64-littleaarch64

Contents of section .data:
 0000 31656c6c 6f                          1ello        


The 'h' trailing the number '1' has been eaten and never made it into the macro
expansion.</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>