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

remove irsimpletype stuff (unused/broken)

[r28043]
parent e36a82c5
......@@ -102,7 +102,6 @@
#include "irpass.h"
#include "irprintf.h"
#include "irprog.h"
#include "irsimpletype.h"
#include "irtypeinfo.h"
#include "irverify.h"
#include "lowering.h"
......
......@@ -1207,22 +1207,6 @@ FIRM_API ir_node *new_rd_Cond(dbg_info *db, ir_node *block, ir_node *c);
FIRM_API ir_node *new_rd_Return(dbg_info *db, ir_node *block,
ir_node *store, int arity, ir_node *in[]);
/** Constructor for a Const_type node.
*
* Adds the node to the start block.
*
* The constant represents a target value. This constructor sets high
* level type information for the constant value.
* Derives mode from passed tarval.
*
* @param *db A pointer for debug information.
* @param *irg The IR graph the node belongs to.
* @param *con Points to an entry in the constant table.
* @param *tp The type of the constant.
*/
FIRM_API ir_node *new_rd_Const_type(dbg_info *db, ir_graph *irg,
tarval *con, ir_type *tp);
/** Constructor for a Const node.
*
* Adds the node to the start block.
......@@ -1255,7 +1239,7 @@ FIRM_API ir_node *new_rd_Const(dbg_info *db, ir_graph *irg, tarval *con);
FIRM_API ir_node *new_rd_Const_long(dbg_info *db, ir_graph *irg,
ir_mode *mode, long value);
/** Constructor for a SymConst_type node.
/** Constructor for a SymConst node.
*
* This is the constructor for a symbolic constant.
* There are several kinds of symbolic constants:
......@@ -1289,15 +1273,6 @@ FIRM_API ir_node *new_rd_Const_long(dbg_info *db, ir_graph *irg,
* @param val A type, ident, entity or enum constant depending on the
* SymConst kind.
* @param kind The kind of the symbolic constant, see the list above
* @param tp The source type of the constant.
*/
FIRM_API ir_node *new_rd_SymConst_type(dbg_info *db, ir_graph *irg,
ir_mode *mode, union symconst_symbol val,
symconst_kind kind, ir_type *tp);
/** Constructor for a SymConst node.
*
* Same as new_rd_SymConst_type, except that it sets the type to type_unknown.
*/
FIRM_API ir_node *new_rd_SymConst(dbg_info *db, ir_graph *irg, ir_mode *mode,
union symconst_symbol value,
......@@ -1305,51 +1280,46 @@ FIRM_API ir_node *new_rd_SymConst(dbg_info *db, ir_graph *irg, ir_mode *mode,
/** Constructor for a SymConst addr_ent node.
*
* Same as new_rd_SymConst_type, except that the constructor is tailored for
* Same as new_rd_SymConst, except that the constructor is tailored for
* symconst_addr_ent.
* Adds the SymConst to the start block of irg. */
FIRM_API ir_node *new_rd_SymConst_addr_ent(dbg_info *db, ir_graph *irg,
ir_mode *mode, ir_entity *symbol,
ir_type *tp);
ir_mode *mode, ir_entity *symbol);
/** Constructor for a SymConst ofs_ent node.
*
* Same as new_rd_SymConst_type, except that the constructor is tailored for
* Same as new_rd_SymConst, except that the constructor is tailored for
* symconst_ofs_ent.
* Adds the SymConst to the start block of irg.
*/
FIRM_API ir_node *new_rd_SymConst_ofs_ent(dbg_info *db, ir_graph *irg,
ir_mode *mode, ir_entity *symbol,
ir_type *tp);
ir_mode *mode, ir_entity *symbol);
/** Constructor for a SymConst type_tag node.
*
* Same as new_rd_SymConst_type, except that the constructor is tailored for
* Same as new_rd_SymConst, except that the constructor is tailored for
* symconst_type_tag.
* Adds the SymConst to the start block of irg.
*/
FIRM_API ir_node *new_rd_SymConst_type_tag(dbg_info *db, ir_graph *irg,
ir_mode *mode, ir_type *symbol,
ir_type *tp);
ir_mode *mode, ir_type *symbol);
/** Constructor for a SymConst size node.
*
* Same as new_rd_SymConst_type, except that the constructor is tailored for
* Same as new_rd_SymConst, except that the constructor is tailored for
* symconst_type_size.
* Adds the SymConst to the start block of irg. */
FIRM_API ir_node *new_rd_SymConst_size(dbg_info *db, ir_graph *irg,
ir_mode *mode, ir_type *symbol,
ir_type *tp);
ir_mode *mode, ir_type *symbol);
/** Constructor for a SymConst size node.
*
* Same as new_rd_SymConst_type, except that the constructor is tailored for
* Same as new_rd_SymConst, except that the constructor is tailored for
* symconst_type_align.
* Adds the SymConst to the start block of irg.
*/
FIRM_API ir_node *new_rd_SymConst_align(dbg_info *db, ir_graph *irg,
ir_mode *mode, ir_type *symbol,
ir_type *tp);
ir_mode *mode, ir_type *symbol);
/** Constructor for a simpleSel node.
*
......@@ -2052,20 +2022,6 @@ FIRM_API ir_node *new_r_Const(ir_graph *irg, tarval *con);
*/
FIRM_API ir_node *new_r_Const_long(ir_graph *irg, ir_mode *mode, long value);
/** Constructor for a Const_type node.
*
* Adds the node to the start block.
*
* The constant represents a target value. This constructor sets high
* level type information for the constant value.
* Derives mode from passed tarval.
*
* @param *irg The IR graph the node belongs to.
* @param *con Points to an entry in the constant table.
* @param *tp The type of the constant.
*/
FIRM_API ir_node *new_r_Const_type(ir_graph *irg, tarval *con, ir_type *tp);
/** Constructor for a SymConst node.
*
* This is the constructor for a symbolic constant.
......@@ -2759,21 +2715,6 @@ FIRM_API ir_node *new_d_Cond(dbg_info *db, ir_node *c);
FIRM_API ir_node *new_d_Return(dbg_info *db, ir_node *store,
int arity, ir_node *in[]);
/** Constructor for a Const_type node.
*
* Adds the node to the start block.
*
* The constant represents a target value. This constructor sets high
* level type information for the constant value.
* Derives mode from passed tarval.
*
* @param *db A pointer for debug information.
* @param *con Points to an entry in the constant table. This pointer is
added to the attributes of the node.
* @param *tp The type of the constant.
*/
FIRM_API ir_node *new_d_Const_type(dbg_info *db, tarval *con, ir_type *tp);
/** Constructor for a Const node.
*
* Adds the node to the block in current_ir_block.
......@@ -2798,7 +2739,7 @@ FIRM_API ir_node *new_d_Const(dbg_info *db, tarval *con);
*/
FIRM_API ir_node *new_d_Const_long(dbg_info *db, ir_mode *mode, long value);
/** Constructor for a SymConst_type node.
/** Constructor for a SymConst node.
*
* This is the constructor for a symbolic constant.
* There are several kinds of symbolic constants:
......@@ -2831,15 +2772,6 @@ FIRM_API ir_node *new_d_Const_long(dbg_info *db, ir_mode *mode, long value);
* @param value A type, ident, entity or enum constant depending on the
* SymConst kind.
* @param kind The kind of the symbolic constant, see the list above
* @param tp The source type of the constant.
*/
FIRM_API ir_node *new_d_SymConst_type(dbg_info *db, ir_mode *mode,
union symconst_symbol value,
symconst_kind kind, ir_type *tp);
/** Constructor for a SymConst node.
*
* Same as new_d_SymConst_type, except that it sets the type to type_unknown.
*/
FIRM_API ir_node *new_d_SymConst(dbg_info *db, ir_mode *mode,
union symconst_symbol value,
......@@ -3539,48 +3471,6 @@ FIRM_API ir_node *new_Const(tarval *con);
*/
FIRM_API ir_node *new_Const_long(ir_mode *mode, long value);
/** Constructor for a Const node.
*
* Derives mode from passed tarval. */
FIRM_API ir_node *new_Const_type(tarval *con, ir_type *tp);
/** Constructor for a SymConst_type node.
*
* This is the constructor for a symbolic constant.
* There are several kinds of symbolic constants:
* - symconst_type_tag The symbolic constant represents a type tag. The
* type the tag stands for is given explicitly.
* - symconst_type_size The symbolic constant represents the size of a type.
* The type of which the constant represents the size
* is given explicitly.
* - symconst_type_align The symbolic constant represents the alignment of a
* type. The type of which the constant represents the
* size is given explicitly.
* - symconst_addr_ent The symbolic constant represents the address of an
* entity (variable or method). The variable is given
* explicitly by a firm entity.
* - symconst_ofs_ent The symbolic constant represents the offset of an
* entity in its owner type.
* - symconst_enum_const The symbolic constant is a enumeration constant of
* an enumeration type.
*
* Inputs to the node:
* No inputs except the block it belongs to.
* Outputs of the node.
* An unsigned integer (I_u) or a pointer (P).
*
* Mention union in declaration so that the firmjni generator recognizes that
* it can not cast the argument to an int.
*
* @param mode The mode for the SymConst.
* @param value A type, ident, entity or enum constant depending on the
* SymConst kind.
* @param kind The kind of the symbolic constant, see the list above
* @param tp The source type of the constant.
*/
FIRM_API ir_node *new_SymConst_type(ir_mode *mode, union symconst_symbol value,
symconst_kind kind, ir_type *tp);
/** Constructor for a SymConst node.
*
* This is the constructor for a symbolic constant.
......
......@@ -391,14 +391,6 @@ FIRM_API int is_strictConv(const ir_node *node);
/** Returns true if node is a SymConst node with kind symconst_addr_ent. */
FIRM_API int is_SymConst_addr_ent(const ir_node *node);
/** Returns the source language type of a Const node.
* Must be an atomic type. Mode of type must be mode of node.
*/
FIRM_API ir_type *get_Const_type(const ir_node *node);
/** Sets the source language type of a Const node. */
FIRM_API void set_Const_type(ir_node *node, ir_type *tp);
/** Returns non-zero if s symconst kind has a type attribute */
#define SYMCONST_HAS_TYPE(kind) ((kind) <= symconst_type_align)
......@@ -432,12 +424,6 @@ FIRM_API union symconst_symbol get_SymConst_symbol(const ir_node *node);
FIRM_API void set_SymConst_symbol(ir_node *node,
union symconst_symbol sym);
/** Access the type of the value represented by the SymConst.
*
* Example: primitive type int for SymConst size. */
FIRM_API ir_type *get_SymConst_value_type(const ir_node *node);
FIRM_API void set_SymConst_value_type(ir_node *node, ir_type *tp);
FIRM_API ir_node **get_Sel_index_arr(ir_node *node);
FIRM_API int get_Sel_n_indexs(const ir_node *node);
FIRM_API ir_node *get_Sel_index(const ir_node *node, int pos);
......@@ -666,11 +652,6 @@ FIRM_API int is_irn_forking(const ir_node *node);
*/
FIRM_API void copy_node_attr(ir_graph *irg, const ir_node *old_node, ir_node *new_node);
/** Return the type associated with the value produced by n
* if the node remarks this type as it is the case for
* Cast, Const, SymConst and some Proj nodes or unknown_type. */
FIRM_API ir_type *get_irn_type(ir_node *n);
/** Return the type attribute of a node n (SymConst, Call, Alloc, Free,
Cast) or NULL.*/
FIRM_API ir_type *get_irn_type_attr(ir_node *n);
......
......@@ -182,12 +182,6 @@ typedef int (*reassociate_func)(ir_node **n);
*/
typedef void (*copy_attr_func)(ir_graph *irg, const ir_node *old_node, ir_node *new_node);
/**
* The get_type operation.
* Return the type of the node self.
*/
typedef ir_type *(*get_type_func)(const ir_node *self);
/**
* The get_type_attr operation. Used to traverse all types that can be
* accessed from an ir_graph.
......@@ -251,7 +245,6 @@ typedef struct {
node_cmp_attr_func node_cmp_attr; /**< Compares two node attributes. */
reassociate_func reassociate; /**< Reassociate a tree. */
copy_attr_func copy_attr; /**< Copy node attributes. */
get_type_func get_type; /**< Return the type of a node. */
get_type_attr_func get_type_attr; /**< Return the type attribute of a node. */
get_entity_attr_func get_entity_attr; /**< Return the entity attribute of a node. */
verify_node_func verify_node; /**< Verify the node. */
......
/*
* Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* Licensees holding valid libFirm Professional Edition licenses may use
* this file in accordance with the libFirm Commercial License.
* Agreement provided with the Software.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
/**
* @file
* @brief Run most simple type analyses.
* @author Goetz Lindenmaier
* @date 22.8.2003
* @version $Id$
* @brief
* We compute type information for each node. It is derived from the
* types of the origines of values, e.g. parameter types can be derived
* from the method type.
* The type information so far is saved in the link field.
*/
#ifndef FIRM_ANA_IRSIMPLETYPE_H
#define FIRM_ANA_IRSIMPLETYPE_H
#include "irgraph.h"
#include "irnode.h"
#include "typerep.h"
#include "begin.h"
/* ------------ Building and Removing the type information ----------- */
/** Computes type information for each node in all ir graphs.
*
* Computes type information for each node. Stores the information in the
* field defined in irtypeinfo.h. Sets typestate in irg to irg_typeinfo_consistent.
*
* Derives the information from nodes/patterns that give hints about the
* type, as projecting an argument from the Start node. Deletes all previous
* type information.
*
* If a non-pointer type is specified for a pointer value (as the Alloc node does:
* it contains the type allocated, but to type the result we need the type that
* describes a pointer to the allocated type) searches for a corresponding pointer
* type. If several exist, uses one of them. If none exists, uses unknown_type.
*
* Uses the link field of types. Sets this field of each type to point to a
* pointer type that points to the type (Got it? ;-)).
*/
FIRM_API void simple_analyse_types(void);
/** Frees all type information datastructures. Sets the flag in irg to "???". */
FIRM_API void free_simple_type_information(void);
#include "end.h"
#endif
......@@ -111,9 +111,8 @@ static void handle_case(ir_node *block, ir_node *irn, long nr, env_t *env)
if (! c) {
ir_mode *mode = get_irn_mode(irn);
ir_type *tp = get_irn_type(irn);
tarval *tv = new_tarval_from_long(nr, mode);
c = new_r_Const_type(current_ir_graph, tv, tp);
tarval *tv = new_tarval_from_long(nr, mode);
c = new_r_Const(current_ir_graph, tv);
}
set_irn_n(succ, pos, c);
......
/*
* Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* This file may be distributed and/or modified under the terms of the
* GNU General Public License version 2 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in the
* packaging of this file.
*
* Licensees holding valid libFirm Professional Edition licenses may use
* this file in accordance with the libFirm Commercial License.
* Agreement provided with the Software.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE.
*/
/**
* @file
* @brief Run most simple type analyses.
* @author Goetz Lindenmaier
* @date 22.8.2003
* @version $Id$
* @brief
* Runs most simple type analyses.
*
* We compute type information for each node. It is derived from the
* types of the origines of values, e.g. parameter types can be derived
* from the method type.
* The type information so far is saved in the link field.
*/
#include "config.h"
#include "irtypeinfo.h"
#include "irsimpletype.h"
#include "irnode_t.h"
#include "irprog_t.h"
#include "irgwalk.h"
#include "ident.h"
#include "trouts.h"
#include "debug.h"
#include "error.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL);
static ir_type *phi_cycle_type = NULL;
/* ------------ Building and Removing the type information ----------- */
/**
* init type link field so that types point to their pointers.
*/
static void precompute_pointer_types(void)
{
#if 0
int i;
set_type_link(firm_unknown_type, firm_unknown_type);
set_type_link(firm_none_type, firm_unknown_type);
for (i = get_irp_n_types() - 1; i >= 0; --i)
set_type_link(get_irp_type(i), (void *)firm_unknown_type);
for (i = get_irp_n_types() - 1; i >= 0; --i) {
ir_type *tp = get_irp_type(i);
if (is_Pointer_type(tp))
set_type_link(get_pointer_points_to_type(tp), (void *)tp);
}
#else
compute_trouts();
#endif
}
/**
* Returns a pointer to type which was stored in the link field
* to speed up search.
*/
static ir_type *find_pointer_type_to (ir_type *tp)
{
#if 0
return (ir_type *)get_type_link(tp);
#else
if (get_type_n_pointertypes_to(tp) > 0)
return get_type_pointertype_to(tp, 0);
else
return firm_unknown_type;
#endif
}
static ir_type *compute_irn_type(ir_node *n);
/**
* Try to determine a type for a Proj node.
* If a type cannot be determined, return @p firm_none_type.
*/
static ir_type *find_type_for_Proj(ir_node *n)
{
ir_type *tp;
/* Avoid nested Tuples. */
ir_node *pred = skip_Tuple(get_Proj_pred(n));
ir_mode *m = get_irn_mode(n);
if (m == mode_T ||
m == mode_BB ||
m == mode_X ||
m == mode_M ||
m == mode_b )
return firm_none_type;
switch (get_irn_opcode(pred)) {
case iro_Proj: {
ir_node *pred_pred;
/* Deal with Start / Call here: we need to know the Proj Nr. */
assert(get_irn_mode(pred) == mode_T);
pred_pred = get_Proj_pred(pred);
if (is_Start(pred_pred)) {
ir_type *mtp = get_entity_type(get_irg_entity(get_irn_irg(pred_pred)));
tp = get_method_param_type(mtp, get_Proj_proj(n));
} else if (is_Call(pred_pred)) {
ir_type *mtp = get_Call_type(pred_pred);
tp = get_method_res_type(mtp, get_Proj_proj(n));
} else if (is_Tuple(pred_pred)) {
panic("Encountered nested Tuple");
} else {
DB((dbg, SET_LEVEL_1, "Proj %ld from Proj from ??: unknown type\n", get_irn_node_nr(n)));
tp = firm_unknown_type;
}
break;
}
case iro_Start:
/* frame pointer, globals and tls */
switch (get_Proj_proj(n)) {
case pn_Start_P_frame_base:
tp = find_pointer_type_to(get_irg_frame_type(get_irn_irg(pred)));
break;
case pn_Start_P_tls:
tp = find_pointer_type_to(get_tls_type());
break;
default:
DB((dbg, SET_LEVEL_1, "Proj %ld %ld from Start: unknown type\n", get_Proj_proj(n), get_irn_node_nr(n)));
tp = firm_unknown_type;
}
break;
case iro_Call:
/* value args pointer */
if (get_Proj_proj(n) == pn_Call_P_value_res_base) {
DB((dbg, SET_LEVEL_1, "Value res base Proj %ld from Call: unknown type\n", get_irn_node_nr(n)));
tp = firm_unknown_type; /* find_pointer_type_to(get....get_Call_type(pred)); */
} else {
DB((dbg, SET_LEVEL_1, "Proj %ld %ld from Call: unknown type\n", get_Proj_proj(n), get_irn_node_nr(n)));
tp = firm_unknown_type;
}
break;
case iro_Tuple:
tp = compute_irn_type(get_Tuple_pred(pred, get_Proj_proj(n)));
break;
default:
tp = compute_irn_type(pred);
}
return tp;
}
/**
* Try to determine the type of a node.
* If a type cannot be determined, return @p firm_none_type.
*/
static ir_type *find_type_for_node(ir_node *n)
{
ir_type *tp = firm_unknown_type;
ir_type *tp1 = NULL, *tp2 = NULL;
ir_node *a = NULL, *b = NULL;
if (is_unop(n)) {
a = get_unop_op(n);
tp1 = compute_irn_type(a);
}
if (is_binop(n)) {
a = get_binop_left(n);
b = get_binop_right(n);
tp1 = compute_irn_type(a);
tp2 = compute_irn_type(b);
}
switch (get_irn_opcode(n)) {
case iro_InstOf:
assert(0 && "op_InstOf not supported");
break;
/* has no type */
case iro_Return: {
/* Check returned type. */
/*
int i;
ir_type *meth_type = get_entity_type(get_irg_entity(current_ir_graph));
for (i = 0; i < get_method_n_ress(meth_type); i++) {
ir_type *res_type = get_method_res_type(meth_type, i);
ir_type *ana_res_type = get_irn_type(get_Return_res(n, i));
if (ana_res_type == firm_unknown_type) continue;
if (res_type != ana_res_type && "return value has wrong type") {
assert(res_type == ana_res_type && "return value has wrong type");
}
}
*/
}
case iro_Block:
case iro_Start:
case iro_End:
case iro_Jmp:
case iro_Cond:
case iro_Raise:
case iro_Call:
case iro_Cmp:
case iro_Store:
case iro_Free:
case iro_Sync:
case iro_Tuple:
case iro_Bad:
case iro_NoMem:
break;
/* compute the type */
case iro_Const:
tp = get_Const_type(n);
break;
case iro_SymConst:
tp = get_SymConst_value_type(n);
break;
case iro_Sel:
tp = find_pointer_type_to(get_entity_type(get_Sel_entity(n)));
break;
/* asymmetric binops */
case iro_Shl:
case iro_Shr:
case iro_Shrs:
case iro_Rotl:
tp = tp1;
break;
case iro_Cast:
tp = get_Cast_type(n);
break;
case iro_Phi: {
int i;
int n_preds = get_Phi_n_preds(n);
if (n_preds == 0)
break;