X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Fcgana.h;h=ea9829645b71b95515bf912c373b92c138ce5720;hb=d0d85962ef52c14950db90e5981a7bea36023ab3;hp=77b4c9bb0442dd923e56bf026be870651d024277;hpb=fe1e62d9503f211c7829369b0e6550744c4de948;p=libfirm diff --git a/ir/ana/cgana.h b/ir/ana/cgana.h index 77b4c9bb0..ea9829645 100644 --- a/ir/ana/cgana.h +++ b/ir/ana/cgana.h @@ -1,48 +1,86 @@ -/* ------------------------------------------------------------------- - * $Id$ - * ------------------------------------------------------------------- +/* + * Project: libFIRM + * File name: ir/ana/cgana.h + * Purpose: Intraprozedural analyses to estimate the call graph. + * Author: Hubert Schmid + * Modified by: + * Created: 09.06.2002 + * CVS-ID: $Id$ + * Copyright: (c) 1999-2003 Universität Karlsruhe + * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + */ + +/** * Intraprozedurale Analyse zur Abschätzung der Aufrulrelation. Es * wird eine Menge von freien Methoden und anschließend die an den * Call-Operationen aufrufbaren Methoden bestimmt. * - * Erstellt: Hubert Schmid, 09.06.2002 - * ---------------------------------------------------------------- */ - + */ #ifndef _CGANA_H_ #define _CGANA_H_ - #include "entity.h" - /* Methoden sind "frei", wenn ihr Funktionszeiger (potentiell) - *"explizit" bekannt ist, d.h.: + * "explizit" bekannt ist, d.h.: * - * - die Methode ist von außen sichtbar (external_visible). + * - die Methode ist von aussen sichtbar (external_visible). * * - ihr Funktionszeiger ist "frei", d.h. der Funktionszeiger wurde - * nicht ausschließlich an den entsprechenden Eingang eines + * nicht ausschliesslich an den entsprechenden Eingang eines * Call-Knotens weitergegeben, sondern z.B. in den Speicher - * geschrieben, als Parameter übergeben, ... + * geschrieben, als Parameter uebergeben, ... * * Die main-Methode ist immer in der Menge enthalten. * - * Die Links an den "ir_node"s werden gelöscht. */ + * Die Links an den "ir_node"s werden geloescht. + */ +/** Analyses a rough estimation of the possible call graph. + * + * Determines for each Call node the set of possibly called methods. + * Stores the result in the field 'callees' of the Call node. If the + * address can not be analysed, e.g. because it is loaded from a + * variable, the array contains the unknown_entity. (See + * "set_Call_callee"). cgana returns the set of 'free' methods, i.e., + * the methods that can be called from external or via function + * pointers. This datastructure must be freed with 'free()' by the + * caller of cgana. + * + * cgana sets the callee_info_state of each graph and the program to + * consistent. + * + * The algorithm implements roughly Static Class Hierarchy Analysis + * as described in "Optimization of Object-Oriented Programs Using + * Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove + * and Craig Chambers. + * + * Performs some optimizations possible by the analysed information: + * - Replace SymConst-name nodes by SymConst-entity nodes if possible. + * - Replace (Sel-method(Alloc)) by SymConst-entity. + * - Replaces Sel nodes by Bad if there is no implementation for the + * selected entity. + * - Replaces Sel-method by SymConst-entity if the method is never overwritten. + * - Replaces Calls by Tuple containing Bads if callee array is empty + * (there is no implementation to call) + * + * Leaves Bad control predecessors in the graph! + */ +void cgana(int *len, ir_entity ***free_methods); -/* Bestimmt für jede Call-Operation die Menge der aufrufbaren Methode - * und speichert das Ergebnis in der Call-Operation. (siehe - * "set_Call_callee"). Die Methode gibt die Menge der - * "freien" Methoden zurück, die vom Aufrufer wieder freigegeben - * werden muss (free). +/** Free callee information. * - * Performs some optimizations possible by the analysed information: - * - Replace SymConst nodes by Const nodes if possible, - * - Replace (Sel-method(Alloc)) by Const method, - * - Replaces unreachable Sel nodes by Bad (@@@ was genau meint unreachable?) - * - Replaces Sel-method by Const if the Method is never overwritten */ -void cgana(int *len, entity ***free_methods); + * Sets callee_info_state of the graph passed to none. Sets callee field + * in all call nodes to NULL. Else it happens that the field contains + * pointers to other than firm arrays. + */ +void free_callee_info(ir_graph *irg); +void free_irp_callee_info(void); + +/* Optimize the address expressions passed to call nodes. + * Performs only the optimizations done by cgana. */ +void opt_call_addrs(void); #endif /* _CGANA_H_ */