Browse Source

removed redundant register removal in EmitEnter.

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6381 8c9fc860-2736-0410-a75d-ab315db34111
felixf 9 năm trước cách đây
mục cha
commit
2b174d17d1
1 tập tin đã thay đổi với 7 bổ sung1 xóa
  1. 7 1
      source/FoxIntermediateBackend.Mod

+ 7 - 1
source/FoxIntermediateBackend.Mod

@@ -1339,10 +1339,13 @@ TYPE
 		VAR call, nocall: Label;
 		VAR call, nocall: Label;
 		VAR parametersSize: LONGINT;
 		VAR parametersSize: LONGINT;
 		VAR prevSection: IntermediateCode.Section;
 		VAR prevSection: IntermediateCode.Section;
+		VAR prevDump: Streams.Writer;
 		BEGIN
 		BEGIN
 			ASSERT(~procedure.type(SyntaxTree.ProcedureType).noPAF);
 			ASSERT(~procedure.type(SyntaxTree.ProcedureType).noPAF);
 			prevSection := SELF.section;
 			prevSection := SELF.section;
 			SELF.section := section;
 			SELF.section := section;
+			prevDump := dump;
+			dump := section.comments;
 			IF backend.hasLinkRegister THEN
 			IF backend.hasLinkRegister THEN
 				Emit(Push(-1, lr));
 				Emit(Push(-1, lr));
 			END;
 			END;
@@ -1375,7 +1378,6 @@ TYPE
 					ReleaseIntermediateOperand(reg);
 					ReleaseIntermediateOperand(reg);
 					CallThis(position, "Activities","ExpandStack",0);
 					CallThis(position, "Activities","ExpandStack",0);
 					Emit(Result(-1, sp));
 					Emit(Result(-1, sp));
-					ReleaseIntermediateOperand(reg);
 					nocall.Resolve(section.pc);
 					nocall.Resolve(section.pc);
 				END;
 				END;
 			ELSE
 			ELSE
@@ -1383,6 +1385,7 @@ TYPE
 			END;
 			END;
 			Emit(Enter(-1, callconv, varSize));
 			Emit(Enter(-1, callconv, varSize));
 			SELF.section := prevSection;
 			SELF.section := prevSection;
+			dump := prevDump;
 		END EmitEnter;
 		END EmitEnter;
 		
 		
 		PROCEDURE Enter(position: LONGINT; callconv: LONGINT; varSize: LONGINT): IntermediateCode.Instruction;
 		PROCEDURE Enter(position: LONGINT; callconv: LONGINT; varSize: LONGINT): IntermediateCode.Instruction;
@@ -1631,6 +1634,9 @@ TYPE
 					END;
 					END;
 				ELSIF registerUsageCount.Use(register)<0 THEN
 				ELSIF registerUsageCount.Use(register)<0 THEN
 					Warning(position, "register removed too often");
 					Warning(position, "register removed too often");
+					IF dump # NIL THEN
+						dump.String("register removed too often"); dump.Ln; dump.Update;
+					END;
 					D.TraceBack;
 					D.TraceBack;
 				END;
 				END;
 			END;
 			END;