During some experiments with GreenCard I stumbled across a serious
restriction in GHC. Here a short example (an small part of a program
generated by GreenCard):

--------------------------------------------------------------
module Foo where
bar :: Double -> Double -> Double -> IO ()
bar a0 a1 a2 = _casm_GC_ ``bar(%0,%1,%2);'' a0 a1 a2
--------------------------------------------------------------

   panne@liesl: > ghc-3.01 -c -fglasgow-exts Foo.hs

   panic! (the `impossible' happened):
           Cannot allocate enough registers for primop (try rearranging code or 
reducing number of arguments?) _casm_GC_ ``bar(%0,%1,%2);'' [(PrelST.State{-3L-} 
PrelGHC.RealWorld{-3r-}) (PrelGHC.State#{-3K-} PrelGHC.RealWorld{-3r-}) 
PrelGHC.Double#{-39-} PrelGHC.Double#{-39-} PrelGHC.Double#{-39-}]

   Please report it as a compiler bug to [EMAIL PROTECTED]

This can be tracked down to some (annoyingly small) constants in
fptools/ghc/includes/GhcConstants.lh:

...
%************************************************************************
%*                                                                      *
\subsection[stg-reg-counts]{How many STG registers are there}
%*                                                                      *
%************************************************************************

\begin{code}
#define MAX_VANILLA_REG 8
#define MAX_FLOAT_REG 4
#define MAX_DOUBLE_REG 2
\end{code}
...

The questions are: Why are these constants so small? Can GhcConstants.lh
simply be edited to give the STG machine more registers? I really wish
it would be that easy! Browsing through GHC's sources, I can't find a
place contradicting my hopes, but I bet something evil is lurking, anyway...

This restriction is really a show-stopper for me, so a quick fix would
be highly appreciated.
        
-- 
Sven Panne                                        Tel.: +49/89/2178-2235
LMU, Institut fuer Informatik                     FAX : +49/89/2178-2211
LFE Programmier- und Modellierungssprachen              Oettingenstr. 67
mailto:[EMAIL PROTECTED]            D-80538 Muenchen
http://www.pms.informatik.uni-muenchen.de/mitarbeiter/panne

Reply via email to