use isl_val to represent gpu_array_bound->size
[ppcg.git] / pet_printer.c
blob00695311871eb84309abc3b1e6d1ca3b4d1f01bf
1 /*
2 * Copyright 2010-2011 INRIA Saclay
4 * Use of this software is governed by the GNU LGPLv2.1 license
6 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
7 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
8 * 91893 Orsay, France
9 */
11 #include "pet_printer.h"
12 #include "pet.h"
14 static __isl_take isl_printer *print_pet_expr_help(__isl_take isl_printer *p,
15 struct pet_expr *expr, int outer,
16 __isl_take isl_printer *(*print_access_fn)(__isl_take isl_printer *p,
17 struct pet_expr *expr, void *usr), void *usr)
19 int i;
21 switch (expr->type) {
22 case pet_expr_double:
23 p = isl_printer_print_str(p, expr->d.s);
24 break;
25 case pet_expr_access:
26 p = print_access_fn(p, expr, usr);
27 break;
28 case pet_expr_unary:
29 if (!outer)
30 p = isl_printer_print_str(p, "(");
31 p = isl_printer_print_str(p, " ");
32 p = isl_printer_print_str(p, pet_op_str(expr->op));
33 p = isl_printer_print_str(p, " ");
34 p = print_pet_expr_help(p, expr->args[pet_un_arg], 0,
35 print_access_fn, usr);
36 if (!outer)
37 p = isl_printer_print_str(p, ")");
38 break;
39 case pet_expr_binary:
40 if (!outer)
41 p = isl_printer_print_str(p, "(");
42 p = print_pet_expr_help(p, expr->args[pet_bin_lhs], 0,
43 print_access_fn, usr);
44 p = isl_printer_print_str(p, " ");
45 p = isl_printer_print_str(p, pet_op_str(expr->op));
46 p = isl_printer_print_str(p, " ");
47 p = print_pet_expr_help(p, expr->args[pet_bin_rhs], 0,
48 print_access_fn, usr);
49 if (!outer)
50 p = isl_printer_print_str(p, ")");
51 break;
52 case pet_expr_ternary:
53 if (!outer)
54 p = isl_printer_print_str(p, "(");
55 p = print_pet_expr_help(p, expr->args[pet_ter_cond], 0,
56 print_access_fn, usr);
57 p = isl_printer_print_str(p, " ? ");
58 p = print_pet_expr_help(p, expr->args[pet_ter_true], 0,
59 print_access_fn, usr);
60 p = isl_printer_print_str(p, " : ");
61 p = print_pet_expr_help(p, expr->args[pet_ter_false], 0,
62 print_access_fn, usr);
63 if (!outer)
64 p = isl_printer_print_str(p, ")");
65 break;
66 case pet_expr_call:
67 p = isl_printer_print_str(p, expr->name);
68 p = isl_printer_print_str(p, "(");
69 for (i = 0; i < expr->n_arg; ++i) {
70 if (i)
71 p = isl_printer_print_str(p, ", ");
72 p = print_pet_expr_help(p, expr->args[i], 1,
73 print_access_fn, usr);
75 p = isl_printer_print_str(p, ")");
76 break;
77 case pet_expr_cast:
78 if (!outer)
79 p = isl_printer_print_str(p, "(");
80 p = isl_printer_print_str(p, "(");
81 p = isl_printer_print_str(p, expr->type_name);
82 p = isl_printer_print_str(p, ") ");
83 p = print_pet_expr_help(p, expr->args[0], 0,
84 print_access_fn, usr);
85 if (!outer)
86 p = isl_printer_print_str(p, ")");
87 break;
90 return p;
93 __isl_give isl_printer *print_pet_expr(__isl_take isl_printer *p,
94 struct pet_expr *expr,
95 __isl_give isl_printer *(*print_access)(__isl_take isl_printer *p,
96 struct pet_expr *expr, void *usr), void *usr)
98 return print_pet_expr_help(p, expr, 1, print_access, usr);