]> git.pld-linux.org Git - packages/fpc.git/blame - fpc-poptasm.patch
- new %%doc
[packages/fpc.git] / fpc-poptasm.patch
CommitLineData
da49cbc9
AM
1Index: compiler/popt386.pas
2===================================================================
3RCS file: /FPC/CVS/fpc/compiler/Attic/popt386.pas,v
4retrieving revision 1.1.2.7
5retrieving revision 1.1.2.9
6diff -u -r1.1.2.7 -r1.1.2.9
7--- compiler/popt386.pas 2000/12/05 09:55:09 1.1.2.7
8+++ compiler/popt386.pas 2001/01/10 10:27:55 1.1.2.9
9@@ -1,5 +1,5 @@
10 {
11- $Id$
12+ $Id$
13 Copyright (c) 1998-2000 by Florian Klaempfl and Jonas Maebe
14
15 This unit contains the peephole optimizer.
16@@ -1510,16 +1510,16 @@
17 If (AktOptProcessor < ClassP6) And
18 GetNextInstruction(p, hp1) And
19 (hp1^.typ = ait_instruction) And
20- (paicpu(hp1)^.opcode = A_JMP) Then
21+ (paicpu(hp1)^.opcode = A_JMP) And
22+ (paicpu(hp1)^.oper[0].typ = top_symbol) Then
23 Begin
24- Inc(paicpu(hp1)^.oper[0].sym^.refs);
25 hp2 := New(Paicpu,op_sym(A_PUSH,S_L,paicpu(hp1)^.oper[0].sym));
26 InsertLLItem(AsmL, p^.previous, p, hp2);
27 Paicpu(p)^.opcode := A_JMP;
28+ Paicpu(p)^.is_jmp := true;
29 AsmL^.Remove(hp1);
30 Dispose(hp1, Done)
31 End;
32-
33 {$ifdef USECMOV}
34 A_Jcc:
35 if (aktspecificoptprocessor=ClassP6) then
36@@ -1760,6 +1760,12 @@
37
38 {
39 $Log$
40+ Revision 1.1.2.9 2001/01/10 10:27:55 jonas
41+ * really fixed problems with -Op2 opts
42+
43+ Revision 1.1.2.8 2001/01/07 15:46:36 jonas
44+ * fixed bug in call/jmp optimization with -Op1 and -Op2
45+
46 Revision 1.1.2.7 2000/12/05 09:55:09 jonas
47 - removed all newoptimizations stuff since it will never be active under
48 1.0.x anyway
49Index: compiler/cpuasm.pas
50===================================================================
51RCS file: /FPC/CVS/fpc/compiler/Attic/cpuasm.pas,v
52retrieving revision 1.1.2.2
53retrieving revision 1.1.2.5
54diff -u -r1.1.2.2 -r1.1.2.5
55--- compiler/cpuasm.pas 2000/10/15 10:51:15 1.1.2.2
56+++ compiler/cpuasm.pas 2001/01/13 15:03:26 1.1.2.5
57@@ -1,5 +1,5 @@
58 {
59- $Id$
60+ $Id$
61 Copyright (c) 1998-2000 by Florian Klaempfl and Peter Vreman
62
63 Contains the assembler object for the i386
64@@ -117,11 +117,13 @@
65 procedure CheckNonCommutativeOpcodes;
66 private
67 segprefix : tregister;
68+ swapped : boolean;
69 procedure init(op : tasmop;_size : topsize); { this need to be called by all constructor }
70 {$ifndef NOAG386BIN}
71 public
72 { the next will reset all instructions that can change in pass 2 }
73 procedure ResetPass2;
74+ function CheckIfValid:boolean;
75 function Pass1(offset:longint):longint;virtual;
76 procedure Pass2;virtual;
77 private
78@@ -318,6 +320,7 @@
79 begin
80 typ:=ait_instruction;
81 is_jmp:=false;
82+ swapped:=false;
83 segprefix:=R_NO;
84 opcode:=op;
85 opsize:=_size;
86@@ -552,14 +555,15 @@
87 var
88 i : longint;
89 begin
90-{$ifndef nojmpfix}
91- if is_jmp then
92- dec(PasmLabel(oper[0].sym)^.refs)
93- else
94-{$endif nojmpfix}
95- for i:=1 to ops do
96- if (oper[i-1].typ=top_ref) then
97- dispose(oper[i-1].ref);
98+ case oper[0].typ of
99+ top_ref:
100+ dispose(oper[0].ref);
101+ top_symbol:
102+ dec(Pasmsymbol(oper[0].sym)^.refs);
103+ end;
104+ for i:=2 to ops do
105+ if (oper[i-1].typ=top_ref) then
106+ dispose(oper[i-1].ref);
107 inherited done;
108 end;
109
110@@ -662,6 +666,8 @@
111 var
112 p : TOper;
113 begin
114+ if Swapped then
115+ exit;
116 { Fix the operands which are in AT&T style and we need them in Intel style }
117 case ops of
118 2 : begin
119@@ -677,6 +683,7 @@
120 oper[2]:=p;
121 end;
122 end;
123+ Swapped:=true;
124 end;
125
126 { This check must be done with the operand in ATT order
127@@ -932,20 +939,15 @@
128 end;
129
130
131-function taicpu.Pass1(offset:longint):longint;
132+function taicpu.CheckIfValid:boolean;
133 var
134 m,i : longint;
135 begin
136- Pass1:=0;
137-{ Save the old offset and set the new offset }
138- InsOffset:=Offset;
139+ CheckIfValid:=false;
140 { Things which may only be done once, not when a second pass is done to
141 optimize }
142 if Insentry=nil then
143 begin
144- { Check if error last time then InsSize=-1 }
145- if InsSize=-1 then
146- exit;
147 { We need intel style operands }
148 SwapOperands;
149 { create the .ot fields }
150@@ -955,16 +957,9 @@
151 end
152 else
153 begin
154-{$ifdef PASS2FLAG}
155- { we are here in a second pass, check if the instruction can be optimized }
156- if (InsEntry^.flags and IF_PASS2)=0 then
157- begin
158- Pass1:=InsSize;
159- exit;
160- end;
161- { update the .ot fields, some top_const can be updated }
162- create_ot;
163-{$endif}
164+ { we've already an insentry so it's valid }
165+ CheckIfValid:=true;
166+ exit;
167 end;
168 { Lookup opcode in the table }
169 InsSize:=-1;
170@@ -987,8 +982,7 @@
171 InsSize:=calcsize(insentry);
172 if (segprefix<>R_NO) then
173 inc(InsSize);
174- Pass1:=InsSize;
175- LastInsOffset:=InsOffset;
176+ CheckIfValid:=true;
177 exit;
178 end;
179 inc(i);
180@@ -999,6 +993,45 @@
181 { No instruction found, set insentry to nil and inssize to -1 }
182 insentry:=nil;
183 inssize:=-1;
184+end;
185+
186+
187+
188+function taicpu.Pass1(offset:longint):longint;
189+begin
190+ Pass1:=0;
191+{ Save the old offset and set the new offset }
192+ InsOffset:=Offset;
193+{ Things which may only be done once, not when a second pass is done to
194+ optimize }
195+ if Insentry=nil then
196+ begin
197+ { Check if error last time then InsSize=-1 }
198+ if InsSize=-1 then
199+ exit;
200+ { set the file postion }
201+ aktfilepos:=fileinfo;
202+ end
203+ else
204+ begin
205+{$ifdef PASS2FLAG}
206+ { we are here in a second pass, check if the instruction can be optimized }
207+ if (InsEntry^.flags and IF_PASS2)=0 then
208+ begin
209+ Pass1:=InsSize;
210+ exit;
211+ end;
212+ { update the .ot fields, some top_const can be updated }
213+ create_ot;
214+{$endif}
215+ end;
216+{ Check if it's a valid instruction }
217+ if CheckIfValid then
218+ begin
219+ LastInsOffset:=InsOffset;
220+ Pass1:=InsSize;
221+ exit;
222+ end;
223 LastInsOffset:=-1;
224 end;
225
226@@ -1677,6 +1710,12 @@
227 end.
228 {
229 $Log$
230+ Revision 1.1.2.5 2001/01/13 15:03:26 jonas
231+ * fixed bug in taicpu.done regardin top_symbols
232+
233+ Revision 1.1.2.4 2001/01/12 19:18:02 peter
234+ * check for valid asm instructions
235+
236 Revision 1.1.2.2 2000/10/15 10:51:15 florian
237 * fixed xmm register access
238
239@@ -1743,4 +1782,4 @@
240 Revision 1.17 1999/08/01 23:55:53 michael
241 * Moved taitempalloc
242
243-}
244\ No newline at end of file
245+}
This page took 0.050838 seconds and 4 git commands to generate.