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