Browse Source

* handle 4-byte records in registers as well in location_force_mem on i8086

git-svn-id: trunk@26002 -
nickysn 11 years ago
parent
commit
039979fdcc
1 changed files with 21 additions and 0 deletions
  1. 21 0
      compiler/i8086/hlcgcpu.pas

+ 21 - 0
compiler/i8086/hlcgcpu.pas

@@ -201,10 +201,12 @@ implementation
     var
       r,tmpref: treference;
       is_sixbyterecord: Boolean;
+      is_fourbyterecord: Boolean;
       is_methodptr: Boolean;
       is_nestedprocptr: Boolean;
     begin
       is_sixbyterecord:=(size.typ=recorddef) and (size.size=6);
+      is_fourbyterecord:=(size.typ=recorddef) and (size.size=4);
       is_methodptr:=(size.typ=procvardef)
         and (po_methodpointer in tprocvardef(size).procoptions)
         and not(po_addressonly in tprocvardef(size).procoptions);
@@ -234,6 +236,25 @@ implementation
           else
             cg.a_load_reg_ref(list,OS_16,OS_16,l.registerhi,tmpref);
 
+          location_reset_ref(l,LOC_REFERENCE,l.size,0);
+          l.reference:=r;
+        end
+      { 4-byte records in registers need special handling as well. A record may
+        be located in registerhi:register if it was converted from a procvar or
+        in GetNextReg(register):register if it was converted from a longint.
+        We can tell between the two by checking whether registerhi has been set. }
+      else if is_fourbyterecord and (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
+        begin
+          tg.gethltemp(list,size,size.size,tt_normal,r);
+          tmpref:=r;
+
+          cg.a_load_reg_ref(list,OS_16,OS_16,l.register,tmpref);
+          inc(tmpref.offset,2);
+          if l.registerhi<>tregister(0) then
+            cg.a_load_reg_ref(list,OS_16,OS_16,l.registerhi,tmpref)
+          else
+            cg.a_load_reg_ref(list,OS_16,OS_16,GetNextReg(l.register),tmpref);
+
           location_reset_ref(l,LOC_REFERENCE,l.size,0);
           l.reference:=r;
         end