~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to compiler/aoptda.pas

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{
2
 
    $Id: aoptda.pas,v 1.7 2004/01/31 17:45:16 peter Exp $
3
 
    Copyright (c) 1998-2002 by Jonas Maebe, member of the Free Pascal
4
 
    Development Team
5
 
 
6
 
    This unit contains the data flow analyzer object of the assembler
7
 
    optimizer.
8
 
 
9
 
    This program is free software; you can redistribute it and/or modify
10
 
    it under the terms of the GNU General Public License as published by
11
 
    the Free Software Foundation; either version 2 of the License, or
12
 
    (at your option) any later version.
13
 
 
14
 
    This program is distributed in the hope that it will be useful,
15
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
    GNU General Public License for more details.
18
 
 
19
 
    You should have received a copy of the GNU General Public License
20
 
    along with this program; if not, write to the Free Software
21
 
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
 
 
23
 
 ****************************************************************************
24
 
}
25
 
Unit aoptda;
26
 
 
27
 
Interface
28
 
 
29
 
uses aasm, cpubase, aoptcpub, aoptbase, aoptcpu;
30
 
 
31
 
Type
32
 
  TAOptDFA = Object(TAoptCpu)
33
 
    { uses the same constructor as TAoptCpu = constructor from TAoptObj }
34
 
 
35
 
    { gathers the information regarding the contents of every register }
36
 
    { at the end of every instruction                                  }
37
 
    Procedure DoDFA;
38
 
 
39
 
    { handles the processor dependent dataflow analizing               }
40
 
    Procedure CpuDFA(p: PInstr); Virtual;
41
 
 
42
 
    { How many instructions are between the current instruction and the }
43
 
    { last one that modified the register                               }
44
 
    InstrSinceLastMod: TInstrSinceLastMod;
45
 
 
46
 
    { convert a TInsChange value into the corresponding register }
47
 
    Function TCh2Reg(Ch: TInsChange): TRegister; Virtual;
48
 
    { returns whether the instruction P reads from register Reg }
49
 
    Function RegReadByInstr(Reg: TRegister; p: Pai): Boolean; Virtual;
50
 
  End;
51
 
 
52
 
Implementation
53
 
 
54
 
uses globals, aoptobj;
55
 
 
56
 
Procedure TAOptDFA.DoDFA;
57
 
{ Analyzes the Data Flow of an assembler list. Analyses the reg contents     }
58
 
{ for the instructions between blockstart and blockend. Returns the last pai }
59
 
{ which has been processed                                                   }
60
 
Var
61
 
    CurProp: PPaiProp;
62
 
    UsedRegs: TUsedRegs;
63
 
    p, hp, NewBlockStart : Pai;
64
 
    TmpReg: TRegister;
65
 
Begin
66
 
  p := BlockStart;
67
 
  UsedRegs.init;
68
 
  UsedRegs.Update(p);
69
 
  NewBlockStart := SkipHead(p);
70
 
  { done implicitely by the constructor
71
 
  FillChar(InstrSinceLastMod, SizeOf(InstrSinceLastMod), 0); }
72
 
  While (P <> BlockEnd) Do
73
 
    Begin
74
 
      CurProp := New(PPaiProp, init);
75
 
      If (p <> NewBlockStart) Then
76
 
        Begin
77
 
          GetLastInstruction(p, hp);
78
 
          CurProp^.Regs := PPaiProp(hp^.OptInfo)^.Regs;
79
 
{ !!!!!!!!!!!! }
80
 
{$ifdef x86}
81
 
          CurProp^.CondRegs.Flags :=
82
 
            PPaiProp(hp^.OptInfo)^.CondRegs.Flags;
83
 
{$endif}
84
 
        End;
85
 
      CurProp^.UsedRegs.InitWithValue(UsedRegs.GetUsedRegs);
86
 
      UsedRegs.Update(Pai(p^.Next));
87
 
      PPaiProp(p^.OptInfo) := CurProp;
88
 
      For TmpReg := LoGPReg To HiGPReg Do
89
 
        Inc(InstrSinceLastMod[TmpReg]);
90
 
      Case p^.typ Of
91
 
        ait_label:
92
 
          If (Pai_label(p)^.l^.is_used) Then
93
 
            CurProp^.DestroyAllRegs(InstrSinceLastMod);
94
 
{$ifdef GDB}
95
 
        ait_stabs, ait_stabn, ait_stab_function_name:;
96
 
{$endif GDB}
97
 
        ait_instruction:
98
 
          if not(PInstr(p)^.is_jmp) then
99
 
            begin
100
 
              If IsLoadMemReg(p) Then
101
 
                Begin
102
 
                  CurProp^.ReadRef(PInstr(p)^.oper[LoadSrc].ref);
103
 
                  TmpReg := RegMaxSize(PInstr(p)^.oper[LoadDst].reg);
104
 
                  If RegInRef(TmpReg, PInstr(p)^.oper[LoadSrc].ref^) And
105
 
                     (CurProp^.GetRegContentType(TmpReg) = Con_Ref) Then
106
 
                    Begin
107
 
                      { a load based on the value this register already }
108
 
                      { contained                                       }
109
 
                      With CurProp^.Regs[TmpReg] Do
110
 
                        Begin
111
 
                          CurProp^.IncWState(TmpReg);
112
 
                           {also store how many instructions are part of the  }
113
 
                           { sequence in the first instruction's PPaiProp, so }
114
 
                           { it can be easily accessed from within            }
115
 
                           { CheckSequence                                    }
116
 
                          Inc(NrOfMods, InstrSinceLastMod[TmpReg]);
117
 
                          PPaiProp(Pai(StartMod)^.OptInfo)^.Regs[TmpReg].NrOfMods := NrOfMods;
118
 
                          InstrSinceLastMod[TmpReg] := 0
119
 
                        End
120
 
                    End
121
 
                  Else
122
 
                    Begin
123
 
                      { load of a register with a completely new value }
124
 
                      CurProp^.DestroyReg(TmpReg, InstrSinceLastMod);
125
 
                      If Not(RegInRef(TmpReg, PInstr(p)^.oper[LoadSrc].ref^)) Then
126
 
                        With CurProp^.Regs[TmpReg] Do
127
 
                          Begin
128
 
                            Typ := Con_Ref;
129
 
                            StartMod := p;
130
 
                            NrOfMods := 1;
131
 
                          End
132
 
                    End;
133
 
  {$ifdef StateDebug}
134
 
                    hp := new(pai_asm_comment,init(strpnew(std_reg2str[TmpReg]+': '+tostr(CurProp^.Regs[TmpReg].WState))));
135
 
                    InsertLLItem(AsmL, p, p^.next, hp);
136
 
  {$endif StateDebug}
137
 
 
138
 
                End
139
 
              Else if IsLoadConstReg(p) Then
140
 
                Begin
141
 
                  TmpReg := RegMaxSize(PInstr(p)^.oper[LoadDst].reg);
142
 
                  With CurProp^.Regs[TmpReg] Do
143
 
                    Begin
144
 
                      CurProp^.DestroyReg(TmpReg, InstrSinceLastMod);
145
 
                      typ := Con_Const;
146
 
                      StartMod := Pointer(PInstr(p)^.oper[LoadSrc].val);
147
 
                    End
148
 
                End
149
 
              Else CpuDFA(Pinstr(p));
150
 
            End;
151
 
        Else CurProp^.DestroyAllRegs(InstrSinceLastMod);
152
 
      End;
153
 
{      Inc(InstrCnt);}
154
 
      GetNextInstruction(p, p);
155
 
    End;
156
 
End;
157
 
 
158
 
Procedure TAoptDFA.CpuDFA(p: PInstr);
159
 
Begin
160
 
  Abstract;
161
 
End;
162
 
 
163
 
Function TAOptDFA.TCh2Reg(Ch: TInsChange): TRegister;
164
 
Begin
165
 
  TCh2Reg:=R_NO;
166
 
  Abstract;
167
 
End;
168
 
 
169
 
Function TAOptDFA.RegReadByInstr(Reg: TRegister; p: Pai): Boolean;
170
 
Begin
171
 
  RegReadByInstr:=false;
172
 
  Abstract;
173
 
End;
174
 
 
175
 
 
176
 
End.
177
 
 
178
 
{
179
 
  $Log: aoptda.pas,v $
180
 
  Revision 1.7  2004/01/31 17:45:16  peter
181
 
    * Change several $ifdef i386 to x86
182
 
    * Change several OS_32 to OS_INT/OS_ADDR
183
 
 
184
 
  Revision 1.6  2002/05/18 13:34:05  peter
185
 
    * readded missing revisions
186
 
 
187
 
  Revision 1.5  2002/05/16 19:46:35  carl
188
 
  + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
189
 
  + try to fix temp allocation (still in ifdef)
190
 
  + generic constructor calls
191
 
  + start of tassembler / tmodulebase class cleanup
192
 
 
193
 
  Revision 1.3  2002/04/15 18:55:40  carl
194
 
  + change reg2str array use
195
 
 
196
 
  Revision 1.2  2002/04/14 16:49:30  carl
197
 
  + att_reg2str -> gas_reg2str
198
 
 
199
 
}