Commit a0279e8a authored by Matthias Braun's avatar Matthias Braun
Browse files

remove unused trouts analysis

parent dc57c6ae
......@@ -46,7 +46,6 @@ libfirminclude_HEADERS = \
opcodes.h \
statev.h \
timing.h \
trouts.h \
tv.h \
typerep.h \
vrp.h
......
......@@ -106,7 +106,6 @@
#include "irverify.h"
#include "lowering.h"
#include "timing.h"
#include "trouts.h"
#include "tv.h"
#include "typerep.h"
......
/*
* This file is part of libFirm.
* Copyright (C) 2012 University of Karlsruhe.
*/
/**
* @file
* @brief Reverse edges that reference types/entities.
* @author Goetz Lindenmaier
* @date 29.10.2004
*/
#ifndef FIRM_ANA_TROUTS_H
#define FIRM_ANA_TROUTS_H
#include <stddef.h>
#include "firm_types.h"
#include "begin.h"
/**
* @ingroup ir_type
* @defgroup trouts Reverse Type Edges
* Trouts list all uses of types and entities.
* Each type gets a list of all Alloc nodes allocating it.
* Each entity gets two lists:
* - one containing all accesses (Load, (Call), Store),
* - and one containing all uses to get a reference (Address, Sel).
* @{
*/
/** Returns number of Load/Store nodes that possibly access entity @p entity. */
FIRM_API size_t get_entity_n_accesses(const ir_entity *entity);
/** Returns Load/Store node number @p pos that possibly accesses entity @p entity. */
FIRM_API ir_node *get_entity_access(const ir_entity *entity, size_t pos);
/** Returns number of references to entity @p entity, in form of Address/Sel,
* including references from constant entities and the like. */
FIRM_API size_t get_entity_n_references(const ir_entity *entity);
/** Returns reference number @p pos of references to an entity, in form of
* Address/Sel, including references from constants. */
FIRM_API ir_node *get_entity_reference(const ir_entity *entity, size_t pos);
/** Returns number of Alloc nodes that create an instance of type @p type. */
FIRM_API size_t get_type_n_allocs(const ir_type *type);
/** Returns Alloc node number @p pos that create an instance of type @p type. */
FIRM_API ir_node *get_type_alloc(const ir_type *type, size_t pos);
/** Returns number of pointertypes that point to type @p type. */
FIRM_API size_t get_type_n_pointertypes_to(const ir_type *type);
/** Returns pointer type number @p pos that points to type @p type. */
FIRM_API ir_type *get_type_pointertype_to(const ir_type *type, size_t pos);
/** Returns number of array types with element type @p type. */
FIRM_API size_t get_type_n_arraytypes_of(const ir_type *type);
/** Returns array type number @p pos with element type @p type. */
FIRM_API ir_type *get_type_arraytype_of(const ir_type *type, size_t pos);
/** Computes the outs of types and entities.
*
* Collects all reference from irnodes to types or entities in the
* corresponding types/entities. Further reverses references between
* types and entities.
*
* Annotates the following nodes:
* Address --> get_Address_entity()
* Alloc --> get_Alloc_type()
* Cast --> get_Cast_type()
* Sel --> get_Sel_entity()
* Load(addr) --> get_addr_entity() \ ent von Address, oder falls Sel: ent von
* Store(addr) --> get_addr_entity() / outermost im compound. Ansonsten: nirgends.
* d.h. wir bekommen die array Elementzugriffe
* an die jack array Klasse annotiert.
* Call(Sel) --> get_Sel_entity() // ev. Tabellenzugriff --> Load.
*
* type --> pointer type refering to this type.
* type --> entity of this type. @@@ to be implemented.
*
* Sets trout state to outs_consistent.
*/
FIRM_API void compute_trouts(void);
/** Frees trout data. */
FIRM_API void free_trouts(void);
/** @} */
#include "end.h"
#endif
......@@ -58,7 +58,6 @@ libfirm_la_SOURCES = \
ana/irmemory.c \
ana/irouts.c \
ana/irscc.c \
ana/trouts.c \
ana/vrp.c \
be/beabi.c \
be/beabihelper.c \
......@@ -266,7 +265,6 @@ EXTRA_DIST = \
ana/irloop_t.h \
ana/irmemory_t.h \
ana/execfreq_t.h \
ana/trouts_t.h \
be/be_t.h \
be/be_types.h \
be/beabi.h \
......
/*
* This file is part of libFirm.
* Copyright (C) 2012 University of Karlsruhe.
*/
/**
* @file
* @brief Reverse edges that reference types/entities.
* @author Goetz Lindenmaier
* @date 29.10.2004
*/
#include "trouts_t.h"
#include "array.h"
#include "pmap.h"
#include "irnode_t.h"
#include "irprog_t.h"
#include "irgwalk.h"
#include "irnode.h"
/*------------------------------------------------------------------*/
/* We represent the fields in entities/types by hashmaps. */
/*------------------------------------------------------------------*/
static pmap *entity_access_map;
static pmap *entity_reference_map;
static pmap *type_pointertype_map;
static pmap *type_arraytype_map;
/**
* Return a flexible array containing all IR-nodes
* that access a given entity.
*/
static ir_node **get_entity_access_array(const ir_entity *ent)
{
if (!entity_access_map) entity_access_map = pmap_create();
ir_node **res = pmap_get(ir_node*, entity_access_map, ent);
if (!res) {
res = NEW_ARR_F(ir_node *, 0);
pmap_insert(entity_access_map, ent, (void *)res);
}
return res;
}
static void set_entity_access_array(const ir_entity *ent, ir_node **accs)
{
pmap_insert(entity_access_map, ent, (void *)accs);
}
/**
* Return a flexible array containing all IR-nodes
* that reference a given entity.
*/
static ir_node **get_entity_reference_array(const ir_entity *ent)
{
if (!entity_reference_map) entity_reference_map = pmap_create();
ir_node **res = pmap_get(ir_node*, entity_reference_map, ent);
if (!res) {
res = NEW_ARR_F(ir_node *, 0);
pmap_insert(entity_reference_map, ent, (void *)res);
}
return res;
}
static void set_entity_reference_array(const ir_entity *ent, ir_node **refs)
{
pmap_insert(entity_reference_map, ent, (void *)refs);
}
/**
* Return a flexible array containing all pointer
* types that points-to a given type.
*/
static ir_type **get_type_pointertype_array(const ir_type *tp)
{
if (!type_pointertype_map) type_pointertype_map = pmap_create();
ir_type **res = pmap_get(ir_type*, type_pointertype_map, tp);
if (!res) {
res = NEW_ARR_F(ir_type *, 0);
pmap_insert(type_pointertype_map, tp, (void *)res);
}
return res;
}
static void set_type_pointertype_array(const ir_type *tp, ir_type **pts)
{
pmap_insert(type_pointertype_map, tp, (void *)pts);
}
/**
* Return a flexible array containing all array
* types that have a given type as element type.
*/
static ir_type **get_type_arraytype_array(const ir_type *tp)
{
if (!type_arraytype_map) type_arraytype_map = pmap_create();
ir_type **res = pmap_get(ir_type*, type_arraytype_map, tp);
if (!res) {
res = NEW_ARR_F(ir_type *, 0);
pmap_insert(type_arraytype_map, tp, (void *)res);
}
return res;
}
static void set_type_arraytype_array(const ir_type *tp, ir_type **pts)
{
pmap_insert(type_arraytype_map, tp, (void *)pts);
}
/*------------------------------------------------------------------*/
/* Accessing the out data structures. */
/* These routines only work properly if firm is in state */
/* trouts_consistent or trouts_inconsistent. */
/*------------------------------------------------------------------*/
/**------------------------------------------------------------------*/
/* Access routines for entities */
/**------------------------------------------------------------------*/
size_t get_entity_n_accesses(const ir_entity *ent)
{
ir_node **accs = get_entity_access_array(ent);
return ARR_LEN(accs);
}
ir_node *get_entity_access(const ir_entity *ent, size_t pos)
{
assert(pos < get_entity_n_accesses(ent));
ir_node **accs = get_entity_access_array(ent);
return accs[pos];
}
static void add_entity_access(const ir_entity *ent, ir_node *n)
{
ir_node **accs = get_entity_access_array(ent);
ARR_APP1(ir_node *, accs, n);
set_entity_access_array(ent, accs);
}
/*------------------------------------------------------------------*/
size_t get_entity_n_references(const ir_entity *ent)
{
ir_node **refs = get_entity_reference_array(ent);
return ARR_LEN(refs);
}
ir_node *get_entity_reference(const ir_entity *ent, size_t pos)
{
ir_node **refs = get_entity_reference_array(ent);
assert(pos < get_entity_n_references(ent));
return refs[pos];
}
static void add_entity_reference(const ir_entity *ent, ir_node *n)
{
ir_node **refs = get_entity_reference_array(ent);
ARR_APP1(ir_node *, refs, n);
set_entity_reference_array(ent, refs);
}
/**------------------------------------------------------------------*/
/* Access routines for types */
/**------------------------------------------------------------------*/
size_t get_type_n_pointertypes_to(const ir_type *tp)
{
ir_type **pts = get_type_pointertype_array(tp);
return ARR_LEN(pts);
}
ir_type *get_type_pointertype_to(const ir_type *tp, size_t pos)
{
ir_type **pts = get_type_pointertype_array(tp);
assert(pos < get_type_n_pointertypes_to(tp));
return pts[pos];
}
void add_type_pointertype_to(const ir_type *tp, ir_type *ptp)
{
ir_type **pts = get_type_pointertype_array(tp);
ARR_APP1(ir_type*, pts, ptp);
set_type_pointertype_array(tp, pts);
}
/*------------------------------------------------------------------*/
size_t get_type_n_arraytypes_of(const ir_type *tp)
{
ir_type **pts = get_type_arraytype_array(tp);
return ARR_LEN(pts);
}
ir_type *get_type_arraytype_of(const ir_type *tp, size_t pos)
{
ir_type **pts = get_type_arraytype_array(tp);
assert(pos < get_type_n_arraytypes_of(tp));
return pts[pos];
}
void add_type_arraytype_of(const ir_type *tp, ir_type *atp)
{
ir_type **pts = get_type_arraytype_array(tp);
ARR_APP1(ir_type*, pts, atp);
set_type_arraytype_array(tp, pts);
}
/*------------------------------------------------------------------*/
/* Building and Removing the out datastructure */
/*------------------------------------------------------------------*/
/** Initialize the trouts handling. */
static void init_trouts(void)
{
}
/** The number of entities that can be accessed by this Sel node. */
static int get_Sel_n_accessed_entities(const ir_node *sel)
{
(void)sel;
return 1;
}
/** The entity that cat be accessed by this Sel node. */
static ir_entity *get_Sel_accessed_entity(const ir_node *sel)
{
return get_Sel_entity(sel);
}
/** An addr node is an Address or a Sel. */
static int get_addr_n_entities(const ir_node *addr)
{
switch (get_irn_opcode(addr)) {
case iro_Sel:
/* Treat jack array sels? */
return get_Sel_n_accessed_entities(addr);
case iro_Address:
return 1;
default:
return 0;
}
}
/** An addr node is an Address or a Sel.
If Sel follow to outermost of compound. */
static ir_entity *get_addr_entity(const ir_node *addr, int pos)
{
(void)pos;
switch (get_irn_opcode(addr)) {
case iro_Sel: {
/* Treat jack array sels? They are compounds! Follow to outermost entity. */
ir_node *ptr = get_Sel_ptr(addr);
while (is_Sel(ptr)) {
addr = ptr;
ptr = get_Sel_ptr(addr);
}
assert(0 <= pos && pos < get_Sel_n_accessed_entities(addr));
return get_Sel_accessed_entity(addr);
}
case iro_Address:
assert(pos == 0);
return get_Address_entity(addr);
default:
return NULL;
}
}
static void chain_accesses(ir_node *n, void *env)
{
(void) env;
ir_node *addr;
if (is_Sel(n)) {
add_entity_reference(get_Sel_entity(n), n);
return;
} else if (is_Address(n)) {
add_entity_reference(get_Address_entity(n), n);
return;
} else if (is_Store(n)) {
addr = get_Store_ptr(n);
} else if (is_Load(n)) {
addr = get_Load_ptr(n);
} else if (is_Call(n)) {
addr = get_Call_ptr(n);
if (! is_Sel(addr)) return; /* Sels before Calls mean a Load / polymorphic Call. */
} else {
return;
}
for (int i = 0, n_ents = get_addr_n_entities(addr); i < n_ents; ++i) {
ir_entity *ent = get_addr_entity(addr, i);
if (ent != NULL)
add_entity_access(ent, n);
}
}
/**
* Handle chain types (pointer, array) by adding them to
* its "inner" type.
*/
static void chain_types(ir_type *tp)
{
if (is_Pointer_type(tp)) {
add_type_pointertype_to(get_pointer_points_to_type(tp), tp);
} else if (is_Array_type(tp)) {
add_type_arraytype_of(get_array_element_type(tp), tp);
}
}
void compute_trouts(void)
{
free_trouts();
init_trouts();
/* Compute outs for IR nodes. */
foreach_irp_irg_r(i, irg) {
irg_walk_graph(irg, NULL, chain_accesses, NULL);
}
walk_const_code(NULL, chain_accesses, NULL);
/* Compute outs for types */
for (size_t i = get_irp_n_types(); i-- > 0;) {
ir_type *type = get_irp_type(i);
chain_types(type);
}
}
void free_trouts(void)
{
if (entity_access_map != NULL) {
/*
for (ir_node **accs = (ir_node **)pmap_first(entity_access_map);
accs != NULL; accs = (ir_node **)pmap_next(entity_access_map)) {
DEL_ARR_F(accs);
}
*/
pmap_destroy(entity_access_map);
entity_access_map = NULL;
}
if (entity_reference_map != NULL) {
/*
for (ir_node **refs = (ir_node **)pmap_first(entity_reference_map);
refs != NULL; refs = (ir_node **)pmap_next(entity_reference_map)) {
DEL_ARR_F(refs);
}
*/
pmap_destroy(entity_reference_map);
entity_reference_map = NULL;
}
if (type_pointertype_map != NULL) {
/*
for (ir_node **pts = (ir_node **)pmap_first(type_pointertype_map);
pts != NULL; pts = (ir_node **)pmap_next(type_pointertype_map)) {
DEL_ARR_F(pts);
}
*/
pmap_destroy(type_pointertype_map);
type_pointertype_map = NULL;
}
if (type_arraytype_map) {
/*
for (ir_node **pts = (ir_node **)pmap_first(type_arraytype_map);
pts != NULL; pts = (ir_node **)pmap_next(type_arraytype_map)) {
DEL_ARR_F(pts);
}
*/
pmap_destroy(type_arraytype_map);
type_arraytype_map = NULL;
}
}
/*
* This file is part of libFirm.
* Copyright (C) 2012 University of Karlsruhe.
*/
/**
* @file
* @brief Reverse edges that reference types/entities.
* @author Goetz Lindenmaier
* @date 29.10.2004
*/
#ifndef FIRM_ANA_TROUTS_T_H
#define FIRM_ANA_TROUTS_T_H
#include "trouts.h"
void add_type_pointertype_to(const ir_type *tp, ir_type *ptp);
void add_type_arraytype_of(const ir_type *tp, ir_type *atp);
#endif
......@@ -18,7 +18,6 @@
#include "irhooks.h"
#include "iredges.h"
#include "irouts.h"
#include "trouts.h"
#include "irgmod.h"
#include "cgana.h"
#include "debug.h"
......
......@@ -19,7 +19,6 @@
#include "irprog_t.h"
#include "entity_t.h"
#include "trouts.h"
#include "irgwalk.h"
#include "tv_t.h"
#include "irprintf.h"
......
......@@ -19,7 +19,6 @@
#include "ircons_t.h"
#include "irgmod.h"
#include "irgopt.h"
#include "trouts.h"
#include "irverify.h"
#include "pmap.h"
#include "array.h"
......
......@@ -23,7 +23,6 @@
#include "irgwalk.h"
#include "cgana.h"
#include "irouts.h"
#include "trouts.h"
#include "iropt_t.h"
#include "pmap.h"
......@@ -86,7 +85,6 @@ void dead_node_elimination(ir_graph *irg)
/* Handle graph state */
free_callee_info(irg);
free_irg_outs(irg);
free_trouts();
free_loop_information(irg);
free_vrp_data(irg);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
......
......@@ -18,7 +18,6 @@
#include "irnode_t.h"
#include "iropt_t.h"
#include "array.h"
#include "trouts.h"
#include "irgwalk.h"
#include "set.h"
#include "debug.h"
......
......@@ -35,7 +35,6 @@
#include "irbackedge_t.h"
#include "opt_init.h"
#include "cgana.h"
#include "trouts.h"
#include "error.h"
#include "irmemory_t.h"
......
......@@ -127,7 +127,7 @@ void normalize_one_return(ir_graph *irg)
/* invalidate analysis information:
* a new Block was added, so dominator, outs and loop are inconsistent,
* trouts and callee-state should be still valid */
* callee-state should be still valid */
confirm_irg_properties(irg,
IR_GRAPH_PROPERTY_NO_BADS
| IR_GRAPH_PROPERTY_NO_TUPLES
......@@ -337,7 +337,7 @@ void normalize_n_returns(ir_graph *irg)
/* Invalidate analysis information:
* Blocks become dead and new Returns were deleted, so dominator, outs and
* loop are inconsistent, trouts and callee-state should be still valid */
* loop are inconsistent, callee-state should be still valid */
confirm_irg_properties(irg,
IR_GRAPH_PROPERTY_NO_TUPLES
| IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES
......
......@@ -24,7 +24,6 @@
#include "irgraph_t.h"
#include "ircons.h"
#include "irflag.h"
#include "trouts.h"
#include "irouts_t.h"
#include "irhooks.h"
#include "ircons_t.h"
......
......@@ -7085,37 +7085,6 @@
RelativePath="..\ir\ana\structure.c"
>
</File>
<File
RelativePath="..\ir\ana\trouts.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>