<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - llvm generates invalid mov command for arm7tdmi target"
   href="http://llvm.org/bugs/show_bug.cgi?id=16855">16855</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm generates invalid mov command for arm7tdmi target
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.3
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>sven.koehler@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Command:
clang -target arm-softfloat-eabi -mcpu=arm7tdmi -mthumb -O2 -c -o foo.o foo.c

Contents of foo.c:
int foo(int a, int b) { return b; }

Generated assembler code (relevant part):
foo:
    mov    r0, r1
    bx    lr

Actual Result:
/tmp/foo-Kf30BB.s: Assembler messages:
/tmp/foo-Kf30BB.s:16: Error: MOV Rd, Rs with two low registers is not permitted
on this architecture -- `mov r0,r1'
clang: error: assembler (via gcc) command failed with exit code 1 (use -v to
see invocation)

Expected Result:
clang/llvm should use movs instead of mov. According to offical arm documents,
mov with two low register is not possible in thumb mode in architectures before
ARMv6. See
<a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489i/Cihedhif.html">http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489i/Cihedhif.html</a>

The drawback of movs is, that is resets some flags and stuff. I omit the
details of my arm-softfloat-eabi gcc/binutils toolchain since the error
detected by the assembler seems to be quite correct.</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>