[PPL-devel] [GIT] ppl/ppl(master): Added interface code for wrap_assign().

Patricia Hill p.m.hill at leeds.ac.uk
Tue Mar 23 12:09:27 CET 2010


Module: ppl/ppl
Branch: master
Commit: 2c22a25b340549e57e511f8961204ed546da541a
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=2c22a25b340549e57e511f8961204ed546da541a

Author: Patricia Hill <p.m.hill at leeds.ac.uk>
Date:   Tue Mar 23 11:08:20 2010 +0000

Added interface code for wrap_assign().

---

 .../OCaml/ppl_interface_generator_ocaml_cc_code.m4 |   44 ++++++++++++++++-
 .../OCaml/ppl_interface_generator_ocaml_ml_code.m4 |   13 +++++
 .../ppl_interface_generator_ocaml_mli_code.m4      |    9 +++
 ...terface_generator_ocaml_procedure_generators.m4 |    1 +
 interfaces/OCaml/ppl_ocaml_common.cc               |   53 ++++++++++++++++++++
 interfaces/OCaml/ppl_ocaml_common.defs.hh          |    9 +++
 interfaces/OCaml/ppl_ocaml_globals.ml              |   13 +++++
 interfaces/OCaml/ppl_ocaml_globals.mli             |   13 +++++
 8 files changed, 154 insertions(+), 1 deletions(-)

diff --git a/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4 b/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4
index 3900367..5ec23cd 100644
--- a/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4
+++ b/interfaces/OCaml/ppl_interface_generator_ocaml_cc_code.m4
@@ -625,7 +625,6 @@ CATCH_ALL
 
 ')
 
-
 m4_define(`ppl_ at CLASS@_widening_assign_with_tokens_code',
 `dnl
 extern "C"
@@ -1325,3 +1324,46 @@ CAMLprim value
 CATCH_ALL
 
 ')
+
+m4_define(`ppl_ at CLASS@_wrap_assign_code',
+`dnl
+extern "C"
+CAMLprim value
+ppl_ at CLASS@_wrap_assign_native
+  (value ph, value caml_vset, value width, value rep, value oflow,
+   value cs, value complexity, value wrap_ind) try {
+  CAMLparam5(ph, caml_vset, width, rep, oflow);
+  CAMLxparam3(cs, complexity, wrap_ind);
+  @CPP_CLASS@& pph = *p_ at CLASS@_val(ph);
+  Variables_Set ppl_vset;
+  if (Int_val(caml_vset) == 0)
+    CAMLreturn(Val_unit);
+  while (true) {
+    ppl_vset.insert(Int_val(Field(caml_vset, 0)));
+    if (Int_val(Field(caml_vset, 1)) == 0)
+      break;
+    caml_vset = Field(caml_vset, 1);
+  }
+  build_ppl_bounded_integer_type_representation(rep);
+  build_ppl_bounded_integer_type_overflow(oflow);
+  Constraint_System ppl_cs = build_ppl_Constraint_System(cs);
+  unsigned ppl_complexity = value_to_unsigned<unsigned>(complexity);
+  bool ppl_wrap_ind = Int_val(wrap_ind);
+  pph.wrap_assign(ppl_vset,
+                  build_ppl_bounded_integer_type_width(width),
+                  build_ppl_bounded_integer_type_representation(rep),
+                  build_ppl_bounded_integer_type_overflow(oflow),
+                  &ppl_cs, ppl_complexity, ppl_wrap_ind);
+  CAMLreturn(Val_unit);
+}
+CATCH_ALL
+
+CAMLprim value
+ppl_ at CLASS@_wrap_assign_bytecode(value * argv, int)
+{
+  return ppl_ at CLASS@_wrap_assign_native(argv[0], argv[1], argv[2], argv[3],
+                                 argv[4], argv[5], argv[6], argv[7]);
+}
+
+')
+
diff --git a/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4 b/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4
index 0642842..aa3fd70 100644
--- a/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4
+++ b/interfaces/OCaml/ppl_interface_generator_ocaml_ml_code.m4
@@ -593,3 +593,16 @@ external ppl_all_affine_ranking_functions_ at TERMINATION_ID@_ at TOPOLOGY@@CLASS at _2:
   = "ppl_all_affine_ranking_functions_ at TERMINATION_ID@_ at TOPOLOGY@@CLASS at _2"
 
 ')
+
+m4_define(`ppl_ at CLASS@_wrap_assign_code',
+`dnl
+external ppl_ at CLASS@_wrap_assign: @!CLASS@
+                                  -> bounded_integer_type_width
+                                  -> bounded_integer_type_representation
+                                  -> bounded_integer_type_overflow
+                                  -> constraint_system
+                                  -> int list -> int -> int -> unit
+                        = "ppl_ at CLASS@_wrap_assign_bytecode"
+                          "ppl_ at CLASS@_wrap_assign_native"
+
+')
diff --git a/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4 b/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4
index acb05a4..6f6125a 100644
--- a/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4
+++ b/interfaces/OCaml/ppl_interface_generator_ocaml_mli_code.m4
@@ -515,3 +515,12 @@ val ppl_all_affine_ranking_functions_ at TERMINATION_ID@_ at TOPOLOGY@@CLASS at _2:
   @!CLASS@ -> @!CLASS@ -> polyhedron
 
 ')
+
+val ppl_ at CLASS@_wrap_assign: @!CLASS@
+                             -> bounded_integer_type_width
+                             -> bounded_integer_type_representation
+                             -> bounded_integer_type_overflow
+                             -> constraint_system
+                             -> int list -> int -> int -> unit
+
+')
diff --git a/interfaces/OCaml/ppl_interface_generator_ocaml_procedure_generators.m4 b/interfaces/OCaml/ppl_interface_generator_ocaml_procedure_generators.m4
index 8b8ff38..fad79c8 100644
--- a/interfaces/OCaml/ppl_interface_generator_ocaml_procedure_generators.m4
+++ b/interfaces/OCaml/ppl_interface_generator_ocaml_procedure_generators.m4
@@ -43,6 +43,7 @@ dnl
 m4_define(`m4_procedure_list',
   `m4_echo_unquoted(ppl_new_ at CLASS@_iterator +pointset_powerset,
 `m4_common_procedure_list',
+ppl_ at CLASS@_wrap_assign +simple,
 ppl_termination_test_ at TERMINATION_ID@_ at TOPOLOGY@@CLASS@ +simple,
 ppl_one_affine_ranking_function_ at TERMINATION_ID@_ at TOPOLOGY@@CLASS@ +simple,
 ppl_all_affine_ranking_functions_ at TERMINATION_ID@_ at TOPOLOGY@@CLASS@ +simple,
diff --git a/interfaces/OCaml/ppl_ocaml_common.cc b/interfaces/OCaml/ppl_ocaml_common.cc
index 8592046..ca1a1ef 100644
--- a/interfaces/OCaml/ppl_ocaml_common.cc
+++ b/interfaces/OCaml/ppl_ocaml_common.cc
@@ -209,6 +209,59 @@ build_ppl_relsym(value caml_relsym) {
   }
 }
 
+Bounded_Integer_Type_Width
+build_ppl_bounded_integer_type_width(value caml_width) {
+  assert(Is_long(caml_width));
+  switch (Int_val(caml_width)) {
+  case 0:
+    return BITS_8;
+  case 1:
+    return BITS_16;
+  case 2:
+    return BITS_32;
+  case 3:
+    return BITS_64;
+  case 4:
+    return BITS_128;
+  default:
+    // We should not be here!
+    throw std::runtime_error("PPL OCaml interface internal error\n:"
+                             "build_ppl_bounded_integer_type_width(width)");
+  }
+}
+
+Bounded_Integer_Type_Representation
+build_ppl_bounded_integer_type_representation(value caml_rep) {
+  assert(Is_long(caml_rep));
+  switch (Int_val(caml_rep)) {
+  case 0:
+    return UNSIGNED;
+  case 1:
+    return SIGNED_2_COMPLEMENT;
+  default:
+    // We should not be here!
+    throw std::runtime_error("PPL OCaml interface internal error\n:"
+                             "build_ppl_bounded_integer_type_representation(rep)");
+  }
+}
+
+Bounded_Integer_Type_Overflow
+build_ppl_bounded_integer_type_overflow(value caml_oflow) {
+  assert(Is_long(caml_oflow));
+  switch (Int_val(caml_oflow)) {
+  case 0:
+    return OVERFLOW_WRAPS;
+  case 1:
+    return OVERFLOW_UNDEFINED;
+  case 2:
+    return OVERFLOW_IMPOSSIBLE;
+  default:
+    // We should not be here!
+    throw std::runtime_error("PPL OCaml interface internal error\n:"
+                             "build_ppl_bounded_integer_type_overflow(oflow)");
+  }
+}
+
 Optimization_Mode
 build_ppl_opt_mode(value caml_opt_mode) {
   assert(Is_long(caml_opt_mode));
diff --git a/interfaces/OCaml/ppl_ocaml_common.defs.hh b/interfaces/OCaml/ppl_ocaml_common.defs.hh
index 21e64f9..ee31a6f 100644
--- a/interfaces/OCaml/ppl_ocaml_common.defs.hh
+++ b/interfaces/OCaml/ppl_ocaml_common.defs.hh
@@ -71,6 +71,15 @@ build_ppl_Complexity_Class(value cc);
 Relation_Symbol
 build_ppl_relsym(value caml_relsym);
 
+Bounded_Integer_Type_Overflow
+build_ppl_bounded_integer_type_overflow(value caml_oflow);
+
+Bounded_Integer_Type_Representation
+build_ppl_bounded_integer_type_representation(value caml_rep);
+
+Bounded_Integer_Type_Width
+build_ppl_bounded_integer_type_width(value caml_width);
+
 Coefficient
 build_ppl_Coefficient(value coeff);
 
diff --git a/interfaces/OCaml/ppl_ocaml_globals.ml b/interfaces/OCaml/ppl_ocaml_globals.ml
index cd263d5..9868e7b 100644
--- a/interfaces/OCaml/ppl_ocaml_globals.ml
+++ b/interfaces/OCaml/ppl_ocaml_globals.ml
@@ -102,6 +102,19 @@ type congruence_system = linear_congruence list
 type relation_symbol = Less_Than_RS | Less_Or_Equal_RS | Equal_RS
                        | Greater_Than_RS | Greater_Or_Equal_RS
 
+type bounded_integer_type_overflow = Overflow_Wraps
+                                     | Overflow_Undefined
+                                     | Overflow_Impossible
+
+type bounded_integer_type_representation = Unsigned
+                                           | Signed_2_Complement
+
+type bounded_integer_type_width = Bits_8
+                                  | Bits_16
+                                  | Bits_32
+                                  | Bits_64
+                                  | Bits_128
+
 type complexity_class = Polynomial_Complexity
                         | Simplex_Complexity
                         | Any_Complexity
diff --git a/interfaces/OCaml/ppl_ocaml_globals.mli b/interfaces/OCaml/ppl_ocaml_globals.mli
index f806f0d..e0d9c69 100644
--- a/interfaces/OCaml/ppl_ocaml_globals.mli
+++ b/interfaces/OCaml/ppl_ocaml_globals.mli
@@ -88,6 +88,19 @@ type congruence_system = linear_congruence list
 type relation_symbol = Less_Than_RS | Less_Or_Equal_RS | Equal_RS
                        | Greater_Than_RS | Greater_Or_Equal_RS
 
+type bounded_integer_type_overflow = Overflow_Wraps
+                                     | Overflow_Undefined
+                                     | Overflow_Impossible
+
+type bounded_integer_type_representation = Unsigned
+                                           | Signed_2_Complement
+
+type bounded_integer_type_width = Bits_8
+                                  | Bits_16
+                                  | Bits_32
+                                  | Bits_64
+                                  | Bits_128
+
 type complexity_class = Polynomial_Complexity
                         | Simplex_Complexity
                         | Any_Complexity




More information about the PPL-devel mailing list