1/*
2 * Copyright 2012 Ecole Normale Superieure
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8 */
9
10#include <isl/ctx.h>
11#include <isl/space.h>
12
13#include <isl_multi_macro.h>
14
15/* Given two multi expressions, "multi1"
16 *
17 * [A1 A2] -> [B1 B2]
18 *
19 * where A2 starts at position "in_pos" and B2 starts at position "out_pos",
20 * and "multi2"
21 *
22 * [C] -> [D]
23 *
24 * return the multi expression
25 *
26 * [A1 C A2] -> [B1 D B2]
27 *
28 * We first insert input dimensions to obtain
29 *
30 * [A1 C A2] -> [B1 B2]
31 *
32 * and
33 *
34 * [A1 C A2] -> [D]
35 *
36 * and then apply range_splice.
37 */
38__isl_give MULTI(BASE) *FN(MULTI(BASE),splice)(
39 __isl_take MULTI(BASE) *multi1, unsigned in_pos, unsigned out_pos,
40 __isl_take MULTI(BASE) *multi2)
41{
42 isl_size n_in1;
43 isl_size n_in2;
44
45 n_in1 = FN(MULTI(BASE),dim)(multi: multi1, type: isl_dim_in);
46 n_in2 = FN(MULTI(BASE),dim)(multi: multi2, type: isl_dim_in);
47 if (n_in1 < 0 || n_in2 < 0)
48 goto error;
49
50 if (FN(MULTI(BASE),check_range)(obj: multi1, type: isl_dim_in, first: in_pos, n: 0) < 0)
51 goto error;
52
53 multi1 = FN(MULTI(BASE),insert_dims)(multi: multi1, type: isl_dim_in, first: in_pos, n: n_in2);
54 multi2 = FN(MULTI(BASE),insert_dims)(multi: multi2, type: isl_dim_in, first: n_in2,
55 n: n_in1 - in_pos);
56 multi2 = FN(MULTI(BASE),insert_dims)(multi: multi2, type: isl_dim_in, first: 0, n: in_pos);
57
58 return FN(MULTI(BASE),range_splice)(multi1, pos: out_pos, multi2);
59error:
60 FN(MULTI(BASE),free)(multi: multi1);
61 FN(MULTI(BASE),free)(multi: multi2);
62 return NULL;
63}
64

source code of polly/lib/External/isl/isl_multi_splice_templ.c