forked from simbuerg/isl-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ctx.h
107 lines (93 loc) · 2.54 KB
/
Ctx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef ISL_CXX_Ctx_H
#define ISL_CXX_Ctx_H
#include "isl/options.h"
#include "isl/band.h"
#include "isl/IslBase.h"
#include "isl/IslException.h"
#include "isl/Stat.h"
#include <mutex>
#include <string>
#include "isl/IslFnPtr.h"
namespace isl {
class Ctx {
struct ptr {
isl_ctx *p;
explicit ptr(isl_ctx *p) : p(p) {}
~ptr() {
isl_ctx_free(p);
}
ptr(const ptr &other) = delete;
ptr &operator=(const ptr &other) = delete;
ptr(ptr && other) = delete;
ptr &operator=(ptr && other) = delete;
};
protected:
std::shared_ptr<ptr> This;
public:
explicit Ctx(std::shared_ptr<ptr> That) : This(That) {}
const Ctx &Context() const { return *this; }
/// \brief Wrap an existing isl object.
///
/// This serves as an entry point into the C++ API.
/// We take ownership of the isl object.
///
/// \param That the isl_ctx we want to wrap.
explicit Ctx(isl_ctx *That) : This(std::make_shared<isl::Ctx::ptr>(That)) {}
/// \brief Release ownership of the wrapped object.
///
/// You are on your own now buddy.
/// The wrapper cannot be used anymore after calling Give()
///
/// \returns the wrapped isl object.
__isl_give isl_ctx *Give();
/// \brief unwrap the stored isl object.
/// \return a the wrapped isl object.
__isl_give isl_ctx *Get() const;
/// \brief Constructor for isl_ctx_alloc
///
static Ctx alloc();
public:
virtual ~Ctx() = default;
private:
mutable std::recursive_mutex M;
public:
void lock() const {
M.lock();
}
void unlock() const {
M.unlock();
}
bool hasError() const {
isl_ctx *ctx = Get();
enum isl_error err = isl_ctx_last_error(ctx);
int goe = isl_options_get_on_error(ctx);
return (err != isl_error_none) && goe != ISL_ON_ERROR_CONTINUE;
}
/// \brief Generated from ::<isl_options_get_tile_scale_tile_loops>
///
///
/// \returns A new int
int getTileScaleTileLoops() const;
/// \brief Generated from ::<isl_options_get_tile_shift_point_loops>
///
///
/// \returns A new int
int getTileShiftPointLoops() const;
/// \brief Generated from ::<isl_options_set_tile_scale_tile_loops>
///
/// \param [in] val
///
/// \returns A new Stat
Stat setTileScaleTileLoops(int val) const;
/// \brief Generated from ::<isl_options_set_tile_shift_point_loops>
///
/// \param [in] val
///
/// \returns A new Stat
Stat setTileShiftPointLoops(int val) const;
Ctx(const Ctx &Other) : This(Other.This) {} Ctx&operator=(const Ctx &Other) {
This = Other.This;
return *this;
}};
} // namespace isl
#endif //ISL_CXX_Ctx_H