[project @ 2000-06-13 16:07:20 by simonmar]
[ghc-hetmet.git] / ghc / driver / mangler / ghc-asm.lprl
index 4b221fe..29a6894 100644 (file)
@@ -42,6 +42,28 @@ for the same reason.  Advantage: No more ridiculous call sequences.
 
 %************************************************************************
 %*                                                                     *
+\subsection{Top-level code}
+%*                                                                     *
+%************************************************************************
+
+\begin{code}
+$TargetPlatform = $TARGETPLATFORM;
+
+($Pgm = $0) =~ s|.*/||;
+$ifile = $ARGV[0];
+$ofile = $ARGV[1];
+
+if ( $TargetPlatform =~ /^i386-/ ) {
+    $StolenX86Regs = $ARGV[2];
+}
+
+&mangle_asm($ifile,$ofile);
+
+exit(0);
+\end{code}
+
+%************************************************************************
+%*                                                                     *
 \subsection{Constants for various architectures}
 %*                                                                     *
 %************************************************************************
@@ -435,7 +457,7 @@ sub mangle_asm {
            $chkcat[$i]  = 'literal';
            $chksymb[$i] = $1;
 
-       } elsif ( /^$TUS[@]?__stg_split_marker(\d+)$TPOSTLBL[@]?$/o ) {
+       } elsif ( /^$TUS[@]?__stg_split_marker(\d*)$TPOSTLBL[@]?$/o ) {
            $chk[++$i]   = $_;
            $chkcat[$i]  = 'splitmarker';
            $chksymb[$i] = $1;
@@ -734,7 +756,7 @@ sub mangle_asm {
                # HWL HACK: dont die, just print a warning
                #print stderr "HWL: this should die! Epilogue junk?: $e\n" if $e =~ /^\t[^\.]/
                #    && $TargetPlatform !~ /^powerpc-/; #ToDo: remove test
-               die "Epilogue junk?: $e\n" if $e =~ /^\t[^\.]/
+               die "Epilogue junk?: $e\n" if $e =~ /^\t[^\.\n]/
                    && $TargetPlatform !~ /^powerpc-/; #ToDo: remove test
 
                # glue together what's left
@@ -795,10 +817,10 @@ sub mangle_asm {
             #
            if ( $TargetPlatform =~ /^i386/ && $to_move =~ /$TCOPYDIRVS/ ) {
                $j = $i + 1;
-               while ( $j < ($numchks - 1)  && $chk[$j] =~ /$T_CONST_LBL/) {
+               while ( $j < $numchks  && $chk[$j] =~ /$T_CONST_LBL/) {
                        $j++;
                }
-               if ( $j < ($numchks - 1)) {
+               if ( $j < $numchks ) {
                        $chk[$j] = $to_move . $chk[$j];
                }
            }
@@ -1495,7 +1517,12 @@ sub mangle_powerpc_tailjump {
       };
     $c;
 }
+\end{code}
 
-# make "require"r happy...
-1;
+\begin{code}
+sub tidy_up_and_die {
+    local($return_val, $msg) = @_;
+    print STDERR $msg;
+    exit (($return_val == 0) ? 0 : 1);
+}
 \end{code}