pprStixTree, 
                           NatM, thenNat, returnNat, mapNat, 
                           mapAndUnzipNat, mapAccumLNat,
-                          getDeltaNat, setDeltaNat
+                          getDeltaNat, setDeltaNat,
+                          ncgPrimopMoan
                        )
 import Outputable
 import CmdLineOpts     ( opt_Static )
              DoubleTanhOp  -> (False, SLIT("tanh"))
 
               other
-                 -> pprPanic "getRegister(x86,unary primop)" 
-                             (pprStixTree (StPrim primop [x]))
+                 -> ncgPrimopMoan "getRegister(x86,unary primop)" 
+                                  (pprStixTree (StPrim primop [x]))
 
 getRegister (StPrim primop [x, y]) -- dyadic PrimOps
   = case primop of
       DoublePowerOp -> getRegister (StCall SLIT("pow") CCallConv DoubleRep 
                                            [x, y])
       other
-         -> pprPanic "getRegister(x86,dyadic primop)" 
-                     (pprStixTree (StPrim primop [x, y]))
+         -> ncgPrimopMoan "getRegister(x86,dyadic primop)" 
+                          (pprStixTree (StPrim primop [x, y]))
   where
 
     --------------------
     in
        returnNat (Any PtrRep code)
   | otherwise
-  = pprPanic "getRegister(x86)" (pprStixTree leaf)
+  = ncgPrimopMoan "getRegister(x86)" (pprStixTree leaf)
   where
     imm = maybeImm leaf
     imm__2 = case imm of Just x -> x
              DoubleTanhOp  -> (False, SLIT("tanh"))
 
               other
-                 -> pprPanic "getRegister(sparc,monadicprimop)" 
-                             (pprStixTree (StPrim primop [x]))
+                 -> ncgPrimopMoan "getRegister(sparc,monadicprimop)" 
+                                  (pprStixTree (StPrim primop [x]))
 
 getRegister (StPrim primop [x, y]) -- dyadic PrimOps
   = case primop of
                                            [x, y])
 
       other
-         -> pprPanic "getRegister(sparc,dyadic primop)" 
-                     (pprStixTree (StPrim primop [x, y]))
+         -> ncgPrimopMoan "getRegister(sparc,dyadic primop)" 
+                          (pprStixTree (StPrim primop [x, y]))
 
   where
     imul_div fn x y = getRegister (StCall fn CCallConv IntRep [x, y])
     in
        returnNat (Any PtrRep code)
   | otherwise
-  = pprPanic "getRegister(sparc)" (pprStixTree leaf)
+  = ncgPrimopMoan "getRegister(sparc)" (pprStixTree leaf)
   where
     imm = maybeImm leaf
     imm__2 = case imm of Just x -> x
 
         uniqOfNatM_State, deltaOfNatM_State,
 
        getUniqLabelNCG, getNatLabelNCG,
+        ncgPrimopMoan
     ) where
 
 #include "HsVersions.h"
 
 import Ratio           ( Rational )
+import IOExts          ( unsafePerformIO )
+import IO              ( hPutStrLn, stderr )
 
 import AbsCSyn         ( node, tagreg, MagicId(..) )
 import ForeignCall     ( CCallConv )
 setDeltaNat delta (NatM_State us _)
    = ((), NatM_State us delta)
 \end{code}
+
+Giving up in a not-too-inelegant way.
+
+\begin{code}
+ncgPrimopMoan :: String -> SDoc -> a
+ncgPrimopMoan msg pp_rep
+   = unsafePerformIO (
+        hPutStrLn stderr (
+        "\n" ++
+        "You've fallen across an unimplemented case in GHC's native code generation\n" ++
+        "machinery.  You can work around this for the time being by compiling\n" ++ 
+        "this module via the C route, by giving the flag -fvia-C.\n" ++
+        "The panic below contains information, intended for the GHC implementors,\n" ++
+        "about the exact place where GHC gave up.  Please send it to us\n" ++
+        "at glasgow-haskell-bugs@haskell.org, so as to encourage us to fix this.\n"
+        )
+     )
+     `seq`
+     pprPanic msg pp_rep
+\end{code}
 
                         other     -> IntRep
 
 foreignCallCode lhs call rhs
-  = pprPanic "Native code generator can't handle foreign call" (ppr call)
+  = ncgPrimopMoan "Native code generator can't handle foreign call" (ppr call)
 \end{code}
 
 
 
 \begin{code}
 simplePrim pk [lhs] op rest  = StAssign pk lhs (StPrim op rest)
-simplePrim pk as    op bs    = simplePrim_error op
-
-simplePrim_error op
-    = error ("ERROR: primitive operation `"++show op++"'cannot be handled\nby the native-code generator.  Workaround: use -fvia-C.\n(Perhaps you should report it as a GHC bug, also.)\n")
+simplePrim pk as    op bs    = ncgPrimopMoan "simplPrim(all targets)" (ppr op)
 \end{code}
 
 %---------------------------------------------------------------------