pet 0.11.8
[pet.git] / interface / pet.py
blob266096dd5a8588e6316188e78218a9800d2422bc
1 from ctypes import *
2 import isl
4 pet = cdll.LoadLibrary("libpet.so")
6 class overflow:
7 avoid = 0
8 ignore = 1
10 class options:
11 @staticmethod
12 def set_autodetect(val):
13 ctx = isl.Context.getDefaultInstance()
14 pet.pet_options_set_autodetect(ctx, val);
15 @staticmethod
16 def set_encapsulate_dynamic_control(val):
17 ctx = isl.Context.getDefaultInstance()
18 pet.pet_options_set_encapsulate_dynamic_control(ctx, val);
19 @staticmethod
20 def set_signed_overflow(val):
21 ctx = isl.Context.getDefaultInstance()
22 pet.pet_options_set_signed_overflow(ctx, val);
24 class scop:
25 def __init__(self, *args, **keywords):
26 if "ptr" in keywords:
27 self.ctx = keywords["ctx"]
28 self.ptr = keywords["ptr"]
29 self.filename = keywords["filename"]
30 self.function = keywords["function"]
31 return
32 def __del__(self):
33 pet.pet_scop_free(self.ptr)
34 def __repr__(self):
35 return ('pet.scop.extract_from_C_source("%s", "%s")'
36 % (self.filename, self.function))
37 @staticmethod
38 def extract_from_C_source(filename, function):
39 ctx = isl.Context.getDefaultInstance()
40 filename_s = filename.encode('ascii')
41 function_s = function.encode('ascii')
42 res = pet.pet_scop_extract_from_C_source(ctx, filename_s, function_s)
43 return scop(ctx=ctx, ptr=res, filename=filename, function=function)
44 def get_instance_set(self):
45 return isl.union_set(ctx=self.ctx,
46 ptr=pet.pet_scop_get_instance_set(self.ptr))
47 def get_may_reads(self):
48 return isl.union_map(ctx=self.ctx,
49 ptr=pet.pet_scop_get_may_reads(self.ptr))
50 def get_may_writes(self):
51 return isl.union_map(ctx=self.ctx,
52 ptr=pet.pet_scop_get_may_writes(self.ptr))
53 def get_must_writes(self):
54 return isl.union_map(ctx=self.ctx,
55 ptr=pet.pet_scop_get_must_writes(self.ptr))
56 def get_must_kills(self):
57 return isl.union_map(ctx=self.ctx,
58 ptr=pet.pet_scop_get_must_kills(self.ptr))
59 def get_tagged_may_reads(self):
60 return isl.union_map(ctx=self.ctx,
61 ptr=pet.pet_scop_get_tagged_may_reads(self.ptr))
62 def get_tagged_may_writes(self):
63 return isl.union_map(ctx=self.ctx,
64 ptr=pet.pet_scop_get_tagged_may_writes(self.ptr))
65 def get_tagged_must_writes(self):
66 return isl.union_map(ctx=self.ctx,
67 ptr=pet.pet_scop_get_tagged_must_writes(self.ptr))
68 def get_tagged_must_kills(self):
69 return isl.union_map(ctx=self.ctx,
70 ptr=pet.pet_scop_get_tagged_must_kills(self.ptr))
71 def get_context(self):
72 return isl.set(ctx=self.ctx, ptr=pet.pet_scop_get_context(self.ptr))
73 def get_schedule(self):
74 return isl.schedule(ctx=self.ctx,
75 ptr=pet.pet_scop_get_schedule(self.ptr))
77 pet.pet_options_set_autodetect.argtypes = [isl.Context, c_int]
78 pet.pet_options_set_encapsulate_dynamic_control.argtypes = [isl.Context, c_int]
79 pet.pet_options_set_signed_overflow.argtypes = [isl.Context, c_int]
80 pet.pet_scop_extract_from_C_source.restype = c_void_p
81 pet.pet_scop_extract_from_C_source.argtypes = [isl.Context, c_char_p, c_char_p]
82 pet.pet_scop_get_instance_set.restype = c_void_p
83 pet.pet_scop_get_instance_set.argtypes = [c_void_p]
84 pet.pet_scop_get_may_reads.restype = c_void_p
85 pet.pet_scop_get_may_reads.argtypes = [c_void_p]
86 pet.pet_scop_get_may_writes.restype = c_void_p
87 pet.pet_scop_get_may_writes.argtypes = [c_void_p]
88 pet.pet_scop_get_must_writes.restype = c_void_p
89 pet.pet_scop_get_must_writes.argtypes = [c_void_p]
90 pet.pet_scop_get_must_kills.restype = c_void_p
91 pet.pet_scop_get_must_kills.argtypes = [c_void_p]
92 pet.pet_scop_get_tagged_may_reads.restype = c_void_p
93 pet.pet_scop_get_tagged_may_reads.argtypes = [c_void_p]
94 pet.pet_scop_get_tagged_may_writes.restype = c_void_p
95 pet.pet_scop_get_tagged_may_writes.argtypes = [c_void_p]
96 pet.pet_scop_get_tagged_must_writes.restype = c_void_p
97 pet.pet_scop_get_tagged_must_writes.argtypes = [c_void_p]
98 pet.pet_scop_get_tagged_must_kills.restype = c_void_p
99 pet.pet_scop_get_tagged_must_kills.argtypes = [c_void_p]
100 pet.pet_scop_get_context.restype = c_void_p
101 pet.pet_scop_get_context.argtypes = [c_void_p]
102 pet.pet_scop_get_schedule.restype = c_void_p
103 pet.pet_scop_get_schedule.argtypes = [c_void_p]
104 pet.pet_scop_free.argtypes = [c_void_p]