فهرست منبع

+ procedures exiting prologue added and stack frame now restored in the delay slot of the return (JMPL) instruction

mazen 23 سال پیش
والد
کامیت
b5882415a3
3فایلهای تغییر یافته به همراه42 افزوده شده و 43 حذف شده
  1. 8 8
      compiler/sparc/aasmcpu.pas
  2. 13 7
      compiler/sparc/cgcpu.pas
  3. 21 28
      compiler/sparc/cpugas.pas

+ 8 - 8
compiler/sparc/aasmcpu.pas

@@ -292,14 +292,14 @@ uses
       end;
 
 
-    constructor taicpu.op_ref_reg(op : tasmop;_size : topsize;const _op1 : treference;_op2 : tregister);
-      begin
-         inherited create(op);
-         init(_size);
-         ops:=2;
-         loadref(0,_op1);
-         loadreg(1,_op2);
-      end;
+constructor taicpu.op_ref_reg(op:tasmop;_size:topsize;const _op1:treference;_op2:tregister);
+	begin
+		inherited create(op);
+		init(_size);
+		ops:=2;
+		loadref(0,_op1);
+		loadreg(1,_op2);
+	end;
 
 
     constructor taicpu.op_ref_ref(op : tasmop;_size : topsize;const _op1,_op2 : treference);

+ 13 - 7
compiler/sparc/cgcpu.pas

@@ -81,9 +81,9 @@ specific processor ABI. It is overriden for each CPU target.
     PROCEDURE a_jmp_cond(list:TAasmOutput;cond:TOpCmp;l:tasmlabel);{ OVERRIDE;}
     PROCEDURE a_jmp_flags(list:TAasmOutput;CONST f:TResFlags;l:tasmlabel);OVERRIDE;
     PROCEDURE g_flags2reg(list:TAasmOutput;Size:TCgSize;CONST f:tresflags;reg:TRegister);OVERRIDE;
-    PROCEDURE g_stackframe_entry(list:TAasmOutput;localsize:LongInt);OVERRIDE;
-    PROCEDURE g_restore_frame_pointer(list:TAasmOutput);OVERRIDE;
-    PROCEDURE g_return_from_proc(list:TAasmOutput;parasize:aword);OVERRIDE;
+    procedure g_stackframe_entry(list:TAasmOutput;localsize:LongInt);override;
+    procedure g_restore_frame_pointer(list:TAasmOutput);override;
+    procedure g_return_from_proc(list:TAasmOutput;parasize:aword);override;
     PROCEDURE g_concatcopy(list:TAasmOutput;CONST source,dest:TReference;len:aword;delsource,loadref:boolean);OVERRIDE;
     class function reg_cgsize(CONST reg:tregister):tcgsize;OVERRIDE;
   PRIVATE
@@ -806,9 +806,8 @@ execution of that instrucion is the called function stack pointer}
 	end;
 procedure tcgSPARC.g_restore_frame_pointer(list:TAasmOutput);
 	begin
-{We use trivial restore, as we set result before}
-		with list do
-			concat(Taicpu.Op_reg_const_reg(A_RESTORE,S_L,R_G0,0,R_G0));
+{This function intontionally does nothing as frame pointer is restored in the
+delay slot of the return instrucion done in g_return_from_proc}
 	end;
 procedure tcgSPARC.g_return_from_proc(list:TAasmOutput;parasize:aword);
 	var
@@ -826,8 +825,12 @@ If no inversion we can use just
 	NOP}
 		with list do
 			begin
+{Return address is computed by adding 8 to the CALL address saved onto %i6}
 				reference_reset_base(RetReference,R_I7,8);
 				concat(Taicpu.Op_ref_reg(A_JMPL,S_L,RetReference,R_G0));
+{We use trivial restore in the delay slot of the JMPL instruction, as we
+already set result onto %i0}
+				concat(Taicpu.Op_reg_const_reg(A_RESTORE,S_L,R_G0,0,R_G0));
 			end
 	end;
 PROCEDURE tcgSPARC.a_loadaddr_ref_reg(list:TAasmOutput;CONST ref:TReference;r:tregister);
@@ -1079,7 +1082,10 @@ BEGIN
 END.
 {
   $Log$
-  Revision 1.7  2002-10-01 21:06:29  mazen
+  Revision 1.8  2002-10-01 21:35:58  mazen
+  + procedures exiting prologue added and stack frame now restored in the delay slot of the return (JMPL) instruction
+
+  Revision 1.7  2002/10/01 21:06:29  mazen
   attinst.inc --> strinst.inc
 
   Revision 1.6  2002/10/01 17:41:50  florian

+ 21 - 28
compiler/sparc/cpugas.pas

@@ -232,37 +232,30 @@ VAR
 {****************************************************************************
                             TISPARCATTASMOUTPUT
  ****************************************************************************}
-
-    const
-      ait_const2str : array[ait_const_32bit..ait_const_8bit] of string[8]=
-       (#9'.long'#9,#9'.short'#9,#9'.byte'#9);
-PROCEDURE TGasSPARC.WriteInstruction(hp:Tai);
-  VAR
-    Op:TAsmOp;
-    s:STRING;
-    i:Integer;
-    sep:STRING[3];
-  BEGIN
-    IF hp.typ<>ait_instruction
-    THEN
-      Exit;
-       taicpu(hp).SetOperandOrder(op_att);
-       op:=taicpu(hp).opcode;
-       { call maybe not translated to call }
-       s:=#9+std_op2str[op]+cond2str[taicpu(hp).condition];
-    IF is_CallJmp(op)
-    THEN
+const
+  ait_const2str:array[ait_const_32bit..ait_const_8bit]of string[8]=(#9'.long'#9,#9'.short'#9,#9'.byte'#9);
+procedure TGasSPARC.WriteInstruction(hp:Tai);
+	var
+		Op:TAsmOp;
+		s:STRING;
+		i:Integer;
+		sep:STRING[3];
+	begin
+		if hp.typ<>ait_instruction
+		then
+			Exit;
+		taicpu(hp).SetOperandOrder(op_att);
+		op:=taicpu(hp).opcode;
+	 {call maybe not translated to call}
+		s:=#9+std_op2str[op]+cond2str[taicpu(hp).condition];
+    if is_CallJmp(op)
+    then
            { call and jmp need an extra handling                          }
            { this code is only called if jmp isn't a labeled instruction  }
            { quick hack to overcome a problem with manglednames=255 chars }
-      BEGIN
-{        IF op<>A_JMPl
-        THEN
-          s:=cond2str(op,taicpu(hp).condition)+','
-        ELSE}
-          s:=#9'b'#9;
-        s:=s+getopstr_jmp(taicpu(hp).oper[0]);
-      END
+			begin
+				s:=#9+std_op2str[op]+#9+getopstr_jmp(taicpu(hp).oper[0]);
+			end
     ELSE
       BEGIN {process operands}
         s:=#9+std_op2str[op];