Simple Load/Store optimization
[libfirm] / ir / ident / ident.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/common/ident_t.h
4  * Purpose:     Data type for unique names.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 1999-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12 /**
13  * @file ident.h
14  *
15  * Declarations for identifiers in the firm library
16  *
17  * Identifiers are used in the firm library. This is the interface to it.
18  */
19
20
21 # ifndef _IDENT_H_
22 # define _IDENT_H_
23
24 # include <stdio.h>
25 # include <assert.h>
26 # include "firm_common.h"
27
28 /* Identifiers */
29
30 /**
31  *  The abstract data type ident.
32  *
33  *  An ident represents an unique string. The == operator
34  *  is sufficient to compare two idents.
35  */
36 typedef const struct set_entry ident;
37
38 /**
39  *  Store a string and create an ident.
40  *
41  *  Stores a string in the ident module and returns a handle for the string.
42  *
43  *  Copies the string. @p str must be zero terminated
44  *
45  * @param str - the string which shall be stored
46  *
47  * @return id - a handle for the generated ident
48  *
49  * @see get_id_str(), get_id_strlen()
50  */
51 ident *new_id_from_str (const char *str);
52
53 /** Store a string and create an ident.
54  *
55  * Stores a string in the ident module and returns a handle for the string.
56  * Copies the string. This version takes non-zero-terminated strings.
57  *
58  * @param str - the string (or whatever) which shall be stored
59  * @param len - the length of the data in bytes
60  *
61  * @return id - a handle for the generated ident
62  *
63  * @see new_id_from_str(), get_id_strlen()
64  */
65 ident *new_id_from_chars (const char *str, int len);
66
67 /**
68  * Returns a string represented by an ident.
69  *
70  * Returns the string represented by id. This string is
71  * NULL terminated. The string may not be changed.
72  *
73  * @param id - the ident
74  *
75  * @return cp - a string
76  *
77  * @see new_id_from_str(), new_id_from_chars(), get_id_strlen()
78  */
79 const char *get_id_str  (ident *id);
80
81 /**
82  * Returns the length of the string represented by an ident.
83  *
84  * @param id - the ident
85  *
86  * @return len - the length of the string
87  *
88  * @see new_id_from_str(), new_id_from_chars(), get_id_str()
89  */
90 int  get_id_strlen(ident *id);
91 /**
92  * Returns true if prefix is a prefix of an ident.
93  *
94  * @param prefix - the prefix
95  * @param id     - the ident
96  *
97  * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
98  */
99 int id_is_prefix (ident *prefix, ident *id);
100
101 /**
102  * Returns true if suffix is a suffix of an ident.
103  *
104  * @param suffix - the suffix
105  * @param id     - the ident
106  *
107  * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
108  */
109 int id_is_suffix (ident *suffix, ident *id);
110
111 /**
112  * Returns true if infix is contained in id.  (Can be suffix or prefix)
113  *
114  * @param infix  - the infix
115  * @param id     - the ident to search in
116  *
117  * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
118  */
119 /* int id_contains(ident *infix, ident *id); */
120
121 /**
122  * Return true if an ident contains a given character.
123  *
124  * @param id     - the ident
125  * @param c      - the character
126  *
127  * @see new_id_from_str(), new_id_from_chars(), get_id_str()
128  */
129 int id_contains_char (ident *id, char c);
130
131 /**
132  * Prints the ident to stdout.
133  *
134  * @param id - The ident to be printed.
135  *
136  * @return
137  *    number of bytes written
138  *
139  * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix(), fprint_id()
140  */
141 int print_id (ident *id);
142
143 /**
144  * Prints the ident to the file passed.
145  *
146  * @param F  - file pointer to print the ident to.
147  * @param id - The ident to print and the file.
148  *
149  * @return
150  *    number of btes written
151  *
152  * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix(), print_id()
153  */
154 int fprint_id (FILE *F, ident *id);
155
156 # endif /* _IDENT_H_ */