add isl_ast_expr_get_val
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 12 Apr 2013 21:29:46 +0000 (23:29 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 28 May 2013 18:42:49 +0000 (20:42 +0200)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/ast.h
isl_ast.c

index 1e46faf..3219fd2 100644 (file)
@@ -6015,10 +6015,13 @@ Return the identifier represented by the AST expression.
        #include <isl/ast.h>
        int isl_ast_expr_get_int(__isl_keep isl_ast_expr *expr,
                isl_int *v);
+       __isl_give isl_val *isl_ast_expr_get_val(
+               __isl_keep isl_ast_expr *expr);
 
 Return the integer represented by the AST expression.
-Note that the integer is returned through the C<v> argument.
-The return value of the function itself indicates whether the
+Note that the integer is returned by C<isl_ast_expr_get_int>
+through the C<v> argument.
+The return value of this function itself indicates whether the
 operation was performed successfully.
 
 =head3 Manipulating and printing the AST
index 76fe450..7947acb 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <isl/ctx.h>
 #include <isl/id.h>
+#include <isl/val.h>
 #include <isl/list.h>
 #include <isl/printer.h>
 
@@ -87,6 +88,7 @@ void *isl_ast_expr_free(__isl_take isl_ast_expr *expr);
 isl_ctx *isl_ast_expr_get_ctx(__isl_keep isl_ast_expr *expr);
 enum isl_ast_expr_type isl_ast_expr_get_type(__isl_keep isl_ast_expr *expr);
 int isl_ast_expr_get_int(__isl_keep isl_ast_expr *expr, isl_int *v);
+__isl_give isl_val *isl_ast_expr_get_val(__isl_keep isl_ast_expr *expr);
 __isl_give isl_id *isl_ast_expr_get_id(__isl_keep isl_ast_expr *expr);
 
 enum isl_ast_op_type isl_ast_expr_get_op_type(__isl_keep isl_ast_expr *expr);
index 6859e7f..afc4a70 100644 (file)
--- a/isl_ast.c
+++ b/isl_ast.c
@@ -1,4 +1,5 @@
 #include <isl_ast_private.h>
+#include <isl/val_int.h>
 
 #undef BASE
 #define BASE ast_expr
@@ -241,6 +242,21 @@ int isl_ast_expr_get_int(__isl_keep isl_ast_expr *expr, isl_int *v)
        return 0;
 }
 
+/* Return the integer value represented by "expr".
+ */
+__isl_give isl_val *isl_ast_expr_get_val(__isl_keep isl_ast_expr *expr)
+{
+       isl_ctx *ctx;
+
+       if (!expr)
+               return NULL;
+       ctx = isl_ast_expr_get_ctx(expr);
+       if (expr->type != isl_ast_expr_int)
+               isl_die(ctx, isl_error_invalid,
+                       "expression not an int", return NULL);
+       return isl_val_int_from_isl_int(ctx, expr->u.i);
+}
+
 __isl_give isl_id *isl_ast_expr_get_id(__isl_keep isl_ast_expr *expr)
 {
        if (!expr)