isl_dim.h File Reference

#include <isl_ctx.h>

Go to the source code of this file.

Data Structures

struct  isl_dim

Enumerations

enum  isl_dim_type {
  isl_dim_param, isl_dim_in, isl_dim_out, isl_dim_set = isl_dim_out,
  isl_dim_div, isl_dim_all
}

Functions

struct isl_dimisl_dim_alloc (struct isl_ctx *ctx, unsigned nparam, unsigned n_in, unsigned n_out)
struct isl_dimisl_dim_set_alloc (struct isl_ctx *ctx, unsigned nparam, unsigned dim)
struct isl_dimisl_dim_copy (struct isl_dim *dim)
struct isl_dimisl_dim_cow (struct isl_dim *dim)
void isl_dim_free (struct isl_dim *dim)
struct isl_dimisl_dim_set_name (struct isl_dim *dim, enum isl_dim_type type, unsigned pos, const char *name)
const char * isl_dim_get_name (struct isl_dim *dim, enum isl_dim_type type, unsigned pos)
struct isl_dimisl_dim_extend (struct isl_dim *dim, unsigned nparam, unsigned n_in, unsigned n_out)
struct isl_dimisl_dim_add (struct isl_dim *dim, enum isl_dim_type type, unsigned n)
struct isl_dimisl_dim_join (struct isl_dim *left, struct isl_dim *right)
struct isl_dimisl_dim_product (struct isl_dim *left, struct isl_dim *right)
struct isl_dimisl_dim_map (struct isl_dim *dim)
struct isl_dimisl_dim_reverse (struct isl_dim *dim)
struct isl_dimisl_dim_drop (struct isl_dim *dim, enum isl_dim_type type, unsigned first, unsigned num)
struct isl_dimisl_dim_drop_inputs (struct isl_dim *dim, unsigned first, unsigned n)
struct isl_dimisl_dim_drop_outputs (struct isl_dim *dim, unsigned first, unsigned n)
struct isl_dimisl_dim_domain (struct isl_dim *dim)
struct isl_dimisl_dim_range (struct isl_dim *dim)
struct isl_dimisl_dim_underlying (struct isl_dim *dim, unsigned n_div)
int isl_dim_equal (struct isl_dim *dim1, struct isl_dim *dim2)
int isl_dim_match (struct isl_dim *dim1, enum isl_dim_type dim1_type, struct isl_dim *dim2, enum isl_dim_type dim2_type)
int isl_dim_compatible (struct isl_dim *dim1, struct isl_dim *dim2)
unsigned isl_dim_size (struct isl_dim *dim, enum isl_dim_type type)
unsigned isl_dim_total (struct isl_dim *dim)


Enumeration Type Documentation

Enumerator:
isl_dim_param 
isl_dim_in 
isl_dim_out 
isl_dim_set 
isl_dim_div 
isl_dim_all 

Definition at line 24 of file isl_dim.h.

00024                   {
00025         isl_dim_param,
00026         isl_dim_in,
00027         isl_dim_out,
00028         isl_dim_set = isl_dim_out,
00029         isl_dim_div,
00030         isl_dim_all,
00031 };


Function Documentation

struct isl_dim* isl_dim_alloc ( struct isl_ctx *  ctx,
unsigned  nparam,
unsigned  n_in,
unsigned  n_out 
) [read]

Definition at line 4 of file isl_dim.c.

00006 {
00007         struct isl_dim *dim;
00008 
00009         dim = isl_alloc_type(ctx, struct isl_dim);
00010         if (!dim)
00011                 return NULL;
00012 
00013         dim->ctx = ctx;
00014         isl_ctx_ref(ctx);
00015         dim->ref = 1;
00016         dim->nparam = nparam;
00017         dim->n_in = n_in;
00018         dim->n_out = n_out;
00019 
00020         dim->n_name = 0;
00021         dim->names = NULL;
00022 
00023         return dim;
00024 }

struct isl_dim* isl_dim_set_alloc ( struct isl_ctx *  ctx,
unsigned  nparam,
unsigned  dim 
) [read]

Definition at line 26 of file isl_dim.c.

00028 {
00029         return isl_dim_alloc(ctx, nparam, 0, dim);
00030 }

struct isl_dim* isl_dim_copy ( struct isl_dim dim  )  [read]

Definition at line 174 of file isl_dim.c.

00175 {
00176         if (!dim)
00177                 return NULL;
00178 
00179         dim->ref++;
00180         return dim;
00181 }

struct isl_dim* isl_dim_cow ( struct isl_dim dim  )  [read]

Definition at line 163 of file isl_dim.c.

00164 {
00165         if (!dim)
00166                 return NULL;
00167 
00168         if (dim->ref == 1)
00169                 return dim;
00170         dim->ref--;
00171         return isl_dim_dup(dim);
00172 }

void isl_dim_free ( struct isl_dim dim  ) 

Definition at line 183 of file isl_dim.c.

00184 {
00185         int i;
00186 
00187         if (!dim)
00188                 return;
00189 
00190         if (--dim->ref > 0)
00191                 return;
00192 
00193         for (i = 0; i < dim->n_name; ++i)
00194                 isl_name_free(dim->ctx, dim->names[i]);
00195         free(dim->names);
00196         isl_ctx_deref(dim->ctx);
00197         
00198         free(dim);
00199 }

struct isl_dim* isl_dim_set_name ( struct isl_dim dim,
enum isl_dim_type  type,
unsigned  pos,
const char *  name 
) [read]

Definition at line 201 of file isl_dim.c.

00204 {
00205         struct isl_name *name;
00206         if (!dim)
00207                 return NULL;
00208         name = isl_name_get(dim->ctx, s);
00209         if (!name)
00210                 goto error;
00211         return set_name(dim, type, pos, name);
00212 error:
00213         isl_dim_free(dim);
00214         return NULL;
00215 }

const char* isl_dim_get_name ( struct isl_dim dim,
enum isl_dim_type  type,
unsigned  pos 
)

Definition at line 217 of file isl_dim.c.

00219 {
00220         struct isl_name *name = get_name(dim, type, pos);
00221         return name ? name->name : NULL;
00222 }

struct isl_dim* isl_dim_extend ( struct isl_dim dim,
unsigned  nparam,
unsigned  n_in,
unsigned  n_out 
) [read]

Definition at line 258 of file isl_dim.c.

00260 {
00261         struct isl_name **names = NULL;
00262 
00263         if (!dim)
00264                 return NULL;
00265         if (dim->nparam == nparam && dim->n_in == n_in && dim->n_out == n_out)
00266                 return dim;
00267 
00268         isl_assert(dim->ctx, dim->nparam <= nparam, goto error);
00269         isl_assert(dim->ctx, dim->n_in <= n_in, goto error);
00270         isl_assert(dim->ctx, dim->n_out <= n_out, goto error);
00271 
00272         dim = isl_dim_cow(dim);
00273 
00274         if (dim->names) {
00275                 names = isl_calloc_array(dim->ctx, struct isl_name *,
00276                                          nparam + n_in + n_out);
00277                 if (!names)
00278                         goto error;
00279                 get_names(dim, isl_dim_param, 0, dim->nparam, names);
00280                 get_names(dim, isl_dim_in, 0, dim->n_in, names + nparam);
00281                 get_names(dim, isl_dim_out, 0, dim->n_out,
00282                                 names + nparam + n_in);
00283                 free(dim->names);
00284                 dim->names = names;
00285                 dim->n_name = nparam + n_in + n_out;
00286         }
00287         dim->nparam = nparam;
00288         dim->n_in = n_in;
00289         dim->n_out = n_out;
00290 
00291         return dim;
00292 error:
00293         free(names);
00294         isl_dim_free(dim);
00295         return NULL;
00296 }

struct isl_dim* isl_dim_add ( struct isl_dim dim,
enum isl_dim_type  type,
unsigned  n 
) [read]

Definition at line 298 of file isl_dim.c.

00300 {
00301         switch (type) {
00302         case isl_dim_param:
00303                 return isl_dim_extend(dim,
00304                                         dim->nparam + n, dim->n_in, dim->n_out);
00305         case isl_dim_in:
00306                 return isl_dim_extend(dim,
00307                                         dim->nparam, dim->n_in + n, dim->n_out);
00308         case isl_dim_out:
00309                 return isl_dim_extend(dim,
00310                                         dim->nparam, dim->n_in, dim->n_out + n);
00311         }
00312         return dim;
00313 }

struct isl_dim* isl_dim_join ( struct isl_dim left,
struct isl_dim right 
) [read]

Definition at line 315 of file isl_dim.c.

00316 {
00317         struct isl_dim *dim;
00318 
00319         if (!left || !right)
00320                 goto error;
00321 
00322         isl_assert(left->ctx, match(left, isl_dim_param, right, isl_dim_param),
00323                         goto error);
00324         isl_assert(left->ctx, match(left, isl_dim_out, right, isl_dim_in),
00325                         goto error);
00326 
00327         dim = isl_dim_alloc(left->ctx, left->nparam, left->n_in, right->n_out);
00328         if (!dim)
00329                 goto error;
00330 
00331         dim = copy_names(dim, isl_dim_param, 0, left, isl_dim_param);
00332         dim = copy_names(dim, isl_dim_in, 0, left, isl_dim_in);
00333         dim = copy_names(dim, isl_dim_out, 0, right, isl_dim_out);
00334 
00335         isl_dim_free(left);
00336         isl_dim_free(right);
00337 
00338         return dim;
00339 error:
00340         isl_dim_free(left);
00341         isl_dim_free(right);
00342         return NULL;
00343 }

struct isl_dim* isl_dim_product ( struct isl_dim left,
struct isl_dim right 
) [read]

Definition at line 345 of file isl_dim.c.

00346 {
00347         struct isl_dim *dim;
00348 
00349         if (!left || !right)
00350                 goto error;
00351 
00352         isl_assert(left->ctx, match(left, isl_dim_param, right, isl_dim_param),
00353                         goto error);
00354 
00355         dim = isl_dim_alloc(left->ctx, left->nparam,
00356                         left->n_in + right->n_in, left->n_out + right->n_out);
00357         if (!dim)
00358                 goto error;
00359 
00360         dim = copy_names(dim, isl_dim_param, 0, left, isl_dim_param);
00361         dim = copy_names(dim, isl_dim_in, 0, left, isl_dim_in);
00362         dim = copy_names(dim, isl_dim_in, left->n_in, right, isl_dim_in);
00363         dim = copy_names(dim, isl_dim_out, 0, left, isl_dim_out);
00364         dim = copy_names(dim, isl_dim_out, left->n_out, right, isl_dim_out);
00365 
00366         isl_dim_free(left);
00367         isl_dim_free(right);
00368 
00369         return dim;
00370 error:
00371         isl_dim_free(left);
00372         isl_dim_free(right);
00373         return NULL;
00374 }

struct isl_dim* isl_dim_map ( struct isl_dim dim  )  [read]

Definition at line 376 of file isl_dim.c.

00377 {
00378         struct isl_name **names = NULL;
00379 
00380         if (!dim)
00381                 return NULL;
00382         isl_assert(dim->ctx, dim->n_in == 0, goto error);
00383         if (dim->n_out == 0)
00384                 return dim;
00385         dim = isl_dim_cow(dim);
00386         if (!dim)
00387                 return NULL;
00388         if (dim->names) {
00389                 names = isl_calloc_array(dim->ctx, struct isl_name *,
00390                                         dim->nparam + dim->n_out + dim->n_out);
00391                 if (!names)
00392                         goto error;
00393                 get_names(dim, isl_dim_param, 0, dim->nparam, names);
00394                 get_names(dim, isl_dim_out, 0, dim->n_out, names + dim->nparam);
00395         }
00396         dim->n_in = dim->n_out;
00397         if (names) {
00398                 copy_names(dim, isl_dim_out, 0, dim, isl_dim_in);
00399                 free(dim->names);
00400                 dim->names = names;
00401                 dim->n_name = dim->nparam + dim->n_out + dim->n_out;
00402         }
00403         return dim;
00404 error:
00405         isl_dim_free(dim);
00406         return NULL;
00407 }

struct isl_dim* isl_dim_reverse ( struct isl_dim dim  )  [read]

Definition at line 420 of file isl_dim.c.

00421 {
00422         unsigned t;
00423         struct isl_name **names = NULL;
00424 
00425         if (!dim)
00426                 return NULL;
00427         if (match(dim, isl_dim_in, dim, isl_dim_out))
00428                 return dim;
00429 
00430         dim = isl_dim_cow(dim);
00431         if (!dim)
00432                 return NULL;
00433 
00434         if (dim->names) {
00435                 names = isl_alloc_array(dim->ctx, struct isl_name *,
00436                                         dim->n_in + dim->n_out);
00437                 if (!names)
00438                         goto error;
00439                 get_names(dim, isl_dim_in, 0, dim->n_in, names);
00440                 get_names(dim, isl_dim_out, 0, dim->n_out, names + dim->n_in);
00441         }
00442 
00443         t = dim->n_in;
00444         dim->n_in = dim->n_out;
00445         dim->n_out = t;
00446 
00447         if (dim->names) {
00448                 dim = set_names(dim, isl_dim_out, 0, dim->n_out, names);
00449                 dim = set_names(dim, isl_dim_in, 0, dim->n_in, names + dim->n_out);
00450                 free(names);
00451         }
00452 
00453         return dim;
00454 error:
00455         free(names);
00456         isl_dim_free(dim);
00457         return NULL;
00458 }

struct isl_dim* isl_dim_drop ( struct isl_dim dim,
enum isl_dim_type  type,
unsigned  first,
unsigned  num 
) [read]

Definition at line 460 of file isl_dim.c.

00462 {
00463         int i;
00464 
00465         if (!dim)
00466                 return NULL;
00467 
00468         if (n == 0)
00469                 return dim;
00470 
00471         isl_assert(dim->ctx, first + num <= n(dim, type), goto error);
00472         dim = isl_dim_cow(dim);
00473         if (!dim)
00474                 goto error;
00475         if (dim->names) {
00476                 for (i = 0; i < num; ++i)
00477                         isl_name_free(dim->ctx, get_name(dim, type, first+i));
00478                 for (i = first+num; i < n(dim, type); ++i)
00479                         set_name(dim, type, i - num, get_name(dim, type, i));
00480                 switch (type) {
00481                 case isl_dim_param:
00482                         get_names(dim, isl_dim_in, 0, dim->n_in,
00483                                 dim->names + offset(dim, isl_dim_in) - num);
00484                 case isl_dim_in:
00485                         get_names(dim, isl_dim_out, 0, dim->n_out,
00486                                 dim->names + offset(dim, isl_dim_out) - num);
00487                 case isl_dim_out:
00488                         ;
00489                 }
00490         }
00491         switch (type) {
00492         case isl_dim_param:     dim->nparam -= num; break;
00493         case isl_dim_in:        dim->n_in -= num; break;
00494         case isl_dim_out:       dim->n_out -= num; break;
00495         }
00496         return dim;
00497 error:
00498         isl_dim_free(dim);
00499         return NULL;
00500 }

struct isl_dim* isl_dim_drop_inputs ( struct isl_dim dim,
unsigned  first,
unsigned  n 
) [read]

Definition at line 502 of file isl_dim.c.

00504 {
00505         return isl_dim_drop(dim, isl_dim_in, first, n);
00506 }

struct isl_dim* isl_dim_drop_outputs ( struct isl_dim dim,
unsigned  first,
unsigned  n 
) [read]

Definition at line 508 of file isl_dim.c.

00510 {
00511         return isl_dim_drop(dim, isl_dim_out, first, n);
00512 }

struct isl_dim* isl_dim_domain ( struct isl_dim dim  )  [read]

Definition at line 514 of file isl_dim.c.

00515 {
00516         if (!dim)
00517                 return NULL;
00518         dim = isl_dim_drop_outputs(dim, 0, dim->n_out);
00519         return isl_dim_reverse(dim);
00520 }

struct isl_dim* isl_dim_range ( struct isl_dim dim  )  [read]

Definition at line 522 of file isl_dim.c.

00523 {
00524         if (!dim)
00525                 return NULL;
00526         return isl_dim_drop_inputs(dim, 0, dim->n_in);
00527 }

struct isl_dim* isl_dim_underlying ( struct isl_dim dim,
unsigned  n_div 
) [read]

Definition at line 529 of file isl_dim.c.

00530 {
00531         int i;
00532 
00533         if (!dim)
00534                 return NULL;
00535         if (n_div == 0 &&
00536             dim->nparam == 0 && dim->n_in == 0 && dim->n_name == 0)
00537                 return dim;
00538         dim = isl_dim_cow(dim);
00539         if (!dim)
00540                 return NULL;
00541         dim->n_out += dim->nparam + dim->n_in + n_div;
00542         dim->nparam = 0;
00543         dim->n_in = 0;
00544 
00545         for (i = 0; i < dim->n_name; ++i)
00546                 isl_name_free(dim->ctx, get_name(dim, isl_dim_out, i));
00547         dim->n_name = 0;
00548 
00549         return dim;
00550 }

int isl_dim_equal ( struct isl_dim dim1,
struct isl_dim dim2 
)

Definition at line 557 of file isl_dim.c.

00558 {
00559         return match(dim1, isl_dim_param, dim2, isl_dim_param) &&
00560                match(dim1, isl_dim_in, dim2, isl_dim_in) &&
00561                match(dim1, isl_dim_out, dim2, isl_dim_out);
00562 }

int isl_dim_match ( struct isl_dim dim1,
enum isl_dim_type  dim1_type,
struct isl_dim dim2,
enum isl_dim_type  dim2_type 
)

Definition at line 243 of file isl_dim.c.

00245 {
00246         return match(dim1, dim1_type, dim2, dim2_type);
00247 }

int isl_dim_compatible ( struct isl_dim dim1,
struct isl_dim dim2 
)

Definition at line 564 of file isl_dim.c.

00565 {
00566         return dim1->nparam == dim2->nparam &&
00567                dim1->n_in + dim1->n_out == dim2->n_in + dim2->n_out;
00568 }

unsigned isl_dim_size ( struct isl_dim dim,
enum isl_dim_type  type 
)

Definition at line 127 of file isl_dim.c.

00128 {
00129         return n(dim, type);
00130 }

unsigned isl_dim_total ( struct isl_dim dim  ) 

Definition at line 552 of file isl_dim.c.

00553 {
00554         return dim->nparam + dim->n_in + dim->n_out;
00555 }


Generated on Fri Jul 17 16:32:57 2009 for CLooG / ISL by  doxygen 1.5.9