Introduce flip-flopping normalisations
[libfirm] / include / libfirm / ident.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    Data type for unique names.
23  * @author   Goetz Lindenmaier
24  * @version  $Id$
25  * @brief
26  *  Declarations for identifiers in the firm library
27  */
28 #ifndef FIRM_IDENT_H
29 #define FIRM_IDENT_H
30
31 #include <stddef.h>
32 #include "firm_types.h"
33 #include "begin.h"
34
35 /**
36  *  Store a string and create an ident.
37  *
38  *  Stores a string in the ident module and returns a handle for the string.
39  *
40  *  Copies the string. @p str must be zero terminated
41  *
42  * @param str   the string which shall be stored
43  * @return id   a handle for the generated ident
44  * @see get_id_str(), get_id_strlen()
45  */
46 FIRM_API ident *new_id_from_str(const char *str);
47
48 /** Store a string and create an ident.
49  *
50  * Stores a string in the ident module and returns a handle for the string.
51  * Copies the string. This version takes non-zero-terminated strings.
52  *
53  * @param str   the string (or whatever) which shall be stored
54  * @param len   the length of the data in bytes
55  * @return id   a handle for the generated ident
56  * @see new_id_from_str(), get_id_strlen()
57  */
58 FIRM_API ident *new_id_from_chars(const char *str, size_t len);
59
60 /**
61  * Returns a string represented by an ident.
62  *
63  * Returns the string represented by id. This string is
64  * NULL terminated. The string may not be changed.
65  *
66  * @param id   the ident
67  * @return cp   a string
68  * @see new_id_from_str(), new_id_from_chars(), get_id_strlen()
69  */
70 FIRM_API const char *get_id_str(ident *id);
71
72 /**
73  * Returns the length of the string represented by an ident.
74  *
75  * @param id   the ident
76  * @return len   the length of the string
77  * @see new_id_from_str(), new_id_from_chars(), get_id_str()
78  */
79 FIRM_API size_t get_id_strlen(ident *id);
80
81 /**
82  * Returns true if prefix is a prefix of an ident.
83  *
84  * @param prefix   the prefix
85  * @param id       the ident
86  * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
87  */
88 FIRM_API int id_is_prefix(ident *prefix, ident *id);
89
90 /**
91  * Returns true if suffix is a suffix of an ident.
92  *
93  * @param suffix   the suffix
94  * @param id       the ident
95  * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
96  */
97 FIRM_API int id_is_suffix(ident *suffix, ident *id);
98
99 /**
100  * Return true if an ident contains a given character.
101  *
102  * @param id    the ident
103  * @param c     the character
104  * @see new_id_from_str(), new_id_from_chars(), get_id_str()
105  */
106 FIRM_API int id_contains_char(ident *id, char c);
107
108 /**
109  * helper function for creating unique idents. It contains an internal counter
110  * and replaces a "%u" inside the tag with the counter.
111  */
112 FIRM_API ident *id_unique(const char *tag);
113
114 /** Computes a definite name for this entity by concatenating
115    the name of the owner type and the name of the entity with
116    a separating "_". */
117 FIRM_API ident *id_mangle_entity(const ir_entity *ent);
118
119 /** mangle underscore: Returns a new ident that represents first_scnd. */
120 FIRM_API ident *id_mangle_u(ident *first, ident* scnd);
121
122 /** mangle dot: Returns a new ident that represents first.scnd. */
123 FIRM_API ident *id_mangle_dot(ident *first, ident* scnd);
124
125 /** mangle: Returns a new ident that represents firstscnd. */
126 FIRM_API ident *id_mangle(ident *first, ident* scnd);
127
128 /** Returns a new ident that represents 'prefixscndsuffix'. */
129 FIRM_API ident *id_mangle3(const char *prefix, ident *middle,
130                            const char *suffix);
131
132 /** returns a mangled name for a Win32 function using its calling convention */
133 FIRM_API ident *id_decorate_win32_c_fkt(const ir_entity *ent, ident *id);
134
135 #include "end.h"
136
137 #endif