Răsfoiți Sursa

* refactored the segment-in-integer-register reference support, so it's handled in make_simple_ref, instead of all over the place in the code generator

git-svn-id: trunk@24752 -
nickysn 12 ani în urmă
părinte
comite
ec76b2cf40
4 a modificat fișierele cu 10 adăugiri și 62 ștergeri
  1. 0 42
      compiler/i8086/cgcpu.pas
  2. 0 6
      compiler/i8086/n8086add.pas
  3. 9 1
      compiler/x86/cgx86.pas
  4. 1 13
      compiler/x86/nx86add.pas

+ 0 - 42
compiler/i8086/cgcpu.pas

@@ -346,13 +346,6 @@ unit cgcpu;
         tmpref:=ref;
         tmpref:=ref;
         make_simple_ref(list,tmpref);
         make_simple_ref(list,tmpref);
 
 
-        if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
-          begin
-            list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
-            tmpref.segment:=NR_ES;
-          end;
-
         if size in [OS_64, OS_S64] then
         if size in [OS_64, OS_S64] then
           internalerror(2013050801);
           internalerror(2013050801);
         if size in [OS_32, OS_S32] then
         if size in [OS_32, OS_S32] then
@@ -498,13 +491,6 @@ unit cgcpu;
         make_simple_ref(list,tmpref);
         make_simple_ref(list,tmpref);
         check_register_size(size,reg);
         check_register_size(size,reg);
 
 
-        if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
-          begin
-            list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
-            tmpref.segment:=NR_ES;
-          end;
-
         if size in [OS_64, OS_S64] then
         if size in [OS_64, OS_S64] then
           internalerror(2013030902);
           internalerror(2013030902);
 
 
@@ -536,13 +522,6 @@ unit cgcpu;
         make_simple_ref(list,tmpref);
         make_simple_ref(list,tmpref);
         check_register_size(size,reg);
         check_register_size(size,reg);
 
 
-        if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
-          begin
-            list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
-            tmpref.segment:=NR_ES;
-          end;
-
         if size in [OS_64, OS_S64] then
         if size in [OS_64, OS_S64] then
           internalerror(2013050803);
           internalerror(2013050803);
 
 
@@ -853,13 +832,6 @@ unit cgcpu;
         tmpref:=ref;
         tmpref:=ref;
         make_simple_ref(list,tmpref);
         make_simple_ref(list,tmpref);
 
 
-        if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
-          begin
-            list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
-            tmpref.segment:=NR_ES;
-          end;
-
         if tosize in [OS_S32,OS_32] then
         if tosize in [OS_S32,OS_32] then
           begin
           begin
             a_load_const_ref(list,OS_16,longint(a and $ffff),tmpref);
             a_load_const_ref(list,OS_16,longint(a and $ffff),tmpref);
@@ -882,13 +854,6 @@ unit cgcpu;
         make_simple_ref(list,tmpref);
         make_simple_ref(list,tmpref);
         check_register_size(fromsize,reg);
         check_register_size(fromsize,reg);
 
 
-        if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
-          begin
-            list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
-            tmpref.segment:=NR_ES;
-          end;
-
         case tosize of
         case tosize of
           OS_8,OS_S8:
           OS_8,OS_S8:
             if fromsize in [OS_8,OS_S8] then
             if fromsize in [OS_8,OS_S8] then
@@ -973,13 +938,6 @@ unit cgcpu;
 {        if tcgsize2size[tosize]<=tcgsize2size[fromsize] then
 {        if tcgsize2size[tosize]<=tcgsize2size[fromsize] then
           fromsize:=tosize;}
           fromsize:=tosize;}
 
 
-        if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
-          begin
-            list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
-            tmpref.segment:=NR_ES;
-          end;
-
         case tosize of
         case tosize of
           OS_8,OS_S8:
           OS_8,OS_S8:
             if fromsize in [OS_8,OS_S8] then
             if fromsize in [OS_8,OS_S8] then

+ 0 - 6
compiler/i8086/n8086add.pas

@@ -556,12 +556,6 @@ interface
                begin
                begin
                  tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,right.location.reference);
                  tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,right.location.reference);
                  href:=right.location.reference;
                  href:=right.location.reference;
-                 if (href.segment<>NR_NO) and (not is_segment_reg(href.segment)) then
-                   begin
-                     current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_PUSH,S_W,href.segment));
-                     current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
-                     href.segment:=NR_ES;
-                   end;
                  inc(href.offset,2);
                  inc(href.offset,2);
                  emit_ref_reg(A_CMP,S_W,href,GetNextReg(left.location.register));
                  emit_ref_reg(A_CMP,S_W,href,GetNextReg(left.location.register));
                  firstjmp32bitcmp;
                  firstjmp32bitcmp;

+ 9 - 1
compiler/x86/cgx86.pas

@@ -576,7 +576,15 @@ unit cgx86;
             { let the register allocator find a suitable register for the reference }
             { let the register allocator find a suitable register for the reference }
             list.Concat(Taicpu.op_reg_reg(A_MOV, S_W, NR_SP, href.base));
             list.Concat(Taicpu.op_reg_reg(A_MOV, S_W, NR_SP, href.base));
             ref:=href;
             ref:=href;
-          end
+          end;
+
+        { if there is a segment in an int register, move it to ES }
+        if (ref.segment<>NR_NO) and (not is_segment_reg(ref.segment)) then
+          begin
+            list.concat(taicpu.op_reg(A_PUSH,S_W,ref.segment));
+            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
+            ref.segment:=NR_ES;
+          end;
 {$endif}
 {$endif}
       end;
       end;
 
 

+ 1 - 13
compiler/x86/nx86add.pas

@@ -249,9 +249,6 @@ unit nx86add;
     procedure tx86addnode.emit_op_right_left(op:TAsmOp;opsize:TCgsize);
     procedure tx86addnode.emit_op_right_left(op:TAsmOp;opsize:TCgsize);
       var
       var
         tmpref: treference;
         tmpref: treference;
-{$ifdef x86_64}
-        tmpreg : tregister;
-{$endif x86_64}
       begin
       begin
         if (right.location.loc in [LOC_CSUBSETREG,LOC_SUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
         if (right.location.loc in [LOC_CSUBSETREG,LOC_SUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF]) then
           hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
           hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
@@ -264,16 +261,7 @@ unit nx86add;
           LOC_CREFERENCE :
           LOC_CREFERENCE :
             begin
             begin
               tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,right.location.reference);
               tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,right.location.reference);
-              tmpref:=right.location.reference;
-{$ifdef i8086}
-              if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
-                begin
-                  current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-                  current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
-                  tmpref.segment:=NR_ES;
-                end;
-{$endif i8086}
-              current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(op,TCGSize2Opsize[opsize],tmpref,left.location.register));
+              current_asmdata.CurrAsmList.concat(taicpu.op_ref_reg(op,TCGSize2Opsize[opsize],right.location.reference,left.location.register));
             end;
             end;
           LOC_CONSTANT :
           LOC_CONSTANT :
             begin
             begin