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 796, Tue Mar 6 00:04:33 2001 UTC revision 797, Fri Mar 16 00:00:17 2001 UTC
# Line 9  Line 9 
9                        structure Shuffle : X86SHUFFLE                        structure Shuffle : X86SHUFFLE
10                           where I = Instr                           where I = Instr
11    
12  (*#line 508.7 "x86/x86.mdl"*)  (*#line 507.7 "x86/x86.mdl"*)
13                        structure MemRegs : MEMORY_REGISTERS where I=Instr                        structure MemRegs : MEMORY_REGISTERS where I=Instr
14                       ) : INSTRUCTION_EMITTER =                       ) : INSTRUCTION_EMITTER =
15  struct  struct
# Line 152  Line 152 
152       | asm_binaryOp (I.LOCK_XADDB) = "lock\n\txaddb"       | asm_binaryOp (I.LOCK_XADDB) = "lock\n\txaddb"
153       | asm_binaryOp (I.LOCK_XADDW) = "lock\n\txaddw"       | asm_binaryOp (I.LOCK_XADDW) = "lock\n\txaddw"
154       | asm_binaryOp (I.LOCK_XADDL) = "lock\n\txaddl"       | asm_binaryOp (I.LOCK_XADDL) = "lock\n\txaddl"
      | asm_binaryOp (I.LOCK_CMPXCHGB) = "lock\n\tcmpxchgb"  
      | asm_binaryOp (I.LOCK_CMPXCHGW) = "lock\n\tcmpxchgw"  
      | asm_binaryOp (I.LOCK_CMPXCHGL) = "lock\n\tcmpxchgl"  
155     and emit_binaryOp x = emit (asm_binaryOp x)     and emit_binaryOp x = emit (asm_binaryOp x)
156     and asm_multDivOp (I.MULL) = "mull"     and asm_multDivOp (I.MULL) = "mull"
157       | asm_multDivOp (I.IDIVL) = "idivl"       | asm_multDivOp (I.IDIVL) = "idivl"
# Line 164  Line 161 
161       | asm_unaryOp (I.INCL) = "incl"       | asm_unaryOp (I.INCL) = "incl"
162       | asm_unaryOp (I.NEGL) = "negl"       | asm_unaryOp (I.NEGL) = "negl"
163       | asm_unaryOp (I.NOTL) = "notl"       | asm_unaryOp (I.NOTL) = "notl"
164         | asm_unaryOp (I.DECW) = "decw"
165         | asm_unaryOp (I.INCW) = "incw"
166         | asm_unaryOp (I.NEGW) = "negw"
167       | asm_unaryOp (I.NOTW) = "notw"       | asm_unaryOp (I.NOTW) = "notw"
168         | asm_unaryOp (I.DECB) = "decb"
169         | asm_unaryOp (I.INCB) = "incb"
170         | asm_unaryOp (I.NEGB) = "negb"
171       | asm_unaryOp (I.NOTB) = "notb"       | asm_unaryOp (I.NOTB) = "notb"
172       | asm_unaryOp (I.LOCK_DECL) = "lock\n\tdecl"       | asm_unaryOp (I.LOCK_DECL) = "lock\n\tdecl"
173       | asm_unaryOp (I.LOCK_INCL) = "lock\n\tincl"       | asm_unaryOp (I.LOCK_INCL) = "lock\n\tincl"
# Line 258  Line 261 
261       | asm_isize (I.I64) = "64"       | asm_isize (I.I64) = "64"
262     and emit_isize x = emit (asm_isize x)     and emit_isize x = emit (asm_isize x)
263    
264  (*#line 510.6 "x86/x86.mdl"*)  (*#line 509.6 "x86/x86.mdl"*)
265     val memReg = MemRegs.memReg     val memReg = MemRegs.memReg
266    
267  (*#line 511.6 "x86/x86.mdl"*)  (*#line 510.6 "x86/x86.mdl"*)
268     fun emitInt32 i =     fun emitInt32 i =
269         let         let
270  (*#line 512.10 "x86/x86.mdl"*)  (*#line 511.10 "x86/x86.mdl"*)
271             val s = Int32.toString i             val s = Int32.toString i
272    
273  (*#line 513.10 "x86/x86.mdl"*)  (*#line 512.10 "x86/x86.mdl"*)
274             val s = (if (i >= 0)             val s = (if (i >= 0)
275                    then s                    then s
276                    else ("-" ^ (String.substring (s, 1, (size s) - 1))))                    else ("-" ^ (String.substring (s, 1, (size s) - 1))))
277         in emit s         in emit s
278         end         end
279    
280  (*#line 516.6 "x86/x86.mdl"*)  (*#line 515.6 "x86/x86.mdl"*)
281     val {low=SToffset, ...} = C.cellRange C.FP     val {low=SToffset, ...} = C.cellRange C.FP
282    
283  (*#line 518.6 "x86/x86.mdl"*)  (*#line 517.6 "x86/x86.mdl"*)
284     fun emitScale 0 = emit "1"     fun emitScale 0 = emit "1"
285       | emitScale 1 = emit "2"       | emitScale 1 = emit "2"
286       | emitScale 2 = emit "4"       | emitScale 2 = emit "4"
# Line 331  Line 334 
334       | emit_disp (I.ImmedLabel lexp) = emit_labexp lexp       | emit_disp (I.ImmedLabel lexp) = emit_labexp lexp
335       | emit_disp _ = error "emit_disp"       | emit_disp _ = error "emit_disp"
336    
337  (*#line 562.7 "x86/x86.mdl"*)  (*#line 561.7 "x86/x86.mdl"*)
338     fun stupidGas (I.ImmedLabel lexp) = emit_labexp lexp     fun stupidGas (I.ImmedLabel lexp) = emit_labexp lexp
339       | stupidGas opnd =       | stupidGas opnd =
340         ( emit "*";         ( emit "*";
341           emit_operand opnd )           emit_operand opnd )
342    
343  (*#line 566.7 "x86/x86.mdl"*)  (*#line 565.7 "x86/x86.mdl"*)
344     fun isMemOpnd (I.MemReg _) = true     fun isMemOpnd (I.MemReg _) = true
345       | isMemOpnd (I.FDirect f) = true       | isMemOpnd (I.FDirect f) = true
346       | isMemOpnd (I.LabelEA _) = true       | isMemOpnd (I.LabelEA _) = true
# Line 345  Line 348 
348       | isMemOpnd (I.Indexed _) = true       | isMemOpnd (I.Indexed _) = true
349       | isMemOpnd _ = false       | isMemOpnd _ = false
350    
351  (*#line 572.7 "x86/x86.mdl"*)  (*#line 571.7 "x86/x86.mdl"*)
352     fun chop fbinOp =     fun chop fbinOp =
353         let         let
354  (*#line 573.15 "x86/x86.mdl"*)  (*#line 572.15 "x86/x86.mdl"*)
355             val n = size fbinOp             val n = size fbinOp
356         in         in
357            (case Char.toLower (String.sub (fbinOp, n - 1)) of            (case Char.toLower (String.sub (fbinOp, n - 1)) of
# Line 357  Line 360 
360            )            )
361         end         end
362    
363  (*#line 579.7 "x86/x86.mdl"*)  (*#line 578.7 "x86/x86.mdl"*)
364     fun isST32 (I.ST r) = (C.registerNum r) = 32     fun isST32 (I.ST r) = (C.registerNum r) = 32
365       | isST32 _ = false       | isST32 _ = false
366    
367  (*#line 583.7 "x86/x86.mdl"*)  (*#line 582.7 "x86/x86.mdl"*)
368     fun emit_fbinaryOp (binOp, src, dst) = (if (isMemOpnd src)     fun emit_fbinaryOp (binOp, src, dst) = (if (isMemOpnd src)
369            then            then
370            ( emit_fbinOp binOp;            ( emit_fbinOp binOp;
# Line 381  Line 384 
384              | _ => error "emit_fbinaryOp"              | _ => error "emit_fbinaryOp"
385              )))              )))
386    
387  (*#line 593.7 "x86/x86.mdl"*)  (*#line 592.7 "x86/x86.mdl"*)
388     val emit_dst = emit_operand     val emit_dst = emit_operand
389    
390  (*#line 594.7 "x86/x86.mdl"*)  (*#line 593.7 "x86/x86.mdl"*)
391     val emit_src = emit_operand     val emit_src = emit_operand
392    
393  (*#line 595.7 "x86/x86.mdl"*)  (*#line 594.7 "x86/x86.mdl"*)
394     val emit_opnd = emit_operand     val emit_opnd = emit_operand
395    
396  (*#line 596.7 "x86/x86.mdl"*)  (*#line 595.7 "x86/x86.mdl"*)
397     val emit_opnd8 = emit_operand8     val emit_opnd8 = emit_operand8
398    
399  (*#line 597.7 "x86/x86.mdl"*)  (*#line 596.7 "x86/x86.mdl"*)
400     val emit_rsrc = emit_operand     val emit_rsrc = emit_operand
401    
402  (*#line 598.7 "x86/x86.mdl"*)  (*#line 597.7 "x86/x86.mdl"*)
403     val emit_lsrc = emit_operand     val emit_lsrc = emit_operand
404    
405  (*#line 599.7 "x86/x86.mdl"*)  (*#line 598.7 "x86/x86.mdl"*)
406     val emit_addr = emit_operand     val emit_addr = emit_operand
407    
408  (*#line 600.7 "x86/x86.mdl"*)  (*#line 599.7 "x86/x86.mdl"*)
409     val emit_src1 = emit_operand     val emit_src1 = emit_operand
410    
411  (*#line 601.7 "x86/x86.mdl"*)  (*#line 600.7 "x86/x86.mdl"*)
412     val emit_ea = emit_operand     val emit_ea = emit_operand
413     fun emitInstr' instr =     fun emitInstr' instr =
414         (case instr of         (case instr of
# Line 501  Line 504 
504               emit ", ";               emit ", ";
505               emit_dst dst )               emit_dst dst )
506           )           )
507           | I.CMPXCHG{lock, sz, src, dst} =>
508             ( (if lock
509                  then (emit "lock\n\t")
510                  else ());
511               emit "cmpxchg";
512    
513               (case sz of
514                 I.I8 => emit "b"
515               | I.I16 => emit "w"
516               | I.I32 => emit "l"
517               );
518    
519               ( emit "\t";
520                 emit_src src;
521                 emit ", ";
522                 emit_dst dst ) )
523         | I.MULTDIV{multDivOp, src} =>         | I.MULTDIV{multDivOp, src} =>
524           ( emit_multDivOp multDivOp;           ( emit_multDivOp multDivOp;
525             emit "\t";             emit "\t";

Legend:
Removed from v.796  
changed lines
  Added in v.797

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