<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 --- - FreeBSD head (12) buildkernel based on clang FReeBSD's 3.9.1 stops for mfpmr and mtpmr instructions not being supported (used in dev/hwpmc/hwpmc_e500.c )"
   href="https://llvm.org/bugs/show_bug.cgi?id=31538">31538</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>FreeBSD head (12) buildkernel based on clang FReeBSD's 3.9.1 stops for mfpmr and mtpmr instructions not being supported (used in dev/hwpmc/hwpmc_e500.c )
          </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>[This report likely should be added to the depends on list in:

<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [META] Using Clang as the FreeBSD/ppc system compiler"
   href="show_bug.cgi?id=25780">Bug 25780</a> - [META] Using Clang as the FreeBSD/ppc system compiler

Also stable/11 recently updated to 3.9.1 as well and also has the
use of the rejected instructions. (I've not done an explicit build
there as yet.) So it is not just head (12) that has the issue.

]

Attempting to buildkernel for FreeBSD head (12) rejects required instructions
for a standard FreeBSD build:

--- hwpmc_e500.o ---
/usr/src/sys/modules/hwpmc/../../dev/hwpmc/hwpmc_e500.c:475:19: error:
unrecognized instruction mnemonic
        uint32_t pmgc0 = mfpmr(PMR_PMGC0);
                         ^
./machine/pmc_mdep.h:24:21: note: expanded from macro 'mfpmr'
          __asm __volatile("mfpmr %0,%1" : "=r"(val) : "K"(reg));       \
                           ^
<inline asm>:1:2: note: instantiated into assembly here
        mfpmr 3,400
        ^
/usr/src/sys/modules/hwpmc/../../dev/hwpmc/hwpmc_e500.c:478:2: error:
unrecognized instruction mnemonic
        mtpmr(PMR_PMGC0, pmgc0);
        ^
./machine/pmc_mdep.h:21:19: note: expanded from macro 'mtpmr'
        __asm __volatile("mtpmr %0,%1" : : "K"(reg), "r"(val))
                         ^
<inline asm>:1:2: note: instantiated into assembly here
        mtpmr 400,3
        ^
. . . (more examples of those instructions) . . .


A partial patch that someone provided (no instruction scheduling
logic or other such) was:

Index: /usr/src/contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td
===================================================================
--- /usr/src/contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td    (revision
309656)
+++ /usr/src/contrib/llvm/lib/Target/PowerPC/PPCInstrInfo.td    (working copy)
@@ -2300,6 +2300,12 @@
 def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR),
                      "mftb $RT, $SPR", IIC_SprMFTB>;

+def MFPMR : XFXForm_1<31, 334, (outs gprc:$RT), (ins i32imm:$PMRN),
+                     "mfpmr $RT, $PMRN", IIC_IntGeneral>;
+
+def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$PMRN, gprc:$RS),
+                     "mtpmr $PMRN, $RS", IIC_IntGeneral>;
+
 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
 // on a 32-bit target.
 let hasSideEffects = 1, usesCustomInserter = 1 in


This patch was enough for buildkernel to no longer stop for these two
instructions. (I've been using the patch for some time, which explains
the 309656 revision reference above.)

(The person that provided the patch reports not having time to do
more for the instructions.)</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>