Added the new state pin_state_exc_pinned t some Operations
[libfirm] / ir / external / read.h
1 /* -*- c -*- */
2
3 /*
4  * Project:     libFIRM
5  * File name:   ir/external/read.c
6  * Purpose:     Read descriptions of external effects
7  * Author:      Florian
8  * Modified by:
9  * Created:     11.10.2004
10  * CVS-ID:      $$
11  * Copyright:   (c) 1999-2004 Universität Karlsruhe
12  * Licence:     This file is protected by GPL -  GNU GENERAL PUBLIC LICENSE.
13  */
14
15 # ifndef _READ_H_
16 # define _READ_H_
17
18 # if 0
19 /* we need strdup */
20 # ifndef _GNU_SOURCE
21 #  define _GNU_SOURCE
22 # endif /* ! defined _GNU_SOURCE */
23 # endif /* 0 */
24
25 # include <stdio.h>
26 # include <string.h>
27 # include <stdlib.h>
28 # include <assert.h>
29
30 # include <libxml/xmlmemory.h>
31 # include <libxml/parser.h>
32 # include <libxml/encoding.h>
33
34 # include "type.h"
35 # include "entity.h"
36
37
38 # define MY_ENCODING "ISO-8859-1"
39
40 /* quick hack until we get a cmd line flag or something: just add
41    '-DEXTERN_VERBOSE' to 'CFLAGS' */
42 # ifndef EXTERN_VERBOSE
43 #  define EXTERN_VERBOSE 1
44 # else
45 #  define EXTERN_VERBOSE 0
46 # endif /* defined EXTERN_VERBOSE */
47
48 # define CHECK(ptr,msg)     assert (ptr && msg)
49
50 # define NODE_NAME(n, m) (0 == xmlStrcmp (n->name, (const xmlChar*) #m))
51 # define CHECK_NAME(n, m) assert (0 == xmlStrcmp (n->name, (const xmlChar*) #m))
52
53 # define NEW(T)     (T*) malloc (sizeof (T))
54
55 /* first, the xml structures */
56
57 typedef struct type_str
58 {
59   const char *name;
60   int id;
61   entity *f_tp;                 /* firm type */
62   struct type_str *prev;        /* linked list */
63 } type_t;
64
65 typedef struct entity_str
66 {
67   const char *name;
68   const char *tp_name;
69   int id;
70   type *f_ent;                  /* firm entity */
71   struct entity_str *prev;      /* linked list */
72 } entity_t;
73
74 /* now the xml nodes */
75 typedef enum eff_node_kind {
76   eff_arg,
77   eff_valref,
78   eff_select,
79   eff_load,
80   eff_store,
81   eff_alloc,
82   eff_call,
83   eff_unknown,
84   eff_join,
85   eff_raise,
86   eff_ret
87 } eff_node_kind_t;
88
89 /* dummy type for all other effects */
90 typedef struct eff_str
91 {
92   eff_node_kind_t kind;
93 } eff_t;
94
95 typedef struct effs_str
96 {
97   char *procname;
98   int n_effs;
99   eff_t **effs;
100   struct effs_str *next;
101 } effs_t;
102
103 typedef struct arg_str
104 {
105   eff_node_kind_t kind;
106   int id;
107   int num;
108 } arg_t;
109
110 typedef struct valref_str
111 {
112   eff_node_kind_t kind;
113   int refid;
114 } valref_t;
115
116 typedef struct select_str
117 {
118   eff_node_kind_t kind;
119   int valrefid;                 /* id of enclosed valref node, or -1 */
120   entity_t *ent;
121 } select_t;
122
123 typedef struct load_str
124 {
125   eff_node_kind_t kind;
126   int id;
127   int ptrrefid;                 /* id of valref node enclosed in select, or -1 */
128   entity_t *ent;
129 } load_t;
130
131 typedef struct store_str
132 {
133   eff_node_kind_t kind;
134   int ptrrefid;                 /* id of ptr valref node enclosed in select, or -1 */
135   int valrefid;                 /* id of val valref node enclosed in select, or -1 */
136   entity_t *ent;
137 } store_t;
138
139 typedef struct alloc_str
140 {
141   eff_node_kind_t kind;
142   int id;
143   int tp_id;
144 } alloc_t;
145
146 typedef struct call_str
147 {
148   eff_node_kind_t kind;
149   int id;
150   int valrefid;                 /* id of enclosed valref node, or -1 */
151   entity_t *ent;                /* called entity */
152   int n_args;
153   int *args;
154 } call_t;
155
156 typedef struct unknown_str
157 {
158   eff_node_kind_t kind;
159   int id;
160 } unknown_t;
161
162 typedef struct join_str
163 {
164   eff_node_kind_t kind;
165   int id;
166   int n_ins;
167   int *ins;
168 } join_t;
169
170 typedef struct ret_str
171 {
172   eff_node_kind_t kind;
173   int ret_id;                   /* returned value, or -1 */
174 } ret_t;
175
176 typedef struct raise_str
177 {
178   eff_node_kind_t kind;
179   /* struct eff_str *next; */
180   int valref;                   /* what was that one for? */
181   int tp_id;
182 } raise_t;
183
184 /*
185   The public interface
186 */
187
188 /** get the type entry with the given name */
189 type_t *getTypeByName (const char*);
190
191 /** get the type entry with the given Id */
192 type_t *getTypeById (const int);
193
194 /** get the entity entry that has the given names */
195 entity_t *getEntityByNames (const char*, const char*);
196
197 /** get the entity entry that has the given Id */
198 entity_t *getEntityById (const int);
199
200 /** get the effect entry for the given name */
201 effs_t *getEffectByName (const char*);
202
203 /** initialise the data structures */
204 void extern_init (void);
205
206 /** read in the file of the given name */
207 void extern_read (const char*);
208
209 /** clean up our mess */
210 void extern_cleanup (void);
211
212 # endif /* defined _READ_H_ */
213
214 /*
215   $Log$
216   Revision 1.4  2004/10/13 11:56:16  liekweg
217   need strdup, don't need _GNU_SOURCE (wtf?)
218
219   Revision 1.3  2004/10/13 08:39:59  liekweg
220   need strdup
221
222   Revision 1.2  2004/10/11 15:56:09  liekweg
223   Cleanup, comments ...
224   Added init func --flo
225
226   Revision 1.1  2004/10/11 09:31:06  liekweg
227   First Import of XML reading procs --flo
228
229 */