isl_rs/bindings/
local_space.rs

1// Automatically generated by isl_bindings_generator.
2// LICENSE: MIT
3
4use crate::bindings::{Aff, BasicMap, Context, DimType, Id, Space};
5use libc::uintptr_t;
6use std::ffi::{CStr, CString};
7use std::os::raw::c_char;
8
9/// Wraps `isl_local_space`.
10pub struct LocalSpace {
11    pub ptr: uintptr_t,
12    pub should_free_on_drop: bool,
13}
14
15extern "C" {
16
17    fn isl_local_space_get_ctx(ls: uintptr_t) -> uintptr_t;
18
19    fn isl_local_space_from_space(space: uintptr_t) -> uintptr_t;
20
21    fn isl_local_space_copy(ls: uintptr_t) -> uintptr_t;
22
23    fn isl_local_space_free(ls: uintptr_t) -> uintptr_t;
24
25    fn isl_local_space_is_params(ls: uintptr_t) -> i32;
26
27    fn isl_local_space_is_set(ls: uintptr_t) -> i32;
28
29    fn isl_local_space_set_tuple_id(ls: uintptr_t, type_: DimType, id: uintptr_t) -> uintptr_t;
30
31    fn isl_local_space_dim(ls: uintptr_t, type_: DimType) -> i32;
32
33    fn isl_local_space_has_dim_name(ls: uintptr_t, type_: DimType, pos: u32) -> i32;
34
35    fn isl_local_space_get_dim_name(ls: uintptr_t, type_: DimType, pos: u32) -> *const c_char;
36
37    fn isl_local_space_set_dim_name(ls: uintptr_t, type_: DimType, pos: u32, s: *const c_char)
38                                    -> uintptr_t;
39
40    fn isl_local_space_has_dim_id(ls: uintptr_t, type_: DimType, pos: u32) -> i32;
41
42    fn isl_local_space_get_dim_id(ls: uintptr_t, type_: DimType, pos: u32) -> uintptr_t;
43
44    fn isl_local_space_set_dim_id(ls: uintptr_t, type_: DimType, pos: u32, id: uintptr_t)
45                                  -> uintptr_t;
46
47    fn isl_local_space_get_space(ls: uintptr_t) -> uintptr_t;
48
49    fn isl_local_space_get_div(ls: uintptr_t, pos: i32) -> uintptr_t;
50
51    fn isl_local_space_find_dim_by_name(ls: uintptr_t, type_: DimType, name: *const c_char) -> i32;
52
53    fn isl_local_space_domain(ls: uintptr_t) -> uintptr_t;
54
55    fn isl_local_space_range(ls: uintptr_t) -> uintptr_t;
56
57    fn isl_local_space_from_domain(ls: uintptr_t) -> uintptr_t;
58
59    fn isl_local_space_add_dims(ls: uintptr_t, type_: DimType, n: u32) -> uintptr_t;
60
61    fn isl_local_space_drop_dims(ls: uintptr_t, type_: DimType, first: u32, n: u32) -> uintptr_t;
62
63    fn isl_local_space_insert_dims(ls: uintptr_t, type_: DimType, first: u32, n: u32) -> uintptr_t;
64
65    fn isl_local_space_set_from_params(ls: uintptr_t) -> uintptr_t;
66
67    fn isl_local_space_intersect(ls1: uintptr_t, ls2: uintptr_t) -> uintptr_t;
68
69    fn isl_local_space_wrap(ls: uintptr_t) -> uintptr_t;
70
71    fn isl_local_space_is_equal(ls1: uintptr_t, ls2: uintptr_t) -> i32;
72
73    fn isl_local_space_lifting(ls: uintptr_t) -> uintptr_t;
74
75    fn isl_local_space_flatten_domain(ls: uintptr_t) -> uintptr_t;
76
77    fn isl_local_space_flatten_range(ls: uintptr_t) -> uintptr_t;
78
79    fn isl_local_space_dump(ls: uintptr_t);
80
81}
82
83impl LocalSpace {
84    /// Wraps `isl_local_space_get_ctx`.
85    pub fn get_ctx(&self) -> Context {
86        let ls = self;
87        let ls = ls.ptr;
88        let isl_rs_result = unsafe { isl_local_space_get_ctx(ls) };
89        let isl_rs_result = Context { ptr: isl_rs_result,
90                                      should_free_on_drop: true };
91        let mut isl_rs_result = isl_rs_result;
92        isl_rs_result.do_not_free_on_drop();
93        isl_rs_result
94    }
95
96    /// Wraps `isl_local_space_from_space`.
97    pub fn from_space(space: Space) -> LocalSpace {
98        let mut space = space;
99        space.do_not_free_on_drop();
100        let space = space.ptr;
101        let isl_rs_result = unsafe { isl_local_space_from_space(space) };
102        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
103                                         should_free_on_drop: true };
104        isl_rs_result
105    }
106
107    /// Wraps `isl_local_space_copy`.
108    pub fn copy(&self) -> LocalSpace {
109        let ls = self;
110        let ls = ls.ptr;
111        let isl_rs_result = unsafe { isl_local_space_copy(ls) };
112        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
113                                         should_free_on_drop: true };
114        isl_rs_result
115    }
116
117    /// Wraps `isl_local_space_free`.
118    pub fn free(self) -> LocalSpace {
119        let ls = self;
120        let mut ls = ls;
121        ls.do_not_free_on_drop();
122        let ls = ls.ptr;
123        let isl_rs_result = unsafe { isl_local_space_free(ls) };
124        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
125                                         should_free_on_drop: true };
126        isl_rs_result
127    }
128
129    /// Wraps `isl_local_space_is_params`.
130    pub fn is_params(&self) -> bool {
131        let ls = self;
132        let ls = ls.ptr;
133        let isl_rs_result = unsafe { isl_local_space_is_params(ls) };
134        let isl_rs_result = match isl_rs_result {
135            0 => false,
136            1 => true,
137            _ => panic!("Got isl_bool = -1"),
138        };
139        isl_rs_result
140    }
141
142    /// Wraps `isl_local_space_is_set`.
143    pub fn is_set(&self) -> bool {
144        let ls = self;
145        let ls = ls.ptr;
146        let isl_rs_result = unsafe { isl_local_space_is_set(ls) };
147        let isl_rs_result = match isl_rs_result {
148            0 => false,
149            1 => true,
150            _ => panic!("Got isl_bool = -1"),
151        };
152        isl_rs_result
153    }
154
155    /// Wraps `isl_local_space_set_tuple_id`.
156    pub fn set_tuple_id(self, type_: DimType, id: Id) -> LocalSpace {
157        let ls = self;
158        let mut ls = ls;
159        ls.do_not_free_on_drop();
160        let ls = ls.ptr;
161        let mut id = id;
162        id.do_not_free_on_drop();
163        let id = id.ptr;
164        let isl_rs_result = unsafe { isl_local_space_set_tuple_id(ls, type_, id) };
165        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
166                                         should_free_on_drop: true };
167        isl_rs_result
168    }
169
170    /// Wraps `isl_local_space_dim`.
171    pub fn dim(&self, type_: DimType) -> i32 {
172        let ls = self;
173        let ls = ls.ptr;
174        let isl_rs_result = unsafe { isl_local_space_dim(ls, type_) };
175        isl_rs_result
176    }
177
178    /// Wraps `isl_local_space_has_dim_name`.
179    pub fn has_dim_name(&self, type_: DimType, pos: u32) -> bool {
180        let ls = self;
181        let ls = ls.ptr;
182        let isl_rs_result = unsafe { isl_local_space_has_dim_name(ls, type_, pos) };
183        let isl_rs_result = match isl_rs_result {
184            0 => false,
185            1 => true,
186            _ => panic!("Got isl_bool = -1"),
187        };
188        isl_rs_result
189    }
190
191    /// Wraps `isl_local_space_get_dim_name`.
192    pub fn get_dim_name(&self, type_: DimType, pos: u32) -> &str {
193        let ls = self;
194        let ls = ls.ptr;
195        let isl_rs_result = unsafe { isl_local_space_get_dim_name(ls, type_, pos) };
196        let isl_rs_result = unsafe { CStr::from_ptr(isl_rs_result) };
197        let isl_rs_result = isl_rs_result.to_str().unwrap();
198        isl_rs_result
199    }
200
201    /// Wraps `isl_local_space_set_dim_name`.
202    pub fn set_dim_name(self, type_: DimType, pos: u32, s: &str) -> LocalSpace {
203        let ls = self;
204        let mut ls = ls;
205        ls.do_not_free_on_drop();
206        let ls = ls.ptr;
207        let s = CString::new(s).unwrap();
208        let s = s.as_ptr();
209        let isl_rs_result = unsafe { isl_local_space_set_dim_name(ls, type_, pos, s) };
210        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
211                                         should_free_on_drop: true };
212        isl_rs_result
213    }
214
215    /// Wraps `isl_local_space_has_dim_id`.
216    pub fn has_dim_id(&self, type_: DimType, pos: u32) -> bool {
217        let ls = self;
218        let ls = ls.ptr;
219        let isl_rs_result = unsafe { isl_local_space_has_dim_id(ls, type_, pos) };
220        let isl_rs_result = match isl_rs_result {
221            0 => false,
222            1 => true,
223            _ => panic!("Got isl_bool = -1"),
224        };
225        isl_rs_result
226    }
227
228    /// Wraps `isl_local_space_get_dim_id`.
229    pub fn get_dim_id(&self, type_: DimType, pos: u32) -> Id {
230        let ls = self;
231        let ls = ls.ptr;
232        let isl_rs_result = unsafe { isl_local_space_get_dim_id(ls, type_, pos) };
233        let isl_rs_result = Id { ptr: isl_rs_result,
234                                 should_free_on_drop: true };
235        isl_rs_result
236    }
237
238    /// Wraps `isl_local_space_set_dim_id`.
239    pub fn set_dim_id(self, type_: DimType, pos: u32, id: Id) -> LocalSpace {
240        let ls = self;
241        let mut ls = ls;
242        ls.do_not_free_on_drop();
243        let ls = ls.ptr;
244        let mut id = id;
245        id.do_not_free_on_drop();
246        let id = id.ptr;
247        let isl_rs_result = unsafe { isl_local_space_set_dim_id(ls, type_, pos, id) };
248        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
249                                         should_free_on_drop: true };
250        isl_rs_result
251    }
252
253    /// Wraps `isl_local_space_get_space`.
254    pub fn get_space(&self) -> Space {
255        let ls = self;
256        let ls = ls.ptr;
257        let isl_rs_result = unsafe { isl_local_space_get_space(ls) };
258        let isl_rs_result = Space { ptr: isl_rs_result,
259                                    should_free_on_drop: true };
260        isl_rs_result
261    }
262
263    /// Wraps `isl_local_space_get_div`.
264    pub fn get_div(&self, pos: i32) -> Aff {
265        let ls = self;
266        let ls = ls.ptr;
267        let isl_rs_result = unsafe { isl_local_space_get_div(ls, pos) };
268        let isl_rs_result = Aff { ptr: isl_rs_result,
269                                  should_free_on_drop: true };
270        isl_rs_result
271    }
272
273    /// Wraps `isl_local_space_find_dim_by_name`.
274    pub fn find_dim_by_name(&self, type_: DimType, name: &str) -> i32 {
275        let ls = self;
276        let ls = ls.ptr;
277        let name = CString::new(name).unwrap();
278        let name = name.as_ptr();
279        let isl_rs_result = unsafe { isl_local_space_find_dim_by_name(ls, type_, name) };
280        isl_rs_result
281    }
282
283    /// Wraps `isl_local_space_domain`.
284    pub fn domain(self) -> LocalSpace {
285        let ls = self;
286        let mut ls = ls;
287        ls.do_not_free_on_drop();
288        let ls = ls.ptr;
289        let isl_rs_result = unsafe { isl_local_space_domain(ls) };
290        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
291                                         should_free_on_drop: true };
292        isl_rs_result
293    }
294
295    /// Wraps `isl_local_space_range`.
296    pub fn range(self) -> LocalSpace {
297        let ls = self;
298        let mut ls = ls;
299        ls.do_not_free_on_drop();
300        let ls = ls.ptr;
301        let isl_rs_result = unsafe { isl_local_space_range(ls) };
302        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
303                                         should_free_on_drop: true };
304        isl_rs_result
305    }
306
307    /// Wraps `isl_local_space_from_domain`.
308    pub fn from_domain(self) -> LocalSpace {
309        let ls = self;
310        let mut ls = ls;
311        ls.do_not_free_on_drop();
312        let ls = ls.ptr;
313        let isl_rs_result = unsafe { isl_local_space_from_domain(ls) };
314        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
315                                         should_free_on_drop: true };
316        isl_rs_result
317    }
318
319    /// Wraps `isl_local_space_add_dims`.
320    pub fn add_dims(self, type_: DimType, n: u32) -> LocalSpace {
321        let ls = self;
322        let mut ls = ls;
323        ls.do_not_free_on_drop();
324        let ls = ls.ptr;
325        let isl_rs_result = unsafe { isl_local_space_add_dims(ls, type_, n) };
326        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
327                                         should_free_on_drop: true };
328        isl_rs_result
329    }
330
331    /// Wraps `isl_local_space_drop_dims`.
332    pub fn drop_dims(self, type_: DimType, first: u32, n: u32) -> LocalSpace {
333        let ls = self;
334        let mut ls = ls;
335        ls.do_not_free_on_drop();
336        let ls = ls.ptr;
337        let isl_rs_result = unsafe { isl_local_space_drop_dims(ls, type_, first, n) };
338        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
339                                         should_free_on_drop: true };
340        isl_rs_result
341    }
342
343    /// Wraps `isl_local_space_insert_dims`.
344    pub fn insert_dims(self, type_: DimType, first: u32, n: u32) -> LocalSpace {
345        let ls = self;
346        let mut ls = ls;
347        ls.do_not_free_on_drop();
348        let ls = ls.ptr;
349        let isl_rs_result = unsafe { isl_local_space_insert_dims(ls, type_, first, n) };
350        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
351                                         should_free_on_drop: true };
352        isl_rs_result
353    }
354
355    /// Wraps `isl_local_space_set_from_params`.
356    pub fn set_from_params(self) -> LocalSpace {
357        let ls = self;
358        let mut ls = ls;
359        ls.do_not_free_on_drop();
360        let ls = ls.ptr;
361        let isl_rs_result = unsafe { isl_local_space_set_from_params(ls) };
362        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
363                                         should_free_on_drop: true };
364        isl_rs_result
365    }
366
367    /// Wraps `isl_local_space_intersect`.
368    pub fn intersect(self, ls2: LocalSpace) -> LocalSpace {
369        let ls1 = self;
370        let mut ls1 = ls1;
371        ls1.do_not_free_on_drop();
372        let ls1 = ls1.ptr;
373        let mut ls2 = ls2;
374        ls2.do_not_free_on_drop();
375        let ls2 = ls2.ptr;
376        let isl_rs_result = unsafe { isl_local_space_intersect(ls1, ls2) };
377        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
378                                         should_free_on_drop: true };
379        isl_rs_result
380    }
381
382    /// Wraps `isl_local_space_wrap`.
383    pub fn wrap(self) -> LocalSpace {
384        let ls = self;
385        let mut ls = ls;
386        ls.do_not_free_on_drop();
387        let ls = ls.ptr;
388        let isl_rs_result = unsafe { isl_local_space_wrap(ls) };
389        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
390                                         should_free_on_drop: true };
391        isl_rs_result
392    }
393
394    /// Wraps `isl_local_space_is_equal`.
395    pub fn is_equal(&self, ls2: &LocalSpace) -> bool {
396        let ls1 = self;
397        let ls1 = ls1.ptr;
398        let ls2 = ls2.ptr;
399        let isl_rs_result = unsafe { isl_local_space_is_equal(ls1, ls2) };
400        let isl_rs_result = match isl_rs_result {
401            0 => false,
402            1 => true,
403            _ => panic!("Got isl_bool = -1"),
404        };
405        isl_rs_result
406    }
407
408    /// Wraps `isl_local_space_lifting`.
409    pub fn lifting(self) -> BasicMap {
410        let ls = self;
411        let mut ls = ls;
412        ls.do_not_free_on_drop();
413        let ls = ls.ptr;
414        let isl_rs_result = unsafe { isl_local_space_lifting(ls) };
415        let isl_rs_result = BasicMap { ptr: isl_rs_result,
416                                       should_free_on_drop: true };
417        isl_rs_result
418    }
419
420    /// Wraps `isl_local_space_flatten_domain`.
421    pub fn flatten_domain(self) -> LocalSpace {
422        let ls = self;
423        let mut ls = ls;
424        ls.do_not_free_on_drop();
425        let ls = ls.ptr;
426        let isl_rs_result = unsafe { isl_local_space_flatten_domain(ls) };
427        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
428                                         should_free_on_drop: true };
429        isl_rs_result
430    }
431
432    /// Wraps `isl_local_space_flatten_range`.
433    pub fn flatten_range(self) -> LocalSpace {
434        let ls = self;
435        let mut ls = ls;
436        ls.do_not_free_on_drop();
437        let ls = ls.ptr;
438        let isl_rs_result = unsafe { isl_local_space_flatten_range(ls) };
439        let isl_rs_result = LocalSpace { ptr: isl_rs_result,
440                                         should_free_on_drop: true };
441        isl_rs_result
442    }
443
444    /// Wraps `isl_local_space_dump`.
445    pub fn dump(&self) {
446        let ls = self;
447        let ls = ls.ptr;
448        let isl_rs_result = unsafe { isl_local_space_dump(ls) };
449        isl_rs_result
450    }
451
452    /// Does not call isl_xxx_free() on being dropped. (For internal use only.)
453    pub fn do_not_free_on_drop(&mut self) {
454        self.should_free_on_drop = false;
455    }
456}
457
458impl Drop for LocalSpace {
459    fn drop(&mut self) {
460        if self.should_free_on_drop {
461            unsafe {
462                isl_local_space_free(self.ptr);
463            }
464        }
465    }
466}