Browse Source

* more ABI compliant parameter passing

git-svn-id: trunk@46783 -
florian 4 years ago
parent
commit
243300c85f
1 changed files with 24 additions and 56 deletions
  1. 24 56
      compiler/xtensa/cpupara.pas

+ 24 - 56
compiler/xtensa/cpupara.pas

@@ -80,61 +80,28 @@ unit cpupara;
 
 
 
 
     function getparaloc(p : tdef) : tcgloc;
     function getparaloc(p : tdef) : tcgloc;
-
       begin
       begin
-         { Later, the LOC_REFERENCE is in most cases changed into LOC_REGISTER
-           if push_addr_param for the def is true
-         }
-         case p.typ of
-            orddef:
-              result:=LOC_REGISTER;
-            floatdef:
-              result:=LOC_REGISTER;
-            enumdef:
-              result:=LOC_REGISTER;
-            pointerdef:
-              result:=LOC_REGISTER;
-            formaldef:
-              result:=LOC_REGISTER;
-            classrefdef:
-              result:=LOC_REGISTER;
-            procvardef:
-              result:=LOC_REGISTER;
-            recorddef:
-              if p.size>24 then
-                result:=LOC_REFERENCE
-              else
-                result:=LOC_REGISTER;
-            objectdef:
-              if is_object(p) and (p.size>24) then
-                result:=LOC_REFERENCE
-              else
-                result:=LOC_REGISTER;
-            stringdef:
-              if is_shortstring(p) or is_longstring(p) then
-                result:=LOC_REFERENCE
-              else
-                result:=LOC_REGISTER;
-            filedef:
-              result:=LOC_REGISTER;
-            arraydef:
-              if is_dynamic_array(p) or (p.size<=24) then
-                getparaloc:=LOC_REGISTER
-              else
-                result:=LOC_REFERENCE;
-            setdef:
-              if is_smallset(p) then
-                result:=LOC_REGISTER
-              else
-                result:=LOC_REFERENCE;
-            variantdef:
-              result:=LOC_REGISTER;
-            { avoid problems with errornous definitions }
-            errordef:
-              result:=LOC_REGISTER;
-            else
-              internalerror(2020082501);
-         end;
+        case p.typ of
+          orddef,
+          floatdef,
+          enumdef,
+          pointerdef,
+          formaldef,
+          classrefdef,
+          procvardef,
+          recorddef,
+          objectdef,
+          stringdef,
+          filedef,
+          arraydef,
+          setdef,
+          variantdef,
+          { avoid problems with errornous definitions }
+          errordef:
+            result:=LOC_REGISTER;
+          else
+            internalerror(2020082501);
+        end;
       end;
       end;
 
 
 
 
@@ -379,7 +346,7 @@ unit cpupara;
 
 
         locpara:=getparaloc(paradef);
         locpara:=getparaloc(paradef);
 
 
-        if (locpara=LOC_REGISTER) and ((maxintreg-curintreg+1)*4<paradef.size) then
+        if (maxintreg-curintreg+1)*4<paralen then
           begin
           begin
             locpara:=LOC_REFERENCE;
             locpara:=LOC_REFERENCE;
             curintreg:=maxintreg+1;
             curintreg:=maxintreg+1;
@@ -389,7 +356,7 @@ unit cpupara;
         loc.size:=paracgsize;
         loc.size:=paracgsize;
         loc.intsize:=paralen;
         loc.intsize:=paralen;
         loc.def:=paradef;
         loc.def:=paradef;
-        if (locpara=LOC_REGISTER) and (is_64bit(paradef)) and
+        if (locpara=LOC_REGISTER) and (paradef.alignment>4) and
            odd(curintreg-RS_A2) then
            odd(curintreg-RS_A2) then
           inc(curintreg);
           inc(curintreg);
         if (paralen = 0) then
         if (paralen = 0) then
@@ -455,6 +422,7 @@ unit cpupara;
                  else
                  else
                    paraloc^.reference.index:=current_procinfo.framepointer;
                    paraloc^.reference.index:=current_procinfo.framepointer;
 
 
+                 cur_stack_offset:=align(cur_stack_offset,paradef.alignment);
                  paraloc^.reference.offset:=cur_stack_offset;
                  paraloc^.reference.offset:=cur_stack_offset;
 
 
                  inc(cur_stack_offset,align(paralen,4));
                  inc(cur_stack_offset,align(paralen,4));