Annotation of researchv10no/cmd/sml/src/mips/mipsglue.nw, revision 1.1.1.1

1.1       root        1: @ For the Mips, all comments are no-ops, so to get diagnostics in
                      2: assembly mode we have to slip in and define a new comment function.
                      3: Our life is further complicated by the fact that the stream on which
                      4: comments are to be written is bound late, so we have to save up comments
                      5: and then write them when asked to [[generate]].
                      6: <<*>>=
                      7: structure MipsAC : ASSEMBLER = struct
                      8:     val diag_out = ref std_out
                      9:     structure MCN = struct
                     10:         open MipsCoder
                     11:        structure M = struct
                     12:            open M
                     13:            fun comment s = output (!diag_out) s
                     14:        end
                     15:     end
                     16:         
                     17:     structure CM = MipsCM(MCN)
                     18:        
                     19:     structure Gen = CPScomp(CM)
                     20:     fun generate (lexp, stream) = (
                     21:         diag_out := stream;
                     22:        Gen.compile lexp;
                     23:        MipsCoder.codestats stream;
                     24:        Emitters.address := 0;
                     25:        MipsCoder.codegen (Emitters.MipsAsm stream);
                     26:        ())
                     27: end
                     28: 
                     29: <<*>>=
                     30: structure MipsCodeStats : ASSEMBLER = struct
                     31:     val diag_out = ref std_out
                     32:     structure MCN = MipsCoder
                     33:         
                     34:     structure CM = MipsCM(MCN)
                     35:        
                     36:     structure Gen = CPScomp(CM)
                     37:     fun generate (lexp, stream) = (
                     38:        Gen.compile lexp;
                     39:        MipsCoder.codestats stream;
                     40:        ())
                     41: end
                     42: 
                     43: @ Mips machines come in two byte-orders, so we need two of
                     44: every machinelike thing.
                     45: <<*>>=
                     46: structure MipsMCBig : CODEGENERATOR = struct
                     47:     structure CM = MipsCM(MipsCoder)
                     48:     structure Gen = CPScomp(CM)
                     49:  
                     50:     fun generate lexp = (
                     51:        Gen.compile lexp;
                     52:        MipsCoder.codegen (Emitters.BigEndian);
                     53:        Emitters.emitted_string ()
                     54:        )
                     55: end
                     56: 
                     57: structure MipsMCLittle : CODEGENERATOR = struct
                     58:     structure CM = MipsCM(MipsCoder)
                     59:     structure Gen = CPScomp(CM)
                     60: fun diag (s : string) f x =
                     61:        f x handle e =>
                     62:                (print "?exception "; print (System.exn_name e);
                     63:                 print " in mipsglue."; print s; print "\n";
                     64:                 raise e)
                     65:  
                     66:     fun generate lexp = (
                     67:        diag "Gen.compile" Gen.compile lexp;
                     68:        diag "MipsCoder.codegen" MipsCoder.codegen (Emitters.LittleEndian);
                     69:        diag "Emitters.emitted_string" Emitters.emitted_string ()
                     70:        )
                     71: end
                     72: 
                     73: 
                     74: structure CompMipsLittle = Batch(structure M=MipsMCLittle and A=MipsAC)
                     75: structure IntMipsLittle = IntShare(MipsMCLittle)
                     76: 
                     77: structure CompMipsBig = Batch(structure M=MipsMCBig and A=MipsAC)
                     78: structure IntMipsBig = IntShare(MipsMCBig)
                     79: 
                     80: structure CompMipsStats = Batch(structure M=MipsMCLittle and A=MipsCodeStats)

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.