Browse Source

* more RiscV paramgr unification

florian 7 months ago
parent
commit
d33e7920a2
3 changed files with 80 additions and 123 deletions
  1. 79 2
      compiler/riscv/pararv.pas
  2. 0 65
      compiler/riscv32/cpupara.pas
  3. 1 56
      compiler/riscv64/cpupara.pas

+ 79 - 2
compiler/riscv/pararv.pas

@@ -27,7 +27,7 @@ unit pararv;
     uses
       globtype,
       aasmdata,
-      symdef,
+      symtype,symdef,
       cgbase,cgutils,
       parabase,paramgr;
 
@@ -45,14 +45,91 @@ unit pararv;
         procedure init_values(var curintreg, curfloatreg, curmmreg: tsuperregister; var cur_stack_offset: aword);
       end;
 
+    function getparaloc(p : tdef) : tcgloc;
+
 implementation
 
     uses
       verbose,
-      symtype,symsym,
+      globals,
+      cpuinfo,
+      symconst,symsym,
       defutil,
       cpubase;
 
+    function getparaloc(p : tdef) : tcgloc;
+      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:
+              if (cs_fp_emulation in current_settings.moduleswitches) or
+                 (current_settings.fputype in [fpu_soft]) then
+                result := LOC_REGISTER
+              else
+                result := LOC_FPUREGISTER;
+            enumdef:
+              result:=LOC_REGISTER;
+            pointerdef:
+              result:=LOC_REGISTER;
+            formaldef:
+              result:=LOC_REGISTER;
+            classrefdef:
+              result:=LOC_REGISTER;
+            procvardef:
+            { this must be fixed for RISC64, the ifdef is not correct }
+{$ifdef RISCV32}
+              if (p.size = sizeof(pint)) then
+                result:=LOC_REGISTER
+              else
+                result:=LOC_REFERENCE;
+{$else RISCV32}
+              result:=LOC_REGISTER;
+{$endif RISCV32}
+            recorddef:
+            { this must be fixed for RISC64, the ifdef is not correct }
+{$ifdef RISCV32}
+              if (p.size > sizeof(pint)) then
+                result:=LOC_REFERENCE
+              else
+{$endif RISCV32}
+                result:=LOC_REGISTER;
+            objectdef:
+              if is_object(p) 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) then
+                getparaloc:=LOC_REGISTER
+              else
+                result:=LOC_REFERENCE;
+            setdef:
+              if is_smallset(p) then
+                result:=LOC_REGISTER
+              else
+                result:=LOC_REFERENCE;
+            variantdef:
+              result:=LOC_REFERENCE;
+            { avoid problems with errornous definitions }
+            errordef:
+              result:=LOC_REGISTER;
+            else
+              internalerror(2002071001);
+         end;
+      end;
+
+
     function trvparamanager.get_volatile_registers_int(calloption: tproccalloption): tcpuregisterset;
       begin
         result:=[RS_X0..RS_X31]-[RS_X2,RS_X8..RS_X9,RS_X18..RS_X27];

+ 0 - 65
compiler/riscv32/cpupara.pas

@@ -52,71 +52,6 @@ unit cpupara;
        defutil,symtable,
        procinfo,cpupi;
 
-    function getparaloc(p : tdef) : tcgloc;
-
-      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:
-              if (cs_fp_emulation in current_settings.moduleswitches) or
-                 (current_settings.fputype in [fpu_soft]) then
-                result := LOC_REGISTER
-              else
-                result := LOC_FPUREGISTER;
-            enumdef:
-              result:=LOC_REGISTER;
-            pointerdef:
-              result:=LOC_REGISTER;
-            formaldef:
-              result:=LOC_REGISTER;
-            classrefdef:
-              result:=LOC_REGISTER;
-            procvardef:
-              if (p.size = sizeof(pint)) then
-                result:=LOC_REGISTER
-              else
-                result:=LOC_REFERENCE;
-            recorddef:
-              if (p.size > 4) then
-                result:=LOC_REFERENCE
-              else
-                result:=LOC_REGISTER;
-            objectdef:
-              if is_object(p) 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) then
-                getparaloc:=LOC_REGISTER
-              else
-                result:=LOC_REFERENCE;
-            setdef:
-              if is_smallset(p) then
-                result:=LOC_REGISTER
-              else
-                result:=LOC_REFERENCE;
-            variantdef:
-              result:=LOC_REFERENCE;
-            { avoid problems with errornous definitions }
-            errordef:
-              result:=LOC_REGISTER;
-            else
-              internalerror(2002071001);
-         end;
-      end;
-
 
     function tcpuparamanager.push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;
       begin

+ 1 - 56
compiler/riscv64/cpupara.pas

@@ -55,62 +55,6 @@ implementation
       defutil,symtable,symcpu,
       procinfo, cpupi;
 
-    function getparaloc(p: tdef): tcgloc;
-      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:
-            if (cs_fp_emulation in current_settings.moduleswitches) or
-               (current_settings.fputype in [fpu_soft]) then
-              result := LOC_REGISTER
-            else
-              result := LOC_FPUREGISTER;
-          enumdef:
-            result := LOC_REGISTER;
-          pointerdef:
-            result := LOC_REGISTER;
-          formaldef:
-            result := LOC_REGISTER;
-          classrefdef:
-            result := LOC_REGISTER;
-          procvardef,
-          recorddef:
-            result := LOC_REGISTER;
-          objectdef:
-            if is_object(p) 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) then
-              getparaloc:=LOC_REGISTER
-            else
-              result := LOC_REFERENCE;
-          setdef:
-            if is_smallset(p) then
-              result := LOC_REGISTER
-            else
-              result := LOC_REFERENCE;
-          variantdef:
-            result := LOC_REFERENCE;
-          { avoid problems with errornous definitions }
-          errordef:
-            result := LOC_REGISTER;
-        else
-          internalerror(2002071001);
-        end;
-      end;
 
     function tcpuparamanager.push_addr_param(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean;
       begin
@@ -144,6 +88,7 @@ implementation
         end;
       end;
 
+
     function tcpuparamanager.ret_in_param(def: tdef; pd: tabstractprocdef): boolean;
       var
         tmpdef: tdef;