File:  [Research Unix] / researchv10no / cmd / sml / src / mips / mipsglue.nw
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

@ For the Mips, all comments are no-ops, so to get diagnostics in
assembly mode we have to slip in and define a new comment function.
Our life is further complicated by the fact that the stream on which
comments are to be written is bound late, so we have to save up comments
and then write them when asked to [[generate]].
<<*>>=
structure MipsAC : ASSEMBLER = struct
    val diag_out = ref std_out
    structure MCN = struct
        open MipsCoder
	structure M = struct
	    open M
	    fun comment s = output (!diag_out) s
	end
    end
        
    structure CM = MipsCM(MCN)
	
    structure Gen = CPScomp(CM)
    fun generate (lexp, stream) = (
        diag_out := stream;
	Gen.compile lexp;
	MipsCoder.codestats stream;
	Emitters.address := 0;
	MipsCoder.codegen (Emitters.MipsAsm stream);
	())
end

<<*>>=
structure MipsCodeStats : ASSEMBLER = struct
    val diag_out = ref std_out
    structure MCN = MipsCoder
        
    structure CM = MipsCM(MCN)
	
    structure Gen = CPScomp(CM)
    fun generate (lexp, stream) = (
	Gen.compile lexp;
	MipsCoder.codestats stream;
	())
end

@ Mips machines come in two byte-orders, so we need two of
every machinelike thing.
<<*>>=
structure MipsMCBig : CODEGENERATOR = struct
    structure CM = MipsCM(MipsCoder)
    structure Gen = CPScomp(CM)
 
    fun generate lexp = (
	Gen.compile lexp;
	MipsCoder.codegen (Emitters.BigEndian);
	Emitters.emitted_string ()
	)
end

structure MipsMCLittle : CODEGENERATOR = struct
    structure CM = MipsCM(MipsCoder)
    structure Gen = CPScomp(CM)
fun diag (s : string) f x =
	f x handle e =>
		(print "?exception "; print (System.exn_name e);
		 print " in mipsglue."; print s; print "\n";
		 raise e)
 
    fun generate lexp = (
	diag "Gen.compile" Gen.compile lexp;
	diag "MipsCoder.codegen" MipsCoder.codegen (Emitters.LittleEndian);
	diag "Emitters.emitted_string" Emitters.emitted_string ()
	)
end


structure CompMipsLittle = Batch(structure M=MipsMCLittle and A=MipsAC)
structure IntMipsLittle = IntShare(MipsMCLittle)

structure CompMipsBig = Batch(structure M=MipsMCBig and A=MipsAC)
structure IntMipsBig = IntShare(MipsMCBig)

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.