[llvm-bugs] [Bug 31538] 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 )

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 4 14:17:04 PST 2017


https://llvm.org/bugs/show_bug.cgi?id=31538

            Bug ID: 31538
           Summary: 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 )
           Product: libraries
           Version: 3.9
          Hardware: Macintosh
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: markmi at dsl-only.net
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

[This report likely should be added to the depends on list in:

Bug 25780 - [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.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170104/d1951bda/attachment.html>


More information about the llvm-bugs mailing list