Browse Source

* movd and opsize fix merged

peter 24 years ago
parent
commit
611d242891
2 changed files with 62 additions and 12 deletions
  1. 8 2
      compiler/i386/cpuasm.pas
  2. 54 10
      compiler/i386/ra386.pas

+ 8 - 2
compiler/i386/cpuasm.pas

@@ -793,7 +793,10 @@ begin
         top_ref :
         top_ref :
           begin
           begin
           { create ot field }
           { create ot field }
-            ot:=OT_MEMORY or opsize_2_type[i,opsize];
+            if (ot and OT_SIZE_MASK)=0 then
+              ot:=OT_MEMORY or opsize_2_type[i,opsize]
+            else
+              ot:=OT_MEMORY or (ot and OT_SIZE_MASK);
             if (ref^.base=R_NO) and (ref^.index=R_NO) then
             if (ref^.base=R_NO) and (ref^.index=R_NO) then
               ot:=ot or OT_MEM_OFFS;
               ot:=ot or OT_MEM_OFFS;
           { fix scalefactor }
           { fix scalefactor }
@@ -1770,7 +1773,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.12  2001-03-25 12:29:45  peter
+  Revision 1.13  2001-04-05 21:33:45  peter
+    * movd and opsize fix merged
+
+  Revision 1.12  2001/03/25 12:29:45  peter
     * offset_fixup fixes (merged)
     * offset_fixup fixes (merged)
 
 
   Revision 1.11  2001/02/20 21:51:36  peter
   Revision 1.11  2001/02/20 21:51:36  peter

+ 54 - 10
compiler/i386/ra386.pas

@@ -270,7 +270,11 @@ begin
              begin
              begin
                { Only allow register as operand to take the size from }
                { Only allow register as operand to take the size from }
                if operands[operand2]^.opr.typ=OPR_REGISTER then
                if operands[operand2]^.opr.typ=OPR_REGISTER then
-                operands[i]^.size:=operands[operand2]^.size
+                 begin
+                   if ((opcode<>A_MOVD) and
+                       (opcode<>A_CVTSI2SS)) then
+                     operands[i]^.size:=operands[operand2]^.size;
+                 end
                else
                else
                 begin
                 begin
                   { if no register then take the opsize (which is available with ATT),
                   { if no register then take the opsize (which is available with ATT),
@@ -347,6 +351,9 @@ begin
                   end;
                   end;
               end;
               end;
             end;
             end;
+          A_MOVD : { movd is a move from a mmx register to a
+                     32 bit register or memory, so no opsize is correct here PM }
+            exit;
           A_OUT :
           A_OUT :
             opsize:=operands[1]^.size;
             opsize:=operands[1]^.size;
           else
           else
@@ -366,9 +373,10 @@ var
 begin
 begin
   { Check only the most common opcodes here, the others are done in
   { Check only the most common opcodes here, the others are done in
     the assembler pass }
     the assembler pass }
+  { movd also added as it needs special care here PM }
   case opcode of
   case opcode of
     A_PUSH,A_POP,A_DEC,A_INC,A_NOT,A_NEG,
     A_PUSH,A_POP,A_DEC,A_INC,A_NOT,A_NEG,
-    A_CMP,A_MOV,
+    A_CMP,A_MOV,A_MOVD,
     A_ADD,A_SUB,A_ADC,A_SBB,
     A_ADD,A_SUB,A_ADC,A_SBB,
     A_AND,A_OR,A_TEST,A_XOR: ;
     A_AND,A_OR,A_TEST,A_XOR: ;
   else
   else
@@ -401,7 +409,7 @@ begin
    end
    end
   else
   else
    begin
    begin
-     for i:=1to ops do
+     for i:=1 to ops do
       begin
       begin
         if (operands[i]^.opr.typ<>OPR_CONSTANT) and
         if (operands[i]^.opr.typ<>OPR_CONSTANT) and
            (operands[i]^.size in [S_B,S_W,S_L]) and
            (operands[i]^.size in [S_B,S_W,S_L]) and
@@ -469,7 +477,7 @@ end;
 procedure T386Instruction.ConcatInstruction(p : taasmoutput);
 procedure T386Instruction.ConcatInstruction(p : taasmoutput);
 var
 var
   siz  : topsize;
   siz  : topsize;
-  i    : longint;
+  i,asize : longint;
   ai   : taicpu;
   ai   : taicpu;
 begin
 begin
 { Get Opsize }
 { Get Opsize }
@@ -481,8 +489,17 @@ begin
       siz:=operands[1]^.size
       siz:=operands[1]^.size
      else
      else
       siz:=operands[Ops]^.size;
       siz:=operands[Ops]^.size;
+     { MOVD should be of size S_LQ or S_QL, but these do not exist PM }
+     if (ops=2) and (operands[1]^.size<>S_NO) and
+        (operands[2]^.size<>S_NO) and (operands[1]^.size<>operands[2]^.size) then
+       siz:=S_NO;
    end;
    end;
 
 
+   if ((opcode=A_MOVD)or
+       (opcode=A_CVTSI2SS)) and
+      ((operands[1]^.size=S_NO) or
+       (operands[2]^.size=S_NO)) then
+     siz:=S_NO;
    { NASM does not support FADD without args
    { NASM does not support FADD without args
      as alias of FADDP
      as alias of FADDP
      and GNU AS interprets FADD without operand differently
      and GNU AS interprets FADD without operand differently
@@ -549,10 +566,12 @@ begin
   if (ops=1) and
   if (ops=1) and
       ((operands[1]^.opr.typ=OPR_REGISTER) and
       ((operands[1]^.opr.typ=OPR_REGISTER) and
       (operands[1]^.opr.reg in [R_ST1..R_ST7])) and
       (operands[1]^.opr.reg in [R_ST1..R_ST7])) and
-     ((opcode=A_FSUBP) or
+      ((opcode=A_FSUBP) or
       (opcode=A_FSUBRP) or
       (opcode=A_FSUBRP) or
       (opcode=A_FDIVP) or
       (opcode=A_FDIVP) or
-      (opcode=A_FDIVRP)) then
+      (opcode=A_FDIVRP) or
+      (opcode=A_FADDP) or
+      (opcode=A_FMULP)) then
      begin
      begin
 {$ifdef ATTOP}
 {$ifdef ATTOP}
        message1(asmr_w_adding_explicit_first_arg_fXX,att_op2str[opcode]);
        message1(asmr_w_adding_explicit_first_arg_fXX,att_op2str[opcode]);
@@ -572,10 +591,12 @@ begin
   if (ops=1) and
   if (ops=1) and
       ((operands[1]^.opr.typ=OPR_REGISTER) and
       ((operands[1]^.opr.typ=OPR_REGISTER) and
       (operands[1]^.opr.reg in [R_ST1..R_ST7])) and
       (operands[1]^.opr.reg in [R_ST1..R_ST7])) and
-     ((opcode=A_FSUB) or
+      ((opcode=A_FSUB) or
       (opcode=A_FSUBR) or
       (opcode=A_FSUBR) or
       (opcode=A_FDIV) or
       (opcode=A_FDIV) or
-      (opcode=A_FDIVR)) then
+      (opcode=A_FDIVR) or
+      (opcode=A_FADD) or
+      (opcode=A_FMUL)) then
      begin
      begin
 {$ifdef ATTOP}
 {$ifdef ATTOP}
        message1(asmr_w_adding_explicit_second_arg_fXX,att_op2str[opcode]);
        message1(asmr_w_adding_explicit_second_arg_fXX,att_op2str[opcode]);
@@ -617,7 +638,27 @@ begin
        OPR_SYMBOL:
        OPR_SYMBOL:
          ai.loadsymbol(i-1,operands[i]^.opr.symbol,operands[i]^.opr.symofs);
          ai.loadsymbol(i-1,operands[i]^.opr.symbol,operands[i]^.opr.symofs);
        OPR_REFERENCE:
        OPR_REFERENCE:
-         ai.loadref(i-1,newreference(operands[i]^.opr.ref));
+         begin
+           ai.loadref(i-1,newreference(operands[i]^.opr.ref));
+           if operands[i]^.size<>S_NO then
+             begin
+               asize:=0;
+               case operands[i]^.size of
+                   S_B :
+                     asize:=OT_BITS8;
+                   S_W, S_IS :
+                     asize:=OT_BITS16;
+                   S_L, S_IL, S_FS:
+                     asize:=OT_BITS32;
+                   S_Q, S_D, S_FL, S_FV :
+                     asize:=OT_BITS64;
+                   S_FX :
+                     asize:=OT_BITS80;
+                 end;
+               if asize<>0 then
+                 ai.oper[i-1].ot:=(ai.oper[i-1].ot and not OT_SIZE_MASK) or asize;
+             end;
+         end;
      end;
      end;
    end;
    end;
 
 
@@ -647,7 +688,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  2001-03-05 21:49:44  peter
+  Revision 1.8  2001-04-05 21:33:45  peter
+    * movd and opsize fix merged
+
+  Revision 1.7  2001/03/05 21:49:44  peter
     * noag386bin fix
     * noag386bin fix
 
 
   Revision 1.6  2001/02/20 21:51:36  peter
   Revision 1.6  2001/02/20 21:51:36  peter