d8fddfc47f75dd8a7bede4c502e7ea3df12d889c
[libfirm] / ir / external / read.h
1 /* -*- c -*- */
2 /*
3  * Project:     libFIRM
4  * File name:   ir/external/read.c
5  * Purpose:     Read descriptions of external effects
6  * Author:      Florian
7  * Modified by: Boris Boesler
8  * Created:     11.10.2004
9  * CVS-ID:      $Id$
10  * Copyright:   (c) 1999-2004 Universität Karlsruhe
11  * Licence:     This file is protected by GPL -  GNU GENERAL PUBLIC LICENSE.
12  */
13
14 #ifndef _READ_H_
15 #define _READ_H_
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <assert.h>
20
21 #include <libxml/xmlmemory.h>
22 #include <libxml/parser.h>
23 #include <libxml/encoding.h>
24
25 #include "type.h"
26 #include "entity.h"
27 #include "ident.h"
28
29 # define MY_ENCODING "ISO-8859-1"
30
31 # define CHECK(ptr,msg)     assert (ptr && msg)
32
33 # define NODE_NAME(n, m) (0 == xmlStrcmp (n->name, (const xmlChar*) #m))
34 # define CHECK_NAME(n, m) assert (0 == xmlStrcmp (n->name, (const xmlChar*) #m))
35
36 # define NEW(T)     (T*) malloc (sizeof (T))
37
38
39 /* first, the xml structures */
40
41 typedef struct type_str
42 {
43   const ident *type_ident;
44   const ident *id;              /* id for references */
45   type *f_tp;                   /* firm type */
46   struct type_str *prev;
47 } type_t;
48
49 typedef struct entity_str
50 {
51   const ident *ent_ident;        /* name of entity */
52   const ident *tp_ident;         /* name of type/class */
53   const ident *id;               /* id for references */
54   const ident *owner;            /* id of owner */
55   entity *f_ent;                 /* firm entity */
56   struct entity_str *prev;
57 } entity_t;
58
59 /* now the xml nodes */
60 typedef enum eff_node_kind {
61   eff_arg,      // done
62   eff_valref,   // eliminated
63   eff_select,   // eliminated
64   eff_load,     // done
65   eff_store,    // done
66   eff_alloc,    // done
67   eff_call,     // done
68   eff_unknown,  // done
69   eff_join,     // TODO
70   eff_raise,    // TODO
71   eff_ret       // done
72 } eff_node_kind_t;
73
74
75 typedef struct arg_str
76 {
77   const ident *type_ident;
78   int num;
79 } arg_t;
80
81 typedef struct valref_str
82 {
83   int dummy;
84 } valref_t;
85
86 typedef struct select_str
87 {
88   entity_t *ent;
89 } select_t;
90
91 typedef struct load_str
92 {
93   const ident *ptrrefid;     /* id of valref node enclosed in select, or -1 */
94   entity_t *ent;
95 } load_t;
96
97 typedef struct store_str
98 {
99   const ident *ptrrefid;     /* id of ptr valref node enclosed in select, or -1 */
100   const ident *valrefid;     /* id of val valref node enclosed in select, or -1 */
101   entity_t *ent;
102 } store_t;
103
104 typedef struct alloc_str
105 {
106   const ident *tp_id;
107 } alloc_t;
108
109 typedef struct call_str
110 {
111   const ident *valrefid;     /* id of enclosed valref node, or -1 */
112   entity_t *ent;             /* called entity */
113   int n_args;
114   const ident **args;
115 } call_t;
116
117 typedef struct unknown_str
118 {
119   int dummy;
120 } unknown_t;
121
122 typedef struct join_str
123 {
124   int n_ins;
125   const ident **ins;
126 } join_t;
127
128 typedef struct ret_str
129 {
130   const ident *ret_id;
131 } ret_t;                     /* returned value, or NO_ID */
132
133 typedef struct raise_str
134 {
135   const ident *valref;       /* what was that one for? */
136   const ident *tp_id;
137 } raise_t;
138
139 /* dummy type for all other effects */
140 typedef struct eff_str
141 {
142   eff_node_kind_t kind;
143   const ident *id;           /* identifier to access this node */
144   union {
145     arg_t arg;
146     valref_t valref;
147     select_t select;
148     load_t load;
149     store_t store;
150     alloc_t alloc;
151     call_t call;
152     unknown_t unknown;
153     join_t join;
154     ret_t ret;
155     raise_t raise;
156   } effect;
157   ir_node *firmnode;
158   struct eff_str *next; /* effects with values are stored in proc.values */
159 } eff_t;
160
161 typedef struct proc_str
162 {
163   const ident *proc_ident;   /* name of procedure */
164   const ident *typeid;
165   int n_effs;
166   eff_t **effs;
167   struct proc_str *next;
168   eff_t *values;             /* @@@ TODO hash set */
169 } proc_t;
170
171
172 typedef struct mod_str
173 {
174   const ident *id;
175   type_t *types;             /* types in module *//* @@@ TODO hash set */
176   entity_t *entities;        /* entities in module *//* @@@ TODO hash set */
177   proc_t *procs;             /* methods with effects */
178   struct mod_str *next;      /* unused - only one module possible */
179 } module_t;
180
181
182 /*
183   The public intyerface
184 */
185 /** read the file and build the graphs */
186 void create_abstraction(const char *filename);
187
188
189 #endif /* defined _READ_H_ */
190
191 /*
192   $Log$
193   Revision 1.6  2004/10/22 13:13:27  boesler
194   replaced char* by idents, minor fix in Firm codegen for call
195
196   Revision 1.5  2004/10/21 15:31:55  boesler
197   added lots of stuff:
198   - build abstract syntax trees
199   - build Firm graphs for many effects, still todos
200
201   Revision 1.1  2004/10/11 09:31:06  liekweg
202   First Import of XML reading procs --flo
203
204 */