X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fcommon%2Firtools.h;h=188725c705515e765bfeda574284b72d9fb90d8c;hb=0cc8bfc863da28d3799e9eca1d1765d564b6e573;hp=a67d8b90f88fc6addcf22b5b1e7ca9bde1808120;hpb=9518de081dea142a017129105f2a89d4ec7df8a5;p=libfirm diff --git a/ir/common/irtools.h b/ir/common/irtools.h index a67d8b90f..188725c70 100644 --- a/ir/common/irtools.h +++ b/ir/common/irtools.h @@ -1,24 +1,56 @@ /* - * Project: libFIRM - * File name: ir/ir/irtools.h - * Purpose: Some often needed tool-functions - * Author: Michael Beck - * Modified by: - * Created: - * CVS-ID: $Id$ - * Copyright: (c) 1999-2005 Universität Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. - */ -#ifndef _IRTOOLS_H_ -#define _IRTOOLS_H_ + * 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 Some often needed tool-functions + * @author Michael Beck + * @version $Id$ + */ +#ifndef FIRM_COMMON_IRTOOLS_H +#define FIRM_COMMON_IRTOOLS_H #include "firm_config.h" #include "firm_types.h" -#ifdef WITH_LIBCORE -#include +#include "lc_opts.h" lc_opt_entry_t *firm_opt_get_root(void); -#endif + +#include "pset.h" + +#undef MIN +#undef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#define MIN(x, y) ((x) < (y) ? (x) : (y)) + +/* calculate the address of the one past last element of an array whose size is + * known statically */ +#define ENDOF(x) ((x) + sizeof(x) / sizeof(*(x))) + +/** + * Three valued compare as demanded by e.g. qsort(3) + * @param c A number. + * @param d Another number. + * @return 0 if c == d, -1 if c < d, 1 if c > d. + */ +#define QSORT_CMP(c, d) (((c) > (d)) - ((c) < (d))) + /** * convert an integer into pointer @@ -30,6 +62,11 @@ lc_opt_entry_t *firm_opt_get_root(void); */ #define PTR_TO_INT(v) ((int)((char *)(v) - (char *)0)) +/** + * Dump a pset containing Firm objects. + */ +void firm_pset_dump(pset *set); + /** * The famous clear_link() walker-function. * Do not implement it by yourself, use this one @@ -49,4 +86,15 @@ void firm_clear_link(ir_node *n, void *env); */ void copy_irn_to_irg(ir_node *n, ir_graph *irg); -#endif /* _IRTOOLS_H_ */ +/** + * Creates an exact copy of a node. + * The copy resists on the same graph in the same block. + * + * @param n the node to copy + * + * @note If the copy is not changed, the next CSE operation will + * replace it by the original, so beware. + */ +ir_node *exact_copy(const ir_node *n); + +#endif