[project @ 2000-06-13 15:35:29 by simonmar]
[ghc-hetmet.git] / ghc / driver / mangler / ghc-asm.lprl
index 73554ae..a653502 100644 (file)
@@ -104,7 +104,7 @@ sub init_TARGET_STUFF {
     $T_HDR_direct   = "\t.SPACE \$TEXT\$\n\t.SUBSPA \$CODE\$\n\t\.align 4\n";
 
     #--------------------------------------------------------#
-    } elsif ( $TargetPlatform =~ /^i386-.*-(linuxaout|freebsd2|nextstep3|cygwin32|mingw32)$/ ) {
+    } elsif ( $TargetPlatform =~ /^i386-.*-(linuxaout|freebsd2|netbsd|nextstep3|cygwin32|mingw32)$/ ) {
                                # NeXT added but not tested. CaS
 
     $T_STABBY      = 1; # 1 iff .stab things (usually if a.out format)
@@ -135,22 +135,22 @@ sub init_TARGET_STUFF {
     $T_HDR_direct   = "\.text\n\t\.align 2,0x90\n";
 
     #--------------------------------------------------------#
-    } elsif ( $TargetPlatform =~ /^i386-.*-(solaris2|linux|freebsd3)$/ ) {
+    } elsif ( $TargetPlatform =~ /^i386-.*-(solaris2|linux|freebsd|netbsd_elf)$/ ) {
 
     $T_STABBY      = 0; # 1 iff .stab things (usually if a.out format)
     $T_US          = ''; # _ if symbols have an underscore on the front
     $T_PRE_APP     = # regexp that says what comes before APP/NO_APP
-                     ($TargetPlatform =~ /-(linux|freebsd3)$/) ? '#' : '/' ;
+                     ($TargetPlatform =~ /-(linux|freebsd|netbsd_elf)$/) ? '#' : '/' ;
     $T_CONST_LBL    = '^\.LC(\d+):$'; # regexp for what such a lbl looks like
     $T_POST_LBL            = ':';
     $T_X86_PRE_LLBL_PAT = '\.L';
     $T_X86_PRE_LLBL        = '.L';
     $T_X86_BADJMP   = '^\tjmp [^\.\*]';
 
-    $T_MOVE_DIRVS   = '^(\s*(\.(p2)?align\s+\d+(,0x90)?|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.size\s+.*|\.type\s+.*|\.Lfe.*\n\t\.size\s+.*|\.ident.*)\n)';
+    $T_MOVE_DIRVS   = '^(\s*(\.(p2)?align\s+\d+(,0x90)?|\.globl\s+\S+|\.text|\.data|\.section\s+.*|\.type\s+.*|\.Lfe.*\n\t\.size\s+.*|\.size\s+.*|\.ident.*)\n)';
     $T_COPY_DIRVS   = '\.(globl)';
 
-    if ( $TargetPlatform =~ /freebsd3/ ) {
+    if ( $TargetPlatform =~ /freebsd|netbsd_elf/ ) {
         $T_hsc_cc_PAT   = '\.ascii.*\)(hsc|cc) (.*)\\\\11"\n\t\.ascii\s+"(.*)\\\\0"';
     } else {
         $T_hsc_cc_PAT   = '\.string.*\)(hsc|cc) (.*)\\\\t(.*)"';
@@ -478,6 +478,11 @@ sub mangle_asm {
 
            $srtchk{$1} = $i;
 
+       } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_ct$TPOSTLBL[@]?$/o ) {
+           $chk[++$i]   = $_;
+           $chkcat[$i]  = 'data';
+           $chksymb[$i] = '';
+
        } elsif ( /^$TUS[@]?ghc.*c_ID$TPOSTLBL/o ) {
            $chk[++$i]  = $_;
            $chkcat[$i] = 'consist';
@@ -487,7 +492,6 @@ sub mangle_asm {
 
        } elsif ( /^$TUS[A-Za-z0-9_]+\.\d+$TPOSTLBL[@]?$/o
               || /^$TUS[@]?.*_CAT$TPOSTLBL[@]?$/o              # PROF: _entryname_CAT
-              || /^$TUS[@]?CC_.*_struct$TPOSTLBL[@]?$/o        # PROF: _CC_ccident_struct
               || /^$TUS[@]?.*_done$TPOSTLBL[@]?$/o             # PROF: _module_done
               || /^$TUS[@]?_module_registered$TPOSTLBL[@]?$/o  # PROF: _module_registered
               ) {
@@ -505,7 +509,7 @@ sub mangle_asm {
            $chkcat[$i]  = 'toc';
            $chksymb[$i] = $1;
 
-       } elsif ( /^$TUS[@]?CC(S)?_.*$/ ) {
+       } elsif ( /^$TUS[@]?([A-Za-z0-9_]+)_cc(s)?$TPOSTLBL[@]?$/o ) {
             # all CC_ symbols go in the data section...
            $chk[++$i]   = $_;
            $chkcat[$i]  = 'data';
@@ -683,8 +687,11 @@ sub mangle_asm {
                    print STDERR "$Pgm: unknown prologue mangling? $TargetPlatform\n";
                }
 
+               # HWL HACK: dont die, just print a warning
+               #print stderr  "HWL: this should die! Prologue junk?: $p\n" if $p =~ /^\t[^\.]/
+               #    && $TargetPlatform !~ /^powerpc-/; #ToDo: remove test
                die "Prologue junk?: $p\n" if $p =~ /^\t[^\.]/
-                   && $TargetPlatform !~ /^(powerpc-|i386-)/; #ToDo: remove test
+                   && $TargetPlatform !~ /^powerpc-/; #ToDo: remove test
 
                # glue together what's left
                $c = $p . $r;
@@ -704,7 +711,6 @@ sub mangle_asm {
                    $e =~ s/^\tret\n//;
                    $e =~ s/^\tpopl \%edi\n//;
                    $e =~ s/^\tpopl \%esi\n//;
-                   $e =~ s/^\tpopl \%ebx\n//;
                    $e =~ s/^\tpopl \%ecx\n//;
                    $e =~ s/^\taddl \$\d+,\%esp\n//;
                } elsif ($TargetPlatform =~ /^m68k-/) {
@@ -724,6 +730,9 @@ sub mangle_asm {
                } else {
                    print STDERR "$Pgm: unknown epilogue mangling? $TargetPlatform\n";
                }
+               # 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[^\.]/
                    && $TargetPlatform !~ /^powerpc-/; #ToDo: remove test
 
@@ -737,7 +746,7 @@ sub mangle_asm {
        # toss the register-windowing save/restore/ret* instructions
        # directly:
        if ( $TargetPlatform =~ /^sparc-/ ) {
-           $c =~ s/^\t(save .*|restore|ret|retl)\n//g;
+           $c =~ s/^\t(save.*|restore|ret|retl)\n//g;
            # throw away PROLOGUE comments
            $c =~ s/^\t!#PROLOGUE# 0\n\t!#PROLOGUE# 1\n//;
        }
@@ -745,7 +754,7 @@ sub mangle_asm {
        # On Alphas, the prologue mangling is done a little later (below)
 
        # toss all calls to __DISCARD__
-       $c =~ s/^\t(call|jbsr|jal)\s+$TUS[@]?__DISCARD__(\@PLT)?\n//go;
+       $c =~ s/^\t(call|jbsr|jal)\s+$TUS[@]?__DISCARD__\n//go;
 
        # MIPS: that may leave some gratuitous asm macros around
        # (no harm done; but we get rid of them to be tidier)
@@ -971,9 +980,7 @@ sub mangle_asm {
                   $chk[$infochk{$symb}] =~ s/\.long ([A-Za-z]\S+_upd)/\.long \.\1/;
                   print OUTASM $chk[$infochk{$symb}];
                 } else {
-# for shared libs --SDM
-                  print OUTASM $chk[$infochk{$symb}];
-#                print OUTASM &rev_tbl($symb, $chk[$infochk{$symb}], 1);
+                 print OUTASM &rev_tbl($symb, $chk[$infochk{$symb}], 1);
                 }
                # entry code will be put here!
 
@@ -1012,10 +1019,6 @@ sub mangle_asm {
                        # The next two only apply if we're not stealing %esi or %edi.
                        $c =~ s/^\tmovl \$${T_US}${symb}_fast\d*,\%esi\n\tjmp \*\%esi\n// if ($StolenX86Regs < 3);
                        $c =~ s/^\tmovl \$${T_US}${symb}_fast\d*,\%edi\n\tjmp \*\%edi\n// if ($StolenX86Regs < 4);
-                       # for PIC code
-                       $c =~ s/^\tleal ${T_US}${symb}_fast\d*\@GOTOFF\(\%ebx\),\%eax\n\tjmp \*\%eax\n//;
-                       $c =~ s/^\tjmp \*${T_US}${symb}_fast\d*\@GOT\(\%ebx\)\n//;
-                       $c =~ s/^\.LPR\d+\:\n\tmovl \(\%esp\),\%ebx\n\tret\n//;
                    } elsif ( $TargetPlatform =~ /^mips-/ ) {
                        $c =~ s/^\tjmp \$31,\(\$27\),0\n\t\.align 4\n\t\.end/\t.align 4\n\t.end/;
                    } elsif ( $TargetPlatform =~ /^m68k-/ ) {
@@ -1024,8 +1027,8 @@ sub mangle_asm {
                    } elsif ( $TargetPlatform =~ /^powerpc-|^rs6000-/ ) {
                        $c =~ s/^\tb \.${T_US}${symb}_fast\d+\n//;
                    } elsif ( $TargetPlatform =~ /^sparc-/ ) {
-                       $c =~ s/^\tcall ${T_US}${symb}_fast\d+,.*\n\tnop\n//;
-                       $c =~ s/^\tcall ${T_US}${symb}_fast\d+,.*\n(\t[a-z].*\n)/$1/;
+                       $c =~ s/^\tcall\s+${T_US}${symb}_fast\d+,.*\n\t\s*nop\n//;
+                       $c =~ s/^\tcall\s+${T_US}${symb}_fast\d+,.*\n(\t\s*[a-z].*\n)/$1/;
                    } else {
                        print STDERR "$Pgm: mystery slow-fast dropthrough: $TargetPlatform\n";
                    }
@@ -1088,9 +1091,7 @@ sub mangle_asm {
                  print OUTASM ".${symb}_vtbl:\n";
                  print OUTASM $chk[$vectorchk{$symb}];
                } else {
-# for shared libs --SDM                  print OUTASM $chk[$vectorchk{$symb}];
-                 print OUTASM $chk[$vectorchk{$symb}];
-#                print OUTASM &rev_tbl($symb, $chk[$vectorchk{$symb}], 0);
+                 print OUTASM &rev_tbl($symb, $chk[$vectorchk{$symb}], 0);
                }
                # direct return code will be put here!
                $chkcat[$vectorchk{$symb}] = 'DONE ALREADY';