70 changes: 45 additions & 25 deletions polly/lib/External/isl/include/isl/space.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
extern "C" {
#endif

isl_ctx *isl_space_get_ctx(__isl_keep isl_space *dim);
isl_ctx *isl_space_get_ctx(__isl_keep isl_space *space);
__isl_export
__isl_give isl_space *isl_space_unit(isl_ctx *ctx);
__isl_give isl_space *isl_space_alloc(isl_ctx *ctx,
unsigned nparam, unsigned n_in, unsigned n_out);
__isl_give isl_space *isl_space_set_alloc(isl_ctx *ctx,
unsigned nparam, unsigned dim);
__isl_give isl_space *isl_space_params_alloc(isl_ctx *ctx, unsigned nparam);
__isl_give isl_space *isl_space_copy(__isl_keep isl_space *dim);
__isl_give isl_space *isl_space_copy(__isl_keep isl_space *space);
__isl_null isl_space *isl_space_free(__isl_take isl_space *space);

isl_bool isl_space_is_params(__isl_keep isl_space *space);
Expand All @@ -35,40 +37,40 @@ isl_bool isl_space_is_map(__isl_keep isl_space *space);
__isl_give isl_space *isl_space_add_param_id(__isl_take isl_space *space,
__isl_take isl_id *id);

__isl_give isl_space *isl_space_set_tuple_name(__isl_take isl_space *dim,
__isl_give isl_space *isl_space_set_tuple_name(__isl_take isl_space *space,
enum isl_dim_type type, const char *s);
isl_bool isl_space_has_tuple_name(__isl_keep isl_space *space,
enum isl_dim_type type);
__isl_keep const char *isl_space_get_tuple_name(__isl_keep isl_space *dim,
__isl_keep const char *isl_space_get_tuple_name(__isl_keep isl_space *space,
enum isl_dim_type type);
__isl_give isl_space *isl_space_set_tuple_id(__isl_take isl_space *dim,
__isl_give isl_space *isl_space_set_tuple_id(__isl_take isl_space *space,
enum isl_dim_type type, __isl_take isl_id *id);
__isl_give isl_space *isl_space_reset_tuple_id(__isl_take isl_space *dim,
__isl_give isl_space *isl_space_reset_tuple_id(__isl_take isl_space *space,
enum isl_dim_type type);
isl_bool isl_space_has_tuple_id(__isl_keep isl_space *dim,
isl_bool isl_space_has_tuple_id(__isl_keep isl_space *space,
enum isl_dim_type type);
__isl_give isl_id *isl_space_get_tuple_id(__isl_keep isl_space *dim,
__isl_give isl_id *isl_space_get_tuple_id(__isl_keep isl_space *space,
enum isl_dim_type type);
__isl_give isl_space *isl_space_reset_user(__isl_take isl_space *space);

__isl_give isl_space *isl_space_set_dim_id(__isl_take isl_space *dim,
enum isl_dim_type type, unsigned pos, __isl_take isl_id *id);
isl_bool isl_space_has_dim_id(__isl_keep isl_space *dim,
isl_bool isl_space_has_dim_id(__isl_keep isl_space *space,
enum isl_dim_type type, unsigned pos);
__isl_give isl_id *isl_space_get_dim_id(__isl_keep isl_space *dim,
__isl_give isl_id *isl_space_get_dim_id(__isl_keep isl_space *space,
enum isl_dim_type type, unsigned pos);

int isl_space_find_dim_by_id(__isl_keep isl_space *dim, enum isl_dim_type type,
__isl_keep isl_id *id);
int isl_space_find_dim_by_id(__isl_keep isl_space *space,
enum isl_dim_type type, __isl_keep isl_id *id);
int isl_space_find_dim_by_name(__isl_keep isl_space *space,
enum isl_dim_type type, const char *name);

isl_bool isl_space_has_dim_name(__isl_keep isl_space *space,
enum isl_dim_type type, unsigned pos);
__isl_give isl_space *isl_space_set_dim_name(__isl_take isl_space *dim,
__isl_give isl_space *isl_space_set_dim_name(__isl_take isl_space *space,
enum isl_dim_type type, unsigned pos,
__isl_keep const char *name);
__isl_keep const char *isl_space_get_dim_name(__isl_keep isl_space *dim,
__isl_keep const char *isl_space_get_dim_name(__isl_keep isl_space *space,
enum isl_dim_type type, unsigned pos);

ISL_DEPRECATED
Expand Down Expand Up @@ -99,39 +101,54 @@ __isl_give isl_space *isl_space_range_factor_domain(
__isl_take isl_space *space);
__isl_give isl_space *isl_space_range_factor_range(
__isl_take isl_space *space);
__isl_export
__isl_give isl_space *isl_space_map_from_set(__isl_take isl_space *space);
__isl_give isl_space *isl_space_map_from_domain_and_range(
__isl_take isl_space *domain, __isl_take isl_space *range);
__isl_give isl_space *isl_space_reverse(__isl_take isl_space *dim);
__isl_give isl_space *isl_space_drop_dims(__isl_take isl_space *dim,
__isl_give isl_space *isl_space_reverse(__isl_take isl_space *space);
__isl_give isl_space *isl_space_range_reverse(__isl_take isl_space *space);
__isl_give isl_space *isl_space_drop_dims(__isl_take isl_space *space,
enum isl_dim_type type, unsigned first, unsigned num);
ISL_DEPRECATED
__isl_give isl_space *isl_space_drop_inputs(__isl_take isl_space *dim,
unsigned first, unsigned n);
ISL_DEPRECATED
__isl_give isl_space *isl_space_drop_outputs(__isl_take isl_space *dim,
unsigned first, unsigned n);
__isl_give isl_space *isl_space_drop_all_params(__isl_take isl_space *space);
__isl_export
__isl_give isl_space *isl_space_domain(__isl_take isl_space *space);
__isl_give isl_space *isl_space_from_domain(__isl_take isl_space *dim);
__isl_give isl_space *isl_space_from_domain(__isl_take isl_space *space);
__isl_export
__isl_give isl_space *isl_space_range(__isl_take isl_space *space);
__isl_give isl_space *isl_space_from_range(__isl_take isl_space *dim);
__isl_give isl_space *isl_space_from_range(__isl_take isl_space *space);
__isl_give isl_space *isl_space_domain_map(__isl_take isl_space *space);
__isl_give isl_space *isl_space_range_map(__isl_take isl_space *space);
__isl_export
__isl_give isl_space *isl_space_params(__isl_take isl_space *space);
__isl_overload
__isl_give isl_space *isl_space_add_unnamed_tuple_ui(
__isl_take isl_space *space, unsigned dim);
__isl_overload
__isl_give isl_space *isl_space_add_named_tuple_id_ui(
__isl_take isl_space *space, __isl_take isl_id *tuple_id, unsigned dim);
__isl_give isl_space *isl_space_set_from_params(__isl_take isl_space *space);

__isl_give isl_space *isl_space_align_params(__isl_take isl_space *dim1,
__isl_take isl_space *dim2);

isl_bool isl_space_is_wrapping(__isl_keep isl_space *dim);
__isl_export
isl_bool isl_space_is_wrapping(__isl_keep isl_space *space);
isl_bool isl_space_domain_is_wrapping(__isl_keep isl_space *space);
isl_bool isl_space_range_is_wrapping(__isl_keep isl_space *space);
isl_bool isl_space_is_product(__isl_keep isl_space *space);
__isl_give isl_space *isl_space_wrap(__isl_take isl_space *dim);
__isl_give isl_space *isl_space_unwrap(__isl_take isl_space *dim);
__isl_export
__isl_give isl_space *isl_space_wrap(__isl_take isl_space *space);
__isl_export
__isl_give isl_space *isl_space_unwrap(__isl_take isl_space *space);

isl_bool isl_space_can_zip(__isl_keep isl_space *space);
__isl_give isl_space *isl_space_zip(__isl_take isl_space *dim);
__isl_give isl_space *isl_space_zip(__isl_take isl_space *space);

isl_bool isl_space_can_curry(__isl_keep isl_space *space);
__isl_give isl_space *isl_space_curry(__isl_take isl_space *space);
Expand All @@ -146,6 +163,7 @@ isl_bool isl_space_is_domain(__isl_keep isl_space *space1,
__isl_keep isl_space *space2);
isl_bool isl_space_is_range(__isl_keep isl_space *space1,
__isl_keep isl_space *space2);
__isl_export
isl_bool isl_space_is_equal(__isl_keep isl_space *space1,
__isl_keep isl_space *space2);
isl_bool isl_space_has_equal_params(__isl_keep isl_space *space1,
Expand All @@ -158,15 +176,17 @@ isl_bool isl_space_tuple_is_equal(__isl_keep isl_space *space1,
ISL_DEPRECATED
isl_bool isl_space_match(__isl_keep isl_space *space1, enum isl_dim_type type1,
__isl_keep isl_space *space2, enum isl_dim_type type2);
unsigned isl_space_dim(__isl_keep isl_space *dim, enum isl_dim_type type);
isl_size isl_space_dim(__isl_keep isl_space *space, enum isl_dim_type type);

__isl_export
__isl_give isl_space *isl_space_flatten_domain(__isl_take isl_space *space);
__isl_export
__isl_give isl_space *isl_space_flatten_range(__isl_take isl_space *space);

__isl_give char *isl_space_to_str(__isl_keep isl_space *space);
__isl_give isl_printer *isl_printer_print_space(__isl_take isl_printer *p,
__isl_keep isl_space *dim);
void isl_space_dump(__isl_keep isl_space *dim);
__isl_keep isl_space *space);
void isl_space_dump(__isl_keep isl_space *space);

#if defined(__cplusplus)
}
Expand Down
4 changes: 3 additions & 1 deletion polly/lib/External/isl/include/isl/space_type.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#ifndef ISL_SPACE_TYPE_H
#define ISL_SPACE_TYPE_H

#include <isl/ctx.h>

#if defined(__cplusplus)
extern "C" {
#endif

struct isl_space;
struct __isl_export isl_space;
typedef struct isl_space isl_space;

enum isl_dim_type {
Expand Down
1 change: 1 addition & 0 deletions polly/lib/External/isl/include/isl/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ enum isl_token_type { ISL_TOKEN_ERROR = -1,
ISL_TOKEN_MAP, ISL_TOKEN_AFF,
ISL_TOKEN_CEIL, ISL_TOKEN_FLOOR,
ISL_TOKEN_IMPLIES,
ISL_TOKEN_INT_DIV,
ISL_TOKEN_LAST };

struct isl_token;
Expand Down
41 changes: 36 additions & 5 deletions polly/lib/External/isl/include/isl/union_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
extern "C" {
#endif

unsigned isl_union_map_dim(__isl_keep isl_union_map *umap,
isl_size isl_union_map_dim(__isl_keep isl_union_map *umap,
enum isl_dim_type type);
isl_bool isl_union_map_involves_dims(__isl_keep isl_union_map *umap,
enum isl_dim_type type, unsigned first, unsigned n);
Expand All @@ -25,11 +25,16 @@ __isl_give isl_union_map *isl_union_map_from_basic_map(
__isl_take isl_basic_map *bmap);
__isl_constructor
__isl_give isl_union_map *isl_union_map_from_map(__isl_take isl_map *map);
__isl_overload
__isl_give isl_union_map *isl_union_map_empty_ctx(isl_ctx *ctx);
__isl_give isl_union_map *isl_union_map_empty_space(
__isl_take isl_space *space);
__isl_give isl_union_map *isl_union_map_empty(__isl_take isl_space *space);
__isl_give isl_union_map *isl_union_map_copy(__isl_keep isl_union_map *umap);
__isl_null isl_union_map *isl_union_map_free(__isl_take isl_union_map *umap);

isl_ctx *isl_union_map_get_ctx(__isl_keep isl_union_map *umap);
__isl_export
__isl_give isl_space *isl_union_map_get_space(__isl_keep isl_union_map *umap);

__isl_give isl_union_map *isl_union_map_reset_user(
Expand All @@ -38,6 +43,7 @@ __isl_give isl_union_map *isl_union_map_reset_user(
int isl_union_map_find_dim_by_name(__isl_keep isl_union_map *umap,
enum isl_dim_type type, const char *name);

__isl_export
__isl_give isl_union_map *isl_union_map_universe(
__isl_take isl_union_map *umap);
__isl_give isl_set *isl_union_map_params(__isl_take isl_union_map *umap);
Expand Down Expand Up @@ -148,6 +154,10 @@ __isl_give isl_union_map *isl_union_map_intersect_domain(
__isl_export
__isl_give isl_union_map *isl_union_map_intersect_range(
__isl_take isl_union_map *umap, __isl_take isl_union_set *uset);
__isl_give isl_union_map *isl_union_map_intersect_domain_factor_range(
__isl_take isl_union_map *umap, __isl_take isl_union_map *factor);
__isl_give isl_union_map *isl_union_map_intersect_range_factor_domain(
__isl_take isl_union_map *umap, __isl_take isl_union_map *factor);
__isl_give isl_union_map *isl_union_map_intersect_range_factor_range(
__isl_take isl_union_map *umap, __isl_take isl_union_map *factor);

Expand All @@ -164,25 +174,35 @@ __isl_give isl_union_map *isl_union_map_apply_domain(
__isl_export
__isl_give isl_union_map *isl_union_map_apply_range(
__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
__isl_overload
__isl_give isl_union_map *isl_union_map_preimage_domain_multi_aff(
__isl_take isl_union_map *umap, __isl_take isl_multi_aff *ma);
__isl_overload
__isl_give isl_union_map *isl_union_map_preimage_range_multi_aff(
__isl_take isl_union_map *umap, __isl_take isl_multi_aff *ma);
__isl_overload
__isl_give isl_union_map *isl_union_map_preimage_domain_pw_multi_aff(
__isl_take isl_union_map *umap, __isl_take isl_pw_multi_aff *pma);
__isl_overload
__isl_give isl_union_map *isl_union_map_preimage_range_pw_multi_aff(
__isl_take isl_union_map *umap, __isl_take isl_pw_multi_aff *pma);
__isl_overload
__isl_give isl_union_map *isl_union_map_preimage_domain_multi_pw_aff(
__isl_take isl_union_map *umap, __isl_take isl_multi_pw_aff *mpa);
__isl_overload
__isl_give isl_union_map *isl_union_map_preimage_domain_union_pw_multi_aff(
__isl_take isl_union_map *umap,
__isl_take isl_union_pw_multi_aff *upma);
__isl_overload
__isl_give isl_union_map *isl_union_map_preimage_range_union_pw_multi_aff(
__isl_take isl_union_map *umap,
__isl_take isl_union_pw_multi_aff *upma);
__isl_export
__isl_give isl_union_map *isl_union_map_reverse(__isl_take isl_union_map *umap);
__isl_export
__isl_give isl_union_map *isl_union_map_range_reverse(
__isl_take isl_union_map *umap);
__isl_export
__isl_give isl_union_map *isl_union_map_from_domain_and_range(
__isl_take isl_union_set *domain, __isl_take isl_union_set *range);

Expand All @@ -205,6 +225,10 @@ __isl_give isl_union_map *isl_union_map_project_out_all_params(
__isl_give isl_union_map *isl_union_map_remove_divs(
__isl_take isl_union_map *bmap);

__isl_export
__isl_give isl_union_set *isl_union_map_bind_range(
__isl_take isl_union_map *umap, __isl_take isl_multi_id *tuple);

isl_bool isl_union_map_plain_is_empty(__isl_keep isl_union_map *umap);
__isl_export
isl_bool isl_union_map_is_empty(__isl_keep isl_union_map *umap);
Expand All @@ -223,6 +247,7 @@ isl_bool isl_union_map_is_subset(__isl_keep isl_union_map *umap1,
__isl_export
isl_bool isl_union_map_is_equal(__isl_keep isl_union_map *umap1,
__isl_keep isl_union_map *umap2);
__isl_export
isl_bool isl_union_map_is_disjoint(__isl_keep isl_union_map *umap1,
__isl_keep isl_union_map *umap2);
__isl_export
Expand All @@ -231,21 +256,25 @@ isl_bool isl_union_map_is_strict_subset(__isl_keep isl_union_map *umap1,

uint32_t isl_union_map_get_hash(__isl_keep isl_union_map *umap);

int isl_union_map_n_map(__isl_keep isl_union_map *umap);
isl_size isl_union_map_n_map(__isl_keep isl_union_map *umap);
__isl_export
isl_stat isl_union_map_foreach_map(__isl_keep isl_union_map *umap,
isl_stat (*fn)(__isl_take isl_map *map, void *user), void *user);
__isl_give isl_map_list *isl_union_map_get_map_list(
__isl_keep isl_union_map *umap);
__isl_export
isl_bool isl_union_map_every_map(__isl_keep isl_union_map *umap,
isl_bool (*test)(__isl_keep isl_map *map, void *user), void *user);
__isl_give isl_union_map *isl_union_map_remove_map_if(
__isl_take isl_union_map *umap,
isl_bool (*fn)(__isl_keep isl_map *map, void *user), void *user);
isl_bool isl_union_map_contains(__isl_keep isl_union_map *umap,
__isl_keep isl_space *space);
__isl_export
__isl_give isl_map *isl_union_map_extract_map(__isl_keep isl_union_map *umap,
__isl_take isl_space *dim);
__isl_take isl_space *space);
__isl_export
isl_bool isl_union_map_isa_map(__isl_keep isl_union_map *umap);
__isl_give isl_map *isl_map_from_union_map(__isl_take isl_union_map *umap);

__isl_give isl_basic_map *isl_union_map_sample(__isl_take isl_union_map *umap);
Expand All @@ -254,9 +283,9 @@ __isl_overload
__isl_give isl_union_map *isl_union_map_fixed_power_val(
__isl_take isl_union_map *umap, __isl_take isl_val *exp);
__isl_give isl_union_map *isl_union_map_power(__isl_take isl_union_map *umap,
int *exact);
isl_bool *exact);
__isl_give isl_union_map *isl_union_map_transitive_closure(
__isl_take isl_union_map *umap, int *exact);
__isl_take isl_union_map *umap, isl_bool *exact);

__isl_give isl_union_map *isl_union_map_lex_lt_union_map(
__isl_take isl_union_map *umap1, __isl_take isl_union_map *umap2);
Expand Down Expand Up @@ -295,9 +324,11 @@ __isl_give isl_union_map *isl_union_set_unwrap(__isl_take isl_union_set *uset);

__isl_export
__isl_give isl_union_map *isl_union_map_zip(__isl_take isl_union_map *umap);
__isl_export
__isl_give isl_union_map *isl_union_map_curry(__isl_take isl_union_map *umap);
__isl_give isl_union_map *isl_union_map_range_curry(
__isl_take isl_union_map *umap);
__isl_export
__isl_give isl_union_map *isl_union_map_uncurry(__isl_take isl_union_map *umap);

__isl_give isl_union_map *isl_union_map_align_params(
Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/include/isl/union_map_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ISL_DECLARE_LIST_TYPE(union_map)
#ifndef isl_union_set
struct __isl_export isl_union_set;
typedef struct isl_union_set isl_union_set;
ISL_DECLARE_LIST_TYPE(union_set)
ISL_DECLARE_EXPORTED_LIST_TYPE(union_set)
#endif

#if defined(__cplusplus)
Expand Down
23 changes: 19 additions & 4 deletions polly/lib/External/isl/include/isl/union_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@
extern "C" {
#endif

unsigned isl_union_set_dim(__isl_keep isl_union_set *uset,
isl_size isl_union_set_dim(__isl_keep isl_union_set *uset,
enum isl_dim_type type);

__isl_constructor
__isl_give isl_union_set *isl_union_set_from_basic_set(
__isl_take isl_basic_set *bset);
__isl_constructor
__isl_give isl_union_set *isl_union_set_from_set(__isl_take isl_set *set);
__isl_overload
__isl_give isl_union_set *isl_union_set_empty_ctx(isl_ctx *ctx);
__isl_give isl_union_set *isl_union_set_empty_space(
__isl_take isl_space *space);
__isl_give isl_union_set *isl_union_set_empty(__isl_take isl_space *space);
__isl_give isl_union_set *isl_union_set_copy(__isl_keep isl_union_set *uset);
__isl_null isl_union_set *isl_union_set_free(__isl_take isl_union_set *uset);

isl_ctx *isl_union_set_get_ctx(__isl_keep isl_union_set *uset);
__isl_export
__isl_give isl_space *isl_union_set_get_space(__isl_keep isl_union_set *uset);

__isl_give isl_union_set *isl_union_set_reset_user(
__isl_take isl_union_set *uset);

__isl_export
__isl_give isl_union_set *isl_union_set_universe(
__isl_take isl_union_set *uset);
__isl_give isl_set *isl_union_set_params(__isl_take isl_union_set *uset);
Expand Down Expand Up @@ -94,6 +100,8 @@ __isl_give isl_union_set *isl_union_set_preimage_union_pw_multi_aff(
__isl_give isl_union_set *isl_union_set_project_out(
__isl_take isl_union_set *uset,
enum isl_dim_type type, unsigned first, unsigned n);
__isl_give isl_union_set *isl_union_set_project_out_all_params(
__isl_take isl_union_set *uset);
__isl_give isl_union_set *isl_union_set_remove_divs(
__isl_take isl_union_set *bset);

Expand All @@ -107,6 +115,7 @@ isl_bool isl_union_set_is_subset(__isl_keep isl_union_set *uset1,
__isl_export
isl_bool isl_union_set_is_equal(__isl_keep isl_union_set *uset1,
__isl_keep isl_union_set *uset2);
__isl_export
isl_bool isl_union_set_is_disjoint(__isl_keep isl_union_set *uset1,
__isl_keep isl_union_set *uset2);
__isl_export
Expand All @@ -115,18 +124,24 @@ isl_bool isl_union_set_is_strict_subset(__isl_keep isl_union_set *uset1,

uint32_t isl_union_set_get_hash(__isl_keep isl_union_set *uset);

int isl_union_set_n_set(__isl_keep isl_union_set *uset);
isl_size isl_union_set_n_set(__isl_keep isl_union_set *uset);
__isl_export
isl_stat isl_union_set_foreach_set(__isl_keep isl_union_set *uset,
isl_stat (*fn)(__isl_take isl_set *set, void *user), void *user);
__isl_export
isl_bool isl_union_set_every_set(__isl_keep isl_union_set *uset,
isl_bool (*test)(__isl_keep isl_set *set, void *user), void *user);
__isl_give isl_basic_set_list *isl_union_set_get_basic_set_list(
__isl_keep isl_union_set *uset);
__isl_give isl_set_list *isl_union_set_get_set_list(
__isl_keep isl_union_set *uset);
isl_bool isl_union_set_contains(__isl_keep isl_union_set *uset,
__isl_keep isl_space *space);
__isl_export
__isl_give isl_set *isl_union_set_extract_set(__isl_keep isl_union_set *uset,
__isl_take isl_space *dim);
__isl_take isl_space *space);
__isl_export
isl_bool isl_union_set_isa_set(__isl_keep isl_union_set *uset);
__isl_give isl_set *isl_set_from_union_set(__isl_take isl_union_set *uset);
__isl_export
isl_stat isl_union_set_foreach_point(__isl_keep isl_union_set *uset,
Expand Down Expand Up @@ -166,7 +181,7 @@ __isl_give isl_printer *isl_printer_print_union_set(__isl_take isl_printer *p,
__isl_keep isl_union_set *uset);
void isl_union_set_dump(__isl_keep isl_union_set *uset);

ISL_DECLARE_LIST_FN(union_set)
ISL_DECLARE_EXPORTED_LIST_FN(union_set)

__isl_give isl_union_set *isl_union_set_list_union(
__isl_take isl_union_set_list *list);
Expand Down
18 changes: 14 additions & 4 deletions polly/lib/External/isl/include/isl/val.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ extern "C" {
#endif

ISL_DECLARE_MULTI(val)
ISL_DECLARE_MULTI_NEG(val)
ISL_DECLARE_MULTI_ARITH(val)
ISL_DECLARE_MULTI_ZERO(val)
ISL_DECLARE_MULTI_NAN(val)
ISL_DECLARE_MULTI_DIMS(val)
ISL_DECLARE_MULTI_DIM_ID(val)
ISL_DECLARE_MULTI_TUPLE_ID(val)
ISL_DECLARE_MULTI_WITH_DOMAIN(val)

__isl_export
Expand All @@ -40,12 +44,14 @@ __isl_null isl_val *isl_val_free(__isl_take isl_val *v);

isl_ctx *isl_val_get_ctx(__isl_keep isl_val *val);
uint32_t isl_val_get_hash(__isl_keep isl_val *val);
__isl_export
long isl_val_get_num_si(__isl_keep isl_val *v);
__isl_export
long isl_val_get_den_si(__isl_keep isl_val *v);
__isl_give isl_val *isl_val_get_den_val(__isl_keep isl_val *v);
double isl_val_get_d(__isl_keep isl_val *v);
size_t isl_val_n_abs_num_chunks(__isl_keep isl_val *v, size_t size);
int isl_val_get_abs_num_chunks(__isl_keep isl_val *v, size_t size,
isl_size isl_val_n_abs_num_chunks(__isl_keep isl_val *v, size_t size);
isl_stat isl_val_get_abs_num_chunks(__isl_keep isl_val *v, size_t size,
void *chunks);

__isl_give isl_val *isl_val_set_si(__isl_take isl_val *v, long i);
Expand Down Expand Up @@ -145,19 +151,23 @@ __isl_give isl_printer *isl_printer_print_val(__isl_take isl_printer *p,
void isl_val_dump(__isl_keep isl_val *v);
__isl_give char *isl_val_to_str(__isl_keep isl_val *v);

isl_bool isl_multi_val_is_zero(__isl_keep isl_multi_val *mv);

__isl_overload
__isl_give isl_multi_val *isl_multi_val_add_val(__isl_take isl_multi_val *mv,
__isl_take isl_val *v);
__isl_give isl_multi_val *isl_multi_val_mod_val(__isl_take isl_multi_val *mv,
__isl_take isl_val *v);

__isl_constructor
__isl_give isl_multi_val *isl_multi_val_read_from_str(isl_ctx *ctx,
const char *str);
__isl_give isl_printer *isl_printer_print_multi_val(__isl_take isl_printer *p,
__isl_keep isl_multi_val *mv);
void isl_multi_val_dump(__isl_keep isl_multi_val *mv);
__isl_give char *isl_multi_val_to_str(__isl_keep isl_multi_val *mv);

ISL_DECLARE_LIST_FN(val)
ISL_DECLARE_EXPORTED_LIST_FN(val)

#if defined(__cplusplus)
}
Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/include/isl/val_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {
struct __isl_export isl_val;
typedef struct isl_val isl_val;

ISL_DECLARE_LIST_TYPE(val)
ISL_DECLARE_EXPORTED_LIST_TYPE(val)

struct __isl_export isl_multi_val;
typedef struct isl_multi_val isl_multi_val;
Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/include/isl/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ __isl_null isl_vec *isl_vec_free(__isl_take isl_vec *vec);

isl_ctx *isl_vec_get_ctx(__isl_keep isl_vec *vec);

int isl_vec_size(__isl_keep isl_vec *vec);
isl_size isl_vec_size(__isl_keep isl_vec *vec);
__isl_give isl_val *isl_vec_get_element_val(__isl_keep isl_vec *vec, int pos);
__isl_give isl_vec *isl_vec_set_element_si(__isl_take isl_vec *vec,
int pos, int v);
Expand Down
8 changes: 4 additions & 4 deletions polly/lib/External/isl/include/isl/vertices.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ struct isl_vertices;
typedef struct isl_vertices isl_vertices;

isl_ctx *isl_vertex_get_ctx(__isl_keep isl_vertex *vertex);
int isl_vertex_get_id(__isl_keep isl_vertex *vertex);
isl_size isl_vertex_get_id(__isl_keep isl_vertex *vertex);
__isl_give isl_basic_set *isl_vertex_get_domain(__isl_keep isl_vertex *vertex);
__isl_give isl_multi_aff *isl_vertex_get_expr(__isl_keep isl_vertex *vertex);
void isl_vertex_free(__isl_take isl_vertex *vertex);
__isl_null isl_vertex *isl_vertex_free(__isl_take isl_vertex *vertex);

__isl_give isl_vertices *isl_basic_set_compute_vertices(
__isl_keep isl_basic_set *bset);
isl_ctx *isl_vertices_get_ctx(__isl_keep isl_vertices *vertices);
int isl_vertices_get_n_vertices(__isl_keep isl_vertices *vertices);
isl_size isl_vertices_get_n_vertices(__isl_keep isl_vertices *vertices);
isl_stat isl_vertices_foreach_vertex(__isl_keep isl_vertices *vertices,
isl_stat (*fn)(__isl_take isl_vertex *vertex, void *user), void *user);
__isl_null isl_vertices *isl_vertices_free(__isl_take isl_vertices *vertices);
Expand All @@ -35,7 +35,7 @@ isl_ctx *isl_cell_get_ctx(__isl_keep isl_cell *cell);
__isl_give isl_basic_set *isl_cell_get_domain(__isl_keep isl_cell *cell);
isl_stat isl_cell_foreach_vertex(__isl_keep isl_cell *cell,
isl_stat (*fn)(__isl_take isl_vertex *vertex, void *user), void *user);
void isl_cell_free(__isl_take isl_cell *cell);
__isl_null isl_cell *isl_cell_free(__isl_take isl_cell *cell);

isl_stat isl_vertices_foreach_cell(__isl_keep isl_vertices *vertices,
isl_stat (*fn)(__isl_take isl_cell *cell, void *user), void *user);
Expand Down
2 changes: 1 addition & 1 deletion polly/lib/External/isl/interface/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extract_interface_SOURCES = \
cpp_conversion.cc \
extract_interface.h \
extract_interface.cc
extract_interface_LDFLAGS = $(CLANG_LDFLAGS)
extract_interface_LDFLAGS = $(CLANG_LDFLAGS) $(CLANG_RFLAG)
extract_interface_LDADD = \
-lclangFrontend -lclangSerialization -lclangParse -lclangSema \
$(LIB_CLANG_EDIT) \
Expand Down
11 changes: 8 additions & 3 deletions polly/lib/External/isl/interface/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_create_stdint_h.m4 \
$(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \
$(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
$(top_srcdir)/m4/ax_cxx_compile_stdcxx_11_no_override.m4 \
$(top_srcdir)/m4/ax_detect_clang.m4 \
$(top_srcdir)/m4/ax_detect_git_head.m4 \
$(top_srcdir)/m4/ax_detect_gmp.m4 \
Expand Down Expand Up @@ -230,13 +231,15 @@ CFLAGS = @CFLAGS@
CLANG_CXXFLAGS = @CLANG_CXXFLAGS@
CLANG_LDFLAGS = @CLANG_LDFLAGS@
CLANG_LIBS = @CLANG_LIBS@
CLANG_RFLAG = @CLANG_RFLAG@
CONFIG_STATUS_DEPENDENCIES = @CONFIG_STATUS_DEPENDENCIES@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXX11FLAGS = @CXX11FLAGS@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH = @CYGPATH@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
Expand Down Expand Up @@ -266,19 +269,22 @@ LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIB_CLANG_EDIT = @LIB_CLANG_EDIT@
LIPO = @LIPO@
LLVM_CONFIG = @LLVM_CONFIG@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MP_CFLAGS = @MP_CFLAGS@
MP_CPPFLAGS = @MP_CPPFLAGS@
MP_LDFLAGS = @MP_LDFLAGS@
MP_LIBS = @MP_LIBS@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_SRCDIR = @OS_SRCDIR@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
Expand Down Expand Up @@ -341,7 +347,6 @@ infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
llvm_config_found = @llvm_config_found@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
Expand Down Expand Up @@ -385,7 +390,7 @@ extract_interface_SOURCES = \
extract_interface.h \
extract_interface.cc

extract_interface_LDFLAGS = $(CLANG_LDFLAGS)
extract_interface_LDFLAGS = $(CLANG_LDFLAGS) $(CLANG_RFLAG)
extract_interface_LDADD = \
-lclangFrontend -lclangSerialization -lclangParse -lclangSema \
$(LIB_CLANG_EDIT) \
Expand Down
1,601 changes: 1,359 additions & 242 deletions polly/lib/External/isl/interface/cpp.cc

Large diffs are not rendered by default.

97 changes: 83 additions & 14 deletions polly/lib/External/isl/interface/cpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,77 +24,146 @@ class cpp_generator : public generator {
function_kind_member_method,
function_kind_constructor,
};
enum method_part {
decl,
impl,
};

virtual void generate();
private:
void print_file(ostream &os, std::string filename);
void print_forward_declarations(ostream &os);
void print_declarations(ostream &os);
void print_class(ostream &os, const isl_class &clazz);
void print_subclass_type(ostream &os, const isl_class &clazz);
void print_class_forward_decl(ostream &os, const isl_class &clazz);
void print_class_factory_decl(ostream &os, const isl_class &clazz,
const std::string &prefix = std::string());
void print_private_constructors_decl(ostream &os,
void print_protected_constructors_decl(ostream &os,
const isl_class &clazz);
void print_copy_assignment_decl(ostream &os, const isl_class &clazz);
void print_public_constructors_decl(ostream &os,
const isl_class &clazz);
void print_constructors_decl(ostream &os, const isl_class &clazz);
void print_destructor_decl(ostream &os, const isl_class &clazz);
void print_ptr_decl(ostream &os, const isl_class &clazz);
void print_get_ctx_decl(ostream &os);
void print_isa_type_template(ostream &os, int indent,
const isl_class &super);
void print_downcast_decl(ostream &os, const isl_class &clazz);
void print_ctx_decl(ostream &os);
void print_persistent_callback_prototype(ostream &os,
const isl_class &clazz, FunctionDecl *method,
bool is_declaration);
void print_persistent_callback_setter_prototype(ostream &os,
const isl_class &clazz, FunctionDecl *method,
bool is_declaration);
void print_persistent_callback_data(ostream &os, const isl_class &clazz,
FunctionDecl *method);
void print_persistent_callbacks_decl(ostream &os,
const isl_class &clazz);
void print_methods_decl(ostream &os, const isl_class &clazz);
bool next_variant(FunctionDecl *fd, std::vector<bool> &convert);
template <enum method_part>
void print_method_variants(ostream &os, const isl_class &clazz,
FunctionDecl *fd);
void print_method_group_decl(ostream &os, const isl_class &clazz,
const set<FunctionDecl *> &methods);
void print_method_decl(ostream &os, const isl_class &clazz,
const function_set &methods);
void print_named_method_decl(ostream &os, const isl_class &clazz,
FunctionDecl *fd, const string &name, function_kind kind,
const std::vector<bool> &convert = {});
template <enum method_part>
void print_method(ostream &os, const isl_class &clazz,
FunctionDecl *method, function_kind kind);
template <enum method_part>
void print_method(ostream &os, const isl_class &clazz,
FunctionDecl *method, function_kind kind,
const std::vector<bool> &convert);
void print_set_enum_decl(ostream &os, const isl_class &clazz,
FunctionDecl *fd, const string &name);
void print_set_enums_decl(ostream &os, const isl_class &clazz,
FunctionDecl *fd);
void print_set_enums_decl(ostream &os, const isl_class &clazz);
void print_implementations(ostream &os);
void print_class_impl(ostream &os, const isl_class &clazz);
void print_check_ptr(ostream &os, const char *ptr);
void print_check_ptr_start(ostream &os, const isl_class &clazz,
const char *ptr);
void print_check_ptr_end(ostream &os, const char *ptr);
void print_class_factory_impl(ostream &os, const isl_class &clazz);
void print_private_constructors_impl(ostream &os,
void print_protected_constructors_impl(ostream &os,
const isl_class &clazz);
void print_public_constructors_impl(ostream &os,
const isl_class &clazz);
void print_constructors_impl(ostream &os, const isl_class &clazz);
void print_copy_assignment_impl(ostream &os, const isl_class &clazz);
void print_destructor_impl(ostream &os, const isl_class &clazz);
void print_check_no_persistent_callback(ostream &os,
const isl_class &clazz, FunctionDecl *fd);
void print_ptr_impl(ostream &os, const isl_class &clazz);
void print_get_ctx_impl(ostream &os, const isl_class &clazz);
void print_downcast_impl(ostream &os, const isl_class &clazz);
void print_ctx_impl(ostream &os, const isl_class &clazz);
void print_persistent_callbacks_impl(ostream &os,
const isl_class &clazz);
void print_methods_impl(ostream &os, const isl_class &clazz);
void print_method_group_impl(ostream &os, const isl_class &clazz,
const set<FunctionDecl *> &methods);
const function_set &methods);
void print_argument_validity_check(ostream &os, FunctionDecl *method,
function_kind kind);
void print_save_ctx(ostream &os, FunctionDecl *method,
function_kind kind);
void print_on_error_continue(ostream &os);
void print_exceptional_execution_check(ostream &os,
FunctionDecl *method);
const isl_class &clazz, FunctionDecl *method,
function_kind kind);
void print_set_persistent_callback(ostream &os, const isl_class &clazz,
FunctionDecl *method, function_kind kind);
void print_method_return(ostream &os, const isl_class &clazz,
FunctionDecl *method);
void print_method_impl(ostream &os, const isl_class &clazz,
FunctionDecl *method, function_kind kind);
void print_set_enum_impl(ostream &os, const isl_class &clazz,
FunctionDecl *fd, const string &enum_name,
const string &method_name);
void print_set_enums_impl(ostream &os, const isl_class &clazz,
FunctionDecl *fd);
void print_set_enums_impl(ostream &os, const isl_class &clazz);
template <enum method_part>
void print_get_method(ostream &os, const isl_class &clazz,
FunctionDecl *fd);
void print_invalid(ostream &os, int indent, const char *msg,
const char *checked_code);
void print_stream_insertion(ostream &os, const isl_class &clazz);
void print_method_param_use(ostream &os, ParmVarDecl *param,
bool load_from_this_ptr);
std::string get_return_type(const isl_class &clazz, FunctionDecl *fd);
ParmVarDecl *get_param(FunctionDecl *fd, int pos,
const std::vector<bool> &convert);
void print_method_header(ostream &os, const isl_class &clazz,
FunctionDecl *method, const string &cname, int num_params,
bool is_declaration, function_kind kind,
const std::vector<bool> &convert = {});
void print_named_method_header(ostream &os, const isl_class &clazz,
FunctionDecl *method, string name, bool is_declaration,
function_kind kind, const std::vector<bool> &convert = {});
void print_method_header(ostream &os, const isl_class &clazz,
FunctionDecl *method, bool is_declaration, function_kind kind);
string generate_callback_args(QualType type, bool cpp);
string generate_callback_type(QualType type);
void print_wrapped_call_checked(std::ostream &os,
void print_wrapped_call_checked(std::ostream &os, int indent,
const std::string &call);
void print_wrapped_call(std::ostream &os, const std::string &call);
void print_wrapped_call(std::ostream &os, int indent,
const std::string &call, QualType rtype);
void print_callback_data_decl(ostream &os, ParmVarDecl *param,
const string &name);
void print_callback_body(ostream &os, int indent, ParmVarDecl *param,
const string &name);
void print_callback_local(ostream &os, ParmVarDecl *param);
std::string rename_method(std::string name);
string type2cpp(const isl_class &clazz);
string isl_bool2cpp();
string isl_namespace();
string type2cpp(QualType type);
bool is_implicit_conversion(const isl_class &clazz, FunctionDecl *cons);
bool is_subclass(QualType subclass_type, const isl_class &class_type);
function_kind get_method_kind(const isl_class &clazz,
FunctionDecl *method);
public:
static string type2cpp(const isl_class &clazz);
static string type2cpp(string type_string);
};
47 changes: 37 additions & 10 deletions polly/lib/External/isl/interface/cpp_conversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,46 @@
* Written by Sven Verdoolaege.
*/

#include <stdio.h>
#include <map>
#include <string>

#include "cpp.h"
#include "cpp_conversion.h"

/* If "clazz" describes a subclass of a C type, then print code
* for converting an object of the class derived from the C type
* to the subclass. Do this by first converting this class
* to the immediate superclass of the subclass and then converting
* from this superclass to the subclass.
*/
void cpp_conversion_generator::cast(const isl_class &clazz, const char *to)
{
string name = cpp_generator::type2cpp(clazz);

if (!clazz.is_type_subclass())
return;

cast(classes[clazz.superclass_name], to);
printf(".as<%s%s>()", to, name.c_str());
}

/* Print a function called "function" for converting objects of
* type "name" from the "from" bindings to the "to" bindings.
* "clazz" from the "from" bindings to the "to" bindings.
* If "clazz" describes a subclass of a C type, then the result
* of the conversion between bindings is derived from the C type and
* needs to be converted back to the subclass.
*/
static void convert(const char *name, const char *from, const char *to,
const char *function)
void cpp_conversion_generator::convert(const isl_class &clazz,
const char *from, const char *to, const char *function)
{
printf("%s%s %s(%s%s obj) {\n", to, name, function, from, name);
printf("\t""return %s""manage(obj.copy());\n", to);
string name = cpp_generator::type2cpp(clazz);

printf("%s%s %s(%s%s obj) {\n",
to, name.c_str(), function, from, name.c_str());
printf("\t""return %s""manage(obj.copy())", to);
cast(clazz, to);
printf(";\n");
printf("}\n");
printf("\n");
}
Expand All @@ -36,12 +65,10 @@ static void convert(const char *name, const char *from, const char *to,
* return manage(obj.copy());
* }
*/
static void print(const isl_class &clazz)
void cpp_conversion_generator::print(const isl_class &clazz)
{
string name = cpp_generator::type2cpp(clazz.name);

convert(name.c_str(), "", "checked::", "check");
convert(name.c_str(), "checked::", "", "uncheck");
convert(clazz, "", "checked::", "check");
convert(clazz, "checked::", "", "uncheck");
}

/* Generate conversion functions for converting objects between
Expand Down
4 changes: 4 additions & 0 deletions polly/lib/External/isl/interface/cpp_conversion.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include "generator.h"

class cpp_conversion_generator : public generator {
void cast(const isl_class &clazz, const char *to);
void convert(const isl_class &clazz, const char *from, const char *to,
const char *function);
void print(const isl_class &clazz);
public:
cpp_conversion_generator(SourceManager &SM,
set<RecordDecl *> &exported_types,
Expand Down
99 changes: 86 additions & 13 deletions polly/lib/External/isl/interface/extract_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/

#include "isl_config.h"
#undef PACKAGE

#include <assert.h>
#include <iostream>
Expand All @@ -41,12 +42,16 @@
#else
#include <memory>
#endif
#ifdef HAVE_LLVM_OPTION_ARG_H
#include <llvm/Option/Arg.h>
#endif
#include <llvm/Support/raw_ostream.h>
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/Host.h>
#include <llvm/Support/ManagedStatic.h>
#include <clang/AST/ASTContext.h>
#include <clang/AST/ASTConsumer.h>
#include <clang/Basic/Builtins.h>
#include <clang/Basic/FileSystemOptions.h>
#include <clang/Basic/FileManager.h>
#include <clang/Basic/TargetOptions.h>
Expand Down Expand Up @@ -83,6 +88,9 @@
using namespace std;
using namespace clang;
using namespace clang::driver;
#ifdef HAVE_LLVM_OPTION_ARG_H
using namespace llvm::opt;
#endif

#ifdef HAVE_ADT_OWNINGPTR_H
#define unique_ptr llvm::OwningPtr
Expand All @@ -94,7 +102,7 @@ static llvm::cl::list<string> Includes("I",
llvm::cl::desc("Header search path"),
llvm::cl::value_desc("path"), llvm::cl::Prefix);

static llvm::cl::opt<string> Language(llvm::cl::Required,
static llvm::cl::opt<string> OutputLanguage(llvm::cl::Required,
llvm::cl::ValueRequired, "language",
llvm::cl::desc("Bindings to generate"),
llvm::cl::value_desc("name"));
Expand Down Expand Up @@ -203,6 +211,32 @@ struct ClangAPI {
static Command *command(Command &C) { return &C; }
};

#ifdef CREATE_FROM_ARGS_TAKES_ARRAYREF

/* Call CompilerInvocation::CreateFromArgs with the right arguments.
* In this case, an ArrayRef<const char *>.
*/
static void create_from_args(CompilerInvocation &invocation,
const ArgStringList *args, DiagnosticsEngine &Diags)
{
CompilerInvocation::CreateFromArgs(invocation, *args, Diags);
}

#else

/* Call CompilerInvocation::CreateFromArgs with the right arguments.
* In this case, two "const char *" pointers.
*/
static void create_from_args(CompilerInvocation &invocation,
const ArgStringList *args, DiagnosticsEngine &Diags)
{
CompilerInvocation::CreateFromArgs(invocation, args->data() + 1,
args->data() + args->size(),
Diags);
}

#endif

/* Create a CompilerInvocation object that stores the command line
* arguments constructed by the driver.
* The arguments are mainly useful for setting up the system include
Expand All @@ -227,9 +261,7 @@ static CompilerInvocation *construct_invocation(const char *filename,
const ArgStringList *args = &cmd->getArguments();

CompilerInvocation *invocation = new CompilerInvocation;
CompilerInvocation::CreateFromArgs(*invocation, args->data() + 1,
args->data() + args->size(),
Diags);
create_from_args(*invocation, args, Diags);
return invocation;
}

Expand Down Expand Up @@ -396,27 +428,66 @@ static void set_invocation(CompilerInstance *Clang,

#endif

/* Helper function for ignore_error that only gets enabled if T
* (which is either const FileEntry * or llvm::ErrorOr<const FileEntry *>)
* has getError method, i.e., if it is llvm::ErrorOr<const FileEntry *>.
*/
template <class T>
static const FileEntry *ignore_error_helper(const T obj, int,
int[1][sizeof(obj.getError())])
{
return *obj;
}

/* Helper function for ignore_error that is always enabled,
* but that only gets selected if the variant above is not enabled,
* i.e., if T is const FileEntry *.
*/
template <class T>
static const FileEntry *ignore_error_helper(const T obj, long, void *)
{
return obj;
}

/* Given either a const FileEntry * or a llvm::ErrorOr<const FileEntry *>,
* extract out the const FileEntry *.
*/
template <class T>
static const FileEntry *ignore_error(const T obj)
{
return ignore_error_helper(obj, 0, NULL);
}

/* Return the FileEntry corresponding to the given file name
* in the given compiler instances, ignoring any error.
*/
static const FileEntry *getFile(CompilerInstance *Clang, std::string Filename)
{
return ignore_error(Clang->getFileManager().getFile(Filename));
}

/* Create an interface generator for the selected language and
* then use it to generate the interface.
*/
static void generate(MyASTConsumer &consumer, SourceManager &SM)
{
generator *gen;

if (Language.compare("python") == 0) {
if (OutputLanguage.compare("python") == 0) {
gen = new python_generator(SM, consumer.exported_types,
consumer.exported_functions, consumer.functions);
} else if (Language.compare("cpp") == 0) {
} else if (OutputLanguage.compare("cpp") == 0) {
gen = new cpp_generator(SM, consumer.exported_types,
consumer.exported_functions, consumer.functions);
} else if (Language.compare("cpp-checked") == 0) {
} else if (OutputLanguage.compare("cpp-checked") == 0) {
gen = new cpp_generator(SM, consumer.exported_types,
consumer.exported_functions, consumer.functions, true);
} else if (Language.compare("cpp-checked-conversion") == 0) {
} else if (OutputLanguage.compare("cpp-checked-conversion") == 0) {
gen = new cpp_conversion_generator(SM, consumer.exported_types,
consumer.exported_functions, consumer.functions);
} else {
cerr << "Language '" << Language << "' not recognized." << endl
cerr << "Language '" << OutputLanguage
<< "' not recognized." << endl
<< "Not generating bindings." << endl;
exit(EXIT_FAILURE);
}
Expand All @@ -432,15 +503,15 @@ int main(int argc, char *argv[])
create_diagnostics(Clang);
DiagnosticsEngine &Diags = Clang->getDiagnostics();
Diags.setSuppressSystemWarnings(true);
TargetInfo *target = create_target_info(Clang, Diags);
Clang->setTarget(target);
set_lang_defaults(Clang);
CompilerInvocation *invocation =
construct_invocation(InputFilename.c_str(), Diags);
if (invocation)
set_invocation(Clang, invocation);
Clang->createFileManager();
Clang->createSourceManager(Clang->getFileManager());
TargetInfo *target = create_target_info(Clang, Diags);
Clang->setTarget(target);
set_lang_defaults(Clang);
HeaderSearchOptions &HSO = Clang->getHeaderSearchOpts();
LangOptions &LO = Clang->getLangOpts();
PreprocessorOptions &PO = Clang->getPreprocessorOpts();
Expand All @@ -464,7 +535,7 @@ int main(int argc, char *argv[])

PP.getBuiltinInfo().initializeBuiltins(PP.getIdentifierTable(), LO);

const FileEntry *file = Clang->getFileManager().getFile(InputFilename);
const FileEntry *file = getFile(Clang, InputFilename);
assert(file);
create_main_file_id(Clang->getSourceManager(), file);

Expand All @@ -482,5 +553,7 @@ int main(int argc, char *argv[])
delete Clang;
llvm::llvm_shutdown();

if (Diags.hasErrorOccurred())
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
484 changes: 434 additions & 50 deletions polly/lib/External/isl/interface/generator.cc

Large diffs are not rendered by default.

116 changes: 108 additions & 8 deletions polly/lib/External/isl/interface/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,124 @@
#include <map>
#include <set>
#include <string>
#include <vector>

#include <clang/AST/Decl.h>

using namespace std;
using namespace clang;

/* Compare the prefix of "s" to "prefix" up to the length of "prefix".
*/
inline int prefixcmp(const char *s, const char *prefix)
{
return strncmp(s, prefix, strlen(prefix));
}

/* Information about a single enum value of an enum set by a function.
* "value" is the enum value.
* "name" is the corresponding name.
* "method_name" is the the name of the method that sets this value.
*/
struct set_enum {
int value;
string name;
string method_name;
set_enum(int value, string name, string method_name) :
value(value), name(name), method_name(method_name) {}
};

/* Helper structure for sorting FunctionDecl pointers
* on the corresponding function names.
*/
struct function_name_less {
bool operator()(FunctionDecl *x, FunctionDecl *y) {
return x->getName() < y->getName();
}
};

/* Set of FunctionDecl pointers sorted on function name.
*/
typedef std::set<FunctionDecl *, function_name_less> function_set;

/* isl_class collects all constructors and methods for an isl "class".
* "name" is the name of the class.
* If this object describes a subclass of a C type, then
* "subclass_name" is the name of that subclass and "superclass_name"
* is the name of the immediate superclass of that subclass. Otherwise,
* "subclass_name" is equal to "name" and "superclass_name" is undefined.
* "type" is the declaration that introduces the type.
* "persistent_callbacks" contains the set of functions that
* set a persistent callback.
* "set_enums" maps the set of functions that set an enum value
* to information associated to each value.
* A function is considered to set an enum value if it returns
* an object of the same type and if its last argument is of an enum type.
* "methods" contains the set of methods, grouped by method name.
* "fn_to_str" is a reference to the *_to_str method of this class, if any.
* "fn_copy" is a reference to the *_copy method of this class, if any.
* "fn_free" is a reference to the *_free method of this class, if any.
* "fn_type" is a reference to a function that described subclasses, if any.
* If "fn_type" is set, then "type_subclasses" maps the values returned
* by that function to the names of the corresponding subclasses.
*/
struct isl_class {
string name;
string superclass_name;
string subclass_name;
RecordDecl *type;
set<FunctionDecl *> constructors;
map<string, set<FunctionDecl *> > methods;
function_set constructors;
set<FunctionDecl *> persistent_callbacks;
map<FunctionDecl *, vector<set_enum> > set_enums;
map<string, function_set> methods;
map<int, string> type_subclasses;
FunctionDecl *fn_type;
FunctionDecl *fn_to_str;
FunctionDecl *fn_copy;
FunctionDecl *fn_free;

/* Return name of "fd" without type suffix, if any. */
static string name_without_type_suffix(FunctionDecl *fd);
/* Does "method" correspond to a static method? */
bool is_static(FunctionDecl *method) const;
/* Is this class a subclass based on a type function? */
bool is_type_subclass() const { return name != subclass_name; }
/* Return name of "fd" without type suffixes, if any. */
static string name_without_type_suffixes(FunctionDecl *fd);
/* Extract the method name corresponding to "fd"
* (including "get" method prefix if any).
*/
string base_method_name(FunctionDecl *fd) const {
string m_name = name_without_type_suffixes(fd);
return m_name.substr(subclass_name.length() + 1);
}
/* The prefix of a "get" method. */
static const char *get_prefix;
/* Is function "fd" with the given name a "get" method? */
bool is_get_method_name(FunctionDecl *fd, const string &name) const;
/* Is function "fd" a "get" method? */
bool is_get_method(FunctionDecl *fd) const {
return is_get_method_name(fd, base_method_name(fd));
}
/* Extract the method name corresponding to "fd". */
string method_name(FunctionDecl *fd) const {
string m_name = name_without_type_suffix(fd);
return m_name.substr(name.length() + 1);
string method_name(FunctionDecl *fd) const;
/* The prefix of any method that may set a (persistent) callback. */
static const char *set_callback_prefix;
/* Given a function that sets a persistent callback,
* return the name of the callback.
*/
string persistent_callback_name(FunctionDecl *fd) const {
return method_name(fd).substr(strlen(set_callback_prefix));
}
/* Does this class have any functions that set a persistent callback?
*/
bool has_persistent_callbacks() const {
return persistent_callbacks.size() != 0;
}
};

/* Base class for interface generators.
*
* "conversions" maps the target type of automatic conversion
* to the second input argument of the conversion function.
*/
class generator {
protected:
Expand All @@ -53,13 +138,24 @@ class generator {
virtual ~generator() {};

protected:
void add_subclass(RecordDecl *decl, const string &name,
const string &sub_name);
void add_class(RecordDecl *decl);
void add_type_subclasses(FunctionDecl *method);
isl_class *method2class(FunctionDecl *fd);
bool callback_takes_argument(ParmVarDecl *param, int pos);
FunctionDecl *find_by_name(const string &name, bool required);
std::map<const Type *, ParmVarDecl *> conversions;
private:
static const std::set<std::string> automatic_conversion_functions;
void extract_automatic_conversion(FunctionDecl *fd);
void extract_class_automatic_conversions(const isl_class &clazz);
void extract_automatic_conversions();
public:
static void die(const char *msg) __attribute__((noreturn));
static void die(string msg) __attribute__((noreturn));
static vector<string> find_superclasses(RecordDecl *decl);
static vector<string> find_superclasses(Decl *decl);
static bool is_subclass(FunctionDecl *decl);
static bool is_overload(Decl *decl);
static bool is_constructor(Decl *decl);
static bool takes(Decl *decl);
Expand All @@ -68,14 +164,18 @@ class generator {
static bool is_isl_ctx(QualType type);
static bool first_arg_is_isl_ctx(FunctionDecl *fd);
static bool is_isl_type(QualType type);
static bool is_isl_neg_error(QualType type);
static bool is_isl_bool(QualType type);
static bool is_isl_stat(QualType type);
static bool is_isl_size(QualType type);
static bool is_long(QualType type);
static bool is_callback(QualType type);
static bool is_string(QualType type);
static bool is_static(const isl_class &clazz, FunctionDecl *method);
static bool is_mutator(const isl_class &clazz, FunctionDecl *fd);
static string extract_type(QualType type);
static const FunctionProtoType *extract_prototype(QualType type);
static ParmVarDecl *persistent_callback_arg(FunctionDecl *fd);
};

#endif /* ISL_INTERFACE_GENERATOR_H */
14,919 changes: 11,645 additions & 3,274 deletions polly/lib/External/isl/interface/isl.py

Large diffs are not rendered by default.

744 changes: 571 additions & 173 deletions polly/lib/External/isl/interface/python.cc

Large diffs are not rendered by default.

30 changes: 25 additions & 5 deletions polly/lib/External/isl/interface/python.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,48 @@ class python_generator : public generator {

private:
void print(const isl_class &clazz);
void print_method_arguments(int first, int n_arg);
void print_method_header(bool is_static, const string &name, int n_arg);
void print_class_header(const isl_class &clazz, const string &name,
const vector<string> &super);
void print_type_check(const string &type, int pos, bool upcast,
const string &super, const string &name, int n);
void print_type_check(int indent, const string &type, const char *fmt,
int pos, bool upcast, const string &super,
const string &name, int n);
void print_type_checks(const string &cname, FunctionDecl *method,
bool first_is_ctx, int n, const vector<string> &super);
void print_copy(QualType type);
void print_callback(ParmVarDecl *param, int arg);
void print_arg_in_call(FunctionDecl *fd, int arg, int skip);
void print_arg_in_call(FunctionDecl *fd, const char *fmt, int arg,
int skip);
void print_argtypes(FunctionDecl *fd);
void print_method_return(FunctionDecl *method);
void print_method_return(int indent, const isl_class &clazz,
FunctionDecl *method, const char *fmt);
void print_restype(FunctionDecl *fd);
void print(map<string, isl_class> &classes, set<string> &done);
void print_constructor(const isl_class &clazz, FunctionDecl *method);
void print_upcast_constructors(const isl_class &clazz);
void print_new(const isl_class &clazz,
const string &python_name);
void print_representation(const isl_class &clazz,
const string &python_name);
void print_copy_callbacks(const isl_class &clazz);
void print_method_type(FunctionDecl *fd);
void print_method_types(const isl_class &clazz);
void print_get_method(const isl_class &clazz, FunctionDecl *fd);
void print_method(const isl_class &clazz, FunctionDecl *method,
vector<string> super);
void print_method_call(int indent, const isl_class &clazz,
FunctionDecl *method, const char *fmt,
int drop_ctx, int drop_user);
void print_argument_checks(const isl_class &clazz, FunctionDecl *fd,
int drop_ctx);
void print_method_overload(const isl_class &clazz,
FunctionDecl *method);
void print_method(const isl_class &clazz, const string &fullname,
const set<FunctionDecl *> &methods, vector<string> super);
const function_set &methods, vector<string> super);
void print_set_enum(const isl_class &clazz, FunctionDecl *fd,
int value, const string &name, const vector<string> &super);
void print_set_enum(const isl_class &clazz, FunctionDecl *fd,
const vector<string> &super);

};
1,550 changes: 925 additions & 625 deletions polly/lib/External/isl/isl_aff.c

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions polly/lib/External/isl/isl_aff_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ __isl_give isl_basic_map *isl_basic_map_from_multi_aff2(
__isl_take isl_multi_aff *maff, int rational)
{
int i;
isl_size dim;
isl_space *space;
isl_basic_map *bmap;

if (!maff)
return NULL;
dim = isl_multi_aff_dim(maff, isl_dim_out);
if (dim < 0)
goto error;

if (isl_space_dim(maff->space, isl_dim_out) != maff->n)
if (dim != maff->n)
isl_die(isl_multi_aff_get_ctx(maff), isl_error_internal,
"invalid space", goto error);

Expand Down Expand Up @@ -198,7 +200,7 @@ __isl_give isl_basic_set *isl_basic_set_from_multi_aff(
{
if (check_input_is_set(isl_multi_aff_peek_space(ma)) < 0)
ma = isl_multi_aff_free(ma);
return bset_from_bmap(isl_basic_map_from_multi_aff(ma));
return bset_from_bmap(basic_map_from_multi_aff(ma));
}

/* Construct a map mapping the domain of the multi-affine expression
Expand Down Expand Up @@ -377,11 +379,13 @@ static __isl_give isl_map *map_from_multi_pw_aff(
__isl_take isl_multi_pw_aff *mpa)
{
int i;
isl_size dim;
isl_space *space;
isl_map *map;

if (!mpa)
return NULL;
dim = isl_multi_pw_aff_dim(mpa, isl_dim_out);
if (dim < 0)
goto error;

if (isl_space_dim(mpa->space, isl_dim_out) != mpa->n)
isl_die(isl_multi_pw_aff_get_ctx(mpa), isl_error_internal,
Expand Down
14 changes: 13 additions & 1 deletion polly/lib/External/isl/isl_aff_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ __isl_give isl_aff *isl_aff_alloc_vec(__isl_take isl_local_space *ls,
__isl_take isl_vec *v);
__isl_give isl_aff *isl_aff_alloc(__isl_take isl_local_space *ls);

isl_size isl_aff_domain_dim(__isl_keep isl_aff *aff, enum isl_dim_type type);
isl_size isl_aff_domain_offset(__isl_keep isl_aff *aff, enum isl_dim_type type);

__isl_give isl_aff *isl_aff_reset_space_and_domain(__isl_take isl_aff *aff,
__isl_take isl_space *space, __isl_take isl_space *domain);
__isl_give isl_aff *isl_aff_reset_domain_space(__isl_take isl_aff *aff,
Expand Down Expand Up @@ -107,6 +110,9 @@ __isl_give isl_pw_aff *isl_pw_aff_reset_domain_space(
__isl_give isl_pw_aff *isl_pw_aff_add_disjoint(
__isl_take isl_pw_aff *pwaff1, __isl_take isl_pw_aff *pwaff2);

__isl_give isl_pw_aff *isl_pw_aff_domain_factor_domain(
__isl_take isl_pw_aff *pa);

__isl_give isl_pw_aff *isl_pw_aff_union_opt(__isl_take isl_pw_aff *pwaff1,
__isl_take isl_pw_aff *pwaff2, int max);

Expand Down Expand Up @@ -146,6 +152,11 @@ __isl_give isl_multi_aff *isl_multi_aff_from_aff_mat(

#include <isl_list_templ.h>

__isl_give isl_pw_multi_aff *isl_pw_multi_aff_move_dims(
__isl_take isl_pw_multi_aff *pma,
enum isl_dim_type dst_type, unsigned dst_pos,
enum isl_dim_type src_type, unsigned src_pos, unsigned n);

__isl_give isl_pw_multi_aff *isl_pw_multi_aff_reset_domain_space(
__isl_take isl_pw_multi_aff *pwmaff, __isl_take isl_space *space);
__isl_give isl_pw_multi_aff *isl_pw_multi_aff_reset_space(
Expand All @@ -157,7 +168,7 @@ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_project_out(
__isl_take isl_pw_multi_aff *pma,
enum isl_dim_type type, unsigned first, unsigned n);

void isl_seq_preimage(isl_int *dst, isl_int *src,
isl_stat isl_seq_preimage(isl_int *dst, isl_int *src,
__isl_keep isl_multi_aff *ma, int n_before, int n_after,
int n_div_ma, int n_div_bmap,
isl_int f, isl_int c1, isl_int c2, isl_int g, int has_denom);
Expand All @@ -169,6 +180,7 @@ __isl_give isl_pw_multi_aff *isl_pw_multi_aff_substitute(
__isl_keep isl_pw_aff *subs);

isl_stat isl_pw_aff_check_named_params(__isl_keep isl_pw_aff *pa);
isl_stat isl_multi_aff_check_named_params(__isl_keep isl_multi_aff *ma);
isl_stat isl_pw_multi_aff_check_named_params(__isl_keep isl_pw_multi_aff *pma);

isl_bool isl_pw_aff_matching_params(__isl_keep isl_pw_aff *pa,
Expand Down
135 changes: 82 additions & 53 deletions polly/lib/External/isl/isl_affine_hull.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,31 +114,36 @@ static void delete_row(struct isl_basic_set *bset, unsigned row)
* so that
* A[i][col] = B[i][col] = a * old(B[i][col])
*/
static void construct_column(
struct isl_basic_set *bset1, struct isl_basic_set *bset2,
static isl_stat construct_column(
__isl_keep isl_basic_set *bset1, __isl_keep isl_basic_set *bset2,
unsigned row, unsigned col)
{
int r;
isl_int a;
isl_int b;
unsigned total;
isl_size total;

total = isl_basic_set_dim(bset1, isl_dim_set);
if (total < 0)
return isl_stat_error;

isl_int_init(a);
isl_int_init(b);
total = 1 + isl_basic_set_n_dim(bset1);
for (r = 0; r < row; ++r) {
if (isl_int_is_zero(bset2->eq[r][col]))
continue;
isl_int_gcd(b, bset2->eq[r][col], bset1->eq[row][col]);
isl_int_divexact(a, bset1->eq[row][col], b);
isl_int_divexact(b, bset2->eq[r][col], b);
isl_seq_combine(bset1->eq[r], a, bset1->eq[r],
b, bset1->eq[row], total);
isl_seq_scale(bset2->eq[r], bset2->eq[r], a, total);
b, bset1->eq[row], 1 + total);
isl_seq_scale(bset2->eq[r], bset2->eq[r], a, 1 + total);
}
isl_int_clear(a);
isl_int_clear(b);
delete_row(bset1, row);

return isl_stat_ok;
}

/* Make first row entries in column col of bset1 identical to
Expand All @@ -150,21 +155,23 @@ static void construct_column(
* so that
* A[i][col] = B[i][col] = old(A[t][col]*B[i][col]-A[i][col]*B[t][col])
*/
static int transform_column(
struct isl_basic_set *bset1, struct isl_basic_set *bset2,
static isl_bool transform_column(
__isl_keep isl_basic_set *bset1, __isl_keep isl_basic_set *bset2,
unsigned row, unsigned col)
{
int i, t;
isl_int a, b, g;
unsigned total;
isl_size total;

for (t = row-1; t >= 0; --t)
if (isl_int_ne(bset1->eq[t][col], bset2->eq[t][col]))
break;
if (t < 0)
return 0;
return isl_bool_false;

total = 1 + isl_basic_set_n_dim(bset1);
total = isl_basic_set_dim(bset1, isl_dim_set);
if (total < 0)
return isl_bool_error;
isl_int_init(a);
isl_int_init(b);
isl_int_init(g);
Expand All @@ -175,34 +182,36 @@ static int transform_column(
isl_int_divexact(a, a, g);
isl_int_divexact(g, b, g);
isl_seq_combine(bset1->eq[i], g, bset1->eq[i], a, bset1->eq[t],
total);
1 + total);
isl_seq_combine(bset2->eq[i], g, bset2->eq[i], a, bset2->eq[t],
total);
1 + total);
}
isl_int_clear(a);
isl_int_clear(b);
isl_int_clear(g);
delete_row(bset1, t);
delete_row(bset2, t);
return 1;
return isl_bool_true;
}

/* The implementation is based on Section 5.2 of Michael Karr,
* "Affine Relationships Among Variables of a Program",
* except that the echelon form we use starts from the last column
* and that we are dealing with integer coefficients.
*/
static struct isl_basic_set *affine_hull(
struct isl_basic_set *bset1, struct isl_basic_set *bset2)
static __isl_give isl_basic_set *affine_hull(
__isl_take isl_basic_set *bset1, __isl_take isl_basic_set *bset2)
{
isl_size dim;
unsigned total;
int col;
int row;

if (!bset1 || !bset2)
dim = isl_basic_set_dim(bset1, isl_dim_set);
if (dim < 0 || !bset2)
goto error;

total = 1 + isl_basic_set_n_dim(bset1);
total = 1 + dim;

row = 0;
for (col = total-1; col >= 0; --col) {
Expand All @@ -214,11 +223,18 @@ static struct isl_basic_set *affine_hull(
set_common_multiple(bset1, bset2, row, col);
++row;
} else if (!is_zero1 && is_zero2) {
construct_column(bset1, bset2, row, col);
if (construct_column(bset1, bset2, row, col) < 0)
goto error;
} else if (is_zero1 && !is_zero2) {
construct_column(bset2, bset1, row, col);
if (construct_column(bset2, bset1, row, col) < 0)
goto error;
} else {
if (transform_column(bset1, bset2, row, col))
isl_bool transform;

transform = transform_column(bset1, bset2, row, col);
if (transform < 0)
goto error;
if (transform)
--row;
}
}
Expand Down Expand Up @@ -301,11 +317,17 @@ __isl_give isl_basic_set *isl_basic_set_recession_cone(
__isl_take isl_basic_set *bset)
{
int i;
isl_bool empty;

empty = isl_basic_set_plain_is_empty(bset);
if (empty < 0)
return isl_basic_set_free(bset);
if (empty)
return bset;

bset = isl_basic_set_cow(bset);
if (!bset)
return NULL;
isl_assert(bset->ctx, bset->n_div == 0, goto error);
if (isl_basic_set_check_no_locals(bset) < 0)
return isl_basic_set_free(bset);

for (i = 0; i < bset->n_eq; ++i)
isl_int_set_si(bset->eq[i][0], 0);
Expand All @@ -315,9 +337,6 @@ __isl_give isl_basic_set *isl_basic_set_recession_cone(

ISL_F_CLR(bset, ISL_BASIC_SET_NO_IMPLICIT);
return isl_basic_set_implicit_equalities(bset);
error:
isl_basic_set_free(bset);
return NULL;
}

/* Move "sample" to a point that is one up (or down) from the original
Expand All @@ -343,12 +362,11 @@ static __isl_give isl_basic_set *add_adjacent_points(
__isl_keep isl_basic_set *bset)
{
int i, up;
int dim;

if (!sample)
goto error;
isl_size dim;

dim = isl_basic_set_dim(hull, isl_dim_set);
if (!sample || dim < 0)
goto error;

for (i = 0; i < dim; ++i) {
for (up = 0; up <= 1; ++up) {
Expand Down Expand Up @@ -476,17 +494,20 @@ static __isl_give isl_basic_set *initialize_hull(__isl_keep isl_basic_set *bset,
* we check if there is any point on a hyperplane parallel to the
* corresponding hyperplane shifted by at least one (in either direction).
*/
static struct isl_basic_set *uset_affine_hull_bounded(struct isl_basic_set *bset)
static __isl_give isl_basic_set *uset_affine_hull_bounded(
__isl_take isl_basic_set *bset)
{
struct isl_vec *sample = NULL;
struct isl_basic_set *hull;
struct isl_tab *tab = NULL;
unsigned dim;
isl_size dim;

if (isl_basic_set_plain_is_empty(bset))
return bset;

dim = isl_basic_set_n_dim(bset);
dim = isl_basic_set_dim(bset, isl_dim_set);
if (dim < 0)
return isl_basic_set_free(bset);

if (bset->sample && bset->sample->size == 1 + dim) {
int contains = isl_basic_set_contains(bset, bset->sample);
Expand Down Expand Up @@ -557,17 +578,18 @@ static __isl_give isl_basic_set *initial_hull(struct isl_tab *tab,
int k;
struct isl_basic_set *bset = NULL;
struct isl_ctx *ctx;
unsigned dim;
isl_size dim;

if (!vec || !tab)
return NULL;
ctx = vec->ctx;
isl_assert(ctx, vec->size != 0, goto error);

bset = isl_basic_set_alloc(ctx, 0, vec->size - 1, 0, vec->size - 1, 0);
if (!bset)
dim = isl_basic_set_dim(bset, isl_dim_set);
if (dim < 0)
goto error;
dim = isl_basic_set_n_dim(bset) - tab->n_unbounded;
dim -= tab->n_unbounded;
for (i = 0; i < dim; ++i) {
k = isl_basic_set_alloc_equality(bset);
if (k < 0)
Expand Down Expand Up @@ -707,15 +729,15 @@ struct isl_tab *isl_tab_detect_equalities(struct isl_tab *tab,
static struct isl_basic_set *affine_hull_with_cone(struct isl_basic_set *bset,
struct isl_basic_set *cone)
{
unsigned total;
isl_size total;
unsigned cone_dim;
struct isl_basic_set *hull;
struct isl_mat *M, *U, *Q;

if (!bset || !cone)
total = isl_basic_set_dim(cone, isl_dim_all);
if (!bset || total < 0)
goto error;

total = isl_basic_set_total_dim(cone);
cone_dim = total - cone->n_eq;

M = isl_mat_sub_alloc6(bset->ctx, cone->eq, 0, cone->n_eq, 1, total);
Expand Down Expand Up @@ -785,6 +807,7 @@ static struct isl_basic_set *affine_hull_with_cone(struct isl_basic_set *bset,
static struct isl_basic_set *uset_affine_hull(struct isl_basic_set *bset)
{
struct isl_basic_set *cone;
isl_size total;

if (isl_basic_set_plain_is_empty(bset))
return bset;
Expand All @@ -800,7 +823,10 @@ static struct isl_basic_set *uset_affine_hull(struct isl_basic_set *bset)
return isl_basic_set_universe(space);
}

if (cone->n_eq < isl_basic_set_total_dim(cone))
total = isl_basic_set_dim(cone, isl_dim_all);
if (total < 0)
bset = isl_basic_set_free(bset);
if (cone->n_eq < total)
return affine_hull_with_cone(bset, cone);

isl_basic_set_free(cone);
Expand Down Expand Up @@ -876,6 +902,7 @@ __isl_give isl_basic_map *isl_basic_map_detect_equalities(
__isl_take isl_basic_map *bmap)
{
int i, j;
isl_size total;
struct isl_basic_set *hull = NULL;

if (!bmap)
Expand All @@ -896,14 +923,15 @@ __isl_give isl_basic_map *isl_basic_map_detect_equalities(
isl_basic_set_free(hull);
return isl_basic_map_set_to_empty(bmap);
}
bmap = isl_basic_map_extend_space(bmap, isl_space_copy(bmap->dim), 0,
hull->n_eq, 0);
bmap = isl_basic_map_extend(bmap, 0, hull->n_eq, 0);
total = isl_basic_set_dim(hull, isl_dim_all);
if (total < 0)
goto error;
for (i = 0; i < hull->n_eq; ++i) {
j = isl_basic_map_alloc_equality(bmap);
if (j < 0)
goto error;
isl_seq_cpy(bmap->eq[j], hull->eq[i],
1 + isl_basic_set_total_dim(hull));
isl_seq_cpy(bmap->eq[j], hull->eq[i], 1 + total);
}
isl_vec_free(bmap->sample);
bmap->sample = isl_vec_copy(hull->sample);
Expand Down Expand Up @@ -1001,8 +1029,7 @@ static __isl_give isl_basic_map *add_strides(__isl_take isl_basic_map *bmap,
if (isl_int_is_one(M->row[0][0]))
return bmap;

bmap = isl_basic_map_extend_space(bmap, isl_space_copy(bmap->dim),
M->n_row - 1, M->n_row - 1, 0);
bmap = isl_basic_map_extend(bmap, M->n_row - 1, M->n_row - 1, 0);

isl_int_init(gcd);
for (i = 1; i < M->n_row; ++i) {
Expand Down Expand Up @@ -1060,10 +1087,10 @@ static __isl_give isl_basic_map *add_strides(__isl_take isl_basic_map *bmap,
static __isl_give isl_basic_map *isl_basic_map_make_strides_explicit(
__isl_take isl_basic_map *bmap)
{
int known;
isl_bool known;
int n_known;
int n, n_col;
int total;
isl_size v_div;
isl_ctx *ctx;
isl_mat *A, *B, *M;

Expand All @@ -1081,16 +1108,18 @@ static __isl_give isl_basic_map *isl_basic_map_make_strides_explicit(
if (isl_int_is_zero(bmap->div[n_known][0]))
break;
ctx = isl_basic_map_get_ctx(bmap);
total = isl_space_dim(bmap->dim, isl_dim_all);
v_div = isl_basic_map_var_offset(bmap, isl_dim_div);
if (v_div < 0)
return isl_basic_map_free(bmap);
for (n = 0; n < bmap->n_eq; ++n)
if (isl_seq_first_non_zero(bmap->eq[n] + 1 + total + n_known,
if (isl_seq_first_non_zero(bmap->eq[n] + 1 + v_div + n_known,
bmap->n_div - n_known) == -1)
break;
if (n == 0)
return bmap;
B = isl_mat_sub_alloc6(ctx, bmap->eq, 0, n, 0, 1 + total + n_known);
B = isl_mat_sub_alloc6(ctx, bmap->eq, 0, n, 0, 1 + v_div + n_known);
n_col = bmap->n_div - n_known;
A = isl_mat_sub_alloc6(ctx, bmap->eq, 0, n, 1 + total + n_known, n_col);
A = isl_mat_sub_alloc6(ctx, bmap->eq, 0, n, 1 + v_div + n_known, n_col);
A = isl_mat_left_hermite(A, 0, NULL, NULL);
A = isl_mat_drop_cols(A, n, n_col - n);
A = isl_mat_lin_to_aff(A);
Expand Down
8 changes: 8 additions & 0 deletions polly/lib/External/isl/isl_align_params_bin_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#undef ARG1
#define ARG1 TYPE
#undef ARG2
#define ARG2 TYPE
#undef SUFFIX
#define SUFFIX bin

#include "isl_align_params_templ.c"
40 changes: 40 additions & 0 deletions polly/lib/External/isl/isl_align_params_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2011 Sven Verdoolaege
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege
*/

#define xFN(TYPE,NAME) TYPE ## _ ## NAME
#define FN(TYPE,NAME) xFN(TYPE,NAME)

/* Align the parameters of the two arguments of type ARG1 and ARG2
* (if needed).
*/
isl_stat FN(FN(ARG1,align_params),SUFFIX)(__isl_keep ARG1 **obj1,
__isl_keep ARG2 **obj2)
{
isl_space *space1, *space2;
isl_bool equal_params;

space1 = FN(ARG1,peek_space)(*obj1);
space2 = FN(ARG2,peek_space)(*obj2);
equal_params = isl_space_has_equal_params(space1, space2);
if (equal_params < 0)
goto error;
if (equal_params)
return isl_stat_ok;
if (FN(ARG1,check_named_params)(*obj1) < 0 ||
FN(ARG2,check_named_params)(*obj2) < 0)
goto error;
*obj1 = FN(ARG1,align_params)(*obj1, FN(ARG2,get_space)(*obj2));
*obj2 = FN(ARG2,align_params)(*obj2, FN(ARG1,get_space)(*obj1));
if (!*obj1 || !*obj2)
goto error;
return isl_stat_ok;
error:
*obj1 = FN(ARG1,free)(*obj1);
*obj2 = FN(ARG2,free)(*obj2);
return isl_stat_error;
}
28 changes: 14 additions & 14 deletions polly/lib/External/isl/isl_arg.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ISL_ARG_PHANTOM_BOOL('h', "help", NULL, "print this help, then exit")

static void set_default_choice(struct isl_arg *arg, void *opt)
{
if (arg->offset == (size_t) -1)
if (arg->offset == ISL_ARG_OFFSET_NONE)
return;
*(unsigned *)(((char *)opt) + arg->offset) = arg->u.choice.default_value;
}
Expand All @@ -33,7 +33,7 @@ static void set_default_flags(struct isl_arg *arg, void *opt)

static void set_default_bool(struct isl_arg *arg, void *opt)
{
if (arg->offset == (size_t) -1)
if (arg->offset == ISL_ARG_OFFSET_NONE)
return;
*(unsigned *)(((char *)opt) + arg->offset) = arg->u.b.default_value;
}
Expand All @@ -42,7 +42,7 @@ static void set_default_child(struct isl_arg *arg, void *opt)
{
void *child;

if (arg->offset == (size_t) -1)
if (arg->offset == ISL_ARG_OFFSET_NONE)
child = opt;
else {
child = calloc(1, arg->u.child.child->options_size);
Expand Down Expand Up @@ -137,7 +137,7 @@ static void free_args(struct isl_arg *arg, void *opt);

static void free_child(struct isl_arg *arg, void *opt)
{
if (arg->offset == (size_t) -1)
if (arg->offset == ISL_ARG_OFFSET_NONE)
free_args(arg->u.child.child->args, opt);
else
isl_args_free(arg->u.child.child,
Expand Down Expand Up @@ -520,7 +520,7 @@ static void print_bool_help(struct isl_arg *decl,
int no = p ? *p == 1 : 0;
pos = print_arg_help(decl, prefixes, no);
pos = print_help_msg(decl, pos);
if (decl->offset != (size_t) -1)
if (decl->offset != ISL_ARG_OFFSET_NONE)
print_default(decl, no ? "yes" : "no", pos);
printf("\n");
}
Expand Down Expand Up @@ -667,7 +667,7 @@ static void print_help(struct isl_arg *arg,
printf("\n");
if (arg[i].help_msg)
printf(" %s\n", arg[i].help_msg);
if (arg[i].offset == (size_t) -1)
if (arg[i].offset == ISL_ARG_OFFSET_NONE)
child = opt;
else
child = *(void **)(((char *) opt) + arg[i].offset);
Expand Down Expand Up @@ -812,7 +812,7 @@ static int parse_choice_option(struct isl_arg *decl, char **arg,

if (!has_argument && (!arg[1] || arg[1][0] == '-')) {
unsigned u = decl->u.choice.default_selected;
if (decl->offset != (size_t) -1)
if (decl->offset != ISL_ARG_OFFSET_NONE)
*(unsigned *)(((char *)opt) + decl->offset) = u;
if (decl->u.choice.set)
decl->u.choice.set(opt, u);
Expand All @@ -830,7 +830,7 @@ static int parse_choice_option(struct isl_arg *decl, char **arg,
continue;

u = decl->u.choice.choice[i].value;
if (decl->offset != (size_t) -1)
if (decl->offset != ISL_ARG_OFFSET_NONE)
*(unsigned *)(((char *)opt) + decl->offset) = u;
if (decl->u.choice.set)
decl->u.choice.set(opt, u);
Expand Down Expand Up @@ -904,14 +904,14 @@ static int parse_bool_option(struct isl_arg *decl, char **arg,
char *endptr;
int val = strtol(arg[1], &endptr, 0);
if (*endptr == '\0' && (val == 0 || val == 1)) {
if (decl->offset != (size_t) -1)
if (decl->offset != ISL_ARG_OFFSET_NONE)
*p = val;
if (decl->u.b.set)
decl->u.b.set(opt, val);
return 2;
}
}
if (decl->offset != (size_t) -1)
if (decl->offset != ISL_ARG_OFFSET_NONE)
*p = 1;
if (decl->u.b.set)
decl->u.b.set(opt, 1);
Expand All @@ -936,7 +936,7 @@ static int parse_bool_option(struct isl_arg *decl, char **arg,
name = skip_prefixes(name, prefixes, &next_prefix);

if (match_long_name(decl, name, name + strlen(name))) {
if (decl->offset != (size_t) -1)
if (decl->offset != ISL_ARG_OFFSET_NONE)
*p = 0;
if (decl->u.b.set)
decl->u.b.set(opt, 0);
Expand Down Expand Up @@ -1116,7 +1116,7 @@ static int parse_child_option(struct isl_arg *decl, char **arg,
void *child;
int first, parsed;

if (decl->offset == (size_t) -1)
if (decl->offset == ISL_ARG_OFFSET_NONE)
child = opt;
else
child = *(void **)(((char *)opt) + decl->offset);
Expand Down Expand Up @@ -1240,15 +1240,15 @@ static int next_arg(struct isl_arg *arg, int a)
}

/* Unless ISL_ARG_SKIP_HELP is set, check if "arg" is
* equal to "--help" and if so call print_help_and_exit.
* equal to "--help" or "-h" and if so call print_help_and_exit.
*/
static void check_help(struct isl_args *args, char *arg, char *prog, void *opt,
unsigned flags)
{
if (ISL_FL_ISSET(flags, ISL_ARG_SKIP_HELP))
return;

if (strcmp(arg, "--help") == 0)
if (strcmp(arg, "--help") == 0 || strcmp(arg, "-h") == 0)
print_help_and_exit(args->args, prog, opt);
}

Expand Down
602 changes: 363 additions & 239 deletions polly/lib/External/isl/isl_ast.c

Large diffs are not rendered by default.

104 changes: 71 additions & 33 deletions polly/lib/External/isl/isl_ast_build.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,17 @@ static __isl_give isl_ast_build *isl_ast_build_init_derived(
{
isl_ctx *ctx;
isl_vec *strides;
isl_size dim;

build = isl_ast_build_cow(build);
if (!build || !build->domain)
goto error;

ctx = isl_ast_build_get_ctx(build);
strides = isl_vec_alloc(ctx, isl_space_dim(space, isl_dim_set));
dim = isl_space_dim(space, isl_dim_set);
if (dim < 0)
goto error;
strides = isl_vec_alloc(ctx, dim);
strides = isl_vec_set_si(strides, 1);

isl_vec_free(build->strides);
Expand Down Expand Up @@ -114,14 +118,16 @@ static __isl_give isl_id *generate_name(isl_ctx *ctx, int i,
*/
__isl_give isl_ast_build *isl_ast_build_from_context(__isl_take isl_set *set)
{
int i, n;
int i;
isl_size n;
isl_ctx *ctx;
isl_space *space;
isl_ast_build *build;

set = isl_set_compute_divs(set);
if (!set)
return NULL;
n = isl_set_dim(set, isl_dim_set);
if (n < 0)
goto error;

ctx = isl_set_get_ctx(set);

Expand All @@ -134,7 +140,6 @@ __isl_give isl_ast_build *isl_ast_build_from_context(__isl_take isl_set *set)
build->generated = isl_set_copy(build->domain);
build->pending = isl_set_universe(isl_set_get_space(build->domain));
build->options = isl_union_map_empty(isl_space_params_alloc(ctx, 0));
n = isl_set_dim(set, isl_dim_set);
build->depth = n;
build->iterators = isl_id_list_alloc(ctx, n);
for (i = 0; i < n; ++i) {
Expand Down Expand Up @@ -358,14 +363,16 @@ __isl_give isl_ast_build *isl_ast_build_set_options(
__isl_give isl_ast_build *isl_ast_build_set_iterators(
__isl_take isl_ast_build *build, __isl_take isl_id_list *iterators)
{
int dim, n_it;
isl_size dim, n_it;

build = isl_ast_build_cow(build);
if (!build)
goto error;

dim = isl_set_dim(build->domain, isl_dim_set);
dim = isl_ast_build_dim(build, isl_dim_set);
n_it = isl_id_list_n_id(build->iterators);
if (dim < 0 || n_it < 0)
goto error;
if (n_it < dim)
isl_die(isl_ast_build_get_ctx(build), isl_error_internal,
"isl_ast_build in inconsistent state", goto error);
Expand Down Expand Up @@ -562,15 +569,14 @@ static void isl_ast_build_reset_schedule_map(__isl_keep isl_ast_build *build)
* if code has been generated for the entire schedule and if none
* of the loops have been eliminated.
*/
__isl_give int isl_ast_build_need_schedule_map(__isl_keep isl_ast_build *build)
isl_bool isl_ast_build_need_schedule_map(__isl_keep isl_ast_build *build)
{
int dim;

if (!build)
return -1;
isl_size dim;

dim = isl_set_dim(build->domain, isl_dim_set);
return build->depth != dim || any_eliminated(build);
dim = isl_ast_build_dim(build, isl_dim_set);
if (dim < 0)
return isl_bool_error;
return isl_bool_ok(build->depth != dim || any_eliminated(build));
}

/* Return a mapping from the internal schedule space to the external
Expand All @@ -594,20 +600,27 @@ __isl_give int isl_ast_build_need_schedule_map(__isl_keep isl_ast_build *build)
__isl_give isl_multi_aff *isl_ast_build_get_schedule_map_multi_aff(
__isl_keep isl_ast_build *build)
{
isl_bool needs_map;
isl_space *space;
isl_multi_aff *ma;

if (!build)
return NULL;
if (build->schedule_map)
return isl_multi_aff_copy(build->schedule_map);
needs_map = isl_ast_build_need_schedule_map(build);
if (needs_map < 0)
return NULL;

space = isl_ast_build_get_space(build, 1);
space = isl_space_map_from_set(space);
ma = isl_multi_aff_identity(space);
if (isl_ast_build_need_schedule_map(build)) {
if (needs_map) {
int i;
int dim = isl_set_dim(build->domain, isl_dim_set);
isl_size dim = isl_ast_build_dim(build, isl_dim_set);

if (dim < 0)
ma = isl_multi_aff_free(ma);
ma = isl_multi_aff_drop_dims(ma, isl_dim_out,
build->depth, dim - build->depth);
for (i = build->depth - 1; i >= 0; --i)
Expand Down Expand Up @@ -762,7 +775,8 @@ static __isl_give isl_set *intersect_stride_constraint(__isl_take isl_set *set,
static __isl_give isl_ast_build *update_values(
__isl_take isl_ast_build *build, __isl_take isl_basic_set *bounds)
{
int sv;
isl_bool sv;
isl_size n;
isl_pw_multi_aff *pma;
isl_aff *aff = NULL;
isl_map *it_map;
Expand All @@ -787,10 +801,10 @@ static __isl_give isl_ast_build *update_values(
build->value = isl_pw_aff_coalesce(build->value);
isl_pw_multi_aff_free(pma);

if (!build->value)
n = isl_pw_aff_n_piece(build->value);
if (n < 0)
return isl_ast_build_free(build);

if (isl_pw_aff_n_piece(build->value) != 1)
if (n != 1)
return build;

isl_pw_aff_foreach_piece(build->value, &extract_single_piece, &aff);
Expand Down Expand Up @@ -992,15 +1006,24 @@ __isl_give isl_ast_build *isl_ast_build_replace_pending_by_guard(
__isl_give isl_ast_build *isl_ast_build_restrict(
__isl_take isl_ast_build *build, __isl_take isl_set *set)
{
isl_bool needs_map;

if (isl_set_is_params(set))
return isl_ast_build_restrict_generated(build, set);

if (isl_ast_build_need_schedule_map(build)) {
needs_map = isl_ast_build_need_schedule_map(build);
if (needs_map < 0)
goto error;
if (needs_map) {
isl_multi_aff *ma;
ma = isl_ast_build_get_schedule_map_multi_aff(build);
set = isl_set_preimage_multi_aff(set, ma);
}
return isl_ast_build_restrict_generated(build, set);
error:
isl_ast_build_free(build);
isl_set_free(set);
return NULL;
}

/* Replace build->executed by "executed".
Expand Down Expand Up @@ -1049,18 +1072,22 @@ static __isl_give isl_ast_build *extract_loop_types(
__isl_take isl_ast_build *build)
{
int i;
isl_size n;
isl_ctx *ctx;
isl_schedule_node *node;

if (!build)
return NULL;
n = isl_schedule_node_band_n_member(build->node);
if (n < 0)
return isl_ast_build_free(build);
ctx = isl_ast_build_get_ctx(build);
if (!build->node)
isl_die(ctx, isl_error_internal, "missing AST node",
return isl_ast_build_free(build));

free(build->loop_type);
build->n = isl_schedule_node_band_n_member(build->node);
build->n = n;
build->loop_type = isl_alloc_array(ctx,
enum isl_ast_loop_type, build->n);
if (build->n && !build->loop_type)
Expand Down Expand Up @@ -1146,11 +1173,11 @@ __isl_give isl_multi_aff *isl_ast_build_get_internal2input(
/* Return the number of variables of the given type
* in the (internal) schedule space.
*/
unsigned isl_ast_build_dim(__isl_keep isl_ast_build *build,
isl_size isl_ast_build_dim(__isl_keep isl_ast_build *build,
enum isl_dim_type type)
{
if (!build)
return 0;
return isl_size_error;
return isl_set_dim(build->domain, type);
}

Expand All @@ -1167,7 +1194,8 @@ __isl_give isl_space *isl_ast_build_get_space(__isl_keep isl_ast_build *build,
int internal)
{
int i;
int dim;
isl_size dim;
isl_bool needs_map;
isl_space *space;

if (!build)
Expand All @@ -1177,10 +1205,15 @@ __isl_give isl_space *isl_ast_build_get_space(__isl_keep isl_ast_build *build,
if (internal)
return space;

if (!isl_ast_build_need_schedule_map(build))
needs_map = isl_ast_build_need_schedule_map(build);
if (needs_map < 0)
return isl_space_free(space);
if (!needs_map)
return space;

dim = isl_set_dim(build->domain, isl_dim_set);
dim = isl_ast_build_dim(build, isl_dim_set);
if (dim < 0)
return isl_space_free(space);
space = isl_space_drop_dims(space, isl_dim_set,
build->depth, dim - build->depth);
for (i = build->depth - 1; i >= 0; --i) {
Expand Down Expand Up @@ -1232,14 +1265,16 @@ __isl_give isl_space *isl_ast_build_get_schedule_space(
__isl_give isl_union_map *isl_ast_build_get_schedule(
__isl_keep isl_ast_build *build)
{
isl_bool needs_map;
isl_union_map *executed;
isl_union_map *schedule;

if (!build)
needs_map = isl_ast_build_need_schedule_map(build);
if (needs_map < 0)
return NULL;

executed = isl_union_map_copy(build->executed);
if (isl_ast_build_need_schedule_map(build)) {
if (needs_map) {
isl_map *proj = isl_ast_build_get_schedule_map(build);
executed = isl_union_map_apply_domain(executed,
isl_union_map_from_map(proj));
Expand Down Expand Up @@ -1820,7 +1855,7 @@ __isl_give isl_ast_build *isl_ast_build_product(
isl_vec *strides;
isl_set *set;
isl_multi_aff *embedding;
int dim, n_it;
isl_size dim, space_dim, n_it;

build = isl_ast_build_cow(build);
if (!build)
Expand All @@ -1829,9 +1864,12 @@ __isl_give isl_ast_build *isl_ast_build_product(
build->outer_pos = build->depth;

ctx = isl_ast_build_get_ctx(build);
dim = isl_set_dim(build->domain, isl_dim_set);
dim += isl_space_dim(space, isl_dim_set);
dim = isl_ast_build_dim(build, isl_dim_set);
space_dim = isl_space_dim(space, isl_dim_set);
n_it = isl_id_list_n_id(build->iterators);
if (dim < 0 || space_dim < 0 || n_it < 0)
goto error;
dim += space_dim;
if (n_it < dim) {
isl_id_list *l;
l = generate_names(ctx, dim - n_it, n_it, build);
Expand All @@ -1846,7 +1884,7 @@ __isl_give isl_ast_build *isl_ast_build_product(
build->pending = isl_set_product(build->pending, isl_set_copy(set));
build->generated = isl_set_product(build->generated, set);

strides = isl_vec_alloc(ctx, isl_space_dim(space, isl_dim_set));
strides = isl_vec_alloc(ctx, space_dim);
strides = isl_vec_set_si(strides, 1);
build->strides = isl_vec_concat(build->strides, strides);

Expand Down
216 changes: 140 additions & 76 deletions polly/lib/External/isl/isl_ast_build_expr.c

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions polly/lib/External/isl/isl_ast_build_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ __isl_give isl_ast_build *isl_ast_build_clear_local_info(
__isl_give isl_ast_build *isl_ast_build_increase_depth(
__isl_take isl_ast_build *build);
int isl_ast_build_get_depth(__isl_keep isl_ast_build *build);
unsigned isl_ast_build_dim(__isl_keep isl_ast_build *build,
isl_size isl_ast_build_dim(__isl_keep isl_ast_build *build,
enum isl_dim_type type);
__isl_give isl_space *isl_ast_build_get_space(
__isl_keep isl_ast_build *build, int internal);
Expand Down Expand Up @@ -244,8 +244,7 @@ __isl_give isl_ast_build *isl_ast_build_restrict_generated(
__isl_take isl_ast_build *build, __isl_take isl_set *set);
__isl_give isl_ast_build *isl_ast_build_replace_pending_by_guard(
__isl_take isl_ast_build *build, __isl_take isl_set *guard);
__isl_give int isl_ast_build_need_schedule_map(
__isl_keep isl_ast_build *build);
isl_bool isl_ast_build_need_schedule_map(__isl_keep isl_ast_build *build);
__isl_give isl_multi_aff *isl_ast_build_get_schedule_map_multi_aff(
__isl_keep isl_ast_build *build);
__isl_give isl_map *isl_ast_build_get_schedule_map(
Expand Down
368 changes: 248 additions & 120 deletions polly/lib/External/isl/isl_ast_codegen.c

Large diffs are not rendered by default.

249 changes: 207 additions & 42 deletions polly/lib/External/isl/isl_ast_graft.c

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions polly/lib/External/isl/isl_ast_graft_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define ISL_AST_GRAFT_PRIVATE_H

#include <isl/ast.h>
#include <isl/ast_build.h>
#include <isl/set.h>
#include <isl/list.h>
#include <isl/printer.h>
Expand Down Expand Up @@ -61,6 +62,8 @@ __isl_give isl_ast_graft_list *isl_ast_graft_list_merge(
__isl_take isl_ast_graft_list *list1,
__isl_take isl_ast_graft_list *list2,
__isl_keep isl_ast_build *build);
__isl_give isl_ast_graft_list *isl_ast_graft_list_group_on_guard(
__isl_take isl_ast_graft_list *list, __isl_keep isl_ast_build *build);

__isl_give isl_ast_node *isl_ast_graft_get_node(
__isl_keep isl_ast_graft *graft);
Expand Down
7 changes: 4 additions & 3 deletions polly/lib/External/isl/isl_ast_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct isl_ast_expr {
isl_val *v;
isl_id *id;
struct {
enum isl_ast_op_type op;
enum isl_ast_expr_op_type op;
unsigned n_arg;
isl_ast_expr **args;
} op;
Expand All @@ -36,8 +36,9 @@ struct isl_ast_expr {

__isl_give isl_ast_expr *isl_ast_expr_alloc_int_si(isl_ctx *ctx, int i);
__isl_give isl_ast_expr *isl_ast_expr_alloc_op(isl_ctx *ctx,
enum isl_ast_op_type op, int n_arg);
__isl_give isl_ast_expr *isl_ast_expr_alloc_binary(enum isl_ast_op_type type,
enum isl_ast_expr_op_type op, int n_arg);
__isl_give isl_ast_expr *isl_ast_expr_alloc_binary(
enum isl_ast_expr_op_type type,
__isl_take isl_ast_expr *expr1, __isl_take isl_ast_expr *expr2);

#undef EL
Expand Down
181 changes: 105 additions & 76 deletions polly/lib/External/isl/isl_bernstein.c

Large diffs are not rendered by default.

168 changes: 168 additions & 0 deletions polly/lib/External/isl/isl_bind_domain_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/*
* Copyright 2018 Cerebras Systems
*
* Use of this software is governed by the MIT license
*
* Written by Sven Verdoolaege,
* Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
*/

#include <isl/space.h>

/* Merge parameter "param" into the input dimension "i" of "obj".
*
* First plug in the parameter for the input dimension in "obj".
* The drop the (now defunct) input dimension and
* move the parameter in its original position.
* Since dimension manipulations destroy spaces, modify the space
* separately by only dropping the parameter.
*/
static __isl_give TYPE *FN(TYPE,merge_param)(__isl_take TYPE *obj, int i,
int param)
{
isl_id *id;
isl_aff *aff;
isl_space *space;
isl_multi_aff *ma;

space = FN(TYPE,get_domain_space)(obj);
id = isl_space_get_dim_id(space, isl_dim_param, param);
aff = isl_aff_param_on_domain_space_id(isl_space_copy(space), id);
space = isl_space_map_from_set(space);
ma = isl_multi_aff_identity(space);
ma = isl_multi_aff_set_aff(ma, i, aff);
obj = FN(TYPE,pullback_multi_aff)(obj, ma);
space = FN(TYPE,get_domain_space)(obj);
obj = FN(TYPE,drop_dims)(obj, isl_dim_in, i, 1);
obj = FN(TYPE,move_dims)(obj, isl_dim_in, i, isl_dim_param, param, 1);
space = isl_space_drop_dims(space, isl_dim_param, param, 1);
obj = FN(TYPE,reset_domain_space)(obj, space);

return obj;
}

/* Given a tuple of identifiers "tuple" that correspond
* to the initial input dimensions of "obj",
* if any of those identifiers appear as parameters
* in "obj", then equate those parameters with the corresponding
* input dimensions and project out the parameters.
* The result therefore has no such parameters.
*/
static __isl_give TYPE *FN(TYPE,equate_initial_params)(__isl_take TYPE *obj,
__isl_keep isl_multi_id *tuple)
{
int i;
isl_size n;

n = isl_multi_id_size(tuple);
if (n < 0)
return FN(TYPE,free)(obj);
for (i = 0; i < n; ++i) {
isl_id *id;
int pos;

id = isl_multi_id_get_at(tuple, i);
if (!id)
return FN(TYPE,free)(obj);
pos = FN(TYPE,find_dim_by_id)(obj, isl_dim_param, id);
isl_id_free(id);
if (pos < 0)
continue;
obj = FN(TYPE,merge_param)(obj, i, pos);
}

return obj;
}

/* Given a tuple of identifiers "tuple" in a space that corresponds
* to the domain of "obj", if any of those identifiers appear as parameters
* in "obj", then equate those parameters with the corresponding
* input dimensions and project out the parameters.
* The result therefore has no such parameters.
*/
static __isl_give TYPE *FN(TYPE,equate_domain_params)(__isl_take TYPE *obj,
__isl_keep isl_multi_id *tuple)
{
isl_stat r;
isl_space *obj_space, *tuple_space;

obj_space = FN(TYPE,get_space)(obj);
tuple_space = isl_multi_id_peek_space(tuple);
r = isl_space_check_domain_tuples(tuple_space, obj_space);
isl_space_free(obj_space);
if (r < 0)
return FN(TYPE,free)(obj);

return FN(TYPE,equate_initial_params)(obj, tuple);
}

/* Bind the domain dimensions of the function "obj" to parameters
* with identifiers specified by "tuple", living in the same space
* as the domain of "obj".
*
* If no parameters with these identifiers appear in "obj" already,
* then the domain dimensions are simply reinterpreted as parameters.
* Otherwise, the parameters are first equated to the corresponding
* domain dimensions.
*/
__isl_give TYPE *FN(TYPE,bind_domain)(__isl_take TYPE *obj,
__isl_take isl_multi_id *tuple)
{
isl_space *space;

obj = FN(TYPE,equate_domain_params)(obj, tuple);
space = FN(TYPE,get_space)(obj);
space = isl_space_bind_map_domain(space, tuple);
isl_multi_id_free(tuple);
obj = FN(TYPE,reset_space)(obj, space);

return obj;
}

/* Given a tuple of identifiers "tuple" in a space that corresponds
* to the domain of the wrapped relation in the domain of "obj",
* if any of those identifiers appear as parameters
* in "obj", then equate those parameters with the corresponding
* input dimensions and project out the parameters.
* The result therefore has no such parameters.
*/
static __isl_give TYPE *FN(TYPE,equate_domain_wrapped_domain_params)(
__isl_take TYPE *obj, __isl_keep isl_multi_id *tuple)
{
isl_stat r;
isl_space *obj_space, *tuple_space;

obj_space = FN(TYPE,get_space)(obj);
tuple_space = isl_multi_id_peek_space(tuple);
r = isl_space_check_domain_wrapped_domain_tuples(tuple_space,
obj_space);
isl_space_free(obj_space);
if (r < 0)
return FN(TYPE,free)(obj);

return FN(TYPE,equate_initial_params)(obj, tuple);
}

/* Given a function living in a space of the form [A -> B] -> C and
* a tuple of identifiers in A, bind the domain dimensions of the relation
* wrapped in the domain of "obj" with identifiers specified by "tuple",
* returning a function in the space B -> C.
*
* If no parameters with these identifiers appear in "obj" already,
* then the domain dimensions are simply reinterpreted as parameters.
* Otherwise, the parameters are first equated to the corresponding
* domain dimensions.
*/
__isl_give TYPE *FN(TYPE,bind_domain_wrapped_domain)(__isl_take TYPE *obj,
__isl_take isl_multi_id *tuple)
{
isl_space *space;

obj = FN(TYPE,equate_domain_wrapped_domain_params)(obj, tuple);
space = FN(TYPE,get_space)(obj);
space = isl_space_bind_domain_wrapped_domain(space, tuple);
isl_multi_id_free(tuple);
obj = FN(TYPE,reset_space)(obj, space);

return obj;
}
45 changes: 27 additions & 18 deletions polly/lib/External/isl/isl_bound.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,35 +109,37 @@ static isl_stat guarded_poly_bound(__isl_take isl_basic_set *bset,
__isl_take isl_qpolynomial *poly, void *user)
{
struct isl_bound *bound = (struct isl_bound *)user;
isl_space *dim;
isl_space *space;
isl_pw_qpolynomial_fold *top_pwf;
isl_pw_qpolynomial_fold *top_pwf_tight;
int nparam;
int n_in;
isl_size nparam;
isl_size n_in;
isl_stat r;

if (!bound->wrapping)
return unwrapped_guarded_poly_bound(bset, poly, user);

nparam = isl_space_dim(bound->dim, isl_dim_param);
n_in = isl_space_dim(bound->dim, isl_dim_in);
if (nparam < 0 || n_in < 0)
goto error;

bset = isl_basic_set_move_dims(bset, isl_dim_param, nparam,
isl_dim_set, 0, n_in);
poly = isl_qpolynomial_move_dims(poly, isl_dim_param, nparam,
isl_dim_in, 0, n_in);

dim = isl_basic_set_get_space(bset);
dim = isl_space_params(dim);
space = isl_basic_set_get_space(bset);
space = isl_space_params(space);

top_pwf = bound->pwf;
top_pwf_tight = bound->pwf_tight;

dim = isl_space_from_domain(dim);
dim = isl_space_add_dims(dim, isl_dim_out, 1);
bound->pwf = isl_pw_qpolynomial_fold_zero(isl_space_copy(dim),
space = isl_space_from_domain(space);
space = isl_space_add_dims(space, isl_dim_out, 1);
bound->pwf = isl_pw_qpolynomial_fold_zero(isl_space_copy(space),
bound->type);
bound->pwf_tight = isl_pw_qpolynomial_fold_zero(dim, bound->type);
bound->pwf_tight = isl_pw_qpolynomial_fold_zero(space, bound->type);

r = unwrapped_guarded_poly_bound(bset, poly, user);

Expand All @@ -151,6 +153,10 @@ static isl_stat guarded_poly_bound(__isl_take isl_basic_set *bset,
bound->pwf_tight);

return r;
error:
isl_basic_set_free(bset);
isl_qpolynomial_free(poly);
return isl_stat_error;
}

static isl_stat guarded_qp(__isl_take isl_qpolynomial *qp, void *user)
Expand Down Expand Up @@ -203,11 +209,11 @@ static isl_stat guarded_fold(__isl_take isl_set *set,
}

__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_bound(
__isl_take isl_pw_qpolynomial_fold *pwf, int *tight)
__isl_take isl_pw_qpolynomial_fold *pwf, isl_bool *tight)
{
unsigned nvar;
isl_size nvar;
struct isl_bound bound;
int covers;
isl_bool covers;

if (!pwf)
return NULL;
Expand All @@ -218,21 +224,23 @@ __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_bound(
if (bound.wrapping)
bound.dim = isl_space_unwrap(bound.dim);
nvar = isl_space_dim(bound.dim, isl_dim_out);
if (nvar < 0)
bound.dim = isl_space_free(bound.dim);
bound.dim = isl_space_domain(bound.dim);
bound.dim = isl_space_from_domain(bound.dim);
bound.dim = isl_space_add_dims(bound.dim, isl_dim_out, 1);

if (nvar == 0) {
if (tight)
*tight = 1;
*tight = isl_bool_true;
return isl_pw_qpolynomial_fold_reset_space(pwf, bound.dim);
}

if (isl_pw_qpolynomial_fold_is_zero(pwf)) {
enum isl_fold type = pwf->type;
isl_pw_qpolynomial_fold_free(pwf);
if (tight)
*tight = 1;
*tight = isl_bool_true;
return isl_pw_qpolynomial_fold_zero(bound.dim, type);
}

Expand Down Expand Up @@ -273,7 +281,8 @@ __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_fold_bound(
}

__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound(
__isl_take isl_pw_qpolynomial *pwqp, enum isl_fold type, int *tight)
__isl_take isl_pw_qpolynomial *pwqp, enum isl_fold type,
isl_bool *tight)
{
isl_pw_qpolynomial_fold *pwf;

Expand All @@ -283,7 +292,7 @@ __isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound(

struct isl_union_bound_data {
enum isl_fold type;
int tight;
isl_bool tight;
isl_union_pw_qpolynomial_fold *res;
};

Expand All @@ -302,7 +311,7 @@ static isl_stat bound_pw(__isl_take isl_pw_qpolynomial *pwqp, void *user)

__isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_bound(
__isl_take isl_union_pw_qpolynomial *upwqp,
enum isl_fold type, int *tight)
enum isl_fold type, isl_bool *tight)
{
isl_space *dim;
struct isl_union_bound_data data = { type, 1, NULL };
Expand All @@ -311,7 +320,7 @@ __isl_give isl_union_pw_qpolynomial_fold *isl_union_pw_qpolynomial_bound(
return NULL;

if (!tight)
data.tight = 0;
data.tight = isl_bool_false;

dim = isl_union_pw_qpolynomial_get_space(upwqp);
data.res = isl_union_pw_qpolynomial_fold_zero(dim, type);
Expand Down
94 changes: 89 additions & 5 deletions polly/lib/External/isl/isl_box.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ static __isl_give isl_fixed_box *isl_fixed_box_init(
isl_multi_val *size;

offset = isl_multi_aff_zero(isl_space_copy(space));
size = isl_multi_val_zero(isl_space_range(space));
space = isl_space_drop_all_params(isl_space_range(space));
size = isl_multi_val_zero(space);
return isl_fixed_box_alloc(offset, size);
}

Expand Down Expand Up @@ -130,14 +131,17 @@ static __isl_give isl_fixed_box *isl_fixed_box_set_valid_extent(
static __isl_give isl_fixed_box *isl_fixed_box_invalidate(
__isl_take isl_fixed_box *box)
{
int i, n;
int i;
isl_size n;
isl_space *space;
isl_val *infty;
isl_aff *nan;

if (!box)
return NULL;
n = isl_multi_val_dim(box->size, isl_dim_set);
if (n < 0)
return isl_fixed_box_free(box);

infty = isl_val_infty(isl_fixed_box_get_ctx(box));
space = isl_space_domain(isl_fixed_box_get_space(box));
Expand All @@ -152,6 +156,27 @@ static __isl_give isl_fixed_box *isl_fixed_box_invalidate(
return box;
}

/* Project the domain of the fixed box onto its parameter space.
* In particular, project out the domain of the offset.
*/
static __isl_give isl_fixed_box *isl_fixed_box_project_domain_on_params(
__isl_take isl_fixed_box *box)
{
isl_bool valid;

valid = isl_fixed_box_is_valid(box);
if (valid < 0)
return isl_fixed_box_free(box);
if (!valid)
return box;

box->offset = isl_multi_aff_project_domain_on_params(box->offset);
if (!box->offset)
return isl_fixed_box_free(box);

return box;
}

/* Return the isl_ctx to which "box" belongs.
*/
isl_ctx *isl_fixed_box_get_ctx(__isl_keep isl_fixed_box *box)
Expand Down Expand Up @@ -212,7 +237,7 @@ __isl_give isl_multi_val *isl_fixed_box_get_size(__isl_keep isl_fixed_box *box)
*/
struct isl_size_info {
isl_basic_set *bset;
int pos;
isl_size pos;
isl_val *size;
isl_aff *offset;
};
Expand All @@ -225,14 +250,16 @@ struct isl_size_info {
*/
static isl_bool is_suitable_bound(__isl_keep isl_constraint *c, unsigned pos)
{
unsigned n_div;
isl_size n_div;
isl_bool is_bound, any_divs;

is_bound = isl_constraint_is_lower_bound(c, isl_dim_set, pos);
if (is_bound < 0 || !is_bound)
return is_bound;

n_div = isl_constraint_dim(c, isl_dim_div);
if (n_div < 0)
return isl_bool_error;
any_divs = isl_constraint_involves_dims(c, isl_dim_div, 0, n_div);
return isl_bool_not(any_divs);
}
Expand Down Expand Up @@ -316,6 +343,8 @@ static __isl_give isl_fixed_box *set_dim_extent(__isl_take isl_fixed_box *box,
info.offset = NULL;
info.pos = isl_map_dim(map, isl_dim_in);
info.bset = isl_basic_map_wrap(isl_map_simple_hull(map));
if (info.pos < 0)
info.bset = isl_basic_set_free(info.bset);
if (isl_basic_set_foreach_constraint(info.bset,
&compute_size_in_direction, &info) < 0)
box = isl_fixed_box_free(box);
Expand Down Expand Up @@ -345,11 +374,14 @@ static __isl_give isl_fixed_box *set_dim_extent(__isl_take isl_fixed_box *box,
__isl_give isl_fixed_box *isl_map_get_range_simple_fixed_box_hull(
__isl_keep isl_map *map)
{
int i, n;
int i;
isl_size n;
isl_space *space;
isl_fixed_box *box;

n = isl_map_dim(map, isl_dim_out);
if (n < 0)
return NULL;
space = isl_map_get_space(map);
box = isl_fixed_box_init(space);

Expand All @@ -366,3 +398,55 @@ __isl_give isl_fixed_box *isl_map_get_range_simple_fixed_box_hull(

return box;
}

/* Try and construct a fixed-size rectangular box with an offset
* in terms of the parameters of "set" that contains "set".
* If no such box can be constructed, then return an invalidated box,
* i.e., one where isl_fixed_box_is_valid returns false.
*
* Compute the box using isl_map_get_range_simple_fixed_box_hull
* by constructing a map from the set and
* project out the domain again from the result.
*/
__isl_give isl_fixed_box *isl_set_get_simple_fixed_box_hull(
__isl_keep isl_set *set)
{
isl_map *map;
isl_fixed_box *box;

map = isl_map_from_range(isl_set_copy(set));
box = isl_map_get_range_simple_fixed_box_hull(map);
isl_map_free(map);
box = isl_fixed_box_project_domain_on_params(box);

return box;
}

#undef BASE
#define BASE multi_val
#include "print_yaml_field_templ.c"

#undef BASE
#define BASE multi_aff
#include "print_yaml_field_templ.c"

/* Print the information contained in "box" to "p".
* The information is printed as a YAML document.
*/
__isl_give isl_printer *isl_printer_print_fixed_box(
__isl_take isl_printer *p, __isl_keep isl_fixed_box *box)
{
if (!box)
return isl_printer_free(p);

p = isl_printer_yaml_start_mapping(p);
p = print_yaml_field_multi_aff(p, "offset", box->offset);
p = print_yaml_field_multi_val(p, "size", box->size);
p = isl_printer_yaml_end_mapping(p);

return p;
}

#undef BASE
#define BASE fixed_box
#include <print_templ_yaml.c>
10 changes: 10 additions & 0 deletions polly/lib/External/isl/isl_check_named_params_templ.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#define xFN(TYPE,NAME) TYPE ## _ ## NAME
#define FN(TYPE,NAME) xFN(TYPE,NAME)

/* Check that "obj" has only named parameters, reporting an error
* if it does not.
*/
isl_stat FN(TYPE,check_named_params)(__isl_keep TYPE *obj)
{
return isl_space_check_named_params(FN(TYPE,peek_space)(obj));
}
Loading