Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /MLRISC/trunk/x86/staged-allocation/test.sml
ViewVC logotype

Diff of /MLRISC/trunk/x86/staged-allocation/test.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3049, Fri May 30 00:58:55 2008 UTC revision 3054, Tue Jun 3 01:26:28 2008 UTC
# Line 1  Line 1 
1    val fast_floating_point = ref true
2    
3  (*  (*
4   * User defined constant type.  Dummy for now.   * User defined constant type.  Dummy for now.
5   * In practice, you'll want to use this type to implement constants with   * In practice, you'll want to use this type to implement constants with
# Line 88  Line 90 
90    
91      val compileSext = CompInstrExt.compileSext      val compileSext = CompInstrExt.compileSext
92    
93      fun compileRext _ = raise Fail "AMD64CompExtFn.compileRext"      fun compileRext _ = raise Fail "CompExtFn.compileRext"
94      fun compileFext _ = raise Fail "AMD64CompExtFn.compileFext"      fun compileFext _ = raise Fail "CompExtFn.compileFext"
95      fun compileCCext _ = raise Fail "AMD64CompExtFn.compileCCext"      fun compileCCext _ = raise Fail "CompExtFn.compileCCext"
96    
97  end  end
98    
# Line 109  Line 111 
111     X86GasPseudoOps(structure T=X86MLTree     X86GasPseudoOps(structure T=X86MLTree
112                     structure MLTreeEval=X86MLTreeEval)                     structure MLTreeEval=X86MLTreeEval)
113    
114    (*
115  functor X86PseudoOpsFn (  functor X86PseudoOpsFn (
116      structure T : MLTREE      structure T : MLTREE
117      structure MLTreeEval : MLTREE_EVAL where T = T      structure MLTreeEval : MLTREE_EVAL where T = T
118    ) : PSEUDO_OPS_BASIS = X86GasPseudoOps (    ) : PSEUDO_OPS_BASIS = X86GasPseudoOps (
119      structure T = T      structure T = T
120      structure MLTreeEval = MLTreeEval)      structure MLTreeEval = MLTreeEval)
121    *)
122    
 (*  
123  functor X86PseudoOpsFn (  functor X86PseudoOpsFn (
124      structure T : MLTREE      structure T : MLTREE
125      structure MLTreeEval : MLTREE_EVAL where T = T      structure MLTreeEval : MLTREE_EVAL where T = T
126    ) : PSEUDO_OPS_BASIS = X86DarwinPseudoOps (    ) : PSEUDO_OPS_BASIS = X86DarwinPseudoOps (
127      structure T = T      structure T = T
128      structure MLTreeEval = MLTreeEval)      structure MLTreeEval = MLTreeEval)
 *)  
129    
130  structure X86PseudoOps = X86PseudoOpsFn(  structure X86PseudoOps = X86PseudoOpsFn(
131              structure T = X86MLTree              structure T = X86MLTree
# Line 187  Line 189 
189              structure InsnProps = X86InsnProps              structure InsnProps = X86InsnProps
190              structure Asm = X86Asm)              structure Asm = X86Asm)
191    
 (*structure X86Stream = InstructionStream(X86PseudoOps)*)  
192  structure X86MLTStream = MLTreeStream (  structure X86MLTStream = MLTreeStream (
193                        structure T = X86MLTree                        structure T = X86MLTree
194                        structure S = X86Stream)                        structure S = X86Stream)
# Line 242  Line 243 
243             val arch = ref Pentium (* Lowest common denominator *)             val arch = ref Pentium (* Lowest common denominator *)
244    
245                    fun cvti2f _ = raise Fail ""                    fun cvti2f _ = raise Fail ""
246                    val fast_floating_point = ref true                    val fast_floating_point = fast_floating_point
247                    )                    )
248    
249  structure X86Emit = CFGEmit (  structure X86Emit = CFGEmit (
# Line 321  Line 322 
322           fun beforeRA (Graph.GRAPH graph) = ()           fun beforeRA (Graph.GRAPH graph) = ()
323           datatype spillOperandKind = datatype spill_operand_kind           datatype spillOperandKind = datatype spill_operand_kind
324           datatype raPhase = datatype ra_phase           datatype raPhase = datatype ra_phase
325           val fast_floating_point = ref true           val fast_floating_point = fast_floating_point
326           structure Int = IntRA           structure Int = IntRA
327           structure Float = FloatRA)           structure Float = FloatRA)
328    
# Line 333  Line 334 
334  structure CCalls = IA32SVIDFn (  structure CCalls = IA32SVIDFn (
335             structure T = X86MLTree             structure T = X86MLTree
336             fun ix x = x             fun ix x = x
337             val fast_floating_point = ref true             val fast_floating_point = fast_floating_point
338             val abi = "")             val abi = "")
339    
340    
# Line 344  Line 345 
345      structure Vararg = IA32VarargCCallFn(      structure Vararg = IA32VarargCCallFn(
346                         structure T = X86MLTree                         structure T = X86MLTree
347                         fun ix x = x                         fun ix x = x
348                         val fast_floating_point = ref true                         val fast_floating_point = fast_floating_point
349                         val abi = "")                         val abi = ""
350                           fun push e = T.EXT(X86InstrExt.PUSHL e)
351                           val leave = T.EXT X86InstrExt.LEAVE
352                           )
353    
354  structure TestSA =  structure TestSA =
355    struct    struct
356    
357      val wordTy = 64      val wordTy = 32
   
     fun codegen (functionName, target, proto, initStms, args) = let  
         val _ = Label.reset()  
   
         val [functionName, target] = List.map Label.global [functionName, target]  
358    
359        fun gen (functionName, stms, result) = let
360          val insnStrm = FlowGraph.build()          val insnStrm = FlowGraph.build()
         (* construct the C call *)  
         val {result, callseq} = CCalls.genCall {  
                    name=T.LABEL target,  
                    paramAlloc=fn _ => false,  
                    structRet=fn _ => T.REG (64, Cells.eax),  
                    saveRestoreDedicated=fn _ => {save=[], restore=[]},  
                    callComment=NONE,  
                    proto=proto,  
                    args=args}  
   
         fun wordLit i = T.LI (T.I.fromInt (wordTy, i))  
   
         val stms = List.concat [  
                    [T.EXT(X86InstrExt.PUSHL(T.REG(64, Cells.ebp))),  
                     T.COPY (wordTy, [Cells.ebp], [Cells.esp])],  
                    initStms,  
                    callseq,  
                    [T.EXT(X86InstrExt.LEAVE)],  
                    [T.RET []]]  
   
361          val stream as X86Stream.STREAM          val stream as X86Stream.STREAM
362             { beginCluster,  (* start a cluster *)             { beginCluster,  (* start a cluster *)
363               endCluster,    (* end a cluster *)               endCluster,    (* end a cluster *)
# Line 401  Line 381 
381          val cfg = X86RA.run cfg          val cfg = X86RA.run cfg
382          val cfg = X86Expand.run cfg          val cfg = X86Expand.run cfg
383          in          in
384           (cfg, stream)        (* end the cluster *)          (cfg, stream)
385           end (* gen *)
386    
387        fun codegen (functionName, target, proto, initStms, args) = let
388            val [functionName, target] = List.map Label.global [functionName, target]
389    
390            (* construct the C call *)
391            val {result, callseq} = CCalls.genCall {
392                       name=T.LABEL target,
393                       paramAlloc=fn _ => false,
394                       structRet=fn _ => T.REG (32, Cells.eax),
395                       saveRestoreDedicated=fn _ => {save=[], restore=[]},
396                       callComment=NONE,
397                       proto=proto,
398                       args=args}
399    
400            fun wordLit i = T.LI (T.I.fromInt (wordTy, i))
401    
402            val stms = List.concat [
403                       [T.EXT(X86InstrExt.PUSHL(T.REG(32, Cells.ebp))),
404                        T.COPY (wordTy, [Cells.ebp], [Cells.esp])],
405                       initStms,
406                       callseq,
407                       [T.EXT(X86InstrExt.LEAVE)],
408                       [T.RET []]]
409    
410    
411            in
412               gen(functionName, stms, result)
413         end (* codegen *)         end (* codegen *)
414    
415      fun dumpOutput (cfg, stream) = let      fun dumpOutput (cfg, stream) = let
# Line 412  Line 420 
420            X86Emit.asmEmit (cfg, blocks)            X86Emit.asmEmit (cfg, blocks)
421          end (* dumpOutput *)          end (* dumpOutput *)
422    
423       fun vararg _ = let
424               val _ = Label.reset()
425               val (lab, stms) = Vararg.genVarargs()
426               val asmOutStrm = TextIO.openOut "mlrisc.s"
427               fun doit () = dumpOutput(gen(lab, stms, [T.GPR (T.REG (wordTy, C.eax))]))
428               val _ = AsmStream.withStream asmOutStrm doit ()
429               val _ = TextIO.closeOut asmOutStrm
430               in
431                  0
432               end
433    
434    end    end
435    
436      (* machine-specific data *)      (* machine-specific data *)

Legend:
Removed from v.3049  
changed lines
  Added in v.3054

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0