update isl for support for recent versions of clang
[ppn.git] / testyaml.cc
blobf521a30abd8dc33446ff54ae79c8eab09fcb3f49
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <unistd.h>
4 #include <fcntl.h>
6 #include <syck.h>
8 #include <isl/set.h>
9 #include <isl/map.h>
11 #include <isa/pdg.h>
12 #include <isa/yaml.h>
14 #include <assert.h>
16 using namespace yaml;
17 using namespace pdg;
19 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(*a))
21 class struct1 : public structure {
22 static serialize *create(void *user) { return new struct1(); }
23 public:
24 struct1 *loop;
25 static void register_type();
26 struct1() : loop(NULL) {}
29 at_init register_struct1(struct1::register_type);
31 void struct1::register_type()
33 static struct_description s1_d = { create };
34 YAML_PTR_FIELD(s1_d, struct1, loop, struct1);
35 structure::register_type("struct1", &typeid(struct1), &s1_d.d);
38 class struct2 : public structure {
39 static serialize *create(void *user) { return new struct2(); }
40 public:
41 struct1 *test;
42 static void register_type();
43 struct2() : test(NULL) {}
46 at_init register_struct2(struct2::register_type);
48 void struct2::register_type()
50 static struct_description s2_d = { create };
51 YAML_PTR_FIELD(s2_d, struct2, test, struct1);
52 structure::register_type("struct2", &typeid(struct2), &s2_d.d);
56 int main(int argc, char * argv[])
58 assert (argc > 2);
59 // int fd = open("../PDG/test2_t.yaml", O_RDONLY);
60 FILE *fp = fopen(argv[1], "r");
62 int type = atoi(argv[2]);
64 switch (type) {
65 case 0: {
66 struct2 * pdg = yaml::Load<struct2>(fp);
67 printf("root: %p\n", pdg);
68 printf("test: %p\n", pdg->test);
69 printf("test|loop: %p\n", pdg->test->loop);
71 pdg->Dump();
73 pdg->free();
74 delete pdg;
75 break;
77 case 1: {
78 isl_ctx *ctx = isl_ctx_alloc();
79 PDG *pdg = PDG::Load(fp, ctx);
80 isl_set *set;
81 isl_map *map;
83 printf("root: %p\n", pdg);
84 printf("dim: %d\n", pdg->dimension);
85 printf("placement: %s\n", pdg->placement->s.c_str());
86 printf("nr nodes: %zd\n", pdg->nodes.size());
87 for (int i = 0; i < pdg->nodes.size(); ++i) {
88 printf("ptr: %p\n", pdg->nodes[i]);
89 printf("nr: %d\n", pdg->nodes[i]->nr);
90 printf("source: %p\n", pdg->nodes[i]->source);
91 printf("dim: %d\n", pdg->nodes[i]->source->dim());
92 printf("constraints:\n");
93 set = pdg->nodes[i]->source->get_isl_set(ctx);
94 isl_set_dump(set);
95 isl_set_free(set);
96 printf("schedule: %p\n", pdg->nodes[i]->schedule);
97 map = pdg->nodes[i]->schedule->get_isl_map(ctx);
98 isl_map_dump(map);
99 isl_map_free(map);
100 printf("stat: %p\n", pdg->nodes[i]->statement);
101 printf("operation: %d\n", pdg->nodes[i]->statement->operation);
104 pdg->Dump();
106 pdg->free();
107 delete pdg;
108 isl_ctx_free(ctx);
109 break;
113 fclose(fp);
115 return 0;