Browse Source

* started to fix stack frame generation on MIPS(EL)

git-svn-id: trunk@21118 -
florian 13 years ago
parent
commit
aadeba4d1a
5 changed files with 51 additions and 39 deletions
  1. 14 1
      compiler/aggas.pas
  2. 25 14
      compiler/mips/aasmcpu.pas
  3. 11 20
      compiler/mips/cgcpu.pas
  4. 0 3
      compiler/mips/cpugas.pas
  5. 1 1
      compiler/mips/strinst.inc

+ 14 - 1
compiler/aggas.pas

@@ -1177,6 +1177,14 @@ implementation
                   else
                   else
                     AsmWriteln(tai_symbol(hp).sym.name);
                     AsmWriteln(tai_symbol(hp).sym.name);
                 end;
                 end;
+               if target_info.system in [system_mipsel_linux,system_mips_linux] then
+                begin
+                  AsmWrite(#9'.ent'#9);
+                  if replaceforbidden then
+                    AsmWriteln(ReplaceForbiddenAsmSymbolChars(tai_symbol(hp).sym.name))
+                  else
+                    AsmWriteln(tai_symbol(hp).sym.name);
+                end;
                if (target_info.system = system_powerpc64_linux) and
                if (target_info.system = system_powerpc64_linux) and
                  (tai_symbol(hp).sym.typ = AT_FUNCTION) then
                  (tai_symbol(hp).sym.typ = AT_FUNCTION) then
                  begin
                  begin
@@ -1247,7 +1255,12 @@ implementation
                AsmWriteLn(#9'.thumb_func');
                AsmWriteLn(#9'.thumb_func');
              end;
              end;
 {$endif arm}
 {$endif arm}
-
+{$if defined(alpha)}
+           ait_ent:
+             begin
+               AsmWriteLn(#9'.ent'#9+tai_ent(hp).Name);
+             end;
+{$endif alpha}
            ait_symbol_end :
            ait_symbol_end :
              begin
              begin
                if tf_needs_symbol_size in target_info.flags then
                if tf_needs_symbol_size in target_info.flags then

+ 25 - 14
compiler/mips/aasmcpu.pas

@@ -38,6 +38,7 @@ const
   O_MOV_DEST   = 1;
   O_MOV_DEST   = 1;
 
 
 type
 type
+  { taicpu }
   taicpu = class(tai_cpu_abstract_sym)
   taicpu = class(tai_cpu_abstract_sym)
     delayslot_annulled: boolean;   { conditinal opcode with ,a }
     delayslot_annulled: boolean;   { conditinal opcode with ,a }
     constructor op_none(op: tasmop);
     constructor op_none(op: tasmop);
@@ -54,6 +55,7 @@ type
 
 
     constructor op_reg_reg_ref(op: tasmop; _op1, _op2: tregister; const _op3: treference);
     constructor op_reg_reg_ref(op: tasmop; _op1, _op2: tregister; const _op3: treference);
     constructor op_reg_reg_const(op: tasmop; _op1, _op2: tregister; _op3: aint);
     constructor op_reg_reg_const(op: tasmop; _op1, _op2: tregister; _op3: aint);
+    constructor op_reg_const_reg(op: tasmop; _op1: tregister; _op2: aint; _op3: tregister);
 
 
     { this is for Jmp instructions }
     { this is for Jmp instructions }
     constructor op_sym(op: tasmop; _op1: tasmsymbol);
     constructor op_sym(op: tasmop; _op1: tasmsymbol);
@@ -84,8 +86,6 @@ implementation
                                  taicpu Constructors
                                  taicpu Constructors
 *****************************************************************************}
 *****************************************************************************}
 
 
-
-
 constructor taicpu.op_none(op: tasmop);
 constructor taicpu.op_none(op: tasmop);
 begin
 begin
   inherited Create(op);
   inherited Create(op);
@@ -153,24 +153,35 @@ end;
 
 
 
 
 constructor taicpu.op_reg_reg_ref(op: tasmop; _op1, _op2: tregister; const _op3: treference);
 constructor taicpu.op_reg_reg_ref(op: tasmop; _op1, _op2: tregister; const _op3: treference);
- begin
-   inherited create(op);
-   ops := 3;
-   loadreg(0, _op1);
-   loadreg(1, _op2);
-   loadref(2, _op3);
+begin
+  inherited create(op);
+  ops := 3;
+  loadreg(0, _op1);
+  loadreg(1, _op2);
+  loadref(2, _op3);
 end;
 end;
 
 
+
 constructor taicpu.op_reg_reg_const(op: tasmop; _op1, _op2: tregister; _op3: aint);
 constructor taicpu.op_reg_reg_const(op: tasmop; _op1, _op2: tregister; _op3: aint);
- begin
-   inherited create(op);
-   ops := 3;
-   loadreg(0, _op1);
-   loadreg(1, _op2);
-   loadconst(2, _op3);
+begin
+  inherited create(op);
+  ops := 3;
+  loadreg(0, _op1);
+  loadreg(1, _op2);
+  loadconst(2, _op3);
 end;
 end;
 
 
 
 
+constructor taicpu.op_reg_const_reg(op: tasmop; _op1: tregister; _op2: aint;
+ _op3: tregister);
+begin
+  inherited create(op);
+  ops := 3;
+  loadreg(0, _op1);
+  loadconst(1, _op2);
+  loadreg(2, _op3);
+end;
+
 
 
 constructor taicpu.op_sym(op: tasmop; _op1: tasmsymbol);
 constructor taicpu.op_sym(op: tasmop; _op1: tasmsymbol);
 begin
 begin

+ 11 - 20
compiler/mips/cgcpu.pas

@@ -1347,55 +1347,46 @@ var
   instr: taicpu;
   instr: taicpu;
 
 
 begin
 begin
+  {
   if STK2_dummy <> 0 then
   if STK2_dummy <> 0 then
   begin
   begin
     list.concat(Taicpu.Op_reg_reg_const(A_P_STK2, STK2_PTR, STK2_PTR, -STK2_dummy));
     list.concat(Taicpu.Op_reg_reg_const(A_P_STK2, STK2_PTR, STK2_PTR, -STK2_dummy));
   end;
   end;
+  }
+  LocalSize := align(LocalSize, 8);
+  a_reg_alloc(list,NR_STACK_POINTER_REG);
+  if current_procinfo.framepointer<>NR_STACK_POINTER_REG then
+    a_reg_alloc(list,NR_FRAME_POINTER_REG);
 
 
   if nostackframe then
   if nostackframe then
     exit;
     exit;
 
 
-    usesfpr := False;
-  if not (po_assembler in current_procinfo.procdef.procoptions) then
-    case target_info.abi of
-      abi_powerpc_aix:
-        firstfpureg := RS_F14;
-      abi_powerpc_sysv:
-        firstfpureg := RS_F14;
-      abi_default:
-        firstfpureg := RS_F14;
-      else
-        internalerror(2003122903);
-    end;
-  for regcounter := firstfpureg to RS_F31 do
+  usesfpr := False;
+  for regcounter := RS_F20 to RS_F30 do
   begin
   begin
     if regcounter in rg[R_FPUREGISTER].used_in_proc then
     if regcounter in rg[R_FPUREGISTER].used_in_proc then
     begin
     begin
       usesfpr     := True;
       usesfpr     := True;
       firstregfpu := regcounter;
       firstregfpu := regcounter;
-      break;
     end;
     end;
   end;
   end;
 
 
   usesgpr := False;
   usesgpr := False;
   if not (po_assembler in current_procinfo.procdef.procoptions) then
   if not (po_assembler in current_procinfo.procdef.procoptions) then
-    for regcounter2 := RS_R13 to RS_R31 do
+    for regcounter2 := RS_R0 to RS_R31 do
     begin
     begin
       if regcounter2 in rg[R_INTREGISTER].used_in_proc then
       if regcounter2 in rg[R_INTREGISTER].used_in_proc then
       begin
       begin
         usesgpr     := True;
         usesgpr     := True;
         firstreggpr := regcounter2;
         firstreggpr := regcounter2;
-        break;
       end;
       end;
     end;
     end;
 
 
-
-  LocalSize := align(LocalSize, 8);
-
   cgcpu_calc_stackframe_size := LocalSize;
   cgcpu_calc_stackframe_size := LocalSize;
-  list.concat(Taicpu.Op_reg_reg_const(A_P_FRAME, NR_FRAME_POINTER_REG, NR_R31, LocalSize));
+  list.concat(Taicpu.Op_reg_const_reg(A_P_FRAME, NR_FRAME_POINTER_REG, LocalSize, NR_R31));
   list.concat(Taicpu.op_none(A_P_SET_NOREORDER));
   list.concat(Taicpu.op_none(A_P_SET_NOREORDER));
   list.concat(Taicpu.op_none(A_P_SET_NOMACRO));
   list.concat(Taicpu.op_none(A_P_SET_NOMACRO));
+//  list.concat(taicpu.op_
   list.concat(Taicpu.Op_reg_reg_const(A_P_SW, NR_FRAME_POINTER_REG, NR_STACK_POINTER_REG, -LocalSize));
   list.concat(Taicpu.Op_reg_reg_const(A_P_SW, NR_FRAME_POINTER_REG, NR_STACK_POINTER_REG, -LocalSize));
   list.concat(Taicpu.Op_reg_reg_const(A_P_SW, NR_R31, NR_STACK_POINTER_REG, -LocalSize + 4));
   list.concat(Taicpu.Op_reg_reg_const(A_P_SW, NR_R31, NR_STACK_POINTER_REG, -LocalSize + 4));
   list.concat(Taicpu.op_reg_reg(A_MOVE, NR_FRAME_POINTER_REG, NR_STACK_POINTER_REG));
   list.concat(Taicpu.op_reg_reg(A_MOVE, NR_FRAME_POINTER_REG, NR_STACK_POINTER_REG));

+ 0 - 3
compiler/mips/cpugas.pas

@@ -175,9 +175,6 @@ unit cpugas;
             s := #9 + gas_op2str[A_ADDIU] + #9 + getopstr(taicpu(hp).oper[0]^)+ ',' + getopstr(taicpu(hp).oper[1]^) + ',' + s1;
             s := #9 + gas_op2str[A_ADDIU] + #9 + getopstr(taicpu(hp).oper[0]^)+ ',' + getopstr(taicpu(hp).oper[1]^) + ',' + s1;
             owner.AsmWriteLn(s);
             owner.AsmWriteLn(s);
           end;
           end;
-          A_P_FRAME:
-          begin
-          end;
           A_P_SET_MACRO:
           A_P_SET_MACRO:
           begin
           begin
             s := #9 + '.set' + #9 + 'macro';
             s := #9 + '.set' + #9 + 'macro';

+ 1 - 1
compiler/mips/strinst.inc

@@ -5,7 +5,7 @@
 'p_set_nomacro',
 'p_set_nomacro',
 'p_set_macro',
 'p_set_macro',
 'p_set_reorder',
 'p_set_reorder',
-'p_frame',
+'.frame',
 'p_mask',
 'p_mask',
 'p_fmask',
 'p_fmask',
 'p_sw',
 'p_sw',