<html>
    <head>
      <base href="https://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 --- - clang 3.9.1 targeting powerpc rejects "cmp 0, %r1, %r3" in a .S file for "too few operands for instruction" (FreeBSD buildkernel context)"
   href="https://llvm.org/bugs/show_bug.cgi?id=31541">31541</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang 3.9.1 targeting powerpc rejects "cmp 0, %r1, %r3" in a .S file for "too few operands for instruction" (FreeBSD buildkernel context)
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.9
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </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>Backend: PowerPC
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>markmi@dsl-only.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>[lib/Target/PowerPC is a guess on my part for where the
issue would be addressed.]

In attempting to buildkernel via FreeBSD's clang 3.9.1 variant
the attempt stops with the following for code that has been in
place in FreeBSD for a very long time (historically gcc 4.2.1
toolchain use):

--- locore.o ---
/usr/src/sys/powerpc/aim/trap_subr32.S:409:2: error: too few operands for
instruction
 cmp 0, %r1, %r3
 ^
*** [locore.o] Error code 1

make[2]: stopped in
/usr/obj/powerpcvtsc_clang_kernel/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG
.ERROR_TARGET='locore.o'
.ERROR_META_FILE='/usr/obj/powerpcvtsc_clang_kernel/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/locore.o.meta'


# Meta data file
/usr/obj/powerpcvtsc_clang_kernel/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG/locore.o.meta
CMD cc -target powerpc-unknown-freebsd12.0
--sysroot=/usr/obj/powerpcvtsc_clang_kernel/powerpc.powerpc/usr/src/tmp
-B/usr/obj/powerpcvtsc_clang_kernel/powerpc.powerpc/usr/src/tmp/usr/bin -c -x
assembler-with-cpp -DLOCORE -O -pipe  -g -nostdinc  -I. -I/usr/src/sys
-I/usr/src/sys/contrib/libfdt -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include
opt_global.h  -msoft-float -fPIC -fno-omit-frame-pointer -mno-altivec
-ffreestanding -fwrapv -fstack-protector -gdwarf-2 -Wall -Wredundant-decls
-Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith
-Winline -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__
-Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas
-Wno-error-tautological-compare -Wno-error-empty-body
-Wno-error-parentheses-equality -Wno-error-unused-function
-Wno-error-pointer-sign -Wno-error-shift-negative-value  -msoft-float 
-std=iso9899:1999  -Werror /usr/src/sys/powerpc/aim/locore.S
CWD
/usr/obj/powerpcvtsc_clang_kernel/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODBG
TARGET locore.o
-- command output --
/usr/src/sys/powerpc/aim/trap_subr32.S:409:2: error: too few operands for
instruction
 cmp 0, %r1, %r3
 ^
*** Error code 1




clang 3.9.1 is not allowing the optional crD to be optional
in the instruction format:

cmp [crD,]L,rA,rB

The following:

# svnlite diff /usr/src/sys/powerpc/aim/trap_subr32.S
Index: /usr/src/sys/powerpc/aim/trap_subr32.S
===================================================================
--- /usr/src/sys/powerpc/aim/trap_subr32.S      (revision 311147)
+++ /usr/src/sys/powerpc/aim/trap_subr32.S      (working copy)
@@ -406,7 +406,7 @@
        mtctr %r1                       /* load counter */
 im1:
        lwzu %r1, 8(%r2)                /* get next pte */
-       cmp 0, %r1, %r3                 /* see if found pte */
+       cmp 0, 0, %r1, %r3              /* see if found pte */
        bdnzf 2, im1                    /* dec count br if cmp ne and if
                                         * count not zero */
        bne instr_sec_hash              /* if not found set up second hash

allows buildkernel to progress past this.
(The above filled in the default value explicltly.)

[So FreeBSD can avoid the specific issue. This issue is unlikely
to be considered an issue that contributes to why the system
compiler for powerpc can not be clang yet.]


Materials around such as:

<a href="http://www.tentech.ca/downloads/other/PPC_Quick_Ref_Card-Rev1_Oct12_2010.pdf">http://www.tentech.ca/downloads/other/PPC_Quick_Ref_Card-Rev1_Oct12_2010.pdf</a>

show the optional status for crD. My guess is that the clang toolchain is
incomplete in its coverage for the intended notation.

(I've no clue if there are other such optional-syntax issues in general.
If there are then FreeBSD does not seem to have examples of hitting any
of the other examples via its clang 3.9.1 variant.)</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>