Commit 671350c7 authored by Jonas Fietz's avatar Jonas Fietz
Browse files

Add structures and initialization for VRP

This commit adds the neccessary attributes to each ir_node. It also adds
the initialization code and some prototypes for the graph_pass and some
support functions.

[r27094]
parent 40fd4b98
......@@ -84,6 +84,7 @@ extern "C" {
#include "irconsconfirm.h"
#include "ircons.h"
#include "irdom.h"
#include "vrp.h"
#include "irdump.h"
#include "iredgekinds.h"
#include "iredges.h"
......
......@@ -922,6 +922,22 @@ typedef ir_type *(*get_Alloc_func)(ir_node *n);
/** Set a new get_Alloc_func and returns the old one. */
get_Alloc_func firm_set_Alloc_func(get_Alloc_func newf);
/**
* sets value ranges through value range propagation
* @param irg The IR-graph on which to work
*
*/
void set_vrp_data(ir_graph *irg);
/**
* Creates an ir_graph pass for set_vrp_data()
*
* @param name The name of this pass or NULL
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *set_vrp_pass(const char *name);
/**
* Removes all entities which are unused.
*
......
/*
* Copyright (C) 1995-2009 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 Analyse the graph with value range propagation
* @author Jonas Fietz
* @version $Id$
*
*/
#include "firm_types.h"
#ifndef VRP_H
#define VRP_H
enum range_types {
VRP_UNDEFINED,
VRP_RANGE,
VRP_ANTIRANGE,
VRP_VARYING
};
enum range_ops {
VRP_NONE,
VRP_ADD,
VRP_SUB
};
/**
* Set vrp data on the graph irg
* @param irg graph on which to set vrp data
*/
void set_vrp_data(ir_graph *irg);
/**
* Creates an ir_prog_pass for vrp
*
* @param name the name of this pass or NULL
*/
ir_graph_pass_t *set_vrp_pass(const char *name);
/**
* Test, if the two nodes can be compared with their vrp information
*
* @param left: the left node
* @param right: the right node
*
* @return the pn_Cmp, if one can be derived
*/
pn_Cmp vrp_cmp(ir_node *left, ir_node *right);
#endif
......@@ -184,6 +184,25 @@ new_ir_node(dbg_info *db, ir_graph *irg, ir_node *block, ir_op *op, ir_mode *mod
if (get_irg_phase_state(irg) == phase_backend) {
be_info_new_node(res);
}
// Init the VRP structures
res->vrp.range_type = VRP_UNDEFINED;
res->vrp.valid = 0;
if(mode_is_int(mode)) {
// We are assuming that 0 is always represented as 0x0000
res->vrp.bits_set = new_tarval_from_long(0, mode);
res->vrp.bits_not_set = new_tarval_from_long(0, mode);
res->vrp.range_bottom = get_tarval_top();
res->vrp.range_top = get_tarval_top();
} else {
res->vrp.bits_set = get_tarval_bad();
res->vrp.bits_not_set = get_tarval_bad();
res->vrp.range_bottom = get_tarval_bad();
res->vrp.range_top = get_tarval_bad();
}
res->vrp.bits_node = NULL;
res->vrp.range_node = NULL;
res->vrp.range_op = VRP_NONE;
return res;
}
......
......@@ -45,6 +45,7 @@
#include "set.h"
#include "list.h"
#include "obst.h"
#include "vrp.h"
struct ir_phase;
......@@ -304,6 +305,21 @@ typedef struct {
ident **clobber; /**< List of clobbered registers. */
} asm_attr;
/** VRP information */
typedef struct {
int valid; /**< 0: VRP info invalid, 1: VRP info valid (not
neccessarily updated) */
tarval *bits_set; /**< The bits which, by analysis, are definitely set */
tarval *bits_not_set; /**< The bits which by analysis are definitely not set */
ir_node *bits_node; /**< The node, from which the rest of the bits
are set */
enum range_types range_type;/**< The range represented by range_top, range_bottom */
tarval *range_bottom, *range_top;
ir_node *range_node; /**< The node to which the range is relative */
enum range_ops range_op; /**< The op which describes the relation
between range_node and range */
} vrp_attr;
/** Some IR-nodes just have one attribute, these are stored here,
some have more. Their name is 'irnodename_attr' */
typedef union {
......@@ -382,6 +398,8 @@ struct ir_node {
struct ir_node **deps; /**< Additional dependencies induced by state. */
void *backend_info;
irn_edges_info_t edge_info; /**< Everlasting out edges. */
vrp_attr vrp; /**< Information supplied by VRP */
/* ------- Opcode depending fields -------- */
attr attr; /**< The set of attributes of this node. Depends on opcode.
Must be last field of struct ir_node. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment