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 730, Fri Nov 10 14:04:49 2000 UTC revision 731, Fri Nov 10 22:57:45 2000 UTC
# Line 9  Line 9 
9                        structure Shuffle : X86SHUFFLE                        structure Shuffle : X86SHUFFLE
10                           where I = Instr                           where I = Instr
11    
12  (*#line 243.7 "x86/x86.md"*)  (*#line 250.7 "x86/x86.md"*)
13                        structure MemRegs : MEMORY_REGISTERS where I=Instr                        structure MemRegs : MEMORY_REGISTERS where I=Instr
14                       ) : INSTRUCTION_EMITTER =                       ) : INSTRUCTION_EMITTER =
15  struct  struct
# Line 238  Line 238 
238       | asm_funOp (I.FCHS) = "fchs"       | asm_funOp (I.FCHS) = "fchs"
239       | asm_funOp (I.FSIN) = "fsin"       | asm_funOp (I.FSIN) = "fsin"
240       | asm_funOp (I.FCOS) = "fcos"       | asm_funOp (I.FCOS) = "fcos"
241       | asm_funOp (I.FTAN) = "ftan"       | asm_funOp (I.FPTAN) = "fptan"
242         | asm_funOp (I.FPATAN) = "fpatan"
243       | asm_funOp (I.FSCALE) = "fscale"       | asm_funOp (I.FSCALE) = "fscale"
244       | asm_funOp (I.FRNDINT) = "frndint"       | asm_funOp (I.FRNDINT) = "frndint"
245       | asm_funOp (I.FSQRT) = "fsqrt"       | asm_funOp (I.FSQRT) = "fsqrt"
# Line 252  Line 253 
253       | asm_fenvOp (I.FSTENV) = "fstenv"       | asm_fenvOp (I.FSTENV) = "fstenv"
254       | asm_fenvOp (I.FNSTENV) = "fnstenv"       | asm_fenvOp (I.FNSTENV) = "fnstenv"
255     and emit_fenvOp x = emit (asm_fenvOp x)     and emit_fenvOp x = emit (asm_fenvOp x)
256       and asm_fsize (I.FP32) = "s"
257         | asm_fsize (I.FP64) = "l"
258         | asm_fsize (I.FP80) = "t"
259       and emit_fsize x = emit (asm_fsize x)
260       and asm_isize (I.I8) = "8"
261         | asm_isize (I.I16) = "16"
262         | asm_isize (I.I32) = "32"
263         | asm_isize (I.I64) = "64"
264       and emit_isize x = emit (asm_isize x)
265    
266  (*#line 245.6 "x86/x86.md"*)  (*#line 252.6 "x86/x86.md"*)
267     val memReg = MemRegs.memReg regmap     val memReg = MemRegs.memReg regmap
268    
269  (*#line 246.6 "x86/x86.md"*)  (*#line 253.6 "x86/x86.md"*)
270     fun emitInt32 i = let     fun emitInt32 i = let
271    
272  (*#line 247.10 "x86/x86.md"*)  (*#line 254.10 "x86/x86.md"*)
273            val s = Int32.toString i            val s = Int32.toString i
274    
275  (*#line 248.10 "x86/x86.md"*)  (*#line 255.10 "x86/x86.md"*)
276            val s = (if (i >= 0)            val s = (if (i >= 0)
277                   then s                   then s
278                   else ("-" ^ (String.substring (s, 1, (size s) - 1))))                   else ("-" ^ (String.substring (s, 1, (size s) - 1))))
# Line 270  Line 280 
280         end         end
281    
282    
283  (*#line 251.6 "x86/x86.md"*)  (*#line 258.6 "x86/x86.md"*)
284       val {low=SToffset, ...} = C.cellRange C.FP
285    
286    (*#line 260.6 "x86/x86.md"*)
287     fun emitScale 0 = emit "1"     fun emitScale 0 = emit "1"
288       | emitScale 1 = emit "2"       | emitScale 1 = emit "2"
289       | emitScale 2 = emit "4"       | emitScale 2 = emit "4"
# Line 293  Line 306 
306        | I.Direct r => emit_GP r        | I.Direct r => emit_GP r
307        | I.MemReg r => emit_operand (memReg opn)        | I.MemReg r => emit_operand (memReg opn)
308        | I.ST f => emit_FP f        | I.ST f => emit_FP f
309          | I.FPR f =>
310            ( emit "%f";
311            emit (Int.toString ((regmap f) - SToffset)))
312        | I.FDirect f => emit_operand (memReg opn)        | I.FDirect f => emit_operand (memReg opn)
313        | I.Displace{base, disp, mem, ...} =>        | I.Displace{base, disp, mem, ...} =>
314          ( emit_disp disp;          ( emit_disp disp;
# Line 323  Line 339 
339       | emit_disp (I.ImmedLabel lexp) = emit_labexp lexp       | emit_disp (I.ImmedLabel lexp) = emit_labexp lexp
340       | emit_disp _ = error "emit_disp"       | emit_disp _ = error "emit_disp"
341    
342  (*#line 294.7 "x86/x86.md"*)  (*#line 304.7 "x86/x86.md"*)
343     fun stupidGas (I.ImmedLabel lexp) = emit_labexp lexp     fun stupidGas (I.ImmedLabel lexp) = emit_labexp lexp
344       | stupidGas opnd =       | stupidGas opnd =
345         ( emit "*";         ( emit "*";
346         emit_operand opnd )         emit_operand opnd )
347    
348  (*#line 298.7 "x86/x86.md"*)  (*#line 308.7 "x86/x86.md"*)
349     fun isMemOpnd (I.MemReg _) = true     fun isMemOpnd (I.MemReg _) = true
350       | isMemOpnd (I.FDirect f) = true       | isMemOpnd (I.FDirect f) = true
351       | isMemOpnd (I.LabelEA _) = true       | isMemOpnd (I.LabelEA _) = true
# Line 337  Line 353 
353       | isMemOpnd (I.Indexed _) = true       | isMemOpnd (I.Indexed _) = true
354       | isMemOpnd _ = false       | isMemOpnd _ = false
355    
356  (*#line 304.7 "x86/x86.md"*)  (*#line 314.7 "x86/x86.md"*)
357     fun chop fbinOp = let     fun chop fbinOp = let
358    
359  (*#line 305.15 "x86/x86.md"*)  (*#line 315.15 "x86/x86.md"*)
360            val n = size fbinOp            val n = size fbinOp
361         in         in
362            (            (
# Line 351  Line 367 
367         end         end
368    
369    
370  (*#line 311.7 "x86/x86.md"*)  (*#line 322.7 "x86/x86.md"*)
371       fun emit_fbinaryOp (binOp, src, dst) = (if (isMemOpnd src)
372              then
373              ( emit_fbinOp binOp;
374              emit "\t";
375              emit_operand src )
376              else
377              ( emit (chop (asm_fbinOp binOp));
378              emit "\t";
379    
380              (
381               case (src, dst) of
382               (_, I.ST 32) =>
383               ( emit_operand src;
384               emit ", %st" )
385             | (I.ST 32, I.ST _) =>
386               ( emit "%st, ";
387               emit_operand dst )
388             | _ => error "emit_fbinaryOp"
389              )))
390    
391    (*#line 332.7 "x86/x86.md"*)
392     val emit_dst = emit_operand     val emit_dst = emit_operand
393    
394  (*#line 312.7 "x86/x86.md"*)  (*#line 333.7 "x86/x86.md"*)
395     val emit_src = emit_operand     val emit_src = emit_operand
396    
397  (*#line 313.7 "x86/x86.md"*)  (*#line 334.7 "x86/x86.md"*)
398     val emit_opnd = emit_operand     val emit_opnd = emit_operand
399    
400  (*#line 314.7 "x86/x86.md"*)  (*#line 335.7 "x86/x86.md"*)
401     val emit_opnd8 = emit_operand8     val emit_opnd8 = emit_operand8
402    
403  (*#line 315.7 "x86/x86.md"*)  (*#line 336.7 "x86/x86.md"*)
404     val emit_rsrc = emit_operand     val emit_rsrc = emit_operand
405    
406  (*#line 316.7 "x86/x86.md"*)  (*#line 337.7 "x86/x86.md"*)
407     val emit_lsrc = emit_operand     val emit_lsrc = emit_operand
408    
409  (*#line 317.7 "x86/x86.md"*)  (*#line 338.7 "x86/x86.md"*)
410     val emit_addr = emit_operand     val emit_addr = emit_operand
411    
412  (*#line 318.7 "x86/x86.md"*)  (*#line 339.7 "x86/x86.md"*)
413     val emit_src1 = emit_operand     val emit_src1 = emit_operand
414    
415    (*#line 340.7 "x86/x86.md"*)
416       val emit_ea = emit_operand
417     fun emitInstr' instr =     fun emitInstr' instr =
418         (         (
419          case instr of          case instr of
# Line 521  Line 561 
561        | I.INTO => emit "into"        | I.INTO => emit "into"
562        | I.COPY{dst, src, tmp} => emitInstrs (Shuffle.shuffle {regmap=regmap, tmp=tmp, dst=dst, src=src})        | I.COPY{dst, src, tmp} => emitInstrs (Shuffle.shuffle {regmap=regmap, tmp=tmp, dst=dst, src=src})
563        | I.FCOPY{dst, src, tmp} => emitInstrs (Shuffle.shufflefp {regmap=regmap, tmp=tmp, dst=dst, src=src})        | I.FCOPY{dst, src, tmp} => emitInstrs (Shuffle.shufflefp {regmap=regmap, tmp=tmp, dst=dst, src=src})
564        | I.FBINARY{binOp, src, dst} => (if (isMemOpnd src)        | I.FBINARY{binOp, src, dst} => emit_fbinaryOp (binOp, src, dst)
            then  
            ( emit_fbinOp binOp;  
            emit "\t";  
            emit_src src )  
            else  
            ( emit (chop (asm_fbinOp binOp));  
            emit "\t";  
            emit_src src;  
            emit ", ";  
            emit_dst dst ))  
565        | I.FIBINARY{binOp, src} =>        | I.FIBINARY{binOp, src} =>
566          ( emit_fibinOp binOp;          ( emit_fibinOp binOp;
567          emit "\t";          emit "\t";
568          emit_src src )          emit_src src )
569        | I.FUNARY funOp => emit_funOp funOp        | I.FUNARY funOp => emit_funOp funOp
570          | I.FUCOM operand =>
571            ( emit "fucom\t";
572            emit_operand operand )
573          | I.FUCOMP operand =>
574            ( emit "fucomp\t";
575            emit_operand operand )
576        | I.FUCOMPP => emit "fucompp"        | I.FUCOMPP => emit "fucompp"
577        | I.FCOMPP => emit "fcompp"        | I.FCOMPP => emit "fcompp"
578        | I.FXCH{opnd} =>        | I.FXCH{opnd} =>
579          ( emit "fxch\t";          ( emit "fxch\t";
580          (if (opnd = (C.ST 1))          emit_FP opnd )
            then ()  
            else (emit_FP opnd)))  
581        | I.FSTPL operand =>        | I.FSTPL operand =>
582            (
583             case operand of
584             I.ST _ =>
585             ( emit "fstp\t";
586             emit_operand operand )
587           | _ =>
588          ( emit "fstpl\t";          ( emit "fstpl\t";
589          emit_operand operand )          emit_operand operand )
590            )
591        | I.FSTPS operand =>        | I.FSTPS operand =>
592          ( emit "fstps\t";          ( emit "fstps\t";
593          emit_operand operand )          emit_operand operand )
# Line 554  Line 595 
595          ( emit "fstps\t";          ( emit "fstps\t";
596          emit_operand operand )          emit_operand operand )
597        | I.FSTL operand =>        | I.FSTL operand =>
598            (
599             case operand of
600             I.ST _ =>
601             ( emit "fst\t";
602             emit_operand operand )
603           | _ =>
604          ( emit "fstl\t";          ( emit "fstl\t";
605          emit_operand operand )          emit_operand operand )
606            )
607        | I.FSTS operand =>        | I.FSTS operand =>
608          ( emit "fsts\t";          ( emit "fsts\t";
609          emit_operand operand )          emit_operand operand )
# Line 567  Line 615 
615        | I.FLDPI => emit "fldpi"        | I.FLDPI => emit "fldpi"
616        | I.FLDZ => emit "fldz"        | I.FLDZ => emit "fldz"
617        | I.FLDL operand =>        | I.FLDL operand =>
618            (
619             case operand of
620             I.ST _ =>
621             ( emit "fld\t";
622             emit_operand operand )
623           | _ =>
624          ( emit "fldl\t";          ( emit "fldl\t";
625          emit_operand operand )          emit_operand operand )
626            )
627        | I.FLDS operand =>        | I.FLDS operand =>
628          ( emit "flds\t";          ( emit "flds\t";
629          emit_operand operand )          emit_operand operand )
# Line 589  Line 644 
644          ( emit_fenvOp fenvOp;          ( emit_fenvOp fenvOp;
645          emit "\t";          emit "\t";
646          emit_opnd opnd )          emit_opnd opnd )
647          | I.FMOVE{fsize, src, dst} =>
648            ( emit "fmove";
649            emit_fsize fsize;
650            emit "\t";
651            emit_src src;
652            emit ", ";
653            emit_dst dst )
654          | I.FILOAD{isize, ea, dst} =>
655            ( emit "fiload";
656            emit_isize isize;
657            emit "\t";
658            emit_ea ea;
659            emit ", ";
660            emit_dst dst )
661          | I.FBINOP{fsize, binOp, lsrc, rsrc, dst} =>
662            ( emit_fbinOp binOp;
663            emit_fsize fsize;
664            emit "\t";
665            emit_lsrc lsrc;
666            emit ", ";
667            emit_rsrc rsrc;
668            emit ", ";
669            emit_dst dst )
670          | I.FIBINOP{isize, binOp, lsrc, rsrc, dst} =>
671            ( emit_fibinOp binOp;
672            emit_isize isize;
673            emit "\t";
674            emit_lsrc lsrc;
675            emit ", ";
676            emit_rsrc rsrc;
677            emit ", ";
678            emit_dst dst )
679          | I.FUNOP{fsize, unOp, src, dst} =>
680            ( emit_funOp unOp;
681            emit_fsize fsize;
682            emit "\t";
683            emit_src src;
684            emit ", ";
685            emit_dst dst )
686          | I.FCMP{fsize, lsrc, rsrc} =>
687            ( emit "fcmp";
688            emit_fsize fsize;
689            emit "\t";
690            emit_lsrc lsrc;
691            emit ", ";
692            emit_rsrc rsrc )
693        | I.SAHF => emit "sahf"        | I.SAHF => emit "sahf"
694        | I.ANNOTATION{i, a} =>        | I.ANNOTATION{i, a} =>
695          ( comment (Annotations.toString a);          ( comment (Annotations.toString a);

Legend:
Removed from v.730  
changed lines
  Added in v.731

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