dol: initial epiphany code generator (untested)
[jump.git] / dol / src / dol / visitor / epiphany / lib / dol.h
1 /* DOL Block Header */
2 #ifndef _DOL_H_
3 #define _DOL_H_
4
5 /* defined by the blocks */
6 typedef struct _local_states *LocalState;
7
8 /* process functions */
9 struct _DOLProcess_struct;
10 typedef void (*ProcessInit)(struct _DOLProcess_struct*);
11 typedef int  (*ProcessFire)(struct _DOLProcess_struct*);
12
13 /* WPTR definition */
14 struct _DOL_wptr {
15         int active;
16         int instance[4];
17 };
18 typedef struct _DOL_wptr *WPTR;
19
20 /* DOL process */
21 typedef struct _DOLProcess_struct {
22         LocalState      local;
23         ProcessInit     init;
24         ProcessFire     fire;
25         WPTR            wptr;
26 } DOLProcess;
27
28 /* DOL-specific functions */
29 int  DOL_read (void*, void*, int, DOLProcess*);
30 int  DOL_write(void*, void*, int, DOLProcess*);
31 int  DOL_rtest(void*, int, DOLProcess*);
32 int  DOL_wtest(void*, int, DOLProcess*);
33 void DOL_detach(DOLProcess*);
34 #define GETINDEX(dim) DOL_get_index(dim, p)
35 int  DOL_get_index(int, DOLProcess*);
36
37 /* port generation */
38 #define PORTNAME_MAXLEN 64
39 #define CREATEPORTVAR(name) char name[PORTNAME_MAXLEN]
40
41 #define CREATEPORT_FUNCTION(_1, _2, _3, _4, _5, \
42         _6, _7, _8, _9, _10, _11, NAME, ...) NAME
43 #define CREATEPORT(...) CREATEPORT_FUNCTION(__VA_ARGS__, \
44         CREATEPORT_4, CREATEPORT_BAD_PARAMETERS, \
45         CREATEPORT_3, CREATEPORT_BAD_PARAMETERS, \
46         CREATEPORT_2, CREATEPORT_BAD_PARAMETERS, \
47         CREATEPORT_1, CREATEPORT_BAD_PARAMETERS, \
48         CREATEPORT_BAD_PARAMETERS, CREATEPORT_BAD_PARAMETERS, \
49         CREATEPORT_BAD_PARAMETERS, CREATEPORT_BAD_PARAMETERS)(__VA_ARGS__)
50
51 #define CREATEPORT_1(port, base, ndim, i0, r0) \
52         DOL_create_port(port, base, ndim, i0, r0, 0, 0, 0, 0, 0, 0)
53
54 #define CREATEPORT_2(port, base, ndim, i0, r0, i1, r1) \
55         DOL_create_port(port, base, ndim, i0, r0, i1, r1, 0, 0, 0, 0)
56
57 #define CREATEPORT_3(port, base, ndim, i0, r0, i1, r1, i2, r2) \
58         DOL_create_port(port, base, ndim, i0, r0, i1, r1, i2, r2, 0, 0)
59
60 #define CREATEPORT_4(port, base, ndim, i0, r0, i1, r1, i2, r2, i3, r3) \
61         DOL_create_port(port, base, ndim, i0, r0, i1, r1, i2, r2, i3, r3)
62
63 char* DOL_create_port(char*, char*, int,
64         int, int, int, int, int, int, int, int);
65
66 #endif /* _DOL_H_ */