123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- {
- DFA
- Copyright (c) 2007 by Florian Klaempfl
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- ****************************************************************************
- }
- unit optdfa;
- {$i fpcdefs.inc}
- interface
- uses
- node;
- procedure createoptinfo(node : tnode);
- implementation
- uses
- globtype,globals,
- cpuinfo,
- nutils,
- nbas,nflw,ncon,ninl,ncal,
- optutils;
- function initnodes(var n:tnode; arg: pointer) : foreachnoderesult;
- begin
- { node worth to add? }
- if (node_complexity(n)>1) and (tstoreddef(n.resultdef).is_intregable or tstoreddef(n.resultdef).is_fpuregable) then
- begin
- plists(arg)^.nodelist.Add(n);
- plists(arg)^.locationlist.Add(@n);
- result:=fen_false;
- end
- else
- result:=fen_norecurse_false;
- end;
- {
- x:=f; read: [f]
- while x do read: []
- a:=b; read: [a,b,d] def: [a] life: read*def=[a]
- c:=d; read: [a,d] def: [a,c] life: read*def=[a]
- e:=a; read: [a] def: [a,c,e] life: read*def=[a]
- function f(b,d,x : type) : type;
- begin
- while x do alive: b,d,x
- begin
- a:=b; alive: b,d,x
- c:=d; alive: a,d,x
- e:=a+c; alive: a,c,x
- dec(x); alive: c,e,x
- end;
- result:=c+e; alive: c,e
- end; alive: result
- }
- type
- tdfainfo = record
- definitionlist : tfplist;
- lifelist : tfplist;
- end;
- procedure createdfainfo(node : tnode);
- begin
- { first, add controll flow information }
- SetNodeSucessors(node);
- { now, collect life information }
- end;
- end.
|