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 /sml/trunk/src/MLRISC/x86/emit/x86Asm.sml
ViewVC logotype

Diff of /sml/trunk/src/MLRISC/x86/emit/x86Asm.sml

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

revision 1155, Wed Mar 20 20:52:51 2002 UTC revision 1156, Thu Mar 21 22:01:11 2002 UTC
# Line 13  Line 13 
13                        structure MLTreeEval : MLTREE_EVAL                        structure MLTreeEval : MLTREE_EVAL
14                           where T = Instr.T                           where T = Instr.T
15    
16  (*#line 509.7 "x86/x86.mdl"*)  (*#line 512.7 "x86/x86.mdl"*)
17                        structure MemRegs : MEMORY_REGISTERS where I=Instr                        structure MemRegs : MEMORY_REGISTERS where I=Instr
18    
19  (*#line 510.7 "x86/x86.mdl"*)  (*#line 513.7 "x86/x86.mdl"*)
20                        val memRegBase : CellsBasis.cell option                        val memRegBase : CellsBasis.cell option
21                       ) : INSTRUCTION_EMITTER =                       ) : INSTRUCTION_EMITTER =
22  struct  struct
# Line 164  Line 164 
164       | asm_binaryOp (I.LOCK_XADDW) = "lock\n\txaddw"       | asm_binaryOp (I.LOCK_XADDW) = "lock\n\txaddw"
165       | asm_binaryOp (I.LOCK_XADDL) = "lock\n\txaddl"       | asm_binaryOp (I.LOCK_XADDL) = "lock\n\txaddl"
166     and emit_binaryOp x = emit (asm_binaryOp x)     and emit_binaryOp x = emit (asm_binaryOp x)
167     and asm_multDivOp (I.MULL1) = "mull"     and asm_multDivOp (I.IMULL1) = "imull"
168         | asm_multDivOp (I.MULL1) = "mull"
169       | asm_multDivOp (I.IDIVL1) = "idivl"       | asm_multDivOp (I.IDIVL1) = "idivl"
170       | asm_multDivOp (I.DIVL1) = "divl"       | asm_multDivOp (I.DIVL1) = "divl"
171     and emit_multDivOp x = emit (asm_multDivOp x)     and emit_multDivOp x = emit (asm_multDivOp x)
# Line 185  Line 186 
186       | asm_unaryOp (I.LOCK_NEGL) = "lock\n\tnegl"       | asm_unaryOp (I.LOCK_NEGL) = "lock\n\tnegl"
187       | asm_unaryOp (I.LOCK_NOTL) = "lock\n\tnotl"       | asm_unaryOp (I.LOCK_NOTL) = "lock\n\tnotl"
188     and emit_unaryOp x = emit (asm_unaryOp x)     and emit_unaryOp x = emit (asm_unaryOp x)
189       and asm_shiftOp (I.SHLDL) = "shldl"
190         | asm_shiftOp (I.SHRDL) = "shrdl"
191       and emit_shiftOp x = emit (asm_shiftOp x)
192     and asm_bitOp (I.BTW) = "btw"     and asm_bitOp (I.BTW) = "btw"
193       | asm_bitOp (I.BTL) = "btl"       | asm_bitOp (I.BTL) = "btl"
194       | asm_bitOp (I.LOCK_BTW) = "lock\n\tbtw"       | asm_bitOp (I.LOCK_BTW) = "lock\n\tbtw"
# Line 272  Line 276 
276       | asm_isize (I.I64) = "64"       | asm_isize (I.I64) = "64"
277     and emit_isize x = emit (asm_isize x)     and emit_isize x = emit (asm_isize x)
278    
279  (*#line 512.6 "x86/x86.mdl"*)  (*#line 515.6 "x86/x86.mdl"*)
280     fun memReg r = MemRegs.memReg {reg=r, base=Option.valOf memRegBase}     fun memReg r = MemRegs.memReg {reg=r, base=Option.valOf memRegBase}
281    
282  (*#line 513.6 "x86/x86.mdl"*)  (*#line 516.6 "x86/x86.mdl"*)
283     fun emitInt32 i =     fun emitInt32 i =
284         let         let
285  (*#line 514.10 "x86/x86.mdl"*)  (*#line 517.10 "x86/x86.mdl"*)
286             val s = Int32.toString i             val s = Int32.toString i
287    
288  (*#line 515.10 "x86/x86.mdl"*)  (*#line 518.10 "x86/x86.mdl"*)
289             val s = (if (i >= 0)             val s = (if (i >= 0)
290                    then s                    then s
291                    else ("-" ^ (String.substring (s, 1, (size s) - 1))))                    else ("-" ^ (String.substring (s, 1, (size s) - 1))))
292         in emit s         in emit s
293         end         end
294    
295  (*#line 518.6 "x86/x86.mdl"*)  (*#line 521.6 "x86/x86.mdl"*)
296     val {low=SToffset, ...} = C.cellRange CellsBasis.FP     val {low=SToffset, ...} = C.cellRange CellsBasis.FP
297    
298  (*#line 520.6 "x86/x86.mdl"*)  (*#line 523.6 "x86/x86.mdl"*)
299     fun emitScale 0 = emit "1"     fun emitScale 0 = emit "1"
300       | emitScale 1 = emit "2"       | emitScale 1 = emit "2"
301       | emitScale 2 = emit "4"       | emitScale 2 = emit "4"
# Line 345  Line 349 
349       | emit_disp (I.ImmedLabel lexp) = emit_labexp lexp       | emit_disp (I.ImmedLabel lexp) = emit_labexp lexp
350       | emit_disp _ = error "emit_disp"       | emit_disp _ = error "emit_disp"
351    
352  (*#line 565.7 "x86/x86.mdl"*)  (*#line 568.7 "x86/x86.mdl"*)
353     fun stupidGas (I.ImmedLabel lexp) = emit_labexp lexp     fun stupidGas (I.ImmedLabel lexp) = emit_labexp lexp
354       | stupidGas opnd =       | stupidGas opnd =
355         ( emit "*";         ( emit "*";
356           emit_operand opnd )           emit_operand opnd )
357    
358  (*#line 569.7 "x86/x86.mdl"*)  (*#line 572.7 "x86/x86.mdl"*)
359     fun isMemOpnd (I.MemReg _) = true     fun isMemOpnd (I.MemReg _) = true
360       | isMemOpnd (I.FDirect f) = true       | isMemOpnd (I.FDirect f) = true
361       | isMemOpnd (I.LabelEA _) = true       | isMemOpnd (I.LabelEA _) = true
# Line 359  Line 363 
363       | isMemOpnd (I.Indexed _) = true       | isMemOpnd (I.Indexed _) = true
364       | isMemOpnd _ = false       | isMemOpnd _ = false
365    
366  (*#line 575.7 "x86/x86.mdl"*)  (*#line 578.7 "x86/x86.mdl"*)
367     fun chop fbinOp =     fun chop fbinOp =
368         let         let
369  (*#line 576.15 "x86/x86.mdl"*)  (*#line 579.15 "x86/x86.mdl"*)
370             val n = size fbinOp             val n = size fbinOp
371         in         in
372            (case Char.toLower (String.sub (fbinOp, n - 1)) of            (case Char.toLower (String.sub (fbinOp, n - 1)) of
# Line 371  Line 375 
375            )            )
376         end         end
377    
378  (*#line 582.7 "x86/x86.mdl"*)  (*#line 585.7 "x86/x86.mdl"*)
379     fun isST0 (I.ST r) = (CellsBasis.registerNum r) = 0     fun isST0 (I.ST r) = (CellsBasis.registerNum r) = 0
380       | isST0 _ = false       | isST0 _ = false
381    
382  (*#line 586.7 "x86/x86.mdl"*)  (*#line 589.7 "x86/x86.mdl"*)
383     fun emit_fbinaryOp (binOp, src, dst) = (if (isMemOpnd src)     fun emit_fbinaryOp (binOp, src, dst) = (if (isMemOpnd src)
384            then            then
385            ( emit_fbinOp binOp;            ( emit_fbinOp binOp;
# Line 395  Line 399 
399              | _ => error "emit_fbinaryOp"              | _ => error "emit_fbinaryOp"
400              )))              )))
401    
402  (*#line 596.7 "x86/x86.mdl"*)  (*#line 599.7 "x86/x86.mdl"*)
403     val emit_dst = emit_operand     val emit_dst = emit_operand
404    
405  (*#line 597.7 "x86/x86.mdl"*)  (*#line 600.7 "x86/x86.mdl"*)
406     val emit_src = emit_operand     val emit_src = emit_operand
407    
408  (*#line 598.7 "x86/x86.mdl"*)  (*#line 601.7 "x86/x86.mdl"*)
409     val emit_opnd = emit_operand     val emit_opnd = emit_operand
410    
411  (*#line 599.7 "x86/x86.mdl"*)  (*#line 602.7 "x86/x86.mdl"*)
412     val emit_opnd8 = emit_operand8     val emit_opnd8 = emit_operand8
413    
414  (*#line 600.7 "x86/x86.mdl"*)  (*#line 603.7 "x86/x86.mdl"*)
415     val emit_rsrc = emit_operand     val emit_rsrc = emit_operand
416    
417  (*#line 601.7 "x86/x86.mdl"*)  (*#line 604.7 "x86/x86.mdl"*)
418     val emit_lsrc = emit_operand     val emit_lsrc = emit_operand
419    
420  (*#line 602.7 "x86/x86.mdl"*)  (*#line 605.7 "x86/x86.mdl"*)
421     val emit_addr = emit_operand     val emit_addr = emit_operand
422    
423  (*#line 603.7 "x86/x86.mdl"*)  (*#line 606.7 "x86/x86.mdl"*)
424     val emit_src1 = emit_operand     val emit_src1 = emit_operand
425    
426  (*#line 604.7 "x86/x86.mdl"*)  (*#line 607.7 "x86/x86.mdl"*)
427     val emit_ea = emit_operand     val emit_ea = emit_operand
428    
429    (*#line 608.7 "x86/x86.mdl"*)
430       val emit_count = emit_operand
431     fun emitInstr' instr =     fun emitInstr' instr =
432         (case instr of         (case instr of
433           I.NOP => emit "nop"           I.NOP => emit "nop"
# Line 516  Line 523 
523               emit ", ";               emit ", ";
524               emit_dst dst )               emit_dst dst )
525           )           )
526           | I.SHIFT{shiftOp, src, dst, count} =>
527             (case count of
528               I.Direct ecx =>
529               ( emit_shiftOp shiftOp;
530                 emit "\t";
531                 emit_src src;
532                 emit ", ";
533                 emit_dst dst )
534             | _ =>
535               ( emit_shiftOp shiftOp;
536                 emit "\t";
537                 emit_src src;
538                 emit ", ";
539                 emit_count count;
540                 emit ", ";
541                 emit_dst dst )
542             )
543         | I.CMPXCHG{lock, sz, src, dst} =>         | I.CMPXCHG{lock, sz, src, dst} =>
544           ( (if lock           ( (if lock
545                then (emit "lock\n\t")                then (emit "lock\n\t")
# Line 537  Line 561 
561             emit "\t";             emit "\t";
562             emit_src src )             emit_src src )
563         | I.MUL3{dst, src2, src1} =>         | I.MUL3{dst, src2, src1} =>
564           ( emit "imul\t$";           ( emit "imull\t$";
565             emitInt32 src2;             emitInt32 src2;
566             emit ", ";             emit ", ";
567             emit_src1 src1;             emit_src1 src1;
# Line 589  Line 613 
613             emit_operand operand )             emit_operand operand )
614         | I.FUCOMPP => emit "fucompp"         | I.FUCOMPP => emit "fucompp"
615         | I.FCOMPP => emit "fcompp"         | I.FCOMPP => emit "fcompp"
616           | I.FCOMI operand =>
617             ( emit "fcomi\t";
618               emit_operand operand )
619           | I.FCOMIP operand =>
620             ( emit "fcomip\t";
621               emit_operand operand )
622           | I.FUCOMI operand =>
623             ( emit "fucomi\t";
624               emit_operand operand )
625           | I.FUCOMIP operand =>
626             ( emit "fucomip\t";
627               emit_operand operand )
628         | I.FXCH{opnd} =>         | I.FXCH{opnd} =>
629           ( emit "fxch\t";           ( emit "fxch\t";
630             emitCell opnd )             emitCell opnd )
# Line 694  Line 730 
730             emit_src src;             emit_src src;
731             emit ", ";             emit ", ";
732             emit_dst dst )             emit_dst dst )
733         | I.FCMP{fsize, lsrc, rsrc} =>         | I.FCMP{i, fsize, lsrc, rsrc} =>
734           ( emit "fcmp";           ( (if i
735             emit_fsize fsize;                then (emit "fcmpi")
736                  else (emit "fcmp"));
737    
738               ( emit_fsize fsize;
739             emit "\t";             emit "\t";
740             emit_lsrc lsrc;             emit_lsrc lsrc;
741             emit ", ";             emit ", ";
742             emit_rsrc rsrc )               emit_rsrc rsrc ) )
743         | I.SAHF => emit "sahf"         | I.SAHF => emit "sahf"
744         | I.LAHF => emit "lahf"         | I.LAHF => emit "lahf"
745         | I.SOURCE{} => emit "source"         | I.SOURCE{} => emit "source"

Legend:
Removed from v.1155  
changed lines
  Added in v.1156

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