@@ -6499,6 +6499,14 @@ The box can be copied and freed using the following functions.
__isl_null isl_fixed_box *isl_fixed_box_free(
__isl_take isl_fixed_box *box);
+An object of type C<isl_fixed_box> can be read from input
+using the following function.
+
+ #include <isl/fixed_box.h>
+ __isl_give isl_fixed_box *
+ isl_fixed_box_read_from_str(isl_ctx *ctx,
+ const char *str);
+
A representation of the information contained in an object
of type C<isl_fixed_box> can be obtained using
@@ -31,6 +31,9 @@ __isl_give isl_multi_val *isl_fixed_box_get_size(__isl_keep isl_fixed_box *box);
__isl_give isl_fixed_box *isl_fixed_box_copy(__isl_keep isl_fixed_box *box);
__isl_null isl_fixed_box *isl_fixed_box_free(__isl_take isl_fixed_box *box);
+__isl_constructor
+__isl_give isl_fixed_box *isl_fixed_box_read_from_str(isl_ctx *ctx,
+ const char *str);
__isl_give isl_printer *isl_printer_print_fixed_box(
__isl_take isl_printer *p, __isl_keep isl_fixed_box *box);
__isl_give char *isl_fixed_box_to_str(__isl_keep isl_fixed_box *box);
#include <isl/constraint.h>
#include <isl/ilp.h>
#include <isl/fixed_box.h>
+#include <isl/stream.h>
/* Representation of a box of fixed size containing the elements
* [offset, offset + size).
@@ -502,8 +503,10 @@ __isl_give isl_fixed_box *isl_set_get_lattice_tile(__isl_keep isl_set *set)
* of an isl_fixed_box object.
*/
enum isl_fb_key {
+ isl_fb_key_error = -1,
isl_fb_key_offset,
isl_fb_key_size,
+ isl_fb_key_end,
};
/* Textual representations of the YAML keys for an isl_fixed_box object.
@@ -542,3 +545,92 @@ __isl_give isl_printer *isl_printer_print_fixed_box(
#undef BASE
#define BASE fixed_box
#include <print_templ_yaml.c>
+
+#undef KEY
+#define KEY enum isl_fb_key
+#undef KEY_ERROR
+#define KEY_ERROR isl_fb_key_error
+#undef KEY_END
+#define KEY_END isl_fb_key_end
+#undef KEY_STR
+#define KEY_STR key_str
+#undef KEY_EXTRACT
+#define KEY_EXTRACT extract_key
+#undef KEY_GET
+#define KEY_GET get_key
+#include "extract_key.c"
+
+#undef BASE
+#define BASE multi_val
+#include "read_in_string_templ.c"
+
+#undef BASE
+#define BASE multi_aff
+#include "read_in_string_templ.c"
+
+/* Read an isl_fixed_box object from "s".
+ *
+ * The input needs to contain both an offset and a size.
+ * If either is specified multiple times, then the last specification
+ * overrides all previous ones. This is simpler than checking
+ * that each is only specified once.
+ */
+static __isl_give isl_fixed_box *isl_stream_read_fixed_box(isl_stream *s)
+{
+ isl_bool more;
+ isl_multi_aff *offset = NULL;
+ isl_multi_val *size = NULL;
+
+ if (isl_stream_yaml_read_start_mapping(s) < 0)
+ return NULL;
+
+ while ((more = isl_stream_yaml_next(s)) == isl_bool_true) {
+ enum isl_fb_key key;
+
+ key = get_key(s);
+ if (isl_stream_yaml_next(s) < 0)
+ goto error;
+ switch (key) {
+ case isl_fb_key_end:
+ case isl_fb_key_error:
+ goto error;
+ case isl_fb_key_offset:
+ isl_multi_aff_free(offset);
+ offset = read_multi_aff(s);
+ if (!offset)
+ goto error;
+ break;
+ case isl_fb_key_size:
+ isl_multi_val_free(size);
+ size = read_multi_val(s);
+ if (!size)
+ goto error;
+ break;
+ }
+ }
+ if (more < 0)
+ goto error;
+
+ if (isl_stream_yaml_read_end_mapping(s) < 0)
+ goto error;
+
+ if (!offset) {
+ isl_stream_error(s, NULL, "no offset specified");
+ goto error;
+ }
+
+ if (!size) {
+ isl_stream_error(s, NULL, "no size specified");
+ goto error;
+ }
+
+ return isl_fixed_box_alloc(offset, size);
+error:
+ isl_multi_aff_free(offset);
+ isl_multi_val_free(size);
+ return NULL;
+}
+
+#undef TYPE_BASE
+#define TYPE_BASE fixed_box
+#include "isl_read_from_str_templ.c"